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

Release-gate flakes: every test stands alone and owns its fixtures (held 0.7.144 and 0.7.146) #2229

Merged opened this in answer to

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

Merged

scout/forge:scout/2219-release-gate-flakes-every-test-stands-al → main 1 commit fork

  • Merged. scout/2219-release-gate-flakes-every-test-stands-al was merged into main as d619984.

Review

Sign in to review this change.
1 file changed +39 −9
test/looks.test.ts +39 −9
@@ -9,7 +9,7 @@
99 */
1010
1111 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
12 import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
12 import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
1313 import { mkdtemp, rm } from "node:fs/promises";
1414 import { tmpdir } from "node:os";
1515 import { join } from "node:path";
@@ -871,18 +871,48 @@ describe("the look", () => {
871871 }, 120_000);
872872
873873 test("a public app made private after its pictures were taken: a reader gets them no more, and no Look card; its writer still does (#845)", async () => {
874 const gallery = getRepo(app.db, "alice", "gallery")!;
875 const galleryApp = getAppByRepo(app.db, gallery.id)!;
876 const look = looksForEnv(app.db, galleryApp.id, "production").find(
874 // Its own app, branch, pull and pictures: no other test's capture.
875 const made = await newApp(app, alice, { name: "vault", visibility: "public" });
876 if (!made.ok) throw new Error(String(made.error));
877 const gallery = made.value.repo;
878 const galleryApp = made.value.app;
879 const branch = await commitToBranch(app, alice, gallery, {
880 branch: "frame",
881 base: gallery.defaultBranch,
882 message: "A frame",
883 files: [{ path: "FRAME.md", content: "frame\n" }],
884 });
885 if (!branch.ok) throw new Error(JSON.stringify(branch.error));
886 const opened = await openPull(app, alice, gallery, {
887 title: "A frame",
888 baseBranch: gallery.defaultBranch,
889 headBranch: "frame",
890 });
891 if (!opened.ok) throw new Error(String(opened.error));
892 const env = previewEnv(opened.value.number);
893 const commitOid = branch.value.commitOid;
894 mkdirSync(join(dataDir, "looks", galleryApp.id, env), { recursive: true });
895 for (const kind of ["thumb", "desktop", "phone"] as const) {
896 const path = `looks/${galleryApp.id}/${env}/${commitOid}-${kind}.png`;
897 writeFileSync(join(dataDir, path), PNG);
898 // Taken as nobody while the app was public.
899 recordLook(app.db, {
900 appId: galleryApp.id,
901 env,
902 commitOid,
903 kind,
904 path,
905 takenAs: "nobody",
906 });
907 }
908 const look = looksForEnv(app.db, galleryApp.id, env).find(
877909 (l) => l.kind === "phone" && l.error === null,
878910 )!;
879 // Taken as nobody while the app was public.
880 app.db.query(`UPDATE look SET taken_as = 'nobody' WHERE app_id = ?1`).run(galleryApp.id);
881 const at = `/alice/gallery/looks/production/${look.commitOid}/phone.png`;
911 const at = `/alice/vault/looks/${env}/${look.commitOid}/phone.png`;
882912 expect((await web(at, bobCookie)).status).toBe(200);
883 const pull = listPulls(app.db, gallery.id, { state: "open" })[0]!;
913 const pull = opened.value;
884914 const card = async (cookie: string) =>
885 (await (await web(`/alice/gallery/pulls/${pull.number}`, cookie)).text()).includes("<h2>Look</h2>");
915 (await (await web(`/alice/vault/pulls/${pull.number}`, cookie)).text()).includes("<h2>Look</h2>");
886916 expect(await card(bobCookie)).toBe(true);
887917 // Made private: the same files, asked again on every fetch.
888918 app.db.query(`UPDATE app SET access = 'private' WHERE id = ?1`).run(galleryApp.id);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs