Session 59: Addendum + work-order 1.6 + Phase 2 + Phase 3 (2352 tests)
Overnight sprint for the Saturday 10 AM ET deploy gate — day one of the
public ledger record locks against freshly posted lines.
Task A — ledger team/opponent (migration 020, applied at 0 rows):
populated in both write paths from the real feed; opponent only when the
player's team matches a game participant (never guessed). Roadmap: Phase
4.5 WNBA ESPN-boxscore settlement (due ~Jul 24) + Phase 5 per-tier
calibration logged.
Task B — work-order 1.6 CLOSED (canonical player keys):
- searchPlayer resolves via nameKey; the old matcher deleted accents
("Sanchez" with acute -> "snchez") and substring-guessed onto the WRONG
player (the mismatched last-10 bug). Ambiguous -> null, never guess.
- Slate JOIN INVARIANT: a graded prop whose player's real team isn't in
the game is dropped (TB player can't render under MIL@PIT) — locked by
tests that fail the suite on regression.
- grades:{sport} TTL 2h -> 6h (expired between 5h cron gaps — the real
cause of /team "No active props" for slate players).
Task C — Phase 2 slate UX: tabs are THE filter (URL ?sport=, deep-linkable,
duplicate legacy tablist removed); cards cap at 6 graded props sorted
A+->F with ALL N READS in-place expander; waiting states show the real
next pipeline run ("Grades post ~6:00 PM ET").
Task D — Phase 3 mobile P0: root cause of vanished 390px nav was HIDE_ON
including '/' (landing had zero navigation) — fixed; html/body overflow-x
contained; GAME LINES collapses to best-line summary + "N BOOKS" expander
below 640px; venue drops before time/pitchers ever truncate.
Live verification: raw ESPN today STILL returns the Jun 13 NYK@SA Finals
game without a date pin; the pinned fetch returns 0 games, 0 off-date.
Backend 2327 -> 2352 tests (202 suites), web build exit 0.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -79,6 +79,29 @@ describe('rowsFromSnapshot — the write shape', () => {
|
||||
expect(r.game_id).toBe('mlb:2026-07-10:BOS@NYY');
|
||||
});
|
||||
|
||||
// Session 59 — team/opponent addendum (migration 020).
|
||||
test('captures team + opponent from the real feed (full-name MLB teams)', () => {
|
||||
const grade = { ...GRADE, team: 'New York Yankees' };
|
||||
const prop = { ...PROP, home_team: 'New York Yankees', away_team: 'Boston Red Sox' };
|
||||
const [r] = rowsFromSnapshot('mlb', [grade], [prop], NOW);
|
||||
expect(r.team).toBe('New York Yankees');
|
||||
expect(r.opponent).toBe('Boston Red Sox');
|
||||
});
|
||||
|
||||
test('opponent is NEVER guessed: team not in the game → opponent null', () => {
|
||||
const grade = { ...GRADE, team: 'Tampa Bay Rays' };
|
||||
const prop = { ...PROP, home_team: 'Milwaukee Brewers', away_team: 'Pittsburgh Pirates' };
|
||||
const [r] = rowsFromSnapshot('mlb', [grade], [prop], NOW);
|
||||
expect(r.team).toBe('Tampa Bay Rays');
|
||||
expect(r.opponent).toBeNull();
|
||||
});
|
||||
|
||||
test('no team from the stats resolve → both null (absent beats wrong)', () => {
|
||||
const [r] = rowsFromSnapshot('mlb', [GRADE], [PROP], NOW);
|
||||
expect(r.team).toBeNull();
|
||||
expect(r.opponent).toBeNull();
|
||||
});
|
||||
|
||||
test('refused reads and grade-less entries never become rows', () => {
|
||||
const refused = { ...GRADE, grade: null, insufficient_data: true };
|
||||
const gradeless = { ...GRADE, grade: undefined };
|
||||
|
||||
@@ -125,3 +125,54 @@ describe('mlbStatsAdapter — batter vs pitcher', () => {
|
||||
expect(mockAxiosGet).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
// Session 59 (work-order 1.6) — canonical player resolution. The old matcher
|
||||
// deleted accented letters ("Sánchez" → "snchez") and substring-guessed on a
|
||||
// miss, which could return ANOTHER player's id (→ wrong last-10 log).
|
||||
describe('searchPlayer — canonical nameKey resolution', () => {
|
||||
const PLAYERS = {
|
||||
data: {
|
||||
people: [
|
||||
{ id: 100, fullName: 'Cristopher Sanchez', currentTeam: { name: 'Philadelphia Phillies', id: 1 }, primaryPosition: { abbreviation: 'P' } },
|
||||
{ id: 200, fullName: 'Brandon Lowe', currentTeam: { name: 'Tampa Bay Rays', id: 2 }, primaryPosition: { abbreviation: '2B' } },
|
||||
{ id: 201, fullName: 'Nathaniel Lowe', currentTeam: { name: 'Texas Rangers', id: 3 }, primaryPosition: { abbreviation: '1B' } },
|
||||
{ id: 202, fullName: 'Josh Lowe', currentTeam: { name: 'Tampa Bay Rays', id: 2 }, primaryPosition: { abbreviation: 'OF' } },
|
||||
{ id: 300, fullName: 'Matthew Boyd', currentTeam: { name: 'Chicago Cubs', id: 4 }, primaryPosition: { abbreviation: 'P' } },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
test('accented query resolves to the unaccented MLB record (Sánchez ≡ Sanchez)', async () => {
|
||||
mockAxiosGet.mockResolvedValue(PLAYERS);
|
||||
const hit = await adapter.searchPlayer('Cristopher Sánchez');
|
||||
expect(hit).toBeTruthy();
|
||||
expect(hit.id).toBe(100);
|
||||
});
|
||||
|
||||
test('never returns another player on a shared last name (Brandon ≠ Nathaniel Lowe)', async () => {
|
||||
mockAxiosGet.mockResolvedValue(PLAYERS);
|
||||
const hit = await adapter.searchPlayer('Brandon Lowe');
|
||||
expect(hit.id).toBe(200);
|
||||
expect(hit.team).toBe('Tampa Bay Rays');
|
||||
});
|
||||
|
||||
test('nickname resolves via nameKey (Matt Boyd → Matthew Boyd)', async () => {
|
||||
mockAxiosGet.mockResolvedValue(PLAYERS);
|
||||
const hit = await adapter.searchPlayer('Matt Boyd');
|
||||
expect(hit && hit.id).toBe(300);
|
||||
});
|
||||
|
||||
test('ambiguous fallback returns null — a missing profile beats a wrong one', async () => {
|
||||
mockAxiosGet.mockResolvedValue({
|
||||
data: {
|
||||
people: [
|
||||
{ id: 400, fullName: 'Jose Ramirez', currentTeam: { name: 'A' }, primaryPosition: { abbreviation: '3B' } },
|
||||
{ id: 401, fullName: 'Jorge Ramirez', currentTeam: { name: 'B' }, primaryPosition: { abbreviation: 'P' } },
|
||||
],
|
||||
},
|
||||
});
|
||||
// "J. Ramirez" collapses to first-initial J — TWO candidates → null.
|
||||
const hit = await adapter.searchPlayer('Jhon Ramirez');
|
||||
expect(hit).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// Session 59 (work-order 2.3) — honest waiting states derive from the REAL
|
||||
// cron schedule (UTC 14,19,22,1,3). A wrong time is a lie; keep HOURS_UTC in
|
||||
// sync with snapshotScheduler's default.
|
||||
|
||||
const { HOURS_UTC, nextRunAt, nextRunLabelET } = require('../../web/src/lib/pipelineSchedule');
|
||||
const { HOURS_UTC: BACKEND_HOURS } = require('../../src/snapshotScheduler');
|
||||
|
||||
describe('pipelineSchedule', () => {
|
||||
test('mirrors the backend default cron hours EXACTLY', () => {
|
||||
expect([...HOURS_UTC].sort((a, b) => a - b)).toEqual([...BACKEND_HOURS].sort((a, b) => a - b));
|
||||
});
|
||||
|
||||
test('next run after 15:30 UTC is 19:00 UTC same day', () => {
|
||||
const now = new Date('2026-07-10T15:30:00Z');
|
||||
expect(nextRunAt(now).toISOString()).toBe('2026-07-10T19:00:00.000Z');
|
||||
});
|
||||
|
||||
test('next run after 23:30 UTC rolls to 01:00 UTC next day', () => {
|
||||
const now = new Date('2026-07-10T23:30:00Z');
|
||||
expect(nextRunAt(now).toISOString()).toBe('2026-07-11T01:00:00.000Z');
|
||||
});
|
||||
|
||||
test('label renders an ET clock time', () => {
|
||||
// 19:00 UTC = 3:00 PM ET in July (EDT).
|
||||
const label = nextRunLabelET(new Date('2026-07-10T15:30:00Z'));
|
||||
expect(label).toBe('~3:00 PM ET');
|
||||
});
|
||||
});
|
||||
@@ -95,3 +95,73 @@ describe('legacy GameCard uses BookChip (brand colors)', () => {
|
||||
expect(src).toContain('book={r.book}');
|
||||
});
|
||||
});
|
||||
|
||||
// Session 59 (work-order 1.6) — THE JOIN INVARIANT. A prop can only attach
|
||||
// to a game where the player's team is one of the two participants. The
|
||||
// audit found Brandon Lowe (TB) rendered under MIL@PIT — a bad feed row the
|
||||
// overlay happily displayed.
|
||||
describe('buildPlayerStripsFromProps — game-participant join guard', () => {
|
||||
const GAME = { home: 'Milwaukee Brewers', away: 'Pittsburgh Pirates' };
|
||||
|
||||
it('drops a graded prop whose player team is not in the game (TB ∉ MIL@PIT)', () => {
|
||||
const props = [{ player: 'Brandon Lowe', stat_type: 'hits', line: 1.5 }];
|
||||
const gradeIndex = adapter.indexGrades([
|
||||
{ player: 'Brandon Lowe', stat_type: 'hits', line: 1.5, direction: 'over', grade: 'A',
|
||||
team: 'Tampa Bay Rays', gradedAt: { line: 1.5, timestamp: '2026-07-10T02:00:00Z' } },
|
||||
]);
|
||||
const strips = adapter.buildPlayerStripsFromProps(props, gradeIndex, {}, Date.now(), GAME);
|
||||
expect(strips).toEqual([]);
|
||||
});
|
||||
|
||||
it('keeps a prop whose player team IS a participant + stamps the team', () => {
|
||||
const props = [{ player: 'Willy Adames', stat_type: 'hits', line: 1.5 }];
|
||||
const gradeIndex = adapter.indexGrades([
|
||||
{ player: 'Willy Adames', stat_type: 'hits', line: 1.5, direction: 'over', grade: 'B',
|
||||
team: 'Milwaukee Brewers', gradedAt: { line: 1.5, timestamp: '2026-07-10T02:00:00Z' } },
|
||||
]);
|
||||
const strips = adapter.buildPlayerStripsFromProps(props, gradeIndex, {}, Date.now(), GAME);
|
||||
expect(strips).toHaveLength(1);
|
||||
expect(strips[0].team).toBe('Milwaukee Brewers');
|
||||
});
|
||||
|
||||
it('keeps props with no team info (cannot verify ≠ wrong)', () => {
|
||||
const props = [{ player: 'Mystery Guy', stat_type: 'hits', line: 0.5 }];
|
||||
const strips = adapter.buildPlayerStripsFromProps(props, {}, {}, Date.now(), GAME);
|
||||
expect(strips).toHaveLength(1);
|
||||
expect(strips[0].props[0].awaiting).toBe(true);
|
||||
});
|
||||
|
||||
// The invariant itself, as the suite-failing rule the work order asked for:
|
||||
it('INVARIANT: every rendered strip with a known team belongs to the game', () => {
|
||||
const props = [
|
||||
{ player: 'Willy Adames', stat_type: 'hits', line: 1.5 },
|
||||
{ player: 'Brandon Lowe', stat_type: 'hits', line: 1.5 },
|
||||
{ player: 'Unknown Player', stat_type: 'runs', line: 0.5 },
|
||||
];
|
||||
const gradeIndex = adapter.indexGrades([
|
||||
{ player: 'Willy Adames', stat_type: 'hits', line: 1.5, direction: 'over', grade: 'B', team: 'Milwaukee Brewers', gradedAt: { line: 1.5, timestamp: 'x' } },
|
||||
{ player: 'Brandon Lowe', stat_type: 'hits', line: 1.5, direction: 'over', grade: 'A', team: 'Tampa Bay Rays', gradedAt: { line: 1.5, timestamp: 'x' } },
|
||||
]);
|
||||
const strips = adapter.buildPlayerStripsFromProps(props, gradeIndex, {}, Date.now(), GAME);
|
||||
const participants = ['milwaukee brewers', 'pittsburgh pirates'];
|
||||
for (const s of strips) {
|
||||
if (!s.team) continue;
|
||||
expect(participants).toContain(String(s.team).toLowerCase());
|
||||
}
|
||||
expect(strips.find((s) => String(s.team).toLowerCase() === 'tampa bay rays')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
// Sánchez/Sanchez single-key regression (work-order 1.6 #4).
|
||||
describe('diacritic variants resolve to ONE key across the slate', () => {
|
||||
it('an accented prop matches an unaccented snapshot grade (one strip, graded)', () => {
|
||||
const props = [{ player: 'Cristopher Sánchez', stat_type: 'strikeouts', line: 5.5 }];
|
||||
const gradeIndex = adapter.indexGrades([
|
||||
{ player: 'Cristopher Sanchez', stat_type: 'strikeouts', line: 5.5, direction: 'over', grade: 'A',
|
||||
gradedAt: { line: 5.5, timestamp: 'x' } },
|
||||
]);
|
||||
const strips = adapter.buildPlayerStripsFromProps(props, gradeIndex, {});
|
||||
expect(strips).toHaveLength(1);
|
||||
expect(strips[0].props[0].grade).toBe('A');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -110,3 +110,66 @@ describe('Phase F — PWA manifest + viewport (§11)', () => {
|
||||
expect(read('app/layout.tsx')).toContain("viewportFit: 'cover'");
|
||||
});
|
||||
});
|
||||
|
||||
// ── Session 59 — work-order Phase 3 (mobile P0) + Phase 2 slate UX ──────────
|
||||
|
||||
describe('Phase 3.1 — the tab bar is the mobile nav EVERYWHERE except auth', () => {
|
||||
const src = read('components/BottomTabBar.tsx');
|
||||
it('does NOT hide on the landing (anon phones had zero navigation)', () => {
|
||||
const hideOn = src.match(/const HIDE_ON = new Set\(\[([^\]]*)\]\)/);
|
||||
expect(hideOn).toBeTruthy();
|
||||
expect(hideOn[1]).not.toContain("'/'");
|
||||
['/login', '/signup', '/auth/callback'].forEach((p) => expect(hideOn[1]).toContain(p));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Phase 3.2 — overflow containment at 390px', () => {
|
||||
const css = read('app/globals.css');
|
||||
it('document never scrolls horizontally on phones', () => {
|
||||
expect(css).toMatch(/@media \(max-width: 767px\)[\s\S]*?html, body \{ overflow-x: hidden/);
|
||||
});
|
||||
it('venue drops first on phones (time/pitchers never truncate)', () => {
|
||||
expect(css).toContain('.gc-venue { display: none');
|
||||
expect(read('components/vyndr/GameCard.tsx')).toContain('className="gc-venue"');
|
||||
});
|
||||
it('book table collapses to a best-line summary with an expander below md', () => {
|
||||
expect(css).toContain('.gl-summary { display: none; }');
|
||||
expect(css).toContain('.gl-full:not(.gl-expanded) { display: none');
|
||||
const card = read('components/vyndr/GameCard.tsx');
|
||||
expect(card).toContain('gl-summary');
|
||||
expect(card).toContain('BOOKS {linesExpanded');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Phase 2.2 — card collapse (6-prop cap, ALL N READS)', () => {
|
||||
const card = read('components/vyndr/GameCard.tsx');
|
||||
it('caps visible graded props and sorts strips best-grade-first', () => {
|
||||
expect(card).toContain('MAX_VISIBLE_PROPS = 6');
|
||||
expect(card).toMatch(/sort\(\(a, b\) => stripBestRank\(a\) - stripBestRank\(b\)\)/);
|
||||
});
|
||||
it('offers the ALL N READS expander in place', () => {
|
||||
expect(card).toContain('ALL {collapsed.totalReads} READS →');
|
||||
expect(card).toContain('COLLAPSE ↑');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Phase 2.1 — sport tabs are THE filter, URL-driven', () => {
|
||||
const slate = read('components/Slate.tsx');
|
||||
it('reads and writes ?sport= on the URL', () => {
|
||||
expect(slate).toContain(".get('sport')"); // tabFromUrl reads the deep link
|
||||
expect(slate).toContain("url.searchParams.set('sport', t)");
|
||||
expect(slate).toContain('history.replaceState');
|
||||
});
|
||||
it('the dashboard has NO second tablist — it subscribes via onTabChange', () => {
|
||||
const dash = read('app/dashboard/page.tsx');
|
||||
expect(dash).toContain('onTabChange');
|
||||
expect(dash).not.toMatch(/role="tablist"\s+aria-label="Sport"/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Phase 2.3 — honest waiting states', () => {
|
||||
it('awaiting props show the real next pipeline run, not passive mystery', () => {
|
||||
expect(read('components/vyndr/StatStrip.tsx')).toContain('nextRunLabelET');
|
||||
expect(read('app/dashboard/page.tsx')).toContain('nextRunLabelET');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user