import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import test from "node:test";
const source = async (relativePath: string) => {
return await readFile(
join(process.cwd(), ...relativePath.split("/")),
"utf8",
);
};
test("audits dashboard page uses a dedicated board component", async () => {
const dashboardPageSource = await source("app/dashboard/audits/page.tsx");
assert.doesNotMatch(
dashboardPageSource,
/DashboardPlaceholderPage/i,
"Dashboard audits route should not render the placeholder page.",
);
assert.match(
dashboardPageSource,
/
]*>\s*\{leadSummary\(\s*lead\|[\s\S]*?\)\s*\}\s*<\/p>/, "Lead summary should not wrap leadSummary output in a nested
.", ); assert.doesNotMatch( detailSource, /
]*>\s*\{leadSummary\(\s*audit\.lead\)\s*\}\s*<\/p>/, "Lead summary should not wrap leadSummary output in a nested
.",
);
});
test("audit detail component renders verified findings before checked-page evidence", async () => {
const detailSource = await source("components/audits/audit-detail.tsx");
const findingsIndex = detailSource.indexOf("Geprüfte Befunde");
const checkedPagesIndex = detailSource.indexOf("Geprüfte Seiten");
assert.notEqual(findingsIndex, -1, "AuditDetail should render a findings section.");
assert.notEqual(checkedPagesIndex, -1, "AuditDetail should still render checked pages.");
assert.equal(
findingsIndex < checkedPagesIndex,
true,
"Findings should be rendered before raw checked-page evidence.",
);
assert.match(
detailSource,
/findings\.map/,
"AuditDetail should render one row per verified finding.",
);
for (const field of [
"claim",
"recommendation",
"customerBenefit",
"evidenceRefs",
"confidence",
]) {
assert.match(
detailSource,
new RegExp(field),
`AuditDetail should surface finding.${field}.`,
);
}
assert.match(
detailSource,
/Evidence|Beleg|Quelle/,
"AuditDetail should label evidence chips for each finding.",
);
});
test("audit detail component renders compact checked-page evidence", async () => {
const detailSource = await source("components/audits/audit-detail.tsx");
assert.match(
detailSource,
/sourceSummaries/,
"AuditDetail should read sourceSummaries from getDetail.",
);
assert.match(
detailSource,
/checkedPageEvidence/,
"AuditDetail should derive checked page evidence from sourceSummaries.checkedPages.",
);
assert.match(
detailSource,
/Geprüfte Seiten/,
"AuditDetail should render a checked-pages evidence card.",
);
assert.match(
detailSource,
/checkedPageEvidence\.map/,
"AuditDetail should render one compact row per checked page.",
);
for (const label of [
"Meta",
"Kontaktformular",
"CTA",
"Interne Links",
]) {
assert.match(
detailSource,
new RegExp(label),
`AuditDetail should expose ${label} evidence for each page.`,
);
}
assert.match(
detailSource,
/page\.screenshots\.map/,
"AuditDetail should render optional screenshot thumbnails when present.",
);
assert.match(
detailSource,
/ {
const pageSource = await source("app/dashboard/audits/[id]/page.tsx");
assert.match(
pageSource,
/params:\s*Promise<\{\s*id:\s*string\s*\}>/,
"Audit detail route should accept params as Promise in Next.js 16 style.",
);
assert.match(
pageSource,
/const \{\s*id\s*\}\s*=\s*await params/,
"Audit detail route should unwrap Promise params.",
);
assert.match(
pageSource,
/