Owner ruling on the empty graph (honesty principle — dead controls are lies): the top-chrome actions row now gates per control. - Import Notes renders ALWAYS (graph enabled) — the one action that works on an empty graph, the entry point itself. It used to hide with everything else, leaving the empty state a dead end with no entry. - Search + settings render only when the snapshot has nodes, and their appear-once mount carries a deliberate 200ms fade (graph-chrome-fade-in, globals.css — the settings-pop register, reduced-motion appears instantly). Computed animationName verified live. - The row's body is now the exported pure GraphChromeRow (the DeleteNodeBody pattern) — the no-match note's truth (visibleIds + snapshot) stays upstream, computed by the wrapper. - The empty-state placeholder copy is LEFT AS-IS (SCOPE rule: it already has copy — icon, title, and the session-mapping paragraph). Pins (tests/render-graph-chrome.test.tsx): empty → Import Notes present, search/settings absent, no fade carriers; populated → all three, exactly two fade carriers; the no-match note follows its upstream truth. SSR of GraphChromeRow both ways. Live-verified on :3001 with scratch data: empty graph → Import Notes only + placeholder intact; a real import through the button (file input via DataTransfer) → nodes land, search + settings fade in (computed chrome-fade-in on both carriers); wipe → reload → back to Import Notes only (the reverse path). Scratch graph restored byte-identical. 932/932, tsc/lint/build green.
65 lines
2.8 KiB
TypeScript
65 lines
2.8 KiB
TypeScript
/**
|
|
* Empty-graph chrome pins (empty-graph chrome wave, owner 2026-09-25):
|
|
* Import Notes renders ALWAYS — the one action that works on an empty
|
|
* graph, the entry point itself; search + settings render only when the
|
|
* snapshot has nodes (dead controls are lies — the honesty principle).
|
|
* GraphChromeRow is the pure seam (the DeleteNodeBody pattern): SSR of
|
|
* both states pins the ruling. Fetches don't run under renderToStaticMarkup
|
|
* (effects never fire), so these pins exercise the component directly.
|
|
*/
|
|
|
|
import React from "react";
|
|
(globalThis as Record<string, unknown>).React = React;
|
|
|
|
import assert from "node:assert/strict";
|
|
import { describe, it } from "node:test";
|
|
import { createElement } from "react";
|
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
import { GraphChromeRow } from "../components/graph-view.tsx";
|
|
import type { GraphRenderSettings } from "../components/graph-canvas.ts";
|
|
|
|
/** Ref doubles — the SSR harness never attaches them. */
|
|
const ref = { current: null };
|
|
|
|
const PROPS = {
|
|
query: "",
|
|
onQuery: () => {},
|
|
noMatch: false,
|
|
importing: false,
|
|
searchInputRef: ref,
|
|
fileInputRef: ref,
|
|
onImportFiles: () => {},
|
|
settings: {} as GraphRenderSettings,
|
|
changeSettings: () => {},
|
|
};
|
|
|
|
describe("GraphChromeRow — the empty-graph ruling (owner, 2026-09-25)", () => {
|
|
it("EMPTY graph: Import Notes renders (the entry point), search + settings absent", () => {
|
|
const html = renderToStaticMarkup(createElement(GraphChromeRow, { ...PROPS, isEmpty: true }));
|
|
assert.ok(html.includes('data-testid="import-notes"'));
|
|
assert.ok(html.includes("Import notes…"));
|
|
assert.ok(!html.includes("Search nodes…"), "search is a lie on an empty graph");
|
|
assert.ok(!html.includes('title="Rendering settings"'), "settings is a lie on an empty graph");
|
|
assert.ok(!html.includes("graph-chrome-fade-in"), "nothing gated = nothing fading in");
|
|
});
|
|
|
|
it("POPULATED graph: all three render, the gated pair carries the fade", () => {
|
|
const html = renderToStaticMarkup(createElement(GraphChromeRow, { ...PROPS, isEmpty: false }));
|
|
assert.ok(html.includes('data-testid="import-notes"'));
|
|
assert.ok(html.includes("Search nodes…"));
|
|
assert.ok(html.includes('title="Rendering settings"'));
|
|
// the appear-once fade rides exactly the two gated controls, never Import Notes
|
|
assert.equal(html.split("graph-chrome-fade-in").length - 1, 2, "two fade carriers: search + settings");
|
|
});
|
|
|
|
it("the no-match note renders only when the wrapper says so (its truth stays upstream)", () => {
|
|
const html = renderToStaticMarkup(
|
|
createElement(GraphChromeRow, { ...PROPS, isEmpty: false, query: "zzz", noMatch: true }),
|
|
);
|
|
assert.ok(html.includes("No matching nodes."));
|
|
const quiet = renderToStaticMarkup(
|
|
createElement(GraphChromeRow, { ...PROPS, isEmpty: false, query: "zzz", noMatch: false }),
|
|
);
|
|
assert.ok(!quiet.includes("No matching nodes."));
|
|
});
|
|
}); |