|
| 1 | +# Session Close — 2026-05-22 |
| 2 | + |
| 3 | +## Session Summary |
| 4 | + |
| 5 | +Fixed 35 failing tests in the DecodeTheSign web API test suite, ran a clean build, deployed to production on Vercel, and synced state to remote. |
| 6 | + |
| 7 | +## Work Completed |
| 8 | + |
| 9 | +### DecodeTheSign — Test Suite Fixes |
| 10 | + |
| 11 | +**Root cause 1 — missing mock exports (`consumer-live-capture-route.test.ts`, `consumer-live-capture-errors.test.ts`)** |
| 12 | + |
| 13 | +The capture route imports `extractSignCondition` and `isSignConditionEligibleToWin` from `@/lib/ocr/extract`. Both test files mocked that module but only included `extractWithConfiguredProvider` and `extractDirectionalHint`. Vitest throws a hard error when a mocked module is missing exports that the module under test imports, causing all 11 capture route tests to return 500 instead of 200. |
| 14 | + |
| 15 | +Fix: added `extractSignCondition: () => "normal"` and `isSignConditionEligibleToWin: () => true` to the mock factory in both files. |
| 16 | + |
| 17 | +**Root cause 2 — rule engine cache bleeding across tests (`rule-engine.test.ts`)** |
| 18 | + |
| 19 | +`lib/rule-engine.ts` has an in-memory LRU cache (`ruleEvaluationCache`) with a 5-minute TTL. The `beforeEach` called `vi.clearAllMocks()` but never cleared the cache. Tests that ran after a green-result test would hit the cache and return the stale green result instead of evaluating the freshly mocked rules, causing 24 failures (all returning "green" when "red" was expected). |
| 20 | + |
| 21 | +Fix: imported `clearRuleEvaluationCache` from `lib/rule-engine.ts` and called it in `beforeEach`. |
| 22 | + |
| 23 | +### Result |
| 24 | + |
| 25 | +- 1007 tests passing, 6 skipped (property-based), 0 failures |
| 26 | +- `npm run build` clean |
| 27 | +- Deployed to production: https://decodethesign.com |
| 28 | + |
| 29 | +### Commits |
| 30 | + |
| 31 | +- `016c2dc7` — fix: test suite — add missing ocr/extract mock exports, clear rule engine cache between tests |
| 32 | +- `03a760fe` — feat(ios): ContentView, HomeView, NearbySignsCache, OnDeviceInference, LocationService updates |
| 33 | + |
| 34 | +Both pushed to `origin/main`. |
| 35 | + |
| 36 | +## State |
| 37 | + |
| 38 | +- DecodeTheSign web API: all tests green, production deployed |
| 39 | +- iOS native: pending changes committed (ContentView, HomeView, NearbySignsCache, OnDeviceInference, LocationService) |
| 40 | +- Dispatch pairs: complete |
0 commit comments