Files
learnharness/tests/graph-view-filters.test.ts
T
amosblomqvist 56ed1fea40 Sync main (graph redesign b07c907): extraction observability ported onto the redesigned pipeline
Conflict resolution: extraction.ts takes main's redesign wholesale and
re-applies 072671f's observability deltas (stage durations, pipeline
failure line) — log shape only, no behavior change. graph-view.tsx's
legend/filters (094bafa) rekeyed from node.name (removed) to
statement/description, matching the new GraphNode shape.
2026-09-08 22:23:07 +03:00

51 lines
2.0 KiB
TypeScript

/**
* Legend/filters predicate tests — the pure half of the graph-view filters
* panel (isNodeVisible); the sigma reducers just consume its verdict.
*/
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { isNodeVisible } from "../components/graph-view.tsx";
import type { NodeStateClass } from "../src/core/index.ts";
const none: ReadonlySet<NodeStateClass> = new Set();
const node = {
statement: "The money multiplier is the maximum ratio of broad money to base money.",
description: "How much broad money banks create from each unit of base money.",
};
describe("isNodeVisible (legend/filters predicate)", () => {
it("is visible with no filters", () => {
assert.equal(isNodeVisible(node, "known", none, ""), true);
});
it("is hidden when its state is toggled off, even if the query matches", () => {
const hidden = new Set<NodeStateClass>(["known"]);
assert.equal(isNodeVisible(node, "known", hidden, "money"), false);
});
it("a toggled-off state does not affect other states", () => {
const hidden = new Set<NodeStateClass>(["known"]);
assert.equal(isNodeVisible(node, "taught", hidden, ""), true);
});
it("search matches the statement case-insensitively", () => {
assert.equal(isNodeVisible(node, "candidate", none, "MONEY multiplier"), true);
});
it("search matches the description when the statement does not", () => {
assert.equal(isNodeVisible(node, "candidate", none, "maximum ratio"), true);
assert.equal(isNodeVisible(node, "candidate", none, " velocity"), false);
});
it("whitespace-only query is no filter", () => {
assert.equal(isNodeVisible(node, "missed", none, " "), true);
});
it("a node with no state entry defaults to candidate", () => {
// candidate hidden → invisible; visible otherwise.
const hidden = new Set<NodeStateClass>(["candidate"]);
assert.equal(isNodeVisible(node, "candidate", hidden, ""), false);
assert.equal(isNodeVisible(node, "candidate", none, ""), true);
});
});