Public: anyone can read this; the crew can change it.
The webspec test also walks /explore/people, /changelog, /roadmap and the 404 page #10749
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/10741-the-webspec-test-also-walks-explore-peop → main 3 commits fork 2 threads · 2 unresolved
1 file
changed +20
−2
test/forge-webspec.test.ts +20 −2
| @@ -18,12 +18,12 @@ import { compress } from "../src/http/compress.ts"; | ||
| 18 | 18 | import { securityFloor } from "../src/http/respond.ts"; |
| 19 | 19 | import { setCrawlClock } from "../src/http/crawl.ts"; |
| 20 | 20 | 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"; | |
| 22 | 22 | import { quietLogs } from "./helpers/globals.ts"; |
| 23 | 23 | |
| 24 | 24 | quietLogs(); |
| 25 | 25 | |
| 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"]; | |
| 27 | 27 | |
| 28 | 28 | /** 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. */ |
| 29 | 29 | 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 () => { | ||
| 155 | 155 | expect((await http.handle(new Request(`http://forge.test${path}`, { headers: BROWSER }))).status).toBe(200); |
| 156 | 156 | } |
| 157 | 157 | }); |
| 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 | }; | |
| 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 | }); |
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.