Public: anyone can read this; the crew can change it.
test/apps-toolbar.test.ts: the opt-out deploy test runs over the 2 s test budget under shard load #13774
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13773-test-apps-toolbar-test-ts-the-opt-out-de → main 2 commits fork
1 file
changed +21
−24
test/apps-toolbar.test.ts +21 −24
| @@ -11,8 +11,8 @@ import { tmpdir } from "node:os"; | ||
| 11 | 11 | import { join } from "node:path"; |
| 12 | 12 | import { brotliDecompressSync, gzipSync } from "node:zlib"; |
| 13 | 13 | import { createApp, type App } from "../src/app.ts"; |
| 14 | import { newApp } from "../src/actions/apps.ts"; | |
| 15 | import { commitToBranch } from "../src/actions/repos.ts"; | |
| 14 | import { enableApp, newApp } from "../src/actions/apps.ts"; | |
| 15 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; | |
| 16 | 16 | import { getAppByRepo } from "../src/core/apps.ts"; |
| 17 | 17 | import { listRuns } from "../src/core/runs.ts"; |
| 18 | 18 | import { AppsRuntime, type EnvStatus } from "../src/apps/runtime.ts"; |
| @@ -626,13 +626,25 @@ describe("the opt-out, from forge.json to the proxy", () => { | ||
| 626 | 626 | adminIfFirst: true, |
| 627 | 627 | }); |
| 628 | 628 | if (!a.ok) throw new Error(a.error); |
| 629 | const made = await newApp(app, a.value, { | |
| 630 | name: "notes", | |
| 631 | description: "A place for words", | |
| 632 | visibility: "public", | |
| 633 | }); | |
| 629 | // A minimal app, not the scaffold: the scaffold's deploy installs and runs | |
| 630 | // its own test suite, which is what made this test slow (#13773). | |
| 631 | const made = await createRepo(app, a.value, { name: "notes", visibility: "public" }); | |
| 634 | 632 | if (!made.ok) throw new Error(String(made.error)); |
| 635 | const repo = made.value.repo; | |
| 633 | const repo = made.value; | |
| 634 | const server = 'Bun.serve({ port: Number(process.env.PORT), fetch: (r) => new URL(r.url).pathname === "/healthz" ? new Response("ok") : new Response("<html><body><h1>hi</h1></body></html>", { headers: { "content-type": "text/html; charset=utf-8" } }) });\n'; | |
| 635 | const off = await commitToBranch(app, a.value, repo, { | |
| 636 | message: "Turn the pill off", | |
| 637 | files: [ | |
| 638 | { path: "src/server.ts", content: server }, | |
| 639 | { | |
| 640 | path: "forge.json", | |
| 641 | content: `${JSON.stringify({ app: { run: "bun run src/server.ts", health: "/healthz" }, toolbar: false })}\n`, | |
| 642 | }, | |
| 643 | ], | |
| 644 | }); | |
| 645 | if (!off.ok) throw new Error(JSON.stringify(off.error)); | |
| 646 | const enabled = enableApp(app, a.value, repo, { slug: "notes" }); | |
| 647 | if (!enabled.ok) throw new Error(String(enabled.error)); | |
| 636 | 648 | const record = getAppByRepo(app.db, repo.id)!; |
| 637 | 649 | const settled = async (commitOid?: string) => { |
| 638 | 650 | const deadline = Date.now() + 90_000; |
| @@ -643,7 +655,7 @@ describe("the opt-out, from forge.json to the proxy", () => { | ||
| 643 | 655 | (commitOid === undefined || r.commitOid === commitOid), |
| 644 | 656 | ); |
| 645 | 657 | if (run && run.state !== "queued" && run.state !== "running") return run; |
| 646 | await Bun.sleep(100); | |
| 658 | await Bun.sleep(20); // real-timer: polls a real deploy running in a child process until it settles | |
| 647 | 659 | } |
| 648 | 660 | throw new Error("the deploy did not settle"); |
| 649 | 661 | }; |
| @@ -655,21 +667,6 @@ describe("the opt-out, from forge.json to the proxy", () => { | ||
| 655 | 667 | }) |
| 656 | 668 | ).text(); |
| 657 | 669 | |
| 658 | // As created: the pill is on, so the page below has something to lose. | |
| 659 | expect((await settled()).state).toBe("ok"); | |
| 660 | expect(runtime.envStatus(record, "production")?.toolbar).toBe(true); | |
| 661 | expect(await page()).toContain(TOOLBAR_ASSET_PATH); | |
| 662 | ||
| 663 | const off = await commitToBranch(app, a.value, repo, { | |
| 664 | message: "Turn the pill off", | |
| 665 | files: [ | |
| 666 | { | |
| 667 | path: "forge.json", | |
| 668 | content: `${JSON.stringify({ app: { run: "bun run src/server.ts" }, toolbar: false })}\n`, | |
| 669 | }, | |
| 670 | ], | |
| 671 | }); | |
| 672 | if (!off.ok) throw new Error(JSON.stringify(off.error)); | |
| 673 | 670 | expect((await settled(off.value.commitOid)).state).toBe("ok"); |
| 674 | 671 | expect(runtime.envStatus(record, "production")?.toolbar).toBe(false); |
| 675 | 672 | const html = await page(); |
new above
offline