Test the page's links list: rows as they stand, old declines, overruling, removing for good

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
thalladaandClaude Opus 5.5 committed 2026-11-16 16:41:14 -05:00
1 parent 4266a2a488
commit 3be20ec049
2 files changed
+32 -2

No files matched your search

+1 -1
View File
@@ -398,7 +398,7 @@ function StatusLine() {
: store.preview : store.preview
? ["read-only", ["r", "revert to this"], ["n", "branch from this"], ["Escape", "back to now"]] ? ["read-only", ["r", "revert to this"], ["n", "branch from this"], ["Escape", "back to now"]]
: sugg : sugg
? [`suggested link → ${clip(sugg.title, 40)}`, ["y", "link"], ["n", "decline"], ["Tab", "next"], ["S", "review all"]] ? [`suggested link → ${clip(sugg.title, 40)}`, ["y", "link"], ["n", "decline"], ["Tab", "next"], ["S", "list all"]]
: selecting : selecting
? commentary ? commentary
? [["Enter", `opens the note with ${store.targetOf(commentary)!.kind === "wiki" ? "its article" : "what it links to"}`], ["e", "shows the note here"], ["D", "delete note"], ["w", "retarget"]] ? [["Enter", `opens the note with ${store.targetOf(commentary)!.kind === "wiki" ? "its article" : "what it links to"}`], ["e", "shows the note here"], ["D", "delete note"], ["w", "retarget"]]
+31 -1
View File
@@ -68,7 +68,7 @@ function counting(o: { fail?: boolean; delay?: number } = {}) {
/** A made-up suggestion in a node. */ /** A made-up suggestion in a node. */
const sugg = (node: NodeId, quote: string, at: number, more: Partial<Suggestion> = {}): Suggestion => ({ const sugg = (node: NodeId, quote: string, at: number, more: Partial<Suggestion> = {}): Suggestion => ({
id: `${node}:${quote}:${at}`, node, range: [at, at + quote.length], quote, key: quote.toLowerCase(), target: W(quote), score: 0.7, tier: "suggest", why: "", source: "wikipedia", title: quote, description: null, kind: "term", ...more, id: `${node}:${quote}:${at}`, node, range: [at, at + quote.length], quote, key: quote.toLowerCase(), target: W(quote[0].toUpperCase() + quote.slice(1)), score: 0.7, tier: "suggest", why: "", source: "wikipedia", title: quote, description: null, kind: "term", ...more,
}); });
describe("the determination store", () => { describe("the determination store", () => {
@@ -333,3 +333,33 @@ describe("the scan route in review mode", () => {
expect(marked.entries.find((s: Suggestion) => s.kind === "forced").review).toBeUndefined(); expect(marked.entries.find((s: Suggestion) => s.kind === "forced").review).toBeUndefined();
}); });
}); });
describe("the links list in the page", () => {
it("shows each stored suggestion as it stands, links nothing accounts for, and old declines as the phrase alone", async () => {
const { Linker: PageLinker } = await import("../src/ui/linker");
const { arms, doc } = library();
const body = doc.snap().nodes[arms].body;
// An old decline with no stored target, a link made by hand, and two stored suggestions: one the reviewer rejected, one waiting.
doc.apply([{ op: "update", id: arms, nolink: ["tastes"] }, { op: "create", parent: arms, kind: "note", quote: "arm", ref: W("Arm") }], "Earlier");
const page = new PageLinker({ doc: () => doc, user: () => "tyler", mode: () => "review", generating: () => true, say: () => {}, emit: () => {}, rendered: () => false });
const rejected = sugg(arms, "cephalopod", body.indexOf("cephalopod"), { review: { link: false, reason: "too general", at: 1 } });
const waiting = sugg(arms, "Fred Hoyle", body.indexOf("Fred Hoyle"));
(page as unknown as { byNode: Map<NodeId, Suggestion[]> }).byNode.set(arms, [rejected, waiting]);
const rows = page.rows([arms], doc.snap());
const by = (q: string) => rows.find((r) => r.quote === q)!;
expect(by("cephalopod")).toMatchObject({ status: "rejected", by: "reviewer", reason: "too general" });
expect(by("Fred Hoyle")).toMatchObject({ status: "pending", by: null });
expect(by("arm")).toMatchObject({ status: "linked", by: null, title: "Arm" });
expect(by("tastes")).toMatchObject({ status: "rejected", target: null, range: null });
// Only the waiting one is drawn as a suggestion.
expect(page.forNode(arms, doc.snap()).map((s) => s.quote)).toEqual(["Fred Hoyle"]);
// A person overrules the reviewer: linked by them, the reviewer's no still shown.
expect(page.accept([rejected], true)).toBe(1);
expect(page.rows([arms], doc.snap()).find((r) => r.quote === "cephalopod")).toMatchObject({ status: "linked", by: "tyler", verdict: false });
// Removing a link declines its words in the node, in one commit.
const note = page.rows([arms], doc.snap()).find((r) => r.quote === "cephalopod")!.note!;
expect(page.removeLink(note)).toBe("cephalopod");
expect(doc.snap().nodes[arms].nolink).toEqual(["cephalopod", "tastes"]);
expect(page.rows([arms], doc.snap()).find((r) => r.quote === "cephalopod")).toMatchObject({ status: "rejected", by: "tyler" });
});
});