Implement public audit pages
This commit is contained in:
22
tests/public-audit-revalidation-route.test.ts
Normal file
22
tests/public-audit-revalidation-route.test.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
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/);
|
||||
});
|
||||
Reference in New Issue
Block a user