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

Two gated tests stop racing the deploy they watch: the run page in web-apps and the look in looks #953

Closed opened this
Closed without merging

scout/forge:scout/842-two-gated-tests-stop-racing-the-deploy-t → main 1 commit fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
2 files changed +20 −7
test/looks.test.ts +8 −4
@@ -424,6 +424,9 @@ describe("the look", () => {
424424 });
425425
426426 test("a look is taken from `app.serving`, while the deploy's tests are still running, and a red check afterward does not remove it", async () => {
427 // The app's test holds open until this file exists, so the look is taken
428 // while it runs however slow the runner is.
429 const gate = join(dataDir, "release-red-test");
427430 const branch = await commitToBranch(app, alice, repo, {
428431 branch: "slow-red-test",
429432 base: repo.defaultBranch,
@@ -435,7 +438,7 @@ describe("the look", () => {
435438 {
436439 app: {
437440 run: "bun run src/server.ts",
438 test: "sleep 2 && exit 1",
441 test: `while [ ! -f '${gate}' ]; do sleep 0.05; done; exit 1`,
439442 tty: "bun run src/tty.ts",
440443 },
441444 },
@@ -455,8 +458,8 @@ describe("the look", () => {
455458 const env = `pull-${opened.value.number}`;
456459 const commitOid = branch.value.commitOid;
457460
458 // Pictured well before the two-second test step could have finished —
459 // the run is still open, checking.
461 // Pictured while the test step is held open — the run is still open,
462 // checking.
460463 const rows = await pictured(env, commitOid);
461464 expect(rows.every((l) => l.error === null)).toBe(true);
462465 const run = listRuns(app.db, repo.id, { env }).find(
@@ -469,8 +472,9 @@ describe("the look", () => {
469472 expect(serving?.payload["env"]).toBe(env);
470473 expect(serving?.payload["testsRunning"]).toBe(true);
471474
472 // The test then finishes red; the run fails, but the picture already
475 // The test is released and finishes red; the run fails, but the picture already
473476 // taken of what is serving is untouched.
477 writeFileSync(gate, "");
474478 const failed = await settled(
475479 (r) => r.env === env && r.commitOid === commitOid,
476480 );
test/web-apps.test.ts +12 −3
@@ -351,7 +351,18 @@ 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: read the state before
355 // and after, and assert the stream only when the two agree.
356 const stateOf = () =>
357 listRuns(app.db, hello.id).find((r) => r.id === run!.id)!.state;
358 const goingState = (s: string) => s === "queued" || s === "running";
359 let before = stateOf();
360 let page = await bodyOf(alice, `/alice/hello/runs/${run!.id}`);
361 while (before !== stateOf() && goingState(before)) {
362 before = stateOf();
363 page = await bodyOf(alice, `/alice/hello/runs/${run!.id}`);
364 }
365 const going = goingState(before);
355366 expect(page).toContain("<h1>Deploy production</h1>");
356367 expect(page).toContain('id="run-log"');
357368 expect(page).toContain('id="run-word"');
@@ -360,8 +371,6 @@ describe("apps, runs and the crew on the web", () => {
360371 expect(page).toContain('class="ln ln-forge"');
361372 expect(page).toContain('id="run-elapsed"');
362373 // 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";
365374 expect(page.includes("data-stream=")).toBe(going);
366375 expect(page.includes('http-equiv="refresh"')).toBe(going);
367376

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs