c0bfacc04e65
update tests to allow empty login passwords — reflects email+OTP account support
- time
- 2026-05-24 07:51 UTC · 5 months ago
- machine
- koh2
- parent
- 72b4d869e53d
↓ peach-browser-c0bfacc0.tar.gzatlas at this save
files changed3 files
src/background/messages.adversarial.test.ts+2 −2src/background/messages.test.ts+6 −4src/background/vault.test.ts+3 −5src/background/messages.adversarial.test.ts+2 −2
@@ -604,13 +604,13 @@604604 expect(r.ok).toBe(false);605605 });606606 607- it("ADD_ENTRY with no password and no passkey returns validation error", async () => {607+ it("ADD_ENTRY with no password and no passkey succeeds for email-only accounts", async () => {608608 await setupUnlockedVault();609609 const r = await dispatch({610610 type: "ADD_ENTRY",611611 payload: { title: "x", username: "u", password: "", url: "https://e.com" },612612 });613- expect(r.ok).toBe(false);613+ expect(r.ok).toBe(true);614614 });615615 });616616 src/background/messages.test.ts+6 −4
@@ -207,7 +207,7 @@207207 ).resolves.toMatchObject({ ok: false, error: "vault_locked" });208208 });209209 210- it("ADD_ENTRY with a missing password returns a validation error", async () => {210+ it("ADD_ENTRY with no password succeeds for email-only accounts", async () => {211211 const vault = await import("./vault");212212 await vault.createVault("correct-pass-12345");213213 @@ -221,7 +221,7 @@221221 url: "https://github.com",222222 },223223 })224- ).resolves.toMatchObject({ ok: false, error: "password or passkey required" });224+ ).resolves.toMatchObject({ ok: true });225225 });226226 227227 it("UPDATE_ENTRY updates an existing entry and returns ok", async () => {@@ -244,7 +244,7 @@244244 expect(vault.getEntryById(entry.id)?.password).toBe("new-secret");245245 });246246 247- it("UPDATE_ENTRY with an empty login password returns an error", async () => {247+ it("UPDATE_ENTRY with an empty password clears it for email-only accounts", async () => {248248 const vault = await import("./vault");249249 await vault.createVault("correct-pass-12345");250250 const entry = await vault.addEntry({@@ -259,7 +259,9 @@259259 type: "UPDATE_ENTRY",260260 payload: { id: entry.id, patch: { password: "" } },261261 })262- ).resolves.toMatchObject({ ok: false, error: "password or passkey required" });262+ ).resolves.toMatchObject({ ok: true });263+264+ expect(vault.getEntryById(entry.id)?.password).toBeUndefined();263265 });264266 265267 it("DELETE_ENTRY soft-deletes the target entry", async () => {src/background/vault.test.ts+3 −5
@@ -592,7 +592,7 @@592592 expect(vault.getDeletedEntries()).toHaveLength(1);593593 });594594 595- it("updateEntry with an empty password on a login entry throws and rolls back", async () => {595+ it("updateEntry with an empty password on a login entry clears the password", async () => {596596 const vault = await import("./vault");597597 598598 await vault.createVault("update-pass-12345");@@ -603,10 +603,8 @@603603 url: "https://github.com",604604 });605605 606- await expect(vault.updateEntry(entry.id, { password: "" })).rejects.toThrow(607- /password or passkey required/i608- );609- expect(vault.getEntryById(entry.id)?.password).toBe("secret123");606+ await expect(vault.updateEntry(entry.id, { password: "" })).resolves.toBeUndefined();607+ expect(vault.getEntryById(entry.id)?.password).toBeUndefined();610608 });611609 612610 it("updateEntry with an empty password on a note entry is allowed", async () => {