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 #7599

open deferred: behind the Later gate opened this
Held by the Later gate, set by trevato . The crew picks nothing here until it is lifted.
opened this

test/tui-people-verify.test.ts depends on test order. Under bun test --randomize (the check runs shards in random order) it fails sometimes:

  • When "someone who is not a forge admin is refused" runs first, it creates carol. She becomes the newest person and the People screen's first row, so v in the verify test points at her, not bobby.
  • "listPeople says who is verified" expects bobby verified, which holds only if the verify test already ran.

It turned the check on #7584 red; it was taken out of that pull at review, to land on its own.

Fix: create carol in beforeAll, before bobby, so bobby is always the first row. The not-admin test checks that nothing changed for either person. The listPeople test compares against each person's actual verified state. With this, ten --randomize runs passed.

Done when the file passes 10 bun test --randomize test/tui-people-verify.test.ts runs in a row. The patch that did it:

diff --git a/test/tui-people-verify.test.ts b/test/tui-people-verify.test.ts
index da32f4f4..f5c9828f 100644
--- a/test/tui-people-verify.test.ts
+++ b/test/tui-people-verify.test.ts
@@ -22,11 +22,17 @@ describe("verify an email from the People screen", () => {
   let forge: Forge;
   let alice: User;
   let bob: User;
+  let carol: User;
 
   beforeAll(async () => {
     dataDir = await mkdtemp(join(tmpdir(), "forge-tui-people-verify-"));
     forge = createApp({ dataDir, port: 0 });
     const a = await seedAdmin(forge, { username: "alice", email: "[email protected]", password: "a-long-passphrase" });
+    // Made before bobby, so bobby is the newest and the first row whichever order the tests run in.
+    const c = await createUser(forge.db, { username: "carol", email: "[email protected]", password: "a-long-passphrase", origin: "seed" });
+    if (!c.ok) throw new Error("signup failed");
+    carol = c.value;
+    markUnproven(forge.db, carol.id);
     const b = await createUser(forge.db, { username: "bobby", email: "[email protected]", password: "a-long-passphrase", origin: "seed" });
     if (!a.ok || !b.ok) throw new Error("signup failed");
     alice = a.value;
@@ -69,7 +75,7 @@ describe("verify an email from the People screen", () => {
       expect(h.text()).not.toContain("y/n");
       await h.press("v", "y");
       expect(emailVerified(forge.db, bob.id)).toBe(true);
-      expect(h.text()).not.toContain("unverified");
+      expect(h.text()).not.toMatch(/bobby.*unverified/);
       expect(h.text()).toContain("bobby's email is verified.");
       expect(
         listEvents(forge.db, { kind: "account.email_verified" }).some(
@@ -99,15 +105,14 @@ describe("verify an email from the People screen", () => {
   });
 
   test("someone who is not a forge admin is refused and nothing changes", async () => {
-    const carol = await createUser(forge.db, { username: "carol", email: "[email protected]", password: "a-long-passphrase", origin: "seed" });
-    if (!carol.ok) throw new Error("signup failed");
-    markUnproven(forge.db, carol.value.id);
+    const before = [emailVerified(forge.db, bob.id), emailVerified(forge.db, carol.id)];
     const me = { ...alice };
     const h = await open(me);
     try {
       me.isAdmin = false;
       await h.press("v", "y");
-      expect(emailVerified(forge.db, carol.value.id)).toBe(false);
+      expect([emailVerified(forge.db, bob.id), emailVerified(forge.db, carol.id)]).toEqual(before);
+      expect(emailVerified(forge.db, carol.id)).toBe(false);
       expect(h.text()).toContain("Only a forge admin can verify an email.");
     } finally {
       h.app.stop();
@@ -116,7 +121,8 @@ describe("verify an email from the People screen", () => {
 
   test("listPeople says who is verified", () => {
     const byName = new Map(listPeople(forge.db).map((p) => [p.username, p.verified]));
-    expect(byName.get("bobby")).toBe(true);
+    // Whether bobby is verified yet depends on whether the verify test ran first; the list agrees either way.
+    expect(byName.get("bobby")).toBe(emailVerified(forge.db, bob.id));
     expect(byName.get("alice")).toBe(true);
     expect(byName.get("carol")).toBe(false);
   });

Files: test/tui-people-verify.test.ts

commented

Live triage (automatic, not written by a person): no pillar named, so it waits behind the Later gate; name a pillar to move it.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs