Item 1 — VERB LAW: one verb, READ (never SCAN), + a lint that enforces it
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>
This commit is contained in:
@@ -10,38 +10,38 @@ function memCache(initial) {
|
||||
describe('pushTickerItems — SCAN dedup', () => {
|
||||
it('replaces a prior SCAN for the same sport (only one MLB SCAN)', async () => {
|
||||
const cache = memCache([
|
||||
{ tag: 'SCAN', sport: 'mlb', text: 'MLB slate scanned · 20 props graded' },
|
||||
{ tag: 'READ', sport: 'mlb', text: 'MLB slate read · 20 props graded' },
|
||||
{ tag: 'MOVE', text: 'Judge o2.5 → o3.5 ▲+1' },
|
||||
]);
|
||||
await svc.pushTickerItems([{ tag: 'SCAN', sport: 'mlb', text: 'MLB slate scanned · 25 props graded' }], cache);
|
||||
await svc.pushTickerItems([{ tag: 'READ', sport: 'mlb', text: 'MLB slate read · 25 props graded' }], cache);
|
||||
const items = cache.store['ticker:items'];
|
||||
expect(items.filter((e) => e.tag === 'SCAN' && e.sport === 'mlb')).toHaveLength(1);
|
||||
expect(items.find((e) => e.tag === 'SCAN').text).toContain('25 props');
|
||||
expect(items.filter((e) => e.tag === 'READ' && e.sport === 'mlb')).toHaveLength(1);
|
||||
expect(items.find((e) => e.tag === 'READ').text).toContain('25 props');
|
||||
});
|
||||
|
||||
it('preserves MOVE/GRADE events and other sports', async () => {
|
||||
const cache = memCache([
|
||||
{ tag: 'MOVE', text: 'move 1' },
|
||||
{ tag: 'A+', text: 'BOMBER graded A+' },
|
||||
{ tag: 'SCAN', sport: 'nba', text: 'NBA slate scanned · 10 props graded' },
|
||||
{ tag: 'READ', sport: 'nba', text: 'NBA slate read · 10 props graded' },
|
||||
]);
|
||||
await svc.pushTickerItems([{ tag: 'SCAN', sport: 'mlb', text: 'MLB slate scanned · 25 props graded' }], cache);
|
||||
await svc.pushTickerItems([{ tag: 'READ', sport: 'mlb', text: 'MLB slate read · 25 props graded' }], cache);
|
||||
const items = cache.store['ticker:items'];
|
||||
expect(items.find((e) => e.tag === 'MOVE')).toBeTruthy();
|
||||
expect(items.find((e) => e.tag === 'A+')).toBeTruthy();
|
||||
expect(items.find((e) => e.tag === 'SCAN' && e.sport === 'nba')).toBeTruthy();
|
||||
expect(items.find((e) => e.tag === 'READ' && e.sport === 'nba')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('dedupes legacy SCAN items that lack a sport field (parse from text)', async () => {
|
||||
const cache = memCache([{ tag: 'SCAN', text: 'MLB slate scanned · 20 props graded' }]);
|
||||
await svc.pushTickerItems([{ tag: 'SCAN', sport: 'mlb', text: 'MLB slate scanned · 25 props graded' }], cache);
|
||||
expect(cache.store['ticker:items'].filter((e) => e.tag === 'SCAN')).toHaveLength(1);
|
||||
const cache = memCache([{ tag: 'READ', text: 'MLB slate read · 20 props graded' }]);
|
||||
await svc.pushTickerItems([{ tag: 'READ', sport: 'mlb', text: 'MLB slate read · 25 props graded' }], cache);
|
||||
expect(cache.store['ticker:items'].filter((e) => e.tag === 'READ')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('stays capped at 50 items', async () => {
|
||||
const many = Array.from({ length: 60 }, (_, i) => ({ tag: 'MOVE', text: `m${i}` }));
|
||||
const cache = memCache(many);
|
||||
await svc.pushTickerItems([{ tag: 'SCAN', sport: 'mlb', text: 'scanned' }], cache);
|
||||
await svc.pushTickerItems([{ tag: 'READ', sport: 'mlb', text: 'read' }], cache);
|
||||
expect(cache.store['ticker:items'].length).toBeLessThanOrEqual(50);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user