7969a4971a
Frontend + wiring only. Wires existing backend into the pages users see. - VYNDR Original archetype rename (41) across archetypeService.js + lib/ archetypes.js + ArchetypeBadge, each keeping legacyName (resolves stale data). Judge -> BOMBER. Old POWER PULL slot -> WHIFF strikeout-artist pitcher. - BACKEND_HANDOFF.md: canonical frontend<->backend data contract. - Grade card intel: scan/page.tsx now forwards the engine's intel fields (season_avg/form/usage/matchup_grade/archetype/...) into mapScanToGradeResult -> STAT CONTEXT + VYNDR INTELLIGENCE sections populate. The chain already preserved them (tierGating + /api/scan spread); the page was dropping them. - Schedule freshness: slateAdapter.isRelevantGame drops completed games >24h old; Slate.filteredGames applies it. (TTL already 60s.) - Landing: Features.tsx rewritten to user-facing copy (no Point-biserial/Zone 14/ABS/Phi-coefficient). - Depth chart Next proxies added (/api/stats/lineup|depth|cascade) - were 404. - GameCard swap DEFERRED (Kev): legacy on-demand card stays as a bridge until the snapshot pipeline populates the grades cache; vyndr/GameCard swaps in then. Backend 2045 -> 2061 tests (+16), 167 suites. Web build clean (exit 0). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
81 lines
3.2 KiB
JavaScript
81 lines
3.2 KiB
JavaScript
// Session 42 — player profile adapter logic + page/proxy/route source assertions.
|
|
|
|
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 adapter = require('../../web/src/lib/playerProfileAdapter');
|
|
const { playerHref } = require('../../web/src/lib/playerHref');
|
|
|
|
describe('playerProfileAdapter', () => {
|
|
it('builds two-letter initials', () => {
|
|
expect(adapter.initials('Victor Wembanyama')).toBe('VW');
|
|
expect(adapter.initials('Giannis')).toBe('GI');
|
|
expect(adapter.initials('')).toBe('??');
|
|
});
|
|
it('maps sport labels', () => {
|
|
expect(adapter.sportLabel('nba')).toBe('NBA');
|
|
expect(adapter.sportLabel('soccer')).toBe('SOC');
|
|
});
|
|
it('flattens prop DNA reliable-first with colors', () => {
|
|
const rows = adapter.dnaRows({ reliable: ['total_bases'], volatile: ['hits'] });
|
|
expect(rows[0]).toMatchObject({ prop: 'Total Bases', state: 'RELIABLE', color: '#00D4A0' });
|
|
expect(rows[1]).toMatchObject({ prop: 'Hits', state: 'VOLATILE', color: '#FFB347' });
|
|
});
|
|
it('writes a blend readout naming primary + secondary', () => {
|
|
const txt = adapter.blendReadout({ primary: { name: 'BOMBER' }, secondary: { name: 'DRIVER' } });
|
|
expect(txt).toContain('Bomber');
|
|
expect(txt).toContain('Driver');
|
|
});
|
|
});
|
|
|
|
describe('playerHref', () => {
|
|
it('encodes name + sport', () => {
|
|
expect(playerHref('De\'Aaron Fox', 'nba')).toBe("/player/De'Aaron%20Fox?sport=nba");
|
|
expect(playerHref('Riley', 'MLB')).toBe('/player/Riley?sport=mlb');
|
|
});
|
|
});
|
|
|
|
describe('player profile page', () => {
|
|
const src = read('app/player/[name]/page.tsx');
|
|
it('fetches the stats API and renders the 9 design sections', () => {
|
|
expect(src).toContain('/api/stats/player/');
|
|
expect(src).toContain('ARCHETYPE DNA');
|
|
expect(src).toContain('PROP DNA');
|
|
expect(src).toContain('VYNDR INTELLIGENCE');
|
|
expect(src).toContain('ACTIVE PROPS');
|
|
expect(src).toContain('SEASON STATS');
|
|
expect(src).toContain('GRADE HISTORY');
|
|
expect(src).toContain('SPLITS');
|
|
});
|
|
it('handles loading + error states (never crashes on missing data)', () => {
|
|
expect(src).toContain("'loading'");
|
|
expect(src).toContain("'error'");
|
|
expect(src).toContain('Could not load');
|
|
});
|
|
it('uses ArchetypeBlend + SportBadge + GradeBadge', () => {
|
|
expect(src).toContain('ArchetypeBlend');
|
|
expect(src).toContain('SportBadge');
|
|
expect(src).toContain('GradeBadge');
|
|
});
|
|
});
|
|
|
|
describe('stats API proxy routes', () => {
|
|
it('player proxy forwards to the Express stats route', () => {
|
|
const src = read('app/api/stats/player/[name]/route.ts');
|
|
expect(src).toContain('/api/stats/player/');
|
|
expect(src).toContain('BACKEND_URL');
|
|
});
|
|
it('leaders proxy forwards to the Express stats route', () => {
|
|
const src = read('app/api/stats/leaders/route.ts');
|
|
expect(src).toContain('/api/stats/leaders');
|
|
});
|
|
});
|
|
|
|
describe('GradeResultCard player-name link (Session 42)', () => {
|
|
it('links the header player name to the profile', () => {
|
|
const src = read('components/vyndr/GradeResultCard.tsx');
|
|
expect(src).toContain('playerHref(d.player');
|
|
});
|
|
});
|