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

forge-webspec walks a public repository, its issues list and an issue, not only the front pages #3141

Merged opened this

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

Merged

scout/forge:scout/3131-forge-webspec-walks-a-public-repository → main 1 commit fork 1 thread · 1 unresolved

  • Merged. scout/3131-forge-webspec-walks-a-public-repository was merged into main as 0fcad74.

Review

Sign in to review this change.
1 file changed +22 −13
test/forge-webspec.test.ts +22 −13
@@ -8,6 +8,7 @@ import { mkdtemp, rm } from "node:fs/promises";
88 import { tmpdir } from "node:os";
99 import { join } from "node:path";
1010 import { createApp, type App } from "../src/app.ts";
11 import { openIssue } from "../src/actions/issues.ts";
1112 import { commitToBranch, createRepo } from "../src/actions/repos.ts";
1213 import { createUser } from "../src/core/users.ts";
1314 import { securityFloor } from "../src/http/respond.ts";
@@ -17,7 +18,7 @@ import { quietLogs } from "./helpers/globals.ts";
1718
1819 quietLogs();
1920
20 const PATHS = ["/", "/signin", "/signup", "/explore"];
21 const PATHS = ["/", "/signin", "/signup", "/explore", "/alice/notes", "/alice/notes/issues", "/alice/notes/issues/1"];
2122
2223 /**
2324 * `check path` -> [section, why it stands]. Every one is expected on every
@@ -38,6 +39,20 @@ beforeAll(async () => {
3839 dir = await mkdtemp(join(tmpdir(), "forge-webspec-"));
3940 app = createApp({ dataDir: dir, port: 0 });
4041 http = forgeHttp(app);
42 const made = await createUser(app.db, {
43 origin: "seed",
44 trusted: true,
45 username: "alice",
46 email: "[email protected]",
47 password: "a-good-passphrase",
48 adminIfFirst: true,
49 });
50 if (!made.ok) throw new Error("user");
51 const repo = await createRepo(app, made.value, { name: "notes", visibility: "public" });
52 if (!repo.ok) throw new Error("repo");
53 await commitToBranch(app, made.value, repo.value, { message: "seed", files: [{ path: "a.txt", content: "a" }] });
54 const issue = openIssue(app, made.value, repo.value, { title: "First", body: "hello" });
55 if (!issue.ok) throw new Error("issue");
4156 });
4257
4358 afterAll(async () => {
@@ -58,18 +73,6 @@ test("the forge's signed-out pages raise exactly the findings named in KNOWN", a
5873 });
5974
6075 test("a page that answers 200 names its canonical address, equal to og:url; a 404 names none", async () => {
61 const made = await createUser(app.db, {
62 origin: "seed",
63 trusted: true,
64 username: "alice",
65 email: "[email protected]",
66 password: "a-good-passphrase",
67 adminIfFirst: true,
68 });
69 if (!made.ok) throw new Error("user");
70 const repo = await createRepo(app, made.value, { name: "notes", visibility: "public" });
71 if (!repo.ok) throw new Error("repo");
72 await commitToBranch(app, made.value, repo.value, { message: "seed", files: [{ path: "a.txt", content: "a" }] });
7376 const head = async (path: string) => {
7477 const res = await http.handle(new Request(`http://forge.test${path}`));
7578 return { status: res.status, html: await res.text() };
@@ -86,3 +89,9 @@ test("a page that answers 200 names its canonical address, equal to og:url; a 40
8689 expect(missing.status).toBe(404);
8790 expect(missing.html).not.toContain('rel="canonical"');
8891 });
92
93 test("the walked repository pages exist", async () => {
94 for (const path of ["/alice/notes", "/alice/notes/issues", "/alice/notes/issues/1"]) {

The path list is repeated by hand here. Build it as PATHS.filter((p) => p.startsWith("/alice")) so the two cannot drift.

95 expect((await http.handle(new Request(`http://forge.test${path}`))).status).toBe(200);
96 }
97 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs