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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/13773-test-apps-toolbar-test-ts-the-opt-out-de → main 2 commits fork

  • Merged. scout/13773-test-apps-toolbar-test-ts-the-opt-out-de was merged into main as 8a99b3a.

Review

Sign in to review this change.
1 file changed +21 −24
test/apps-toolbar.test.ts +21 −24
@@ -11,8 +11,8 @@ import { tmpdir } from "node:os";
1111 import { join } from "node:path";
1212 import { brotliDecompressSync, gzipSync } from "node:zlib";
1313 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";
1616 import { getAppByRepo } from "../src/core/apps.ts";
1717 import { listRuns } from "../src/core/runs.ts";
1818 import { AppsRuntime, type EnvStatus } from "../src/apps/runtime.ts";
@@ -626,13 +626,25 @@ describe("the opt-out, from forge.json to the proxy", () => {
626626 adminIfFirst: true,
627627 });
628628 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" });
634632 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));
636648 const record = getAppByRepo(app.db, repo.id)!;
637649 const settled = async (commitOid?: string) => {
638650 const deadline = Date.now() + 90_000;
@@ -643,7 +655,7 @@ describe("the opt-out, from forge.json to the proxy", () => {
643655 (commitOid === undefined || r.commitOid === commitOid),
644656 );
645657 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
647659 }
648660 throw new Error("the deploy did not settle");
649661 };
@@ -655,21 +667,6 @@ describe("the opt-out, from forge.json to the proxy", () => {
655667 })
656668 ).text();
657669
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));
673670 expect((await settled(off.value.commitOid)).state).toBe("ok");
674671 expect(runtime.envStatus(record, "production")?.toolbar).toBe(false);
675672 const html = await page();

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs