Public: anyone can read this; the crew can change it.

test/web-apps.test.ts: the run page case reads the run's state and the page in an order that cannot disagree #1021

Closed opened this
Closed without merging

scout/forge:scout/967-test-web-apps-test-ts-the-run-page-case → main 1 commit fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
1 file changed +17 −4
test/web-apps.test.ts +17 −4
@@ -351,7 +351,21 @@ describe("apps, runs and the crew on the web", () => {
351351 "Nothing open.",
352352 );
353353
354 const page = await bodyOf(alice, `/alice/hello/runs/${run!.id}`);
354 // The deploy may finish while the page renders, so read the state before
355 // and after; a render is judged only when both reads agree. A settled run
356 // never goes back, so a second render at most once settles the question.
357 const isGoing = () => {
358 const s = listRuns(app.db, hello.id).find((r) => r.id === run!.id)!.state;
359 return s === "queued" || s === "running";
360 };
361 let before = isGoing();
362 let page = await bodyOf(alice, `/alice/hello/runs/${run!.id}`);
363 let going = isGoing();
364 while (before !== going) {
365 before = going;
366 page = await bodyOf(alice, `/alice/hello/runs/${run!.id}`);
367 going = isGoing();
368 }
355369 expect(page).toContain("<h1>Deploy production</h1>");
356370 expect(page).toContain('id="run-log"');
357371 expect(page).toContain('id="run-word"');
@@ -360,10 +374,9 @@ describe("apps, runs and the crew on the web", () => {
360374 expect(page).toContain('class="ln ln-forge"');
361375 expect(page).toContain('id="run-elapsed"');
362376 // The stream and the no-script refresh exist only while it is going.
363 const fresh = listRuns(app.db, hello.id).find((r) => r.id === run!.id)!;
364 const going = fresh.state === "queued" || fresh.state === "running";
365377 expect(page.includes("data-stream=")).toBe(going);
366 expect(page.includes('http-equiv="refresh"')).toBe(going);
378 // Match the tag itself: the page's inline script names it too.
379 expect(/<meta\s+http-equiv="refresh"/.test(page)).toBe(going);
367380
368381 const door = await web(alice, `/runs/${run!.id}`);
369382 expect(door.status).toBe(303);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs