80683e71b4
P0 fixes + wiring real data into the S42 Player Intelligence architecture. - P0 dropdown z-index: the nav's backdrop-filter stacking context let the Ticker/HeartbeatBar paint over the avatar/More dropdowns and eat clicks. nav now position:relative zIndex:2; menus zIndex:100. Avatar Settings -> /settings. - Real MLB stats: mlbStatsAdapter.searchPlayer + getPlayerStats (name->id-> season+gamelog). playerIntelService.resolvePlayerStats normalizes into the archetype classifier; getPlayerIntel returns found:true + real season + archetype classified from real stats. NBA via nbaStatsClient (degrades). - Game cards: slateAdapter.groupPropsByPlayer (playerStrips, name once) + mapPitchers (MLB probables), folded into mapScheduleToGameCards. Legacy GameCard line grid renders BookChip (brand colors) not grey text. - Grade card intel: analyzeViaEngine1.buildIntelFields computes stat-context + form/usage/matchup/rest from the existing feature vector (zero extra I/O); gradeAdapter lights up the card sections. Archetype deferred (needs season line at grade time). - Depth chart foundation: depthChartService (getLineup/getDepthChart/ getCascadeProjection) + /api/stats/lineup|depth|cascade, graceful + injectable. - Mobile: player hero name overflow-wrap + 24px on <=640px (was clipping). Backend 2011 -> 2045 tests (+34), 163 suites. Web build clean (exit 0). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
73 lines
2.8 KiB
JavaScript
73 lines
2.8 KiB
JavaScript
// Session 43 — depth chart / lineup / cascade foundation. Sources injected.
|
|
|
|
const svc = require('../../src/services/depthChartService');
|
|
|
|
describe('getLineup (MLB, injected schedule)', () => {
|
|
const mlbAdapter = {
|
|
async getScheduleWithPitchers() {
|
|
return [{
|
|
home: { team: 'Atlanta Braves', probablePitcher: { name: 'Spencer Strider' } },
|
|
away: { team: 'Philadelphia Phillies', probablePitcher: { name: 'Zack Wheeler' } },
|
|
}];
|
|
},
|
|
};
|
|
|
|
it('returns the probable starting pitcher for the team', async () => {
|
|
const r = await svc.getLineup('mlb', 'Atlanta', { mlbAdapter, date: '2026-06-18' });
|
|
expect(r).toHaveLength(1);
|
|
expect(r[0]).toMatchObject({ player: 'Spencer Strider', position: 'SP' });
|
|
});
|
|
|
|
it('returns [] when the team is not playing / unknown', async () => {
|
|
expect(await svc.getLineup('mlb', 'Seattle', { mlbAdapter, date: '2026-06-18' })).toEqual([]);
|
|
expect(await svc.getLineup('mlb', '', { mlbAdapter })).toEqual([]);
|
|
});
|
|
|
|
it('degrades to [] when the adapter throws', async () => {
|
|
const bad = { async getScheduleWithPitchers() { throw new Error('down'); } };
|
|
expect(await svc.getLineup('mlb', 'Atlanta', { mlbAdapter: bad })).toEqual([]);
|
|
});
|
|
});
|
|
|
|
describe('getDepthChart', () => {
|
|
it('builds positions with starter/backup/third from an injected roster', async () => {
|
|
const chart = await svc.getDepthChart('nba', 'SA', {
|
|
roster: [
|
|
{ player: 'Wembanyama', position: 'C', depth: 1 },
|
|
{ player: 'Backup Big', position: 'C', depth: 2 },
|
|
{ player: 'Vassell', position: 'SG', depth: 1 },
|
|
],
|
|
});
|
|
const center = chart.positions.find((p) => p.position === 'C');
|
|
expect(center.starter).toBe('Wembanyama');
|
|
expect(center.backup).toBe('Backup Big');
|
|
});
|
|
|
|
it('returns a valid empty structure when no roster source', async () => {
|
|
const chart = await svc.getDepthChart('mlb', 'ATL');
|
|
expect(chart).toEqual({ sport: 'mlb', team: 'ATL', positions: [] });
|
|
});
|
|
});
|
|
|
|
describe('getCascadeProjection', () => {
|
|
it('distributes usage to teammates, weighting usage sponges heaviest', async () => {
|
|
const r = await svc.getCascadeProjection('nba', 'Keldon Murray', 'SA', {
|
|
teammates: [
|
|
{ player: 'Wembanyama', archetype: 'VOLUME SCORER' },
|
|
{ player: 'Bench Spark', archetype: 'USAGE SPONGE' },
|
|
{ player: 'Glue Guy', archetype: 'ROLE GLUE' },
|
|
],
|
|
});
|
|
expect(r).toHaveLength(3);
|
|
// usage sponge gets the biggest bump
|
|
expect(r[0].player).toBe('Bench Spark');
|
|
expect(r[0].delta.startsWith('+')).toBe(true);
|
|
expect(r[0].reason).toContain('OUT');
|
|
});
|
|
|
|
it('returns [] with no teammates / no player', async () => {
|
|
expect(await svc.getCascadeProjection('nba', 'X', 'SA', { teammates: [] })).toEqual([]);
|
|
expect(await svc.getCascadeProjection('nba', '', 'SA')).toEqual([]);
|
|
});
|
|
});
|