Public: anyone can read this; the crew can change it.
Full suite red: test/flow-pages.test.ts #12899
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/12878-full-suite-red-test-flow-pages-test-ts → main 2 commits fork
1 file
changed +11
−2
test/flow-pages.test.ts +11 −2
| @@ -26,6 +26,7 @@ let app: App; | ||
| 26 | 26 | let servers: Servers; |
| 27 | 27 | let seed: HomeFlowSeed; |
| 28 | 28 | let cookie = ""; |
| 29 | const warm: Worker[] = []; | |
| 29 | 30 | |
| 30 | 31 | beforeAll(async () => { |
| 31 | 32 | dataDir = await mkdtemp(join(tmpdir(), "forge-pages-")); |
| @@ -33,10 +34,18 @@ beforeAll(async () => { | ||
| 33 | 34 | seed = await seedHomeFlow(app); |
| 34 | 35 | expect((await makeBoard(app, seed.owner, "Mine")).ok).toBe(true); |
| 35 | 36 | servers = await serve(app); |
| 37 | // A worker's cold start (its modules loading) is what a loaded machine makes slow: | |
| 38 | // pay it here, not inside a test. | |
| 39 | for (let i = 0; i < 2; i++) { | |
| 40 | const worker = new Worker(new URL("../src/flow/pages_worker.ts", import.meta.url).href); | |
| 41 | await ask(worker, 0, { kind: "query", params: readParams(new URLSearchParams("source=nope")), now: Date.now() }); | |
| 42 | warm.push(worker); | |
| 43 | } | |
| 36 | 44 | cookie = `forge_session=${createSession(app.db, seed.owner.id).token}`; |
| 37 | 45 | }); |
| 38 | 46 | |
| 39 | 47 | afterAll(async () => { |
| 48 | for (const w of warm) w.terminate(); | |
| 40 | 49 | servers.stop(); |
| 41 | 50 | app.close(); |
| 42 | 51 | await rm(dataDir, { recursive: true, force: true }); |
| @@ -59,7 +68,7 @@ function ask(worker: Worker, id: number, job: PagesAsk["job"]): Promise<PagesAns | ||
| 59 | 68 | describe("the worker reads each page's picture on a handle of its own", () => { |
| 60 | 69 | test("/boards: the figures, the outflow, the ready lists and the boards' own list come back as plain data", async () => { |
| 61 | 70 | app.db.run("PRAGMA wal_checkpoint(TRUNCATE)"); |
| 62 | const worker = new Worker(new URL("../src/flow/pages_worker.ts", import.meta.url).href); | |
| 71 | const worker = warm.shift()!; | |
| 63 | 72 | try { |
| 64 | 73 | const now = Date.now(); |
| 65 | 74 | const answer = await ask(worker, 1, { kind: "boards", viewer: "owner", now, boardsSince: 0, out: null }); |
| @@ -113,7 +122,7 @@ describe("a board's panels and the data page's query are read, and a board's cha | ||
| 113 | 122 | const made = await writeBoard(app, seed.owner, "mine", { title: "Mine", range: "7d", refresh: "off", panels: [{ title: "Runs", chart: "line", query: { source: "runs", aggregate: "count", groupBy: { bucket: "day" } }, w: 1, h: 1 }] }); |
| 114 | 123 | expect(made.ok).toBe(true); |
| 115 | 124 | app.db.run("PRAGMA wal_checkpoint(TRUNCATE)"); |
| 116 | const worker = new Worker(new URL("../src/flow/pages_worker.ts", import.meta.url).href); | |
| 125 | const worker = warm.shift()!; | |
| 117 | 126 | try { |
| 118 | 127 | const now = Date.now(); |
| 119 | 128 | const board = (await ask(worker, 1, { kind: "board", slug: "mine", now, boardsSince: 0 })).picture as BoardPicture; |
new above
offline