Public: anyone can read this; the crew can change it.
test/looks.test.ts: the look-while-tests-run case holds the app's tests open with a gate, not a 2 s sleep #991
scout/forge:scout/968-test-looks-test-ts-the-look-while-tests → main 1 commit fork
1 file
changed +16
−5
test/looks.test.ts +16 −5
| @@ -19,7 +19,7 @@ import { addToCrew, createAgent } from "../src/actions/crew.ts"; | ||
| 19 | 19 | import { setIssueStateThrough } from "../src/actions/issues.ts"; |
| 20 | 20 | import { openPull } from "../src/actions/pulls.ts"; |
| 21 | 21 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; |
| 22 | import { envDataDir, previewEnv } from "../src/apps/data.ts"; | |
| 22 | import { envDataDir, envDir, previewEnv } from "../src/apps/data.ts"; | |
| 23 | 23 | import { readGrant } from "../src/apps/proxy.ts"; |
| 24 | 24 | import { AppsRuntime } from "../src/apps/runtime.ts"; |
| 25 | 25 | import { getAppByRepo, type AppRecord } from "../src/core/apps.ts"; |
| @@ -424,6 +424,9 @@ describe("the look", () => { | ||
| 424 | 424 | }); |
| 425 | 425 | |
| 426 | 426 | 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 blocks until this file exists in its checkout (the one | |
| 428 | // place a contained step shares with the forge), then exits red. | |
| 429 | const gate = ".gate"; | |
| 427 | 430 | const branch = await commitToBranch(app, alice, repo, { |
| 428 | 431 | branch: "slow-red-test", |
| 429 | 432 | base: repo.defaultBranch, |
| @@ -435,7 +438,7 @@ describe("the look", () => { | ||
| 435 | 438 | { |
| 436 | 439 | app: { |
| 437 | 440 | run: "bun run src/server.ts", |
| 438 | test: "sleep 2 && exit 1", | |
| 441 | test: `while [ ! -e ${gate} ]; do sleep 0.05; done; exit 1`, | |
| 439 | 442 | tty: "bun run src/tty.ts", |
| 440 | 443 | }, |
| 441 | 444 | }, |
| @@ -455,8 +458,8 @@ describe("the look", () => { | ||
| 455 | 458 | const env = `pull-${opened.value.number}`; |
| 456 | 459 | const commitOid = branch.value.commitOid; |
| 457 | 460 | |
| 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 at the gate — the run is still | |
| 462 | // open, checking. | |
| 460 | 463 | const rows = await pictured(env, commitOid); |
| 461 | 464 | expect(rows.every((l) => l.error === null)).toBe(true); |
| 462 | 465 | const run = listRuns(app.db, repo.id, { env }).find( |
| @@ -468,8 +471,16 @@ describe("the look", () => { | ||
| 468 | 471 | ); |
| 469 | 472 | expect(serving?.payload["env"]).toBe(env); |
| 470 | 473 | expect(serving?.payload["testsRunning"]).toBe(true); |
| 474 | writeFileSync( | |
| 475 | join( | |
| 476 | envDir(dataDir, record.id, previewEnv(opened.value.number)), | |
| 477 | commitOid.slice(0, 7), | |
| 478 | gate, | |
| 479 | ), | |
| 480 | "", | |
| 481 | ); | |
| 471 | 482 | |
| 472 | // The test then finishes red; the run fails, but the picture already | |
| 483 | // Release the gate: the test then finishes red; the run fails, but the picture already | |
| 473 | 484 | // taken of what is serving is untouched. |
| 474 | 485 | const failed = await settled( |
| 475 | 486 | (r) => r.env === env && r.commitOid === commitOid, |
new above
offline