66d52a9ce0
The product argued with itself: FAB/nav said "Scan", Free tier "5 scans", ticker "MLB slate scanned" — while the Ledger says "MY READS". Swept every user-visible surface to READ: - BottomTabBar FAB + Nav link: 'Scan' → 'Read' - Pricing free tier: '5 scans to try the model' → '5 reads …' - StatStrip: 'Awaiting next scan' → 'Awaiting next read' - Ticker badge + snapshotService event: tag 'SCAN' → 'READ', 'slate scanned' → 'slate read' (readSportOf parses BOTH old and new so cached ticker items dedupe cleanly through the rollover) - upgradePitch: 'You've scanned N parlays' / 'unlimited scans' → read/reads Internal untouched (not user-visible): /api/scan routes, scan_count column, scanning state, DemoScan/ScanIcon, scanlines CSS, the transitional SCAN color-map key. tests/unit/verbLaw.test.js is the enforcement: it fails on user-visible scan/scanned/scans copy across web/src + src/services (skips comments). Suite 270/3254 green, web build exit 0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
82 lines
3.7 KiB
JavaScript
82 lines
3.7 KiB
JavaScript
// Session 45 — Phase 3: pre-graded snapshot overlay + the GameCard swap.
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const WEB = path.join(__dirname, '..', '..', 'web', 'src');
|
|
const read = (rel) => fs.readFileSync(path.join(WEB, rel), 'utf8');
|
|
const a = require('../../web/src/lib/slateAdapter');
|
|
|
|
describe('snapshot overlay adapter', () => {
|
|
const grades = [
|
|
{ player: 'Aaron Judge', stat_type: 'total_bases', line: 1.5, direction: 'over', grade: 'A+', archetype: 'BOMBER', gradedAt: { line: 1.5, odds: -115, timestamp: '2026-06-18T18:00:00Z' } },
|
|
{ player: 'Aaron Judge', stat_type: 'home_runs', line: 0.5, direction: 'over', grade: 'C', archetype: 'BOMBER', gradedAt: { line: 0.5, odds: 120, timestamp: '2026-06-18T18:00:00Z' } },
|
|
];
|
|
const deltas = [{ player: 'Aaron Judge', stat: 'total_bases', side: 'O', delta: 1.0, direction: 'toward', currentLine: 2.5 }];
|
|
|
|
it('indexes grades + deltas for lookup', () => {
|
|
const gi = a.indexGrades(grades);
|
|
expect(gi['aaron judge|total_bases'].grade).toBe('A+');
|
|
const di = a.indexDeltas(deltas);
|
|
expect(di['aaron judge|total_bases|O'].direction).toBe('toward');
|
|
});
|
|
|
|
it('overlays grades onto game props → playerStrips (name once, archetype, gradedAt, delta)', () => {
|
|
const gameProps = [
|
|
{ player: 'Aaron Judge', stat_type: 'total_bases', line: 1.5 },
|
|
{ player: 'Aaron Judge', stat_type: 'home_runs', line: 0.5 },
|
|
];
|
|
const strips = a.buildPlayerStripsFromProps(gameProps, a.indexGrades(grades), a.indexDeltas(deltas), new Date('2026-06-18T20:00:00Z').getTime());
|
|
expect(strips).toHaveLength(1); // name once
|
|
expect(strips[0].archetype).toEqual({ primary: 'BOMBER' });
|
|
const tb = strips[0].props.find((p) => p.stat === 'TB');
|
|
expect(tb.grade).toBe('A+');
|
|
expect(tb.gradedAt.ago).toBe('2h ago');
|
|
expect(tb.gradedAt.odds).toBe(-115);
|
|
expect(tb.delta).toEqual({ delta: 1.0, direction: 'toward', currentLine: 2.5 });
|
|
});
|
|
|
|
it('marks ungraded props as awaiting (no Read button)', () => {
|
|
const strips = a.buildPlayerStripsFromProps(
|
|
[{ player: 'New Guy', stat_type: 'hits', line: 1.5 }],
|
|
a.indexGrades(grades), a.indexDeltas(deltas),
|
|
);
|
|
expect(strips[0].props[0].awaiting).toBe(true);
|
|
expect(strips[0].props[0].grade).toBeNull();
|
|
});
|
|
|
|
it('gradedAgo formats relative time', () => {
|
|
const now = new Date('2026-06-18T20:00:00Z').getTime();
|
|
expect(a.gradedAgo('2026-06-18T19:30:00Z', now)).toBe('30m ago');
|
|
expect(a.gradedAgo('2026-06-18T18:00:00Z', now)).toBe('2h ago');
|
|
expect(a.gradedAgo(undefined, now)).toBe('');
|
|
});
|
|
});
|
|
|
|
describe('Slate uses the VYNDR card + pre-graded snapshot (swap is real)', () => {
|
|
const src = read('components/Slate.tsx');
|
|
it('imports the VYNDR GameCard component (legacy only for types)', () => {
|
|
expect(src).toContain("import VyndrGameCard");
|
|
expect(src).toContain("'@/components/vyndr/GameCard'");
|
|
expect(src).toContain('<VyndrGameCard');
|
|
// legacy component default-import is gone (only `import type` remains)
|
|
expect(src).not.toMatch(/^import GameCard /m);
|
|
});
|
|
it('fetches the pre-graded snapshot and builds playerStrips', () => {
|
|
expect(src).toContain('/api/snapshot/');
|
|
expect(src).toContain('buildPlayerStripsFromProps');
|
|
expect(src).toContain('slateGameToCardData');
|
|
});
|
|
it('retired the on-demand Read grade flow', () => {
|
|
expect(src).not.toContain('const onGrade = useCallback');
|
|
});
|
|
});
|
|
|
|
describe('StatStrip renders snapshot states', () => {
|
|
const src = read('components/vyndr/StatStrip.tsx');
|
|
it('renders Awaiting next read + line-delta sub-line', () => {
|
|
expect(src).toContain('Awaiting next read');
|
|
expect(src).toContain('TOWARD');
|
|
expect(src).toContain('Graded ');
|
|
});
|
|
});
|