Session 57: Phase 0 — Kill the Lies (2309 tests)
Work-order Phase 0 (Jul 10 live audit): every fabricated UI element deleted
or rewired to real data. Deletion sprint — no new product features.
0.1 Fake NBA game: root cause was scheduleService fetching the ESPN
scoreboard with no ?dates= param or date filter — off-season ESPN
returns the NEAREST slate (Jun 13 NYK@SA Finals rendered as tonight).
Now pinned to the requested ET date + defensive filter; undated events
dropped. Honest month-aware per-sport empty states (lib/emptyState.js).
0.2 Fake header counters: liveTick stripped to a bare 1s pulse (the
auto-incrementing "247 graded", sin-driven brain-%, aPlus/cascades are
dead). New GET /api/snapshot/summary (cache-only, before /:sport) +
Next proxy; HeartbeatBar shows the real graded count and SYNC =
elapsed since the last pipeline run (amber past 5 min).
0.3 Ticker: hardcoded fallback items deleted (real snapshot exhaust only);
MOVE kept — computeLineDeltas is real movement. <4 real items → no
ticker; bar publishes --ticker-h so the fixed header collapses cleanly.
0.4 /terminal retired: route redirects to /dashboard; VVI/injury-wire/
leaders layouts preserved unrouted as §12 content-engine templates.
Nav PRIMARY = Slate/Scan/Ledger; BottomTabBar Terminal→Explore; PWA
shortcut Terminal→Ledger; #terminal alias → /dashboard.
0.5 ›Query nav pill deleted (duplicate /scan link).
Backend 2289 → 2309 tests (199 suites), web build exit 0.
Spec: specs/phase-0-kill-the-lies.md. Next: work-order Phase 1 (ledger
persistence + settlement).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,12 +28,16 @@ function mountApp() {
|
||||
return app;
|
||||
}
|
||||
|
||||
// NOTE (Session 57, Phase 0): the event date must fall on the REQUESTED ET
|
||||
// date (2026-06-12) — 00:40Z Jun 13 = 20:40 ET Jun 12. The old fixture was
|
||||
// dated a day later and the route served it anyway; that exact hole is how the
|
||||
// Jun 13 NYK@SA Finals game kept rendering as "tonight" all July.
|
||||
const ESPN_NBA = {
|
||||
data: {
|
||||
events: [
|
||||
{
|
||||
id: '401234567',
|
||||
date: '2026-06-14T00:40:00Z',
|
||||
date: '2026-06-13T00:40:00Z',
|
||||
status: { type: { state: 'pre' } },
|
||||
competitions: [{
|
||||
venue: { fullName: 'Frost Bank Center' },
|
||||
@@ -81,6 +85,57 @@ describe('GET /api/schedule/:sport', () => {
|
||||
expect(axios.get.mock.calls.length).toBe(callsAfterFirst); // served from cache
|
||||
});
|
||||
|
||||
test('pins the ESPN fetch to the requested date (?dates=YYYYMMDD)', async () => {
|
||||
axios.get.mockResolvedValue(ESPN_NBA);
|
||||
await request(mountApp()).get('/api/schedule/nba?date=2026-06-12');
|
||||
expect(axios.get.mock.calls[0][0]).toContain('dates=20260612');
|
||||
});
|
||||
|
||||
// Session 57 (Phase 0) regression — in the off-season ESPN returns the
|
||||
// NEAREST slate, not today's. Any event whose ET date ≠ the requested date
|
||||
// must be dropped, or a June Finals game renders as tonight's slate in July.
|
||||
test('filters out events from a different ET date (fake off-season game)', async () => {
|
||||
axios.get.mockResolvedValue({
|
||||
data: {
|
||||
events: [
|
||||
{
|
||||
id: '401999999',
|
||||
date: '2026-06-14T00:30:00Z', // Jun 13 ET — NOT the requested Jun 12
|
||||
status: { type: { state: 'pre' } },
|
||||
competitions: [{
|
||||
competitors: [
|
||||
{ homeAway: 'home', score: '0', team: { displayName: 'San Antonio Spurs', abbreviation: 'SA' } },
|
||||
{ homeAway: 'away', score: '0', team: { displayName: 'New York Knicks', abbreviation: 'NYK' } },
|
||||
],
|
||||
}],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
const res = await request(mountApp()).get('/api/schedule/nba?date=2026-06-12');
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.body.games).toEqual([]);
|
||||
});
|
||||
|
||||
test('drops events with no parseable date (live feed only)', async () => {
|
||||
axios.get.mockResolvedValue({
|
||||
data: {
|
||||
events: [{
|
||||
id: '77', // no `date` field at all
|
||||
status: { type: { state: 'pre' } },
|
||||
competitions: [{
|
||||
competitors: [
|
||||
{ homeAway: 'home', score: '0', team: { displayName: 'A', abbreviation: 'A' } },
|
||||
{ homeAway: 'away', score: '0', team: { displayName: 'B', abbreviation: 'B' } },
|
||||
],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
});
|
||||
const res = await request(mountApp()).get('/api/schedule/nba?date=2026-06-12');
|
||||
expect(res.body.games).toEqual([]);
|
||||
});
|
||||
|
||||
test('returns empty array (not error) when no games today', async () => {
|
||||
axios.get.mockResolvedValue({ data: { events: [] } });
|
||||
const res = await request(mountApp()).get('/api/schedule/mlb?date=2026-06-12');
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
// Session 57 (Phase 0) — GET /api/snapshot/summary: the HeartbeatBar's honest
|
||||
// data source. Real graded counts + latest pipeline run time from cache-only
|
||||
// Redis reads; must never invent numbers on a cold cache.
|
||||
|
||||
const express = require('express');
|
||||
const request = require('supertest');
|
||||
|
||||
const store = {};
|
||||
jest.mock('../../src/utils/redis', () => ({
|
||||
cacheGet: jest.fn(async (k) => (k in store ? store[k] : null)),
|
||||
cacheSet: jest.fn(async (k, v) => { store[k] = v; return true; }),
|
||||
}));
|
||||
|
||||
function mountApp() {
|
||||
delete require.cache[require.resolve('../../src/routes/snapshot')];
|
||||
const snapshotRoutes = require('../../src/routes/snapshot');
|
||||
const app = express();
|
||||
app.use('/api/snapshot', snapshotRoutes);
|
||||
return app;
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
for (const k of Object.keys(store)) delete store[k];
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('GET /api/snapshot/summary', () => {
|
||||
test('sums real graded counts across sports and reports the latest run', async () => {
|
||||
store['snapshot:mlb:latest'] = {
|
||||
updated_at: '2026-07-10T18:00:00.000Z',
|
||||
grades: [{ player: 'A' }, { player: 'B' }, { player: 'C' }],
|
||||
};
|
||||
store['snapshot:wnba:latest'] = {
|
||||
updated_at: '2026-07-10T19:00:00.000Z',
|
||||
grades: [{ player: 'D' }],
|
||||
};
|
||||
const res = await request(mountApp()).get('/api/snapshot/summary');
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.body.graded).toBe(4);
|
||||
expect(res.body.updated_at).toBe('2026-07-10T19:00:00.000Z'); // latest run
|
||||
expect(res.body.sports.mlb).toBe(3);
|
||||
expect(res.body.sports.wnba).toBe(1);
|
||||
expect(res.body.sports.nba).toBe(0); // off-season → honest zero
|
||||
});
|
||||
|
||||
test('falls back to the grades:{sport} envelope when no snapshot exists', async () => {
|
||||
store['grades:mlb'] = { updated_at: '2026-07-10T16:00:00.000Z', grades: [{ player: 'A' }, { player: 'B' }] };
|
||||
const res = await request(mountApp()).get('/api/snapshot/summary');
|
||||
expect(res.body.graded).toBe(2);
|
||||
expect(res.body.updated_at).toBe('2026-07-10T16:00:00.000Z');
|
||||
});
|
||||
|
||||
test('cold cache → zeros and null timestamp, never invented numbers', async () => {
|
||||
const res = await request(mountApp()).get('/api/snapshot/summary');
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.body.graded).toBe(0);
|
||||
expect(res.body.updated_at).toBeNull();
|
||||
});
|
||||
|
||||
test('is not captured by the /:sport route (summary ≠ a sport)', async () => {
|
||||
store['snapshot:mlb:latest'] = { updated_at: 'x', grades: [{ player: 'A' }] };
|
||||
const res = await request(mountApp()).get('/api/snapshot/summary');
|
||||
// The /:sport handler would return { sport, grades, deltas }.
|
||||
expect(res.body.sport).toBeUndefined();
|
||||
expect(res.body.grades).toBeUndefined();
|
||||
expect(typeof res.body.graded).toBe('number');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user