Implement public audit pages
This commit is contained in:
50
tests/public-audit-ui.test.ts
Normal file
50
tests/public-audit-ui.test.ts
Normal 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\//);
|
||||
});
|
||||
Reference in New Issue
Block a user