Public: anyone can read this; the crew can change it.
Main holds a picture of the seeded app page, so a pull's looks show it beside main #17907
Merged 22h 14m ago, live in production
scout/forge:scout/9832-main-holds-a-picture-of-the-seeded-app-p → main 0 commits fork
1 file
changed +48
−0
test/main-looks-seeded-app.test.ts added +48
| @@ -0,0 +1,48 @@ | ||
| 1 | /** Main holds a picture of the seeded app page, so a pull shows it beside main (#9832). */ | |
| 2 | import { expect, test } from "bun:test"; | |
| 3 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; | |
| 4 | import { tmpdir } from "node:os"; | |
| 5 | import { dirname, join } from "node:path"; | |
| 6 | import { createApp } from "../src/app.ts"; | |
| 7 | import { looksForEnv, recordLook } from "../src/core/looks.ts"; | |
| 8 | import { keepAsMain, mainLook } from "../src/looks/main_looks.ts"; | |
| 9 | import { pairCounts, pairsLine } from "../src/looks/pairs.ts"; | |
| 10 | import { ownerLooksFor, PREVIEW_APP_PAGE } from "../src/spawn/preview-looks.ts"; | |
| 11 | ||
| 12 | const repo = { ownerName: "trevato", name: "forge" }; | |
| 13 | ||
| 14 | test("the seeded app page is an owner look at desk and phone, on previews only", () => { | |
| 15 | const preview = ownerLooksFor("trevato/forge", repo, "pull-5"); | |
| 16 | expect(preview.filter((l) => l.page === PREVIEW_APP_PAGE).map((l) => l.kind).sort()).toEqual(["desktop", "phone"]); | |
| 17 | // production is not seeded: nothing of preview-admin is asked of it | |
| 18 | expect(ownerLooksFor("trevato/forge", repo, "production")).toEqual([]); | |
| 19 | }); | |
| 20 | ||
| 21 | test("a landed pull's picture of the seeded app page becomes main's and pairs beside main", () => { | |
| 22 | const dir = mkdtempSync(join(tmpdir(), "mainlooks-seeded-")); | |
| 23 | try { | |
| 24 | const d = createApp({ dataDir: dir, port: 0 }).db; | |
| 25 | d.run("PRAGMA foreign_keys = OFF"); | |
| 26 | const take = (env: string, kind: "phone" | "desktop") => { | |
| 27 | const path = join("looks", "app1", env, `c-app-${kind}.png`); | |
| 28 | mkdirSync(dirname(join(dir, path)), { recursive: true }); | |
| 29 | writeFileSync(join(dir, path), "png"); | |
| 30 | recordLook(d, { appId: "app1", env, commitOid: "c", page: PREVIEW_APP_PAGE, kind, path }); | |
| 31 | }; | |
| 32 | take("pull-1", "phone"); | |
| 33 | take("pull-1", "desktop"); | |
| 34 | expect(keepAsMain(d, dir, "app1", "pull-1")).toBe(2); | |
| 35 | expect(mainLook(dir, "app1", PREVIEW_APP_PAGE, "phone")).toBeDefined(); | |
| 36 | expect(mainLook(dir, "app1", PREVIEW_APP_PAGE, "desktop")).toBeDefined(); | |
| 37 | ||
| 38 | take("pull-2", "phone"); | |
| 39 | take("pull-2", "desktop"); | |
| 40 | const head = looksForEnv(d, "app1", "pull-2", "any"); | |
| 41 | const main = looksForEnv(d, "app1", "pull-1", "any"); | |
| 42 | const c = pairCounts(head, main); | |
| 43 | expect(c).toEqual({ pages: 1, beside: 1, fresh: 0, mainEmpty: false }); | |
| 44 | expect(pairsLine(c)).toBe("1 page beside main · 0 new to this pull"); | |
| 45 | } finally { | |
| 46 | rmSync(dir, { recursive: true, force: true }); | |
| 47 | } | |
| 48 | }); |
new above
offline