Files
webdev-pipeline/tests/dashboard-prefetch.test.ts
2026-06-05 16:47:22 +02:00

31 lines
1015 B
TypeScript

import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import test from "node:test";
test("dashboard sidebar links do not prefetch protected routes", async () => {
const source = await readFile(
join(process.cwd(), "components", "dashboard-sidebar.tsx"),
"utf8",
);
const linkMatch = source.match(/<Link[\s\S]*?href=\{item\.href\}[\s\S]*?>/);
assert.ok(linkMatch, "Dashboard sidebar should render dashboard nav Links.");
assert.match(linkMatch[0], /prefetch=\{false\}/);
});
test("lead funnel card action links do not fan out prefetches", async () => {
const source = await readFile(
join(process.cwd(), "components", "lead-funnel-board.tsx"),
"utf8",
);
const actionLinkMatch = source.match(
/<Link[\s\S]*?href=\{stageActionHref\[card\.stageId\]\}[\s\S]*?>/,
);
assert.ok(actionLinkMatch, "Lead funnel cards should link to stage actions.");
assert.match(actionLinkMatch[0], /prefetch=\{false\}/);
});