Public: anyone can read this; the crew can change it.
The forge shows no banner over the board: a test fails when a page other than /settings or /status prints a setting warning #13310
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/13294-the-forge-shows-no-banner-over-the-board → main 1 commit fork
1 file
changed +11
−3
test/no-setting-banner.test.ts +11 −3
| @@ -4,13 +4,15 @@ | ||
| 4 | 4 | * forge's settings in their unusual states (egress reported, every limit at |
| 5 | 5 | * its floor, a flag declared and set); nothing that draws as an alert may sit |
| 6 | 6 | * above the page's content. There is no allowlist: a healthy forge draws no |
| 7 | * red above its content, and a real failure is not a setting. | |
| 7 | * red above its content, and a real failure is not a setting. Home, /next and an | |
| 8 | * app page are among the pages read (#13294). | |
| 8 | 9 | */ |
| 9 | 10 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 10 | 11 | import { mkdtempSync, rmSync } from "node:fs"; |
| 11 | 12 | import { tmpdir } from "node:os"; |
| 12 | 13 | import { join } from "node:path"; |
| 13 | 14 | import { createApp, type App } from "../src/app.ts"; |
| 15 | import { createRepo } from "../src/actions/repos.ts"; | |
| 14 | 16 | import { changeCapacity } from "../src/actions/capacity.ts"; |
| 15 | 17 | import { makeFlags } from "../src/core/flags.ts"; |
| 16 | 18 | import { createSession } from "../src/core/sessions.ts"; |
| @@ -28,7 +30,10 @@ const REASON = "test: an unusual setting"; | ||
| 28 | 30 | /** Any element that draws as an alert or a danger notice. */ |
| 29 | 31 | const ALERT = /<(?!script|style|svg|path)[a-z0-9]+\b[^>]*(?:role="alert"|data-tone="danger"|class="[^"]*\b(?:danger|toast|error)\b[^"]*")[^>]*>/g; |
| 30 | 32 | |
| 31 | /** What sits above a page's content: the markup before `<main`, and main's own top up to the page's first heading. */ | |
| 33 | /** | |
| 34 | * What sits above a page's content: the markup before `<main`, and main's own top up to the page's | |
| 35 | * first heading. | |
| 36 | */ | |
| 32 | 37 | function aboveContent(html: string): string { |
| 33 | 38 | const main = html.indexOf("<main"); |
| 34 | 39 | // The content starts at the page's heading, or at the board's grid (the board has no heading). |
| @@ -47,6 +52,9 @@ beforeAll(async () => { | ||
| 47 | 52 | const made = await seedAdmin(app, { username: "alice", email: "[email protected]", password: "a-good-passphrase" }); |
| 48 | 53 | if (!made.ok) throw new Error(made.error); |
| 49 | 54 | cookie = `forge_session=${createSession(app.db, made.value.id).token}`; |
| 55 | // An app page and its /next need a repo to open. | |
| 56 | const repo = await createRepo(app, made.value, { name: "forge" }); | |
| 57 | if (!repo.ok) throw new Error(String(repo.error)); | |
| 50 | 58 | // Every limit at its floor: the tightest state a limit can be in. |
| 51 | 59 | for (const key of Object.keys(LIMITS) as LimitKey[]) { |
| 52 | 60 | const r = setLimit(app.db, key, LIMITS[key].min, made.value.id); |
| @@ -73,7 +81,7 @@ const read = async (path: string): Promise<string> => { | ||
| 73 | 81 | return res.text(); |
| 74 | 82 | }; |
| 75 | 83 | |
| 76 | for (const path of ["/", "/board", "/map", "/system", "/apps"]) { | |
| 84 | for (const path of ["/", "/alice/forge/next", "/alice/forge", "/board", "/map", "/system", "/apps"]) { | |
| 77 | 85 | test(`${path} draws no alert above its content because of a setting`, async () => { |
| 78 | 86 | const html = await read(path); |
| 79 | 87 | expect(html).toContain("<main"); |
new above
offline