Public: anyone can read this; the crew can change it.
signup-fresh: main.ts's part is the seedSignup option, read from its createApp call, not a boot timed against a clock #17198
Merged 47h 1m ago, live in production
fix/signup-fresh-boot → main 0 commits
2 files
changed +12
−29
scripts/test-honesty-allow.json −1
| @@ -368,7 +368,6 @@ | ||
| 368 | 368 | "test/signin-page.test.ts": {"wait":1}, |
| 369 | 369 | "test/signin-password-doors.test.ts": {"wait":1}, |
| 370 | 370 | "test/signins.test.ts": {"wait":5}, |
| 371 | "test/signup-fresh.test.ts": {"wait":1}, | |
| 372 | 371 | "test/snapshot-destination.test.ts": {"wait":2}, |
| 373 | 372 | "test/snapshot-drill-page.test.ts": {"wait":2}, |
| 374 | 373 | "test/snapshot-one-core.test.ts": {"wait":2}, |
test/signup-fresh.test.ts +12 −28
| @@ -4,10 +4,9 @@ | ||
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | import { describe, expect, test } from "bun:test"; |
| 7 | import { mkdtempSync } from "node:fs"; | |
| 7 | import { mkdtempSync, readFileSync } from "node:fs"; | |
| 8 | 8 | import { tmpdir } from "node:os"; |
| 9 | 9 | import { join } from "node:path"; |
| 10 | import { Database } from "bun:sqlite"; | |
| 11 | 10 | import { createApp } from "../src/app.ts"; |
| 12 | 11 | import { getSignup, seedSignup, setSignup, signupChanges } from "../src/settings/signup.ts"; |
| 13 | 12 | |
| @@ -69,30 +68,15 @@ describe("createApp with seedSignup", () => { | ||
| 69 | 68 | }); |
| 70 | 69 | |
| 71 | 70 | describe("main.ts", () => { |
| 72 | test("booting on an empty data directory stores invite", async () => { | |
| 73 | const dir = mkdtempSync(join(tmpdir(), "fresh-")); | |
| 74 | const proc = Bun.spawn(["bun", "run", join(import.meta.dir, "../src/main.ts")], { | |
| 75 | env: { ...process.env, FORGE_DATA: dir, FORGE_APP_DATA: "", FORGE_SIGNUP: "", PORT: "0", FORGE_PORT: "0" }, | |
| 76 | stdout: "ignore", | |
| 77 | stderr: "ignore", | |
| 78 | }); | |
| 79 | try { | |
| 80 | // A wall-clock deadline, not a count of tries: a loaded check box has booted main.ts in | |
| 81 | // 11.8 s (the gate box's usual is 3.1 s), and what this asserts is the stored value. | |
| 82 | const deadline = Date.now() + 40_000; | |
| 83 | let value: string | undefined; | |
| 84 | while (value === undefined && Date.now() < deadline) { | |
| 85 | await Bun.sleep(100); | |
| 86 | try { | |
| 87 | const db = new Database(join(dir, "forge.db"), { readonly: true }); | |
| 88 | value = db.query<{ value: string }, []>("SELECT value FROM forge_setting WHERE key = 'signup'").get()?.value; | |
| 89 | db.close(); | |
| 90 | } catch {} | |
| 91 | } | |
| 92 | expect(value).toBe("invite"); | |
| 93 | } finally { | |
| 94 | proc.kill(); | |
| 95 | await proc.exited; | |
| 96 | } | |
| 97 | }, 60_000); | |
| 71 | // The forge's own boot asks createApp to seed (the tests above show what that stores). Booting | |
| 72 | // main.ts to read it back timed a whole boot, every migration from nothing, against a clock: on a | |
| 73 | // loaded runner that took 10.5 to 11.8 s against a 10 s wait (06:25, 11:10, 14:59 on 2026-12-01), | |
| 74 | // and raising the wait only moves the line. What main.ts adds is this one option, read here. | |
| 75 | test("the forge's boot asks createApp to seed signup = invite on an empty data directory", () => { | |
| 76 | const main = readFileSync(join(import.meta.dir, "../src/main.ts"), "utf8"); | |
| 77 | const start = main.indexOf("const app = createApp({"); | |
| 78 | expect(start).toBeGreaterThan(-1); | |
| 79 | const call = main.slice(start, main.indexOf("\n});", start)); | |
| 80 | expect(call).toMatch(/^\s*seedSignup: true,$/m); | |
| 81 | }); | |
| 98 | 82 | }); |
new above
offline