From 6c97772ec9df60fc94327b6dd88901c296a2119d Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Mon, 16 Nov 2026 23:43:58 -0500 Subject: [PATCH] Browser tests and README: tops found by title, addresses named from titles The browser tests find sections by their titles from the library root and open the starter trees at /doc/; a renamed document's address follows its title. The README's addresses, text-format targets and /api/docs say the same. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab --- README.md | 33 +++++++++++++++++---------------- e2e/forks.spec.ts | 4 ++-- e2e/helpers.ts | 30 +++++++++++++++--------------- e2e/keyboard.spec.ts | 2 +- e2e/links.spec.ts | 14 +++++++------- e2e/menu.spec.ts | 37 +++++++++++++++++++------------------ e2e/more.spec.ts | 4 ++-- e2e/mouse.spec.ts | 2 +- e2e/panes.spec.ts | 4 ++-- e2e/research.spec.ts | 2 +- e2e/reviewer.spec.ts | 2 +- 11 files changed, 68 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index 5bad89d..226885a 100644 --- a/README.md +++ b/README.md @@ -303,19 +303,20 @@ IE_DATA/wiki-cache/ Wikipedia answers (derived) IE_DATA/models/ the embedding model ``` -Each document has a slug, made from its title when it is created and kept on rename, and a title. +A document is a section of the library root; nothing else marks it. Its name in an address is +made from its title (so it changes with it); nothing of it is stored. | | | |---|---| | `/` | the library | -| `/doc/` | a document | -| `/doc//` | a node in it (the id is what counts: a moved node is still found) | +| `/doc/` | a document | +| `/doc//` | a node in it (the id is what counts: a moved node is still found) | | `/n/` | any node | | `/w//` | a Wikipedia article as a page of its own (the column) | The address follows the focus; opening a document or jumping makes a history entry. -On startup every `library/*.md` whose slug (its file name) has not been imported before is +On startup every `library/*.md` whose file name has not been imported before is imported at the end of the library, so a starter document you delete stays deleted. A file that does not parse is logged and skipped. @@ -349,9 +350,9 @@ Its text. ^ "words" link -> w:Octopus a link: a target and no text ^ "other words" note why -> w:Hoyle state: a note that also has a target -^ "a phrase" link -> /fixed-points/Recursion without names/How Y works +^ "a phrase" link -> /Fixed points/Recursion without names/How Y works ^ "nearby" link -> ./A section about something -^ "a quote" link -> /octopus-minds/Arms that decide ^"tastes what it touches" +^ "a quote" link -> /Octopus minds/Arms that decide ^"tastes what it touches" ^ "the web" link -> https://example.org/page "Its title" ``` @@ -360,7 +361,7 @@ A `^` line is a note on the section above it, or, indented, on the note above: ` `define`, `why`, `example`, `challenge` or any question. The quote must be exact words of the parent's text (the first occurrence is anchored); a missing quote is an error naming the file, line, section and quote. A target is `w:Title` (`w.fr:Titre` for another language), a node by its -document's slug and section titles (`./Section` in the same document, `^"quote"` for a note there), +titles from the library root (`./Section` below the top of the file, `^"quote"` for a note there), or an `http(s)` address with an optional title. A target containing `: ` is quoted; in a path `\/`, `\^` and `\\` escape a slash, a caret and a backslash. Wrapped lines join with a space; a line ending in `\` keeps its break; a text line starting with `#`, `^` or `\` is written with a `\` in @@ -378,16 +379,16 @@ same tree. |---|---| | `GET /api/tree[/<branch>]` | the whole library as JSON, with conflicts and recent history | | `POST /api/ops[/<branch>]` | `{ ops, message?, author?, actor? }`, applied as one commit. `create` and `update` take `ref`: `{ "kind": "wiki", "title", "lang" }`, `{ "kind": "node", "id", "doc", "path" }` or `{ "kind": "url", "url", "title" }`; `"ref": null` removes it | -| `GET /api/docs` | the documents, in library order: `{ node, slug, title, excerpt }` | +| `GET /api/docs` | the documents, in library order: `{ node, slug, title, excerpt }` (`slug`: the name made from the title) | | `POST /api/docs` `{ title }` | a new blank document | | `POST /api/docs/import?name=file.md` | body: the file (2 MB at most); 422 with `problems` if it does not parse | -| `GET` / `PATCH {title}` / `DELETE /api/docs/<slug>` | read, rename, delete (undoable) | -| `POST /api/docs/<slug>/duplicate` `{ title }` | a copy of the document | -| `GET /api/docs/<slug>/export[/<branch>]` | the text format; header `x-skipped` counts what was left out | -| `GET /api/docs/<slug>/tree[/<branch>]`, `POST /api/docs/<slug>/ops[/<branch>]` | one document's subtree with its conflicts; ops as above | +| `GET` / `PATCH {title}` / `DELETE /api/docs/<name or node id>` | read, rename, delete (undoable) | +| `POST /api/docs/<name or node id>/duplicate` `{ title }` | a copy of the document | +| `GET /api/docs/<name or node id>/export[/<branch>]` | the text format; header `x-skipped` counts what was left out | +| `GET /api/docs/<name or node id>/tree[/<branch>]`, `POST /api/docs/<name or node id>/ops[/<branch>]` | one document's subtree with its conflicts; ops as above | | `GET /api/wiki/…` | Wikipedia through the server's cache: `summary`, `article` (`&full=1` for every section), `section`, `senses`, `suggest`, `search`, `lookup` (server/wikiRoutes.ts) | | `POST /api/links/scan` `{ node, review? }` | scan a node and record what is found as pending; with `review`, the model reviewer judges what is new, and the approved links are handed back to be made | -| `GET /api/links/pending?doc=<slug>&tier=auto\|suggest&all=1&claim=1` | pending suggestions with the context a reviewer needs; `all` with every determination; `claim` hands out the approved links no page has made | +| `GET /api/links/pending?doc=<name or node id>&tier=auto\|suggest&all=1&claim=1` | pending suggestions with the context a reviewer needs; `all` with every determination; `claim` hands out the approved links no page has made | | `POST /api/links/accept` / `reject` `{ ids, author? }` | link them in one commit, or record them as declined | | `POST /api/links/decide` `{ ids, link, by }` | record a person's decision made in their own replica | | `POST` / `GET` / `DELETE /api/links/jobs` `{ scope: "doc" \| "library", doc?, review? }` | a background scan (reviewed, with `review`): start, progress, cancel | @@ -397,7 +398,7 @@ same tree. An outside agent reads and writes with the same ops the keyboard uses: ```sh -curl localhost:4747/api/docs/tides/tree +curl localhost:4747/api/docs/the-tides/tree curl localhost:4747/api/ops -H 'content-type: application/json' -d '{ "author": "my-agent", "message": "Add a remark", "ops": [{ "op": "create", "parent": "<node id>", "title": "A remark", "body": "Text." }] @@ -430,8 +431,8 @@ npm run fixtures render DIR && npm run fixtures check DIR Two replicas pointing one link at different targets is left to a person (`1` `2` in history). - Export cannot hold a note's title, sections under a note, or the prompt sentences the first document's sections cite. -- Two replicas creating documents with the same slug at once both keep it; the first in the library - wins the address. Two replicas linking the same words both keep their link. +- Two documents with the same title share a name; the first in the library has the short address. + Two replicas linking the same words both keep their link. - In history, the documents a commit touched are placed by where its nodes are now: a commit that only deleted names none. - Articles are shown without images, references or infoboxes. diff --git a/e2e/forks.spec.ts b/e2e/forks.spec.ts index 2327480..27a3401 100644 --- a/e2e/forks.spec.ts +++ b/e2e/forks.spec.ts @@ -73,7 +73,7 @@ async function still(page: Page) { } async function open(page: Page) { - await page.goto("/doc/infinite-expand"); + await page.goto("/doc/infinispand"); await page.waitForSelector(".strip .pane"); await page.evaluate(() => document.fonts.ready); await expect(page.locator(".strip .pane")).toHaveCount(2); @@ -92,7 +92,7 @@ async function tabTo(page: Page, words: string) { /** The owner's screenshot: Two kinds of cell, with Eukaryote (opened from its link), Simple cells and Complex cells beside each other in the next column, and Bacteria opened from Eukaryote's text. */ async function cells(page: Page) { - await page.goto("/doc/the-eukaryotic-cell"); + await page.goto("/doc/the-one-merger"); await page.waitForSelector(".strip .pane"); await page.evaluate(() => document.fonts.ready); await jump(page, "Two kinds of cell"); diff --git a/e2e/helpers.ts b/e2e/helpers.ts index 98451c0..9897023 100644 --- a/e2e/helpers.ts +++ b/e2e/helpers.ts @@ -77,34 +77,34 @@ export const writeReport = (name: string, report: unknown) => writeFileSync(`tes interface Snap { root: string; - nodes: Record<string, { id: string; parent: string | null; kind: string; title: string; body: string; slug?: string; ref?: unknown; anchors: { text: string }[]; children: string[] }>; + nodes: Record<string, { id: string; parent: string | null; kind: string; title: string; body: string; ref?: unknown; anchors: { text: string }[]; children: string[] }>; } const W = (title: string) => ({ kind: "wiki", title, lang: "en" }); -/** Find a section by its document's slug and title path. */ -function find(s: Snap, slug: string, ...path: string[]): string { - let at = s.nodes[s.root].children.find((c) => s.nodes[c].slug === slug)!; - for (const t of path) at = s.nodes[at].children.find((c) => s.nodes[c].kind === "section" && s.nodes[c].title === t)!; - if (!at) throw new Error(`no ${slug}/${path.join("/")}`); +/** Find a section by its titles from the library root. */ +function find(s: Snap, ...path: string[]): string { + let at = s.root; + for (const t of path) at = s.nodes[at]?.children.find((c) => s.nodes[c].kind === "section" && s.nodes[c].title === t) as string; + if (!at) throw new Error(`no /${path.join("/")}`); return at; } const noteOn = (s: Snap, parent: string, quote: string) => s.nodes[parent].children.find((c) => s.nodes[c].kind === "note" && s.nodes[c].anchors[0]?.text === quote)!; export async function seedLinks(request: APIRequestContext) { const s: Snap = await (await request.get("/api/tree")).json(); - const recursion = find(s, "fixed-points", "Recursion without names"); + const recursion = find(s, "Fixed points", "Recursion without names"); if (s.nodes[recursion].children.some((c) => s.nodes[c].ref)) return; // already seeded by an earlier test - const howY = find(s, "fixed-points", "Recursion without names", "How Y works"); - const triple = find(s, "origin-of-the-elements", "Fusion in ordinary stars", "The triple-alpha process"); - const separate = find(s, "octopus-minds", "A separate experiment"); - const ancestor = find(s, "octopus-minds", "A separate experiment", "The common ancestor"); - const programs = find(s, "what-a-proof-is", "Proof assistants", "Proofs as programs"); - const kinds = find(s, "the-eukaryotic-cell", "Two kinds of cell"); + const howY = find(s, "Fixed points", "Recursion without names", "How Y works"); + const triple = find(s, "Where the elements come from", "Fusion in ordinary stars", "The triple-alpha process"); + const separate = find(s, "Octopus minds", "A separate experiment"); + const ancestor = find(s, "Octopus minds", "A separate experiment", "The common ancestor"); + const programs = find(s, "What a proof is", "Proof assistants", "Proofs as programs"); + const kinds = find(s, "The one merger", "Two kinds of cell"); const ops = [ { op: "create", parent: recursion, kind: "note", quote: "fixed-point combinator", ref: W("Fixed-point combinator") }, { op: "update", id: noteOn(s, recursion, "lambda calculus"), ref: W("Lambda calculus") }, - { op: "create", parent: recursion, kind: "note", quote: "Y combinator", ref: { kind: "node", id: howY, doc: "fixed-points", path: ["Recursion without names", "How Y works"] } }, + { op: "create", parent: recursion, kind: "note", quote: "Y combinator", ref: { kind: "node", id: howY, path: ["Fixed points", "Recursion without names", "How Y works"] } }, { op: "create", parent: recursion, kind: "note", quote: "self-reference", ref: { kind: "url", url: "https://plato.stanford.edu/entries/self-reference/", title: "Self-Reference (Stanford Encyclopedia of Philosophy)" } }, { op: "update", id: noteOn(s, triple, "an excited state at almost exactly the energy"), ref: W("Hoyle state") }, { op: "create", parent: triple, kind: "note", quote: "Fred Hoyle", ref: W("Fred Hoyle") }, @@ -113,7 +113,7 @@ export async function seedLinks(request: APIRequestContext) { // A link on words that already carry a note of their own: two notes on one span. { op: "create", parent: ancestor, kind: "note", quote: "The camera-like eye", ref: W("Cephalopod") }, { op: "create", parent: programs, kind: "note", quote: "a function turning proofs", ref: W("Lambda calculus") }, - { op: "create", parent: programs, kind: "note", quote: "Several of the leading systems", ref: { kind: "node", id: recursion, doc: "fixed-points", path: ["Recursion without names"] } }, + { op: "create", parent: programs, kind: "note", quote: "Several of the leading systems", ref: { kind: "node", id: recursion, path: ["Fixed points", "Recursion without names"] } }, { op: "create", parent: kinds, kind: "note", quote: "Eukaryotes", ref: W("Eukaryote") }, { op: "create", parent: kinds, kind: "note", quote: "Bacteria", ref: W("Bacteria") }, ]; diff --git a/e2e/keyboard.spec.ts b/e2e/keyboard.spec.ts index aa92b89..09fc87b 100644 --- a/e2e/keyboard.spec.ts +++ b/e2e/keyboard.spec.ts @@ -15,7 +15,7 @@ const titlesUnder = (page: Page, title: string) => /** The first document, opened in the column (hoisted, with the library one step out). */ async function open(page: Page) { - await page.goto("/doc/infinite-expand"); + await page.goto("/doc/infinispand"); await page.waitForSelector("article"); await page.evaluate(() => document.fonts.ready); } diff --git a/e2e/links.spec.ts b/e2e/links.spec.ts index d22879e..6e1b95a 100644 --- a/e2e/links.spec.ts +++ b/e2e/links.spec.ts @@ -182,7 +182,7 @@ test("panes: Tab and Enter open an article in the next pane; its sections open a }); test("a note that also links opens as one pane: its text above, the article in full beneath", async ({ page }) => { - await wide(page, "/doc/origin-of-the-elements"); + await wide(page, "/doc/where-the-elements-come-from"); await inPane(page, "The triple-alpha process", "an excited state at almost exactly the energy"); await keys(page, "Enter"); const pane = panes(page).last(); @@ -221,14 +221,14 @@ test("a note that also links, clicked or entered, opens its article with the not const words = "an excited state at almost exactly the energy"; const note = "It is called the Hoyle state"; // Panes, by click. - await wide(page, "/doc/origin-of-the-elements"); + await wide(page, "/doc/where-the-elements-come-from"); await jump(page, "The triple-alpha process"); await keys(page, "l"); await panes(page).last().locator(".anchor", { hasText: words }).click(); await expect(panes(page).last()).toHaveClass(/note-pane/); await expectCommentary(page, note, "Hoyle state", "excited, spin-0 resonant state"); // The column, by keyboard: Enter on the words opens the note as a page; h returns to the words. - await column(page, "/doc/origin-of-the-elements"); + await column(page, "/doc/where-the-elements-come-from"); await jump(page, "The triple-alpha process"); await keys(page, "Enter i"); await tabTo(page, words); @@ -323,7 +323,7 @@ test("Linked from and Mentioned in list what links here, reachable by j and Ente }); test("linking by hand: the picker links to the library, to Wikipedia and to an address; it retargets; /unlink and D remove", async ({ page }) => { - await column(page, "/doc/tides"); + await column(page, "/doc/the-tides"); await jump(page, "The tides"); const doc = await state(page, (s) => s.focus.node); const linkCount = () => page.evaluate((d) => { @@ -342,7 +342,7 @@ test("linking by hand: the picker links to the library, to Wikipedia and to an a await expect(picker.locator(".choice.selected .t")).toHaveText("Octopus minds"); await keys(page, "Enter"); await expect(picker).toHaveCount(0); - expect(await linkCount()).toEqual([`${word}|node|`]); + expect(await linkCount()).toEqual([`${word}|node|Octopus minds`]); // its path: the titles from the library root await expect(page.locator(".lnk.l-node", { hasText: word })).toBeVisible(); // The same picker on that link retargets it, here to Wikipedia: suggestions arrive under their own head. await keys(page, "w"); @@ -385,7 +385,7 @@ test("linking by hand: the picker links to the library, to Wikipedia and to an a }); test("a disambiguation page lists its senses as rows; a missing article, an unreachable Wikipedia and a slow one say so plainly", async ({ page }) => { - await wide(page, "/doc/tides"); + await wide(page, "/doc/the-tides"); await jump(page, "The tides"); await keys(page, "i i"); await command(page, "/link w:Mercury"); @@ -474,7 +474,7 @@ test("a hostile article cannot run script or load anything from elsewhere, in a let dialogs = 0; page.on("dialog", (d) => (dialogs++, d.dismiss())); for (const view of [wide, column]) { - await view(page, "/doc/tides"); + await view(page, "/doc/the-tides"); await jump(page, "The tides"); await keys(page, "i i"); await command(page, "/link w:Hostile article"); diff --git a/e2e/menu.spec.ts b/e2e/menu.spec.ts index c061dd6..90f9e50 100644 --- a/e2e/menu.spec.ts +++ b/e2e/menu.spec.ts @@ -36,7 +36,7 @@ const menuList = async (page: Page) => { await expect(page.locator(".panel.docs .filter")).not.toBeFocused(); await expect.poll(() => state(page, (s) => `${s.mode}/${s.menu.focus}`)).toBe("docs/list"); }; -async function open(page: Page, path = "/doc/infinite-expand") { +async function open(page: Page, path = "/doc/infinispand") { await page.goto(path); await page.waitForSelector("article"); } @@ -62,7 +62,7 @@ test("the library is the first page: its documents are its sections, and opening await keys(page, "j Enter"); // the first document's row: it opens in place of the list await expect(page.locator(".top h1")).toHaveText("Infinispand"); await expect(page.locator(".crumbs")).toHaveText(/Library/); - await expect(page).toHaveURL(/\/doc\/infinite-expand$/); + await expect(page).toHaveURL(/\/doc\/infinispand$/); await expect(page.locator(".docbar .doc-title .name")).toHaveText("Infinispand"); await keys(page, "h"); // stepping out of the document returns to the library, on its row await expect(page.locator(".top h1")).toHaveText("Library"); @@ -113,12 +113,13 @@ test("import a .md file, then export it and get the same document back", async ( const again = page.waitForEvent("filechooser"); await command(page, "/import"); await (await again).setFiles({ name: "menu-fixture.md", mimeType: "text/markdown", buffer: Buffer.from(text) }); - await expect(page).toHaveURL(/\/doc\/menu-fixture-2$/); + // A second top with the same name is addressed by its id as well. + await expect(page).toHaveURL(/\/doc\/menu-fixture\/[^/]+$/); expect(await shape()).toBe(imported); expect(await state(page, (s) => [s.currentDoc, ...s.snap.nodes[s.currentDoc].children].filter((id: string) => s.snap.nodes[id].by !== "llm").length)).toBe(0); // Both are on the server, as sections of the library. await synced(page); - expect((await (await page.request.get("/api/docs")).json()).map((d: any) => d.slug)).toEqual(expect.arrayContaining(["menu-fixture", "menu-fixture-2"])); + expect((await (await page.request.get("/api/docs")).json()).filter((d: any) => d.slug === "menu-fixture")).toHaveLength(2); }); test("a file with a quote that is not in its text is refused, naming the section and the quote", async ({ page }) => { @@ -151,7 +152,7 @@ test("filter and open; the address names the document and the node, and survives await expect(page.locator(".top h1")).toHaveText("Menu fixture"); expect(await state(page, (s) => s.focus.node)).toBe(section); // A link to a document opens it; Back returns to the node; Back again to the library. - await open(page, "/doc/infinite-expand"); + await open(page, "/doc/infinispand"); await expect(page.locator(".top h1")).toHaveText("Infinispand"); await page.goBack(); await expect(page.locator(".top h1")).toHaveText("Menu fixture"); @@ -174,7 +175,7 @@ test("the jump box searches every document, says which one each match is in, and await page.keyboard.press("Enter"); await expect(page.locator(".top h1")).toHaveText("The tides"); expect(await state(page, (s) => s.snap.nodes[s.focus.node].title)).toBe("Amphidromes"); - await expect(page).toHaveURL(/\/doc\/tides\/\d+%40\d+$/); + await expect(page).toHaveURL(/\/doc\/the-tides\/\d+%40\d+$/); // Back to where the jump started. await page.goBack(); await expect(page.locator(".top h1")).toHaveText("Infinispand"); @@ -202,7 +203,7 @@ test("the library opens from this browser without the network, and catches up wh await page.reload(); await page.waitForSelector("article"); await expect(page.locator(".docbar .save-state")).toHaveText("saved", { timeout: 15_000 }); - expect(JSON.stringify(await (await page.request.get("/api/docs/tides/tree")).json())).toContain("Renamed offline"); + expect(JSON.stringify(await (await page.request.get("/api/docs/the-tides/tree")).json())).toContain("Renamed offline"); }); test("create, rename and duplicate from the menu", async ({ page }) => { @@ -221,9 +222,9 @@ test("create, rename and duplicate from the menu", async ({ page }) => { await page.keyboard.press("Enter"); await expect(page.locator(".top h1")).toHaveText("Scratch pad, renamed"); await expect(page.locator(".panel.docs .doc.current .title")).toHaveText("Scratch pad, renamed"); - await expect(page).toHaveURL(/\/doc\/scratch-pad$/); // the slug, and so links, stay + await expect(page).toHaveURL(/\/doc\/scratch-pad-renamed$/); // the address follows the title; links go by node id await synced(page); - const listed = await (await page.request.get("/api/docs/scratch-pad")).json(); + const listed = await (await page.request.get("/api/docs/scratch-pad-renamed")).json(); expect(listed.title).toBe("Scratch pad, renamed"); await keys(page, "s"); @@ -234,8 +235,8 @@ test("create, rename and duplicate from the menu", async ({ page }) => { await expect(page).toHaveURL(/\/doc\/scratch-copy$/); // The copy sits after the original in the library, and is one commit in its history. expect(await state(page, (s) => s.commits()[0].message)).toBe("Duplicate “Scratch pad, renamed” as “Scratch copy”"); - const order = await state(page, (s) => s.snap.nodes[s.snap.root].children.filter((c: string) => !s.snap.nodes[c].articles).map((c: string) => s.snap.nodes[c].slug)); - expect(order.indexOf("scratch-copy")).toBe(order.indexOf("scratch-pad") + 1); + const order = await state(page, (s) => s.snap.nodes[s.snap.root].children.filter((c: string) => !s.snap.nodes[c].articles).map((c: string) => s.snap.nodes[c].title)); + expect(order.indexOf("Scratch copy")).toBe(order.indexOf("Scratch pad, renamed") + 1); }); test("delete asks first, and is an ordinary delete that u undoes", async ({ page }) => { @@ -252,13 +253,13 @@ test("delete asks first, and is an ordinary delete that u undoes", async ({ page await synced(page); expect((await page.request.get("/api/docs/scratch-copy")).status()).toBe(404); await keys(page, "Escape u"); - await expect.poll(() => state(page, (s) => s.snap.nodes[s.snap.root].children.map((c: string) => s.snap.nodes[c].slug))).toContain("scratch-copy"); + await expect.poll(() => state(page, (s) => s.snap.nodes[s.snap.root].children.map((c: string) => s.snap.nodes[c].title))).toContain("Scratch copy"); await synced(page); expect((await page.request.get("/api/docs/scratch-copy")).status()).toBe(200); }); test("a node moves from one document to another, and undo works wherever the last edit was", async ({ page }) => { - await open(page, "/doc/scratch-pad"); + await open(page, "/doc/scratch-pad-renamed"); await keys(page, "a"); await page.keyboard.type("Only in the scratch pad"); await page.keyboard.press("Enter"); @@ -267,7 +268,7 @@ test("a node moves from one document to another, and undo works wherever the las await expect(page.locator(".top h1")).toHaveText("Menu fixture"); expect(await titles(page)).not.toContain("Only in the scratch pad"); await expect - .poll(async () => JSON.stringify(await (await page.request.get("/api/docs/scratch-pad/tree")).json())) + .poll(async () => JSON.stringify(await (await page.request.get("/api/docs/scratch-pad-renamed/tree")).json())) .toContain("Only in the scratch pad"); expect(JSON.stringify(await (await page.request.get("/api/docs/menu-fixture/tree")).json())).not.toContain("Only in the scratch pad"); // Undo is the library's too: u here takes back the edit made in the scratch pad. @@ -280,7 +281,7 @@ test("a node moves from one document to another, and undo works wherever the las await synced(page); const tree = await (await page.request.get("/api/tree")).json(); const node = Object.values<any>(tree.nodes).find((n) => n.title === "Only in the scratch pad"); - const target = Object.values<any>(tree.nodes).find((n) => n.slug === "menu-fixture"); + const target = tree.nodes[tree.nodes[tree.root].children.find((c: string) => tree.nodes[c].title === "Menu fixture")]; const res = await page.request.post("/api/ops", { data: { author: "mover", message: "Move it across", ops: [{ op: "move", id: node.id, parent: target.id }] } }); expect(res.ok()).toBe(true); await expect.poll(() => titles(page)).not.toContain("Only in the scratch pad"); @@ -302,7 +303,7 @@ test("a note being written in one document lands there after the reader has move await expect(page.locator(".top h1")).toHaveText("Scratch pad, renamed"); await idle(page); await expect(page.locator(".pending, .writing")).toHaveCount(0); - const notes = await state(page, (s) => s.snap.nodes[s.snap.nodes[s.snap.root].children.find((c: string) => s.snap.nodes[c].slug === "menu-fixture")].children.filter((c: string) => /mock/i.test(s.snap.nodes[c].body)).length); + const notes = await state(page, (s) => s.snap.nodes[s.snap.nodes[s.snap.root].children.find((c: string) => s.snap.nodes[c].title === "Menu fixture")].children.filter((c: string) => /mock/i.test(s.snap.nodes[c].body)).length); expect(notes).toBe(1); expect(await state(page, (s) => s.snap.nodes[s.focus.node].title)).not.toBe(where); }); @@ -318,14 +319,14 @@ test("the : commands do the same", async ({ page }) => { const download = page.waitForEvent("download"); await command(page, "/export"); expect(await (await download).suggestedFilename()).toBe("menu-fixture.md"); - await command(page, "/open made-by-command"); + await command(page, "/open renamed-by-command"); await expect(page.locator(".top h1")).toHaveText("Renamed by command"); }); test("the menu works in panes and at phone width", async ({ page }) => { await page.setViewportSize({ width: 1920, height: 1080 }); await autoLayout(page); - await open(page, "/doc/infinite-expand"); + await open(page, "/doc/infinispand"); await expect(page.locator(".strip .pane")).toHaveCount(2); // the library, and the document await openByMenu(page, "menu fixture"); await expect(page.locator(".strip .pane.root h1")).toHaveText("Library"); diff --git a/e2e/more.spec.ts b/e2e/more.spec.ts index 3cfaf3f..8c7c983 100644 --- a/e2e/more.spec.ts +++ b/e2e/more.spec.ts @@ -3,7 +3,7 @@ import { expect, test, type Page } from "@playwright/test"; import { idle, jump, keys, settle, state } from "./helpers"; async function open(page: Page) { - await page.goto("/doc/infinite-expand"); + await page.goto("/doc/infinispand"); await page.waitForSelector("article"); } @@ -121,7 +121,7 @@ test("an outside agent edits over HTTP with the same ops, and the open page foll await open(page); const tree = await (await request.get("/api/tree/main")).json(); // The tree is the whole library; its documents are the root's sections. - expect(Object.values<any>(tree.nodes).filter((n) => n.parent === tree.root).map((n) => n.slug)).toContain("infinite-expand"); + expect(Object.values<any>(tree.nodes).filter((n) => n.parent === tree.root).map((n) => n.title)).toContain("Infinispand"); const target = Object.values<any>(tree.nodes).find((n) => n.title === "The first document"); expect(target).toBeTruthy(); const res = await request.post("/api/ops/main", { diff --git a/e2e/mouse.spec.ts b/e2e/mouse.spec.ts index fdf2062..beb4af5 100644 --- a/e2e/mouse.spec.ts +++ b/e2e/mouse.spec.ts @@ -45,7 +45,7 @@ test.describe.configure({ mode: "serial" }); test.beforeAll(async ({ request }) => { // A link on "simple ratio" (to the mock Wikipedia's Octopus), once. const s = await (await request.get("/api/tree")).json(); - const doc = s.nodes[s.root].children.find((c: string) => s.nodes[c].slug === "tuning-and-temperament"); + const doc = s.nodes[s.root].children.find((c: string) => s.nodes[c].title === "Tuning and temperament"); const sec = s.nodes[doc].children.find((c: string) => s.nodes[c].title === "Why some intervals sound smooth"); if (s.nodes[sec].children.some((c: string) => s.nodes[c].ref)) return; const res = await request.post("/api/ops", { data: { author: "mouse", message: "A link for the mouse tests", ops: [{ op: "create", parent: sec, kind: "note", quote: "simple ratio", ref: { kind: "wiki", title: "Octopus", lang: "en" } }] } }); diff --git a/e2e/panes.spec.ts b/e2e/panes.spec.ts index 31e5395..28ed9e1 100644 --- a/e2e/panes.spec.ts +++ b/e2e/panes.spec.ts @@ -19,7 +19,7 @@ const paneTitles = async (page: Page) => (await panes(page)).map((p) => p.title) const nodeId = (page: Page, title: string) => page.evaluate((t) => (Object.values((globalThis as any).__ie.snap.nodes) as any[]).find((n) => n.title === t).id as string, title); async function open(page: Page) { - await page.goto("/doc/infinite-expand"); + await page.goto("/doc/infinispand"); await page.waitForSelector(".strip .pane"); await page.evaluate(() => document.fonts.ready); // The library pane and the document's; hoisting makes the document the first. @@ -57,7 +57,7 @@ test("the library is the first pane, and a document opens in the next; reload an await page.keyboard.press("Enter"); // From the menu a document opens in place of the one open, not beside it. expect(await paneTitles(page)).toEqual(["Library", "Infinispand", "The tides"]); - await expect(page).toHaveURL(/\/doc\/tides$/); + await expect(page).toHaveURL(/\/doc\/the-tides$/); await page.goBack(); await expect.poll(() => paneTitles(page)).toEqual(third); await page.goForward(); diff --git a/e2e/research.spec.ts b/e2e/research.spec.ts index 4bc8003..99138e0 100644 --- a/e2e/research.spec.ts +++ b/e2e/research.spec.ts @@ -13,7 +13,7 @@ async function open(page: Page) { (globalThis as any).__opened = []; window.open = ((url: string) => ((globalThis as any).__opened.push(String(url)), null)) as typeof window.open; }); - await page.goto("/doc/infinite-expand"); + await page.goto("/doc/infinispand"); await page.waitForSelector("article"); } diff --git a/e2e/reviewer.spec.ts b/e2e/reviewer.spec.ts index bcc1a6d..5902010 100644 --- a/e2e/reviewer.spec.ts +++ b/e2e/reviewer.spec.ts @@ -187,7 +187,7 @@ test("when the model fails, nothing is linked unreviewed: everything is suggeste test("a background job is reviewed as it goes, with the model's calls counted, and can be stopped; a finished one links what was approved", async ({ page }) => { await column(page); - await page.goto("/doc/tides"); + await page.goto("/doc/the-tides"); await page.waitForFunction(() => (globalThis as any).__ie?.ready); await command(page, "/linkall"); await page.waitForFunction(() => (globalThis as any).__ie.links.job?.state === "running" && (globalThis as any).__ie.links.job.done > 0);