Open a note that also links as its article with the note on top
Words carrying a note and a Wikipedia link (one note with a body and a target, as the bulk linking pass made by merging links onto glosses, or a note and a link on the same words) opened only the note: a click toggled the gloss inline in both views, Enter did the same in the column, and in panes Enter opened the note's pane with the article folded to its summary. Now Enter or a click opens one page: the note's text first, then the article in full (in the column the note is hoisted and h returns to its words; in panes it is the next pane). A note's target is its own or that of a link on exactly its words. Node and web targets show their card beneath the note the same way. Browser tests cover click and keyboard in both views and the same-span case; the old test only covered the folded panes path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
f86a06fa06
commit
02e044af35
11 files changed
+187
-57
No files matched your search
+5
-1
@@ -2,7 +2,8 @@
|
||||
* What the browser tests share: driving the page from the keyboard, reading the store the page
|
||||
* exposes as globalThis.__ie, waiting for it to settle, and the links written into the shared
|
||||
* library over the op API, as an outside agent would (every kind of target, a note that also links,
|
||||
* a cross-document node link, two documents mentioning one article; the articles are the mock
|
||||
* a cross-document node link, two documents mentioning one article, a link and a note on the same
|
||||
* words; the articles are the mock
|
||||
* Wikipedia's fixtures in server/wikiMock.ts).
|
||||
*/
|
||||
import { writeFileSync } from "node:fs";
|
||||
@@ -85,6 +86,7 @@ export async function seedLinks(request: APIRequestContext) {
|
||||
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 ops = [
|
||||
{ op: "create", parent: recursion, kind: "note", quote: "fixed-point combinator", ref: W("Fixed-point combinator") },
|
||||
@@ -95,6 +97,8 @@ export async function seedLinks(request: APIRequestContext) {
|
||||
{ op: "create", parent: triple, kind: "note", quote: "Fred Hoyle", ref: W("Fred Hoyle") },
|
||||
{ op: "create", parent: separate, kind: "note", quote: "octopus", ref: W("Octopus") },
|
||||
{ op: "update", id: noteOn(s, separate, "cephalopod"), ref: W("Cephalopod") },
|
||||
// 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"] } },
|
||||
];
|
||||
|
||||
+68
-9
@@ -174,7 +174,7 @@ test("panes: Tab and Enter open an article in the next pane; its sections open a
|
||||
expect(await spine.evaluate((el) => getComputedStyle(el).backgroundColor)).not.toBe(await page.locator(".pane.root .spine").evaluate((el) => getComputedStyle(el).backgroundColor));
|
||||
});
|
||||
|
||||
test("a note that also links opens as one pane: its text above, the article beneath, folded to its summary until l", async ({ page }) => {
|
||||
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 inPane(page, "The triple-alpha process", "an excited state at almost exactly the energy");
|
||||
await keys(page, "Enter");
|
||||
@@ -182,22 +182,81 @@ test("a note that also links opens as one pane: its text above, the article bene
|
||||
await expect(pane).toHaveClass(/note-pane/);
|
||||
await expect(pane.locator(".body").first()).toContainText("It is called the Hoyle state");
|
||||
const block = pane.locator(".wiki.embedded");
|
||||
await expect(block).toHaveClass(/folded/);
|
||||
await expect(block.locator(".wiki-head h2")).toHaveText("Hoyle state");
|
||||
await expect(block.locator(".wattr")).toBeVisible();
|
||||
// j reaches the article under the note; l unfolds it in place; its sections are rows.
|
||||
await keys(page, "j");
|
||||
expect(await state(page, (s) => s.aux?.host?.startsWith("n"))).toBe(true);
|
||||
await keys(page, "l");
|
||||
await expect(block).not.toHaveClass(/folded/);
|
||||
await expect(block.locator(".wiki-head h2")).toHaveText("Hoyle state");
|
||||
await expect(block.locator(".wiki-text").first()).toContainText("excited, spin-0 resonant state");
|
||||
await expect(block.locator(".wattr")).toBeVisible();
|
||||
await expect(block.locator(".wrow .title")).toHaveText(["Prediction", "Structure"]);
|
||||
expect(await block.locator(".wiki-text a[data-wiki]").evaluateAll((as) => as.map((a) => a.getAttribute("data-wiki")))).toEqual(["Carbon-12", "Fred Hoyle", "Triple-alpha process"]);
|
||||
// j reaches the article under the note, then its sections; l opens one as the next pane.
|
||||
await keys(page, "j");
|
||||
expect(await state(page, (s) => s.aux?.host?.startsWith("n"))).toBe(true);
|
||||
await keys(page, "j l");
|
||||
await expect(panes(page).last().locator(".wiki-head h2")).toContainText("Prediction");
|
||||
await keys(page, "h h");
|
||||
await keys(page, "h h h");
|
||||
expect(await state(page, (s) => s.aux)).toBeNull();
|
||||
});
|
||||
|
||||
/** The page a note with a target opens as: the note's text first, as the library's, then the article. */
|
||||
async function expectCommentary(page: Page, note: string, article: string, lead: string) {
|
||||
const host = page.locator(".pane.note-pane, article:has(> header h1.note-title)").last();
|
||||
await expect(host.locator(".body").first()).toContainText(note);
|
||||
const block = host.locator(".wiki.embedded");
|
||||
await expect(block).not.toHaveClass(/folded/);
|
||||
await expect(block.locator(".wiki-head h2")).toHaveText(article);
|
||||
await expect(block.locator(".wiki-text").first()).toContainText(lead);
|
||||
// The note's text comes before the article's.
|
||||
const [n, a] = await Promise.all([host.locator(".body").first().boundingBox(), block.boundingBox()]);
|
||||
expect(n!.y).toBeLessThan(a!.y);
|
||||
}
|
||||
|
||||
test("a note that also links, clicked or entered, opens its article with the note on top, in panes and in the column", async ({ page }) => {
|
||||
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 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 jump(page, "The triple-alpha process");
|
||||
await keys(page, "Enter i");
|
||||
await tabTo(page, words);
|
||||
await keys(page, "Enter");
|
||||
await expectCommentary(page, note, "Hoyle state", "excited, spin-0 resonant state");
|
||||
// Its sections open in place, as on the article page.
|
||||
for (let i = 0; i < 6 && !(await page.locator(".wrow.focused").count()); i++) await keys(page, "j");
|
||||
await keys(page, "l");
|
||||
await expect(page.locator(".wrow.open .wiki-text")).toContainText("Hoyle reasoned");
|
||||
await keys(page, "h h h");
|
||||
expect(await selected(page)).toBe(words);
|
||||
await expect(page.locator(".wiki.embedded")).toHaveCount(0);
|
||||
// The column, by click.
|
||||
await page.locator(".anchor", { hasText: words }).click();
|
||||
await expectCommentary(page, note, "Hoyle state", "excited, spin-0 resonant state");
|
||||
await page.goBack();
|
||||
await expect(page.locator(".wiki.embedded")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("a note and a link on the same words open as that one page: the note on top, the linked article beneath", async ({ page }) => {
|
||||
const words = "The camera-like eye";
|
||||
const note = "The octopus eye has a lens";
|
||||
await wide(page, "/doc/octopus-minds");
|
||||
await inPane(page, "The common ancestor", words);
|
||||
await keys(page, "Enter");
|
||||
await expectCommentary(page, note, "Cephalopod", "molluscan class Cephalopoda");
|
||||
await column(page, "/doc/octopus-minds");
|
||||
await jump(page, "The common ancestor");
|
||||
await keys(page, "l");
|
||||
await page.locator(".anchor", { hasText: words }).click();
|
||||
await expectCommentary(page, note, "Cephalopod", "molluscan class Cephalopoda");
|
||||
await keys(page, "h");
|
||||
expect(await selected(page)).toBe(words);
|
||||
});
|
||||
|
||||
test("a link to a node in another document opens it, and Back returns; in panes it opens next and h returns", async ({ page }) => {
|
||||
await column(page, "/doc/what-a-proof-is");
|
||||
await jump(page, "Proofs as programs");
|
||||
|
||||
Reference in new issue
Block a user