Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PRODUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The differentiator is a review-first application packet and receipt trail: users

## Capabilities and Constraints

- Guest workflows use local browser storage; signed-in workflows can persist to the service.
- The web workspace requires Google sign-in. Public resume tools remain available to visitors.
- Browser-assisted submit refuses CAPTCHA, missing required answers, outstanding uploads, excluded companies, duplicate URLs, low fit, and daily-cap violations.
- Production deploys are manual.
- Product claims must preserve the boundary between assisted fill and unattended automation.
Expand Down
74 changes: 43 additions & 31 deletions __tests__/production-smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,27 @@ import {
runProductionSmoke,
} from '../scripts/production-smoke.mjs';

function workspaceRedirect(path: string) {
if (!['/jobs', '/history', '/resume-builder', '/settings'].includes(path)) return null;
return new Response(null, {
status: 307,
headers: { location: `/sign-in?${new URLSearchParams({ returnTo: path })}` },
});
}

describe('production smoke harness', () => {
it('normalizes base URLs and keeps auth checks opt-in', () => {
expect(normalizeBaseUrl('https://rolepatch.com/')).toBe('https://rolepatch.com');
expect(buildSmokeChecks({ hasSessionCookie: false }).map((check) => check.name)).toEqual([
'landing',
'jobs workspace',
'history workspace',
'resume builder',
'jobs requires sign-in',
'history requires sign-in',
'resume builder requires sign-in',
'pricing',
'proof project',
'truehire proof preview guard',
'settings readiness',
'settings requires sign-in',
'workspace sign-in',
]);
expect(buildSmokeChecks({ hasSessionCookie: true }).map((check) => check.name)).toContain(
'apply queue api'
Expand All @@ -34,10 +43,10 @@ describe('production smoke harness', () => {
it('runs public smoke checks without a session cookie', async () => {
const fetchImpl = vi.fn(async (input: string | URL | Request) => {
const url = input instanceof Request ? input.url : String(input);
if (url.endsWith('/jobs')) return new Response('<h1 id="jobs-heading">Jobs</h1>');
if (url.endsWith('/history')) return new Response('<h1 id="history-heading">History</h1>');
if (url.endsWith('/resume-builder'))
return new Response('<h1 id="resume-builder-master-heading">Resume Builder</h1>');
const privateRoute = workspaceRedirect(new URL(url).pathname);
if (privateRoute) return privateRoute;
if (url.endsWith('/sign-in'))
return new Response('Sign in to RolePatch. Continue with Google');
if (url.endsWith('/pricing')) return new Response('<h1>Tokens</h1>');
if (url.endsWith('/proof')) {
return new Response('<h1>TrueHire proof project</h1><h2>Candidate proof profile</h2>');
Expand All @@ -48,9 +57,6 @@ describe('production smoke harness', () => {
{ status: 400 }
);
}
if (url.endsWith('/settings')) {
return new Response('<h1>Feature availability</h1><h2>Chrome extension</h2>');
}
return new Response('<h1>RolePatch</h1>', {
headers: { 'content-security-policy': CONTENT_SECURITY_POLICY },
});
Expand All @@ -63,8 +69,8 @@ describe('production smoke harness', () => {

expect(summary.authenticated).toBe(false);
expect(summary.failed).toBe(0);
expect(summary.passed).toBe(8);
expect(fetchImpl).toHaveBeenCalledTimes(8);
expect(summary.passed).toBe(9);
expect(fetchImpl).toHaveBeenCalledTimes(9);
expect(fetchImpl.mock.calls.some(([url]) => String(url).includes('/api/apply-agent'))).toBe(
false
);
Expand Down Expand Up @@ -95,7 +101,7 @@ describe('production smoke harness', () => {
);

it('runs authenticated apply-agent read checks when a session cookie is supplied', async () => {
const fetchImpl = vi.fn(async (input: string | URL | Request) => {
const fetchImpl = vi.fn(async (input: string | URL | Request, init?: RequestInit) => {
const url = input instanceof Request ? input.url : String(input);
if (url.endsWith('/api/apply-agent/queue')) {
return Response.json({ queue: [] });
Expand All @@ -106,10 +112,13 @@ describe('production smoke harness', () => {
if (url.endsWith('/api/apply-agent/receipts')) {
return Response.json({ receipts: [] });
}
if (url.endsWith('/jobs')) return new Response('<h1 id="jobs-heading">Jobs</h1>');
if (url.endsWith('/history')) return new Response('<h1 id="history-heading">History</h1>');
if (url.endsWith('/resume-builder'))
if (url.endsWith('/resume-builder') && new Headers(init?.headers).has('cookie')) {
return new Response('<h1 id="resume-builder-master-heading">Resume Builder</h1>');
}
const privateRoute = workspaceRedirect(new URL(url).pathname);
if (privateRoute) return privateRoute;
if (url.endsWith('/sign-in'))
return new Response('Sign in to RolePatch. Continue with Google');
if (url.endsWith('/pricing')) return new Response('<h1>Tokens</h1>');
if (url.endsWith('/proof')) {
return new Response('<h1>TrueHire proof project</h1><h2>Candidate proof profile</h2>');
Expand All @@ -120,9 +129,6 @@ describe('production smoke harness', () => {
{ status: 400 }
);
}
if (url.endsWith('/settings')) {
return new Response('<h1>Feature availability</h1><h2>Chrome extension</h2>');
}
return new Response('<h1>RolePatch</h1>', {
headers: { 'content-security-policy': CONTENT_SECURITY_POLICY },
});
Expand All @@ -136,7 +142,7 @@ describe('production smoke harness', () => {

expect(summary.authenticated).toBe(true);
expect(summary.failed).toBe(0);
expect(summary.passed).toBe(11);
expect(summary.passed).toBe(13);
expect(fetchImpl.mock.calls.map(([url]) => String(url))).toEqual(
expect.arrayContaining([
'https://rolepatch.com/api/apply-agent/queue',
Expand All @@ -158,7 +164,7 @@ describe('production smoke harness', () => {
});

expect(summary.passed).toBe(0);
expect(summary.failed).toBe(8);
expect(summary.failed).toBe(9);
expect(summary.results[0]).toMatchObject({
ok: false,
status: 0,
Expand All @@ -184,18 +190,22 @@ describe('production smoke harness', () => {
return;
}

const privateRoute = workspaceRedirect(path);
if (privateRoute) {
response.writeHead(privateRoute.status, Object.fromEntries(privateRoute.headers));
response.end();
return;
}
response.writeHead(200, {
'content-type': 'text/html',
...(path === '/' ? { 'content-security-policy': CONTENT_SECURITY_POLICY } : {}),
});
response.end(
{
'/': '<h1>RolePatch</h1>',
'/history': '<h1 id="history-heading">History</h1>',
'/pricing': '<h1>Tokens</h1>',
'/sign-in': 'Sign in to RolePatch. Continue with Google',
'/proof': '<h1>TrueHire proof project</h1><h2>Candidate proof profile</h2>',
'/resume-builder': '<h1 id="resume-builder-master-heading">Resume Builder</h1>',
'/settings': '<h1>Feature availability</h1><h2>Chrome extension</h2>',
}[path] ?? '<h1>Unexpected route</h1>'
);
});
Expand Down Expand Up @@ -250,7 +260,7 @@ describe('production smoke harness', () => {
});

expect(spacedScriptPath).toContain(' ');
expect(stdout).toContain('RolePatch production smoke: 7/8 passed');
expect(stdout).toContain('RolePatch production smoke: 8/9 passed');
expect(code).toBe(1);
expect(stderr).toBe('');
expect(
Expand All @@ -260,15 +270,16 @@ describe('production smoke harness', () => {
.map((line) => line.replace(/^(PASS|FAIL) /, '').replace(/ \d+ \d+ms.*$/, ''))
).toEqual([
'landing',
'jobs workspace',
'history workspace',
'resume builder',
'jobs requires sign-in',
'history requires sign-in',
'resume builder requires sign-in',
'pricing',
'proof project',
'truehire proof preview guard',
'settings readiness',
'settings requires sign-in',
'workspace sign-in',
]);
expect(stdout).toContain('FAIL jobs workspace 503');
expect(stdout).toContain('FAIL jobs requires sign-in 503');
expect(requestedPaths).toEqual([
'/',
'/jobs',
Expand All @@ -278,6 +289,7 @@ describe('production smoke harness', () => {
'/proof',
'/api/proof/truehire-preview',
'/settings',
'/sign-in',
]);
} finally {
await new Promise<void>((resolve, reject) =>
Expand Down
1 change: 1 addition & 0 deletions __tests__/release-verify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('release verifier', () => {
'e2e/settings-readiness.spec.ts',
'e2e/history.spec.ts',
'e2e/resume-builder.spec.ts',
'e2e/workspace-access.spec.ts',
'--workers=1',
]);
expect(BUILT_SERVER_COMMAND).toEqual([process.execPath, ['.next/standalone/server.js']]);
Expand Down
3 changes: 1 addition & 2 deletions docs/product/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ diff view for review.

## Who it's for

- **Job seekers (guest mode)** — full app works without auth via
`localStorage`. No sign-up required to try every core flow.
- **Visitors** — public résumé tools, pricing, articles, and product information.
- **Signed-in users (Google OAuth via better-auth)** — persistence to
Cloudflare D1 with `user_id` filtering, token purchases, saved
searches, company watches, recruiter reply routing.
Expand Down
7 changes: 6 additions & 1 deletion docs/product/surfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ when a route is added or removed.
| `/llms.txt`, `/llms-full.txt`, `/index.md`, `/api/ai` | Agent-indexing surfaces served by `agent-edge.mjs`. |
| `/.well-known/security.txt` | Static trust surface (`public/.well-known/security.txt`). |

## App (auth-aware, guest works via localStorage)
## Web workspace

Workspace pages require a valid Google sign-in session. The `/sign-in` page
returns visitors to their requested workspace page after sign-in. Returning
visitors can import their browser-saved base résumés, saved jobs, tailored
résumés, cover letters, and extra experience after they sign in.

| Route | Purpose |
| --- | --- |
Expand Down
Loading
Loading