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
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/2219-release-gate-flakes-every-test-stands-al → main 1 commit fork
1 file
changed +39
−9
test/looks.test.ts +39 −9
| @@ -9,7 +9,7 @@ | ||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | 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"; | |
| 13 | 13 | import { mkdtemp, rm } from "node:fs/promises"; |
| 14 | 14 | import { tmpdir } from "node:os"; |
| 15 | 15 | import { join } from "node:path"; |
| @@ -871,18 +871,48 @@ describe("the look", () => { | ||
| 871 | 871 | }, 120_000); |
| 872 | 872 | |
| 873 | 873 | 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( | |
| 877 | 909 | (l) => l.kind === "phone" && l.error === null, |
| 878 | 910 | )!; |
| 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`; | |
| 882 | 912 | expect((await web(at, bobCookie)).status).toBe(200); |
| 883 | const pull = listPulls(app.db, gallery.id, { state: "open" })[0]!; | |
| 913 | const pull = opened.value; | |
| 884 | 914 | 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>"); | |
| 886 | 916 | expect(await card(bobCookie)).toBe(true); |
| 887 | 917 | // Made private: the same files, asked again on every fetch. |
| 888 | 918 | app.db.query(`UPDATE app SET access = 'private' WHERE id = ?1`).run(galleryApp.id); |
new above
offline