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>
55 lines
1.9 KiB
JavaScript
55 lines
1.9 KiB
JavaScript
// Session 52 — GET /api/internal/snapshot/status (verification probe).
|
|
|
|
const express = require('express');
|
|
const request = require('supertest');
|
|
|
|
const mockCacheGet = jest.fn();
|
|
jest.mock('../../src/utils/redis', () => ({
|
|
cacheGet: (...a) => mockCacheGet(...a),
|
|
cacheSet: jest.fn(),
|
|
}));
|
|
|
|
beforeEach(() => {
|
|
jest.resetAllMocks();
|
|
process.env.VYNDR_INTERNAL_KEY = 'test-internal-key-9999';
|
|
});
|
|
|
|
function mountApp() {
|
|
delete require.cache[require.resolve('../../src/routes/internal')];
|
|
const internalRoutes = require('../../src/routes/internal');
|
|
const app = express();
|
|
app.use(express.json());
|
|
app.use('/api/internal', internalRoutes);
|
|
return app;
|
|
}
|
|
|
|
describe('GET /api/internal/snapshot/status', () => {
|
|
it('requires the internal key', async () => {
|
|
const res = await request(mountApp()).get('/api/internal/snapshot/status');
|
|
expect(res.status).toBe(401);
|
|
});
|
|
|
|
it('reports cron state, last snapshot, redis keys, ticker count', async () => {
|
|
process.env.SNAPSHOT_CRON = '1';
|
|
mockCacheGet.mockImplementation(async (key) => {
|
|
if (key === 'snapshot:mlb:latest') return { updated_at: '2026-06-19T18:00:00Z', grades: [{}, {}, {}], deltas: [{}] };
|
|
if (key === 'grades:mlb') return { grades: [{}, {}, {}] };
|
|
if (key === 'ticker:items') return [{ type: 'READ' }, { type: 'ALERT' }];
|
|
return null;
|
|
});
|
|
|
|
const res = await request(mountApp())
|
|
.get('/api/internal/snapshot/status')
|
|
.set('x-internal-key', 'test-internal-key-9999');
|
|
|
|
expect(res.status).toBe(200);
|
|
expect(res.body.cron_armed).toBe(true);
|
|
expect(res.body.last_snapshot.mlb.gradeCount).toBe(3);
|
|
expect(res.body.last_snapshot.mlb.deltaCount).toBe(1);
|
|
expect(res.body.redis_keys['snapshot:mlb:latest']).toBe(true);
|
|
expect(res.body.redis_keys['snapshot:mlb:previous']).toBe(false);
|
|
expect(res.body.ticker_count).toBe(2);
|
|
delete process.env.SNAPSHOT_CRON;
|
|
});
|
|
});
|