Implement public audit pages

This commit is contained in:
Matthias
2026-06-05 14:14:07 +02:00
parent 03cb65fde4
commit 47ee2c2d51
25 changed files with 1039 additions and 45 deletions

View File

@@ -0,0 +1,50 @@
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("public audit route uses cache components and never leaks the requested slug in fallback states", async () => {
const routeSource = await source("app/audit/[slug]/page.tsx");
const configSource = await source("next.config.ts");
assert.match(configSource, /cacheComponents:\s*true/);
assert.match(routeSource, /params:\s*Promise<\{\s*slug:\s*string\s*\}>/);
assert.match(routeSource, /<Suspense/);
assert.match(routeSource, /cacheTag\(publicAuditCacheTag\(normalizedSlug\)\)/);
assert.match(routeSource, /cacheLife\("days"\)/);
assert.match(routeSource, /api\.audits\.getPublicBySlug/);
assert.match(routeSource, /robots:\s*\{[\s\S]*index:\s*false/);
assert.doesNotMatch(routeSource, /Audit:\s*\{slug\}/);
assert.doesNotMatch(routeSource, /Verwendete Skills|usedSkills/i);
});
test("public audit presentation renders observations, screenshots, and final offer", async () => {
const pageSource = await source("components/public-audit/public-audit-page.tsx");
const screenshotSource = await source("components/public-audit/public-audit-screenshot.tsx");
const statusSource = await source("components/public-audit/public-audit-status.tsx");
assert.match(pageSource, /observation\.observation/);
assert.match(pageSource, /observation\.impact/);
assert.match(pageSource, /observation\.suggestion/);
assert.match(pageSource, /audit\.screenshots\.map/);
assert.match(pageSource, /audit\.finalOffer/);
assert.match(pageSource, /href=\{audit\.finalOffer\.ctaHref\}/);
assert.match(screenshotSource, /alt=\{screenshot\.alt\}/);
assert.match(statusSource, /Dieser Audit ist noch nicht freigegeben/);
assert.match(statusSource, /Dieser Audit ist nicht verfügbar/);
});
test("sitemap stays indexable while excluding public audit URLs", async () => {
const sitemapSource = await source("app/sitemap.ts");
assert.match(sitemapSource, /MetadataRoute\.Sitemap/);
assert.match(sitemapSource, /NEXT_PUBLIC_SITE_URL/);
assert.doesNotMatch(sitemapSource, /\/audit\//);
});