Commit Graph

4 Commits

Author SHA1 Message Date
Jordan Ritter 3e0a6a0d85 fix(web-inspector): shim localStorage in vitest setup for Node 25 compatibility
Node 25 ships an experimental built-in localStorage global accessor that
shadows jsdom's mock, leaving window.localStorage as an empty stub with
no clear/setItem/removeItem/getItem methods. This broke all 22 telemetry
tests with 'window.localStorage.clear is not a function' and was
blocking pre-commit hooks repo-wide.

Add a vitest setup file that installs a proper in-memory Storage shim
on both globalThis and window before each test, so jsdom-environment
tests behave the same on Node 20 and Node 25.
2026-05-27 12:49:08 -07:00
Tyler Slaton 3db4f85d6d Revert "fix(web-inspector): polyfill localStorage in vitest env for Node 22.4+"
This reverts commit 63d1d9e02c.
2026-05-15 15:56:18 -07:00
Atai Barkai 11db8e89bf refactor(showcase/shell-dojo, web-inspector): post-review cleanup
Findings from a self-review pass on this PR:

- code-block.tsx: hoist the seven per-row inline-style objects to module
  scope so the file-render hot path stops re-allocating ~3 fresh objects
  per line per render. ~500-line demos previously allocated ~1.5k style
  objects on every parent re-render.
- page.tsx URL-sync effect: add a same-value guard before
  history.replaceState so unrelated re-renders don't write the same
  query string back to the address bar.
- page.tsx FileTreeRow: collapse the color ternary chain — both selected
  and highlighted leaves resolve to the same primary color, so
  `isSelected || isHighlighted ? primary : disabled` reads cleaner than
  the nested `?:?:`.
- page.tsx: trim the restated WHAT-comment above the reset-on-demo
  effect (the function body already says what the comment said).
- vitest.setup.ts MemoryStorage: coerce keys in getItem/removeItem to
  match setItem and the real Storage spec (all key args coerce to string).

Deferred to a follow-up PR (would also touch showcase/shell/* and
showcase/shell-docs/*): hoisting `escapeHtml` (5 copies in the repo
today), the hljs `try { highlight } catch { escapeHtml }` pattern (also
copied), and the file-tree build/sort utilities the dojo duplicates from
showcase/shell/.../code/page.tsx.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 16:16:42 -07:00
Atai Barkai 63d1d9e02c fix(web-inspector): polyfill localStorage in vitest env for Node 22.4+
Node 22.4+ ships an experimental built-in `localStorage` global that is
installed before vitest's jsdom environment runs, leaving
`window.localStorage` as an uninitialized stub without `getItem` /
`setItem` / `clear`. The telemetry persistence tests all crash with
"window.localStorage.clear is not a function" on Node 25.

Add a vitest setup file that installs a minimal in-memory `Storage`
shim on `globalThis.{localStorage,sessionStorage}` so tests behave the
same on Node 18/20/22/25+ without depending on
`--no-experimental-webstorage`. All 29 web-inspector tests now pass on
Node 25.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 16:16:09 -07:00