test(web): reunite lineage windowing and detach-control coverage
The rebase both-added this file: the base's lineage-window tests and the detach-control tests landed as competing versions. Keep both suites, and teach the panel mocks about the base's row-ordering export. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
4dc6d32100
commit
aeecfd01a9
1 file changed
+51
-1
@@ -11,6 +11,7 @@ const testState = vi.hoisted(() => ({
|
||||
vi.mock("@t3tools/client-runtime/state/thread-relationships", () => ({
|
||||
deriveThreadRelationshipGraph: () => ({ nodes: new Map() }),
|
||||
immediateThreadRelationships: () => testState.relationships,
|
||||
orderWebThreadLineageRows: ({ rows }: { readonly rows: ReadonlyArray<unknown> }) => rows,
|
||||
resolveMergeBackTargetThreadId: () => null,
|
||||
}));
|
||||
vi.mock("@t3tools/client-runtime/state/thread-workflows", () => ({
|
||||
@@ -39,7 +40,11 @@ vi.mock("../ui/menu", () => ({
|
||||
MenuItem: ({ children }: { readonly children: ReactNode }) => <>{children}</>,
|
||||
}));
|
||||
|
||||
import { ThreadRelationshipsPanel } from "./ThreadRelationshipsControl";
|
||||
import {
|
||||
resolveThreadLineageWindow,
|
||||
ThreadLineageRowList,
|
||||
ThreadRelationshipsPanel,
|
||||
} from "./ThreadRelationshipsControl";
|
||||
|
||||
const environmentId = "environment:relationships" as EnvironmentId;
|
||||
const threadId = "thread:relationships" as ThreadId;
|
||||
@@ -80,3 +85,48 @@ describe("ThreadRelationshipsPanel", () => {
|
||||
expect(renderPanel()).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
const rows = Array.from({ length: 20 }, (_, index) => `row-${index}`);
|
||||
|
||||
function renderRowList(visibleCount: number) {
|
||||
const { visibleRows, hiddenCount } = resolveThreadLineageWindow(rows, visibleCount);
|
||||
return renderToStaticMarkup(
|
||||
<ThreadLineageRowList hiddenCount={hiddenCount} onShowMore={() => {}}>
|
||||
{visibleRows.map((row) => (
|
||||
<li key={row}>{row}</li>
|
||||
))}
|
||||
</ThreadLineageRowList>,
|
||||
);
|
||||
}
|
||||
|
||||
describe("thread lineage row list", () => {
|
||||
it("shows six rows before the first expansion", () => {
|
||||
const { visibleRows, hiddenCount } = resolveThreadLineageWindow(rows, 6);
|
||||
|
||||
expect(visibleRows).toEqual(rows.slice(0, 6));
|
||||
expect(hiddenCount).toBe(14);
|
||||
});
|
||||
|
||||
it("offers one page at a time", () => {
|
||||
expect(renderRowList(6)).toContain("Show 12 more");
|
||||
expect(renderRowList(6 + 12)).toContain("Show 2 more");
|
||||
});
|
||||
|
||||
it("omits the expansion affordance when everything fits", () => {
|
||||
const markup = renderRowList(rows.length);
|
||||
|
||||
expect(markup).not.toContain("more");
|
||||
expect(resolveThreadLineageWindow(rows.slice(0, 6), 6).hiddenCount).toBe(0);
|
||||
});
|
||||
|
||||
it("keeps the rows in a bounded, labelled scroll region and the button outside it", () => {
|
||||
const markup = renderRowList(6);
|
||||
const list = /<ul([^>]*)>/.exec(markup)?.[1] ?? "";
|
||||
|
||||
expect(list).toContain('aria-label="Related threads"');
|
||||
expect(list).toContain("max-h-[13.5rem]");
|
||||
expect(list).toContain("overflow-y-auto");
|
||||
expect(list).toContain("overscroll-contain");
|
||||
expect(markup.indexOf("</ul>")).toBeLessThan(markup.indexOf("<button"));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user