Files
vyndr/tests/unit/session41AuditFixes.test.js
builtbykev 71d3b7b786 E10 Report issue template + E12 /report archive, to spec
PHASE 0 — the spec, read not recalled. E10: "Hybrid: dark billboard header
that survives every client, light paper body Gmail can't wreck. 600px,
stacked, no webfont dependence." Content law: "One email per slate day.
Top read, what changed, the record. Nothing else." E12: "EVERY ISSUE SHOWS
ITS OWN DAY RECORD -- THE ARCHIVE IS A LEDGER TOO."

COMPOSED, NOT FORKED. The audit had E10 as PARTIAL, not absent:
newsletterService already builds the daily report's CONTENT and lints its
voice. What was missing is the designed hybrid SHELL, so reportTemplate.js
is a template over that builder rather than a second report -- the same
call made for the movement strip, and for the same reason.

PHASE 1 — the hybrid shell is an ENGINEERING constraint, not a look, and
the tests say so: Gmail strips style blocks, Outlook ignores flexbox, and
a dark body renders as a black rectangle in several clients. Hence tables,
inline styles, 600px fixed, system fonts, no image required to read, and
the green SHIFTS from #00D4A0 to #00A57D on paper because the dark-mode
green is unreadable there.

FACT-CONTRACTED: a section whose data is absent is OMITTED and NAMED in
`omitted`, never filled. There is no code path producing a placeholder
figure. The honesty block carries the real numbers -- graded count,
cleared-ceiling count, the realized rate against baseline, and that we do
not issue A grades.

E1'S LAW TRAVELS EVEN THOUGH ITS RENDERING CANNOT. An SVG strip is not
reliable in email, so movementText carries the RULE: green only when the
move favours the read, and a flat market says FLAT · [N]D rather than
showing nothing.

NO DESIGNER SAMPLE DATA. Nabers 1,120.5, No 128, DAY RECORD 9-4 are a spec
for what a live issue renders; pasting them in would be fabrication
carrying a designer's authority and would look entirely correct. Tested.

PHASE 2 — /report is now the real archive, REPLACING the S41 redirect to
/blog. That redirect existed because the surface did not; E12 built it, so
the placeholder is correctly gone and the S41 test is updated rather than
worked around. Every row carries its own day record, and an unknown record
says UNSETTLED -- never a dash that reads as zero. Empty archive is an
honest state.

Backend: public read-only /api/report over Redis issues, plus the Next
proxy. Both surfaces registered under the reachability guard.

A test bug I made twice now: my check for forbidden sample values matched
the template's own doc block, which NAMES those values as things never to
paste. Documentation worth keeping, so both suites strip comments before
matching -- a guard that reads its own warning is not reading the code.

WAVE-2 STATUS: E1, F9-F11, E10, E12 done. Still gated -- F5 article media
and E16/F8 on the card-system reconciliation; the in-season hub IA on the
social chat's formula; E9/E15 on model; E2/E6 on licensing.

Read-only throughout; serving fingerprint unchanged including
newsletterService; accrual clock unchanged at 0 eligible dates.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W1sivYNqY2TS5ftykmHBU9
2026-08-07 22:17:59 -04:00

92 lines
3.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Session 41 — P0 audit fixes. Frontend assertions read page source as text
// (same pattern as the Phase DH suites); backend stat-gate acceptance is
// covered in tests/integration/analyze.test.js.
const fs = require('fs');
const path = require('path');
const ROOT = path.join(__dirname, '..', '..');
const WEB = path.join(ROOT, 'web', 'src');
const read = (rel) => fs.readFileSync(path.join(WEB, rel), 'utf8');
describe('Session 41 — backend MLB stat_type whitelist', () => {
const analyze = fs.readFileSync(path.join(ROOT, 'src', 'routes', 'analyze.js'), 'utf8');
const scan = fs.readFileSync(path.join(ROOT, 'src', 'routes', 'scan.js'), 'utf8');
const mlbStats = ['hits', 'strikeouts', 'total_bases', 'rbi', 'home_runs', 'earned_runs', 'hits_allowed', 'innings_pitched'];
it.each(mlbStats)('/api/analyze gate whitelists MLB stat %s', (stat) => {
expect(analyze).toContain(`'${stat}'`);
});
it.each(mlbStats)('/api/scan (parlay) gate whitelists MLB stat %s', (stat) => {
expect(scan).toContain(`'${stat}'`);
});
});
describe('Session 41 — broken-route redirects', () => {
// Session 42 — /settings is now a real settings page (replaced the S41
// redirect). The 404 it fixed is still fixed; the route just renders content.
it('/settings is a real page (no longer a redirect stub)', () => {
const src = read('app/settings/page.tsx');
expect(src).not.toContain("redirect('/profile')");
expect(src).toContain('DANGER ZONE');
});
it('/report is now the REAL Report archive, no longer a redirect to /blog', () => {
// The S41 redirect existed BECAUSE the surface did not. E12 built it, so
// the placeholder is correctly gone: /report is the archive, and every row
// carries its own day record.
const page = read('app/report/page.tsx');
expect(page).toContain('ReportArchive');
expect(page).not.toContain("redirect('/blog')");
});
it.skip('SUPERSEDED — /report used to redirect to /blog', () => {
const src = read('app/report/page.tsx');
expect(src).toContain("redirect('/blog')");
});
it('/settings/security stays the real MFA page (NOT clobbered into a redirect)', () => {
// The audit spec wanted this redirected too, but it is a working MFA
// enrollment flow — overwriting it would be a security-feature regression.
const src = read('app/settings/security/page.tsx');
expect(src).toContain('mfa');
expect(src).not.toContain("redirect('/profile')");
});
});
describe('Session 41 — profile reads tier from useAuth', () => {
const src = read('app/profile/page.tsx');
it('destructures tier from useAuth (same source as the nav)', () => {
expect(src).toMatch(/tier:\s*authTier/);
});
it('derives the displayed tier from the auth session', () => {
expect(src).toContain('authTier || profile.tier');
});
});
describe('Session 41 — self-hosted fonts (no Google Fonts CDN)', () => {
const layout = read('app/layout.tsx');
const globals = read('app/globals.css');
it('layout uses next/font instead of a runtime <link>', () => {
expect(layout).toContain("from 'next/font/google'");
expect(layout).toContain('Inter(');
expect(layout).toContain('JetBrains_Mono(');
});
it('removed the runtime Google Fonts stylesheet <link>', () => {
// The historical reference survives in a code comment; what must be gone
// is the actual CDN stylesheet href that caused the 503.
expect(layout).not.toMatch(/href=["'][^"']*fonts\.googleapis\.com/);
expect(layout).not.toContain('rel="stylesheet"');
});
it('globals.css :root maps --sans/--mono onto the next/font variables', () => {
expect(globals).toContain('--sans: var(--font-sans)');
expect(globals).toContain('--mono: var(--font-mono)');
});
});