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

The webspec test also walks /explore/people, /changelog, /roadmap and the 404 page #10749

Merged opened this

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

Merged

scout/forge:scout/10741-the-webspec-test-also-walks-explore-peop → main 3 commits fork 2 threads · 2 unresolved

  • Merged. scout/10741-the-webspec-test-also-walks-explore-peop was merged into main as e80e423.

Review

Sign in to review this change.
1 file changed +20 −2
test/forge-webspec.test.ts +20 −2
@@ -18,12 +18,12 @@ import { compress } from "../src/http/compress.ts";
1818 import { securityFloor } from "../src/http/respond.ts";
1919 import { setCrawlClock } from "../src/http/crawl.ts";
2020 import { forgeHttp, type ForgeHttp } from "../src/http/server.ts";
21 import { webspec } from "../src/release/webspec.ts";
21 import { bodyProblems, headProblems, headerProblems, s, webspec } from "../src/release/webspec.ts";
2222 import { quietLogs } from "./helpers/globals.ts";
2323
2424 quietLogs();
2525
26 const PATHS = ["/", "/signin", "/signup", "/explore", "/alice/notes", "/alice/notes/issues", "/alice/notes/issues/1", "/alice/notes/tree/main", "/alice/notes/blob/main/a.txt"];
26 const PATHS = ["/", "/signin", "/signup", "/explore", "/alice/notes", "/alice/notes/issues", "/alice/notes/issues/1", "/alice/notes/tree/main", "/alice/notes/blob/main/a.txt", "/explore?kind=people", "/apps", "/changelog"];
2727
2828 /** A person's browser: a request with no User-Agent counts against the crawl budget (#8129), which shrinks while the check machine is loaded, so these tests are never crawlers. */
2929 const BROWSER = { "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/120.0 Safari/537.36" };
@@ -155,3 +155,21 @@ test("the walked repository pages exist", async () => {
155155 expect((await http.handle(new Request(`http://forge.test${path}`, { headers: BROWSER }))).status).toBe(200);
156156 }
157157 });
158
159 test("the 404 page raises exactly the head, body and header findings named in KNOWN_404", async () => {
160 const res = await through(false)("http://forge.test/no-such-page-here");
161 expect(res.status).toBe(404);
162 const html = await res.text();
163 const problems = [...headProblems(html), ...bodyProblems(html, false), ...headerProblems(res.headers, false)];
164 // `check message` -> [section, why it stands], as KNOWN: a 404 has no address of its own, so it names no canonical and no og:url (asserted above).
165 const KNOWN_404: Record<string, [string, string]> = {
166 "canonical no <link rel=\"canonical\">": [s("canonical"), "a 404 names no canonical address, by design"],
167 "open-graph missing og:url": [s("open-graph"), "a 404 names no address to share, by design"],
168 };

Name each finding with its section as well as why, matching KNOWN: [section, why]; then filter on the section too, so a finding moving between sections fails.

169 const keyOf = (p: { check: string; message: string }) => `${p.check} ${p.message}`;
170 // New: not named, or citing another section than the one named.
outdated

This filter silently excludes the whole caching section. Name what stands in KNOWN_404 with its why, or remove the filter. The comment on line 166 claims caching is not a page's but nothing proves or names it.

171 expect(problems.filter((p) => KNOWN_404[keyOf(p)]?.[0] !== p.section).map((p) => `${keyOf(p)} [${p.section}]`)).toEqual([]);
172 // Fixed: named but no longer found, so the entry must go.
173 const found = new Set(problems.map(keyOf));
174 expect(Object.keys(KNOWN_404).filter((k) => !found.has(k))).toEqual([]);
175 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs