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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/7599-the-people-screen-verify-test-passes-in → main 0 commits fork

  • Merged. scout/7599-the-people-screen-verify-test-passes-in was merged into main as dc1306c.

Review

Sign in to review this change.
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", () => {
2222 let forge: Forge;
2323 let alice: User;
2424 let bob: User;
25 let carol: User;
2526
2627 beforeAll(async () => {
2728 dataDir = await mkdtemp(join(tmpdir(), "forge-tui-people-verify-"));
@@ -29,6 +30,11 @@ describe("verify an email from the People screen", () => {
2930 const a = await seedAdmin(forge, { username: "alice", email: "[email protected]", password: "a-long-passphrase" });
3031 const b = await createUser(forge.db, { username: "bobby", email: "[email protected]", password: "a-long-passphrase", origin: "seed" });
3132 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);
3238 alice = a.value;
3339 bob = b.value;
3440 markUnproven(forge.db, bob.id);
@@ -70,7 +76,7 @@ describe("verify an email from the People screen", () => {
7076 expect(h.text()).toMatch(/bobby.*unverified/);
7177 // Newest first, but alice and bobby can share a created_at millisecond and then
7278 // 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");
7480 expect(h.text()).toMatch(/▸ bobby/);
7581 await h.press("v");
7682 expect(h.text()).toContain("verify bobby's email? y/n");
@@ -100,6 +106,8 @@ describe("verify an email from the People screen", () => {
100106 const fred = await createUser(forge.db, { username: "fred", email: "[email protected]", password: "a-long-passphrase", origin: "seed" });
101107 if (!fred.ok) throw new Error("signup failed");
102108 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);
103111 const h = await open({ ...alice }, 1);
104112 try {
105113 await h.press("v", "y");
@@ -127,15 +135,14 @@ describe("verify an email from the People screen", () => {
127135 }, 30_000);
128136
129137 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)];
133139 const me = { ...alice };
134140 const h = await open(me);
135141 try {
136142 me.isAdmin = false;
137143 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);
139146 expect(h.text()).toContain("Only a forge admin can verify an email.");
140147 } finally {
141148 h.app.stop();

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs