Public: anyone can read this; the crew can change it.
A pull's looks show the before and after pairs on a real pull, and say why when main has no picture of a page #9737
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/9733-a-pull-s-looks-show-the-before-and-after → main 2 commits fork
2 files
changed +19
−2
src/web/pages/looks.ts +5 −2
| @@ -226,8 +226,11 @@ export function lookCard( | ||
| 226 | 226 | const compare = (before: readonly Look[], after: readonly Look[]): Html => |
| 227 | 227 | before.length === 0 |
| 228 | 228 | ? html`<div class="looks"> |
| 229 | ${after.map((l) => picture(l, l.kind, page))} | |
| 230 | </div>` | |
| 229 | ${after.map((l) => picture(l, l.kind, page))} | |
| 230 | </div> | |
| 231 | <p class="muted small" data-no-main> | |
| 232 | main has no picture of ${page === DEFAULT_PAGE ? "this page" : page} yet. | |
| 233 | </p>` | |
| 231 | 234 | : html`<div class="looks" data-compare> |
| 232 | 235 | <div> |
| 233 | 236 | <p class="muted small">main</p> |
test/pull-looks-pair.test.ts +14
| @@ -19,6 +19,7 @@ let dataDir: string; | ||
| 19 | 19 | let app: App; |
| 20 | 20 | let servers: Servers; |
| 21 | 21 | let page = ""; |
| 22 | let pullNumber = 0; | |
| 22 | 23 | const MAIN = "b".repeat(40); |
| 23 | 24 | const HEAD = "c".repeat(40); |
| 24 | 25 | |
| @@ -46,6 +47,7 @@ beforeAll(async () => { | ||
| 46 | 47 | take(pr, HEAD, { kind: "phone" }); |
| 47 | 48 | take(pr, HEAD, { kind: "phone", theme: "dark" }); |
| 48 | 49 | take(pr, HEAD, { kind: "desktop" }); // main has no desktop look |
| 50 | pullNumber = o.value.number; | |
| 49 | 51 | servers = await serve(app); |
| 50 | 52 | page = await (await fetch(`${servers.url}/alice/garden/pulls/${o.value.number}`)).text(); |
| 51 | 53 | }, 30_000); |
| @@ -88,3 +90,15 @@ test("an unpaired look stands alone, and every image keeps its size", () => { | ||
| 88 | 90 | for (const img of page.match(/<img[^>]*looks\/[^>]*>/g) ?? []) |
| 89 | 91 | expect(img).toMatch(/width="\d+"[\s\S]*height="\d+"/); |
| 90 | 92 | }); |
| 93 | ||
| 94 | test("with no picture on main, the head stands alone under one line, no empty frame", async () => { | |
| 95 | expect(page).not.toContain("data-no-main"); | |
| 96 | app.db.run("DELETE FROM look WHERE env = 'production'"); | |
| 97 | const text = await (await fetch(`${servers.url}/alice/garden/pulls/${pullNumber}`)).text(); | |
| 98 | expect(text).toContain("main has no picture of this page yet."); | |
| 99 | expect(text).not.toContain("data-compare"); | |
| 100 | expect(text).not.toContain(">this pull<"); | |
| 101 | expect(text).toContain(`/${HEAD}/phone.png`); | |
| 102 | expect(text).toContain(`/${HEAD}/desktop.png`); | |
| 103 | expect(text).not.toContain(MAIN); | |
| 104 | }); |