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, /