693689c2cf53

add SUBMIT_FEEDBACK handler tests, update Projects.md §3.7 and session notes (v2.1.0)

time
2026-04-26 13:33 UTC · 6 months ago
machine
koh2
parent
280e301ab2db
1 file src/background/messages.test.ts+49 −0
src/background/messages.test.ts+49 −0
@@ -589,4 +589,53 @@589589 590590     expect(fetchMock).not.toHaveBeenCalled();591591   });592+593+  it("SUBMIT_FEEDBACK returns ok:true and skips network when FEEDBACK_ENDPOINT is empty", async () => {594+    const response = await dispatch({595+      type: "SUBMIT_FEEDBACK",596+      payload: {597+        category: "Bug report",598+        message: "the popup flashes",599+        version: "2.1.0",600+        browser: "Chrome",601+      },602+    });603+604+    expect(response).toMatchObject({ ok: true });605+    expect(fetchMock).not.toHaveBeenCalled();606+  });607+608+  it("SUBMIT_FEEDBACK returns ok:false when message is empty whitespace", async () => {609+    const response = await dispatch({610+      type: "SUBMIT_FEEDBACK",611+      payload: {612+        category: "Bug report",613+        message: "  ",614+        version: "2.1.0",615+        browser: "Chrome",616+      },617+    });618+619+    expect(response).toMatchObject({ ok: false, error: "message is empty" });620+    expect(fetchMock).not.toHaveBeenCalled();621+  });622+623+  it("SUBMIT_FEEDBACK does not refresh the auto-lock timer", async () => {624+    const vault = await import("./vault");625+    await vault.createVault("correct-pass-12345");626+    const alarmsCreate = chrome.alarms.create as unknown as ReturnType<typeof vi.fn>;627+628+    // Sanity: a non-excluded message (GET_ENTRIES) DOES refresh the timer629+    alarmsCreate.mockClear();630+    await dispatch({ type: "GET_ENTRIES" });631+    expect(alarmsCreate).toHaveBeenCalled();632+633+    // SUBMIT_FEEDBACK is in the exclusion list and must not re-arm634+    alarmsCreate.mockClear();635+    await dispatch({636+      type: "SUBMIT_FEEDBACK",637+      payload: { category: "Bug report", message: "hi", version: "2.1.0", browser: "Chrome" },638+    });639+    expect(alarmsCreate).not.toHaveBeenCalled();640+  });592641 });

view file