23 lines
883 B
TypeScript
23 lines
883 B
TypeScript
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 revalidation route requires a secret and slug before invalidating cache", async () => {
|
|
const routeSource = await source("app/api/internal/revalidate-public-audit/route.ts");
|
|
|
|
assert.match(routeSource, /PUBLIC_AUDIT_REVALIDATION_SECRET/);
|
|
assert.match(routeSource, /request\.headers\.get\("authorization"\)/);
|
|
assert.match(routeSource, /Bearer \$\{secret\}/);
|
|
assert.match(routeSource, /parsePublicAuditSlug/);
|
|
assert.match(routeSource, /revalidatePublicAudit\(normalizedSlug\)/);
|
|
assert.match(routeSource, /NextResponse\.json\(\{\s*ok:\s*true/);
|
|
});
|