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

Merged opened this

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

Merged

mason/forge:mason/13294-the-forge-shows-no-banner-over-the-board → main 1 commit fork

  • Merged. mason/13294-the-forge-shows-no-banner-over-the-board was merged into main as 0d1a476.

Review

Sign in to review this change.
1 file changed +11 −3
test/no-setting-banner.test.ts +11 −3
@@ -4,13 +4,15 @@
44 * forge's settings in their unusual states (egress reported, every limit at
55 * its floor, a flag declared and set); nothing that draws as an alert may sit
66 * 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).
89 */
910 import { afterAll, beforeAll, expect, test } from "bun:test";
1011 import { mkdtempSync, rmSync } from "node:fs";
1112 import { tmpdir } from "node:os";
1213 import { join } from "node:path";
1314 import { createApp, type App } from "../src/app.ts";
15 import { createRepo } from "../src/actions/repos.ts";
1416 import { changeCapacity } from "../src/actions/capacity.ts";
1517 import { makeFlags } from "../src/core/flags.ts";
1618 import { createSession } from "../src/core/sessions.ts";
@@ -28,7 +30,10 @@ const REASON = "test: an unusual setting";
2830 /** Any element that draws as an alert or a danger notice. */
2931 const ALERT = /<(?!script|style|svg|path)[a-z0-9]+\b[^>]*(?:role="alert"|data-tone="danger"|class="[^"]*\b(?:danger|toast|error)\b[^"]*")[^>]*>/g;
3032
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 */
3237 function aboveContent(html: string): string {
3338 const main = html.indexOf("<main");
3439 // 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 () => {
4752 const made = await seedAdmin(app, { username: "alice", email: "[email protected]", password: "a-good-passphrase" });
4853 if (!made.ok) throw new Error(made.error);
4954 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));
5058 // Every limit at its floor: the tightest state a limit can be in.
5159 for (const key of Object.keys(LIMITS) as LimitKey[]) {
5260 const r = setLimit(app.db, key, LIMITS[key].min, made.value.id);
@@ -73,7 +81,7 @@ const read = async (path: string): Promise<string> => {
7381 return res.text();
7482 };
7583
76 for (const path of ["/", "/board", "/map", "/system", "/apps"]) {
84 for (const path of ["/", "/alice/forge/next", "/alice/forge", "/board", "/map", "/system", "/apps"]) {
7785 test(`${path} draws no alert above its content because of a setting`, async () => {
7886 const html = await read(path);
7987 expect(html).toContain("<main");

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs