Public: anyone can read this; the crew can change it.

One table test fails when a list page renders empty with no next action #13958

Merged opened this

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

Merged

scout/forge:scout/13947-one-table-test-fails-when-a-list-page-re → main 4 commits fork 2 threads · 2 unresolved

  • Merged. scout/13947-one-table-test-fails-when-a-list-page-re was merged into main as 018511c.

Review

Sign in to review this change.
2 files changed +38 −0
src/web/pages/audit.ts +1
@@ -136,6 +136,7 @@ export async function auditPage(ctx: Ctx): Promise<Response> {
136136 icon: "shield",
137137 title: "No apps to audit",
138138 note: "An app's policy shows here once it has a contract.",
139 action: btn("New app", { href: "/apps/new", variant: "link" }),

Principle 8 and keyboard path: the link works with JavaScript off. Check what a viewer who cannot create apps sees here; the link should lead somewhere they can use, or fall back to sign in.

139140 })
140141 : html`<p class="mb">
141142 ${summary(sound.length, open, unsound.length, unread.length)}
test/empty-states.test.ts +37
@@ -127,3 +127,40 @@ test("emptyList takes its link from the table unless the page names one, and can
127127 expect(people).toContain(EMPTY_WORDS.people.sentence);
128128 expect(people.match(/<a\s/g)?.length).toBe(1);
129129 });
130
131 // One table for every list page a fresh admin can open (#13947): a page that draws an empty state
132 // has exactly one link or form in it, or is named in ALLOWED with the reason it has none. A failing
133 // page is named in the failure, so the fix points at the page.
134 const ALLOWED: Readonly<Record<string, string>> = {
135 "/boards": "the page's own 'Make a board' disclosure under the empty state is the one door",
136 "/apps": "the page's own 'New app' button is the one door",
137 "/displays": "a display is a file in a repository, so the next step is a git push, not a page",
138 "/settings/subscriptions": "the add-token form sits on the same page, directly below",
139 "/root/fresh/branches": "the create-branch form sits on the same page, directly above",
140 "/root/fresh/commits": "history comes from a git push; there is no page to send anyone to",
141 "/root/fresh/releases": "a release is recorded by the forge when production serves a version",
142 "/root/fresh/forks": "the Fork button in the repository's header is the one door",
143 };
144 const EMPTY_PAGES = [
145 "/apps", "/boards", "/asks", "/audit", "/displays", "/explore", "/settings/subscriptions",
146 "/root/fresh/issues", "/root/fresh/pulls", "/root/fresh/runs", "/root/fresh/branches",
147 "/root/fresh/commits", "/root/fresh/releases", "/root/fresh/forks",
148 ];
149
150 test("every empty list page has one link in its empty state, or is allowed with a reason", async () => {
151 const failing: string[] = [];
152 for (const path of EMPTY_PAGES) {
153 const blocks = emptyBlocks(await (await fetch(servers.url + path, { headers: { cookie } })).text());
154 if (blocks.length === 0) failing.push(`${path}: draws no empty state (is it still a list page?)`);
155 const n = blocks.reduce((sum, b) => sum + links(b).length, 0);
156 if (ALLOWED[path] === undefined && n !== 1) failing.push(`${path}: empty state has ${n} links, wants 1`);
157 if (ALLOWED[path] !== undefined && n > 0) {
158 failing.push(`${path}: has a link now; drop it from ALLOWED (${ALLOWED[path]})`);
159 }
160 }
161 expect(failing).toEqual([]);
162 });
163
164 test("every allowed page names its reason", () => {
165 for (const [path, why] of Object.entries(ALLOWED)) expect(`${path}: ${why.length > 10}`).toBe(`${path}: true`);

Weak test: it checks only that a reason is longer than 10 characters, and the string-compare form hides the failure. Make the reason required by the type, or drop this test.

166 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs