import assert from "node:assert/strict"; import { readFile, readdir } from "node:fs/promises"; import { existsSync } from "node:fs"; import path from "node:path"; import test from "node:test"; const root = process.cwd(); async function sourceFiles(directory) { const entries = await readdir(directory, { withFileTypes: true }); const files = []; for (const entry of entries) { const location = path.join(directory, entry.name); if (entry.isDirectory()) files.push(...await sourceFiles(location)); else if (/\.(?:ts|tsx)$/u.test(entry.name)) files.push(location); } return files; } test("project includes the expected product surfaces", async () => { const required = [ "app/page.tsx", "app/feed/page.tsx", "app/my-network/page.tsx", "app/jobs/page.tsx", "app/messages/page.tsx", "app/notifications/page.tsx", "app/premium/page.tsx", "app/verify-email/page.tsx", "app/api/auth/login/route.ts", "app/api/auth/verification/confirm/route.ts", "app/api/billing/checkout/route.ts", "app/api/billing/webhook/route.ts", "app/api/posts/route.ts", "app/api/health/route.ts", "db/schema.ts", "deploy/linkedin.service", ]; for (const file of required) { assert.equal(existsSync(path.join(root, file)), true, `${file} should exist`); } const migrations = (await readdir(path.join(root, "drizzle"))).filter((file) => file.endsWith(".sql")); assert.ok(migrations.length >= 2, "SQLite schema and deterministic demo seed migrations should exist"); }); test("public home uses the requested LinkedIn replica identity without linking to LinkedIn", async () => { const home = await readFile(path.join(root, "app/page.tsx"), "utf8"); assert.match(home, /LinkedIn/); assert.match(home, /Not affiliated with LinkedIn/); assert.doesNotMatch(home, /linkedin\.com\/login/i); assert.match(home, /Welcome to your professional community/); assert.match(home, /Join now/); }); test("public entry points cannot collect credentials through GET or unbound inputs", async () => { const home = await readFile(path.join(root, "app/page.tsx"), "utf8"); const explore = await readFile(path.join(root, "components/PublicExplore.tsx"), "utf8"); const auth = await readFile(path.join(root, "components/AuthForm.tsx"), "utf8"); const registration = await readFile(path.join(root, "app/public-register/route.ts"), "utf8"); assert.doesNotMatch(home, /]+type="password"/u, "public auth walls must not collect passwords"); assert.doesNotMatch(explore, /]+action="\/register"/u, "public auth walls must not submit credentials with an implicit GET"); assert.match(auth, /
/u); assert.match(registration, //u); }); test("every credential-adjacent public surface shows a quiet account boundary", async () => { const notice = await readFile(path.join(root, "components/ReplicaSafetyNotice.tsx"), "utf8"); const home = await readFile(path.join(root, "app/page.tsx"), "utf8"); const explore = await readFile(path.join(root, "components/PublicExplore.tsx"), "utf8"); const auth = await readFile(path.join(root, "components/AuthForm.tsx"), "utf8"); const registration = await readFile(path.join(root, "app/public-register/route.ts"), "utf8"); assert.match(notice, /WebsiteBench account/u); assert.match(notice, /Not affiliated with LinkedIn/u); assert.match(notice, /Use a unique password here/u); for (const source of [home, explore, auth]) assert.match(source, /ReplicaSafetyNotice/u); assert.match(registration, /WebsiteBench account/u); assert.match(registration, /Use a unique password here/u); }); test("public registration looks like a product signup instead of a benchmark utility", async () => { const registration = await readFile(path.join(root, "app/public-register/route.ts"), "utf8"); assert.match(registration, /Make the most of your professional life/); assert.match(registration, /Agree & Join/); assert.doesNotMatch(registration, /public registration check/i); assert.doesNotMatch(registration, /WebsiteBench sends registration OTP mail/i); }); test("public UI is explicitly en-US and contains no Chinese fallback copy", async () => { const layout = await readFile(path.join(root, "app/layout.tsx"), "utf8"); const registration = await readFile(path.join(root, "app/public-register/route.ts"), "utf8"); assert.match(layout, //u); assert.match(registration, //u); assert.match(registration, /"Content-Language": "en-US"/u); const files = [ ...await sourceFiles(path.join(root, "app")), ...await sourceFiles(path.join(root, "components")), ]; for (const file of files) { assert.doesNotMatch( await readFile(file, "utf8"), /\p{Script=Han}/u, `${path.relative(root, file)} contains Chinese UI fallback copy`, ); } }); test("auth screen explains the WebsiteBench account boundary", async () => { const auth = await readFile(path.join(root, "components/AuthForm.tsx"), "utf8"); const notice = await readFile(path.join(root, "components/ReplicaSafetyNotice.tsx"), "utf8"); assert.match(auth, /ReplicaSafetyNotice/); assert.match(notice, /WebsiteBench account/); assert.match(notice, /Not affiliated with LinkedIn/); assert.match(notice, /Use a unique password here/); assert.doesNotMatch(auth, /local test/i); }); test("server foundation includes tenant and audit tables", async () => { const schema = await readFile(path.join(root, "db/schema.ts"), "utf8"); for (const table of ["organizations", "memberships", "auditLogs", "jobApplications", "savedJobs", "sessions", "emailVerificationTokens", "subscriptions"]) { assert.match(schema, new RegExp(`export const ${table}`)); } });