File size: 5,956 Bytes
062a991
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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, /<input\b/u, "public home must use explicit local-account links instead of credential inputs");
  assert.doesNotMatch(explore, /<input[^>]+type="password"/u, "public auth walls must not collect passwords");
  assert.doesNotMatch(explore, /<form[^>]+action="\/register"/u, "public auth walls must not submit credentials with an implicit GET");
  assert.match(auth, /<form method="post" onSubmit=\{submit\}>/u);
  assert.match(registration, /<form method="post" data-external-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 &amp; 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, /<html lang="en-US">/u);
  assert.match(registration, /<html lang="en-US">/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}`));
  }
});