import test from "node:test"; import assert from "node:assert/strict"; import React from "react"; import { renderToStaticMarkup } from "react-dom/server"; import { VaultTreeGroupRow, VaultTreeInlineRenameInput, VaultTreeItemRow, } from "./VaultTreeRow.tsx"; test("VaultTreeGroupRow exposes shared selected and expanded tree row state", () => { const markup = renderToStaticMarkup( undefined} onToggle={() => undefined} />, ); assert.match(markup, /data-vault-tree-row="group"/); assert.match(markup, /data-selected="true"/); assert.match(markup, /data-expanded="true"/); assert.match(markup, /Production/); assert.match(markup, /3/); }); test("VaultTreeGroupRow can render an action beside the group label", () => { const markup = renderToStaticMarkup( Edit} actions={Row action} />, ); const labelIndex = markup.indexOf("Production"); const labelActionIndex = markup.indexOf('data-label-action="edit"'); const countIndex = markup.indexOf(">3<", labelActionIndex); const rowActionIndex = markup.indexOf('data-row-action="count"', countIndex); assert.ok(labelIndex >= 0); assert.ok(labelActionIndex > labelIndex); assert.ok(countIndex > labelActionIndex); assert.ok(rowActionIndex > countIndex); }); test("VaultTreeItemRow exposes shared selected item state", () => { const markup = renderToStaticMarkup( undefined} />, ); assert.match(markup, /data-vault-tree-row="item"/); assert.match(markup, /data-selected="true"/); assert.match(markup, /Failover checklist/); }); test("VaultTreeInlineRenameInput uses shared inline edit marker", () => { const markup = renderToStaticMarkup( undefined} onCancel={() => undefined} />, ); assert.match(markup, /data-vault-tree-inline-edit="true"/); assert.match(markup, /value="Ops"/); });