Skip to content

✅ test(ui): polyfill in-memory localStorage for Node 26 vitest (UI-TEST-01) - #147

Merged
konih merged 1 commit into
mainfrom
lane/ui-test-01-localstorage
Jul 31, 2026
Merged

konih merged 1 commit into
mainfrom
lane/ui-test-01-localstorage

Conversation

@konih

@konih konih commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

UI-TEST-01 (P3) — fix 2 pre-existing Node-26 localStorage test failures

Under Node 26, vitest runs without --localstorage-file so window.localStorage is undefined, and 2 tests in ui/src/store/inventory.test.ts ("persists column visibility toggles", "resets to defaults") threw TypeError: Cannot read properties of undefined. A/B-verified as pre-existing on clean main, unrelated to any dep bump.

Fix: minimal in-memory Storage polyfill in the existing ui/src/test/setup.ts, guarded by !window.localStorage (mirrors the existing window.scrollTo polyfill in the same file), installed via Object.defineProperty. Test-only; no production source, no vite bundle.

Gates: npm test 50/50 green (Node v26.5.0); npm run lint clean; npm run typecheck clean. Independent review: APPROVE, no findings — the target tests are behavioural round-trips (store setItem→getItem), so the polyfill is genuinely exercised.

Node 26 runs vitest without --localstorage-file, leaving
window.localStorage undefined and breaking two inventory store
tests. Add a minimal in-memory localStorage mock to the existing
vitest setup file, guarded like the existing scrollTo polyfill.
@konih
konih merged commit 18994a3 into main Jul 31, 2026
24 checks passed
@konih
konih deleted the lane/ui-test-01-localstorage branch July 31, 2026 11:52
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

Copy link
Copy Markdown

konih added a commit that referenced this pull request Jul 31, 2026
Bump chart version/appVersion 0.10.0 -> 0.11.0 for the next minor. Unreleased
since v0.10.0: feat(netguard) NET-01 --allow-private-sinks opt-in (#146) +
fix(controller) inventory store source Start non-blocking / DR-FIND-01 (#143),
plus DR-FIND-03 lab-bootstrap docs (#148), UI-TEST-01 (#147), SEC-04j
CI-hardening (#150).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant