Public: anyone can read this; the crew can change it.
The People-screen verify test passes in any order: carol is made up front, and listPeople is checked against the real state #16998
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/7599-the-people-screen-verify-test-passes-in → main 0 commits fork
1 file
changed +12
−5
test/tui-people-verify.test.ts +12 −5
| @@ -22,6 +22,7 @@ describe("verify an email from the People screen", () => { | ||
| 22 | 22 | let forge: Forge; |
| 23 | 23 | let alice: User; |
| 24 | 24 | let bob: User; |
| 25 | let carol: User; | |
| 25 | 26 | |
| 26 | 27 | beforeAll(async () => { |
| 27 | 28 | dataDir = await mkdtemp(join(tmpdir(), "forge-tui-people-verify-")); |
| @@ -29,6 +30,11 @@ describe("verify an email from the People screen", () => { | ||
| 29 | 30 | const a = await seedAdmin(forge, { username: "alice", email: "[email protected]", password: "a-long-passphrase" }); |
| 30 | 31 | const b = await createUser(forge.db, { username: "bobby", email: "[email protected]", password: "a-long-passphrase", origin: "seed" }); |
| 31 | 32 | if (!a.ok || !b.ok) throw new Error("signup failed"); |
| 33 | // Made up front, so no test creates a person who could take the first row. | |
| 34 | const c = await createUser(forge.db, { username: "carol", email: "[email protected]", password: "a-long-passphrase", origin: "seed" }); | |
| 35 | if (!c.ok) throw new Error("signup failed"); | |
| 36 | carol = c.value; | |
| 37 | markUnproven(forge.db, carol.id); | |
| 32 | 38 | alice = a.value; |
| 33 | 39 | bob = b.value; |
| 34 | 40 | markUnproven(forge.db, bob.id); |
| @@ -70,7 +76,7 @@ describe("verify an email from the People screen", () => { | ||
| 70 | 76 | expect(h.text()).toMatch(/bobby.*unverified/); |
| 71 | 77 | // Newest first, but alice and bobby can share a created_at millisecond and then |
| 72 | 78 | // sort by name: put the cursor on bobby rather than assume his row. |
| 73 | if (!/▸ bobby/.test(h.text())) await h.press("j"); | |
| 79 | for (let i = 0; i < 6 && !/▸ bobby/.test(h.text()); i++) await h.press("j"); | |
| 74 | 80 | expect(h.text()).toMatch(/▸ bobby/); |
| 75 | 81 | await h.press("v"); |
| 76 | 82 | expect(h.text()).toContain("verify bobby's email? y/n"); |
| @@ -100,6 +106,8 @@ describe("verify an email from the People screen", () => { | ||
| 100 | 106 | const fred = await createUser(forge.db, { username: "fred", email: "[email protected]", password: "a-long-passphrase", origin: "seed" }); |
| 101 | 107 | if (!fred.ok) throw new Error("signup failed"); |
| 102 | 108 | markUnproven(forge.db, fred.value.id); |
| 109 | // The cursor starts on the first row: make it fred's, whichever test ran before. | |
| 110 | forge.db.query("UPDATE user SET created_at = '2099-01-01T00:00:00.000Z' WHERE id = ?1").run(fred.value.id); | |
| 103 | 111 | const h = await open({ ...alice }, 1); |
| 104 | 112 | try { |
| 105 | 113 | await h.press("v", "y"); |
| @@ -127,15 +135,14 @@ describe("verify an email from the People screen", () => { | ||
| 127 | 135 | }, 30_000); |
| 128 | 136 | |
| 129 | 137 | test("someone who is not a forge admin is refused and nothing changes", async () => { |
| 130 | const carol = await createUser(forge.db, { username: "carol", email: "carol@forge.test", password: "a-long-passphrase", origin: "seed" }); | |
| 131 | if (!carol.ok) throw new Error("signup failed"); | |
| 132 | markUnproven(forge.db, carol.value.id); | |
| 138 | const before = [emailVerified(forge.db, bob.id), emailVerified(forge.db, carol.id)]; | |
| 133 | 139 | const me = { ...alice }; |
| 134 | 140 | const h = await open(me); |
| 135 | 141 | try { |
| 136 | 142 | me.isAdmin = false; |
| 137 | 143 | await h.press("v", "y"); |
| 138 | expect(emailVerified(forge.db, carol.value.id)).toBe(false); | |
| 144 | expect([emailVerified(forge.db, bob.id), emailVerified(forge.db, carol.id)]).toEqual(before); | |
| 145 | expect(emailVerified(forge.db, carol.id)).toBe(false); | |
| 139 | 146 | expect(h.text()).toContain("Only a forge admin can verify an email."); |
| 140 | 147 | } finally { |
| 141 | 148 | h.app.stop(); |
new above
offline