open-design/apps/web/tests
Patrick A 9146dc1c57
fix(web): persist design files view state across navigation (#2303)
* fix(web): persist design-files view state across navigation

pageSize, sortKey, sortDir, and kindFilter reset on every navigation
because DesignFilesPanel remounts via key={projectId}. Persist them to
localStorage under od:design-files:view-state:v1:<projectId> so each
project's view prefs survive tab-switching.

- Read persisted state via lazy useState initializers (SSR-safe try/catch)
- Write back in a single useEffect keyed on all four values
- Scoped per-project so proj-a settings never bleed into proj-b
- Schema-guarded: invalid/missing fields fall through to defaults
- Red spec: apps/web/tests/components/DesignFilesPanel.view-state-persist.test.tsx

* fix(web): address review feedback on view-state persistence

- Add typeof window guard in readViewState for explicit SSR safety
- Consolidate 4 separate localStorage reads into a single useRef read at
  mount time; each lazy useState initializer now reads from savedViewState.current
  instead of re-parsing localStorage independently

* fix(web): harden design-files view-state persistence

- Validate restored kindFilter values against the current ProjectFileKind
  union via isProjectFileKind() so stale stored values from a prior schema
  are dropped silently instead of being cast unchecked.

- Introduce DEFAULT_SORT_KEY/SORT_DIR/PAGE_SIZE constants so the useState
  initialisers and the new validation guard share a single source of truth.

- Add viewStateHasMounted ref to skip the first-render write in the persist
  useEffect. Without this guard every project the user visits accumulates a
  default-value entry in localStorage on mount, growing stale-key garbage
  unboundedly and making future field additions silently inject defaults into
  every existing entry.

- Harden kindFilter test: replace the silent early-return-on-missing-trigger
  with expect(filterTrigger).not.toBeNull() so a render failure surfaces as
  a real test failure rather than a passing no-op.

* test(e2e): design files view state persists across navigation and reload

Adds a Playwright UI smoke test in e2e/ui/ that exercises the three key
guarantees of the view-state persistence fix:

  (a) Tab-away / tab-back: navigating to a file tab and returning remounts
      DesignFilesPanel (conditionally rendered); all four prefs (sortKey,
      sortDir, pageSize, kindFilter) are restored from localStorage.

  (b) Hard reload: localStorage survives page.reload(); prefs are intact on
      the next mount.

  (c) Per-project key isolation: a second project starts with defaults and
      does not inherit values from the first project's localStorage entry.

The test uses OD_PORT=18011 / OD_WEB_PORT=18012 to avoid port conflicts with
the default development ports.

Also fixes a race in DesignFilesPanel: the stale-kind cleanup useEffect was
running against an empty availableKinds set before the async file list arrived
on mount, which cleared a kindFilter correctly restored from localStorage.
Guard added: skip the cleanup when availableKinds is empty.

Red on origin/main (no persistence logic exists there); green on this branch.

* fix(e2e): address code-reviewer feedback on view-state-persist test

- Add data-testid='df-page-size-select' to per-page <select> in
  DesignFilesPanel (W2: decouple test from i18n string 'Show')
- Add StrictMode comment to viewStateHasMounted guard explaining
  the dev-mode double-write behaviour (W1: document the invariant)
- Switch nav-away from dblclick to single-click + Open button,
  matching the pattern used in app-design-files.test.ts (W4)
- Raise timeout from 60s to 90s for cold CI runners (W3)
- Unify seedTextFile/seedPngFile into shared seedFile helper (N3)
- Add home-hero-input assertion in gotoEntryHome (N2)
- Switch waitForPageSizeSelect to use data-testid (W2)

* test(e2e): split design-files persist into nav, reload, and per-project scenarios

* fix(web): tighten isPageSize to discrete option set, add invalid-value regression test

* fix(web): isolate DesignFilesPanel.test.tsx from persisted view-state key
2026-05-30 03:39:27 +00:00
..
analytics feat(analytics): emit file_upload_result from all three upload entries (#2459) 2026-05-21 18:28:56 +08:00
artifacts fix(web): parse ask-question blocks as question-form alias (#1194) (#3053) 2026-05-27 06:34:36 +00:00
components fix(web): persist design files view state across navigation (#2303) 2026-05-30 03:39:27 +00:00
edit-mode feat(web): merge Draw + Screenshot into one Studio mark tool (#3081) (#3277) 2026-05-29 06:51:38 +00:00
helpers refactor(web): split global CSS by ownership (#2609) 2026-05-25 05:48:28 +00:00
hooks fix(web): coalesce chokidar rewrite bursts before refreshing files (#2326) 2026-05-20 11:12:53 +08:00
i18n test(i18n): lock zh-CN to tier-1 explicit translation parity (#2920) 2026-05-25 20:08:41 +08:00
lib fix(web): clarify finalize BYOK requirements for Local CLI users (#3041) 2026-05-27 06:20:33 +00:00
observability feat(observability): web lifecycle telemetry + stable installationId migration (#2527) 2026-05-21 15:37:48 +08:00
providers feat(daemon): add Antigravity agent adapter (#3157) 2026-05-29 05:43:37 +00:00
runtime fix(web): target comment picker elements precisely (#3263) 2026-05-29 07:47:08 +00:00
state fix(web): surface Claude Design zip import failures (#1862) (#3047) 2026-05-27 06:24:38 +00:00
styles fix(web): restore changes silently dropped by PR #2461 sync merge (#3210) 2026-05-28 12:50:05 +00:00
utils fix(web): handle dropped file read failures (#2858) 2026-05-25 06:05:17 +00:00
analytics-app-version.test.tsx fix(analytics): app_version=0.0.0 + media providers clicks + lock run_finished error_code (#2453) 2026-05-20 21:50:11 +08:00
analytics-configure-globals.test.ts feat(analytics): ship PostHog v2 event schema (#2285) 2026-05-20 13:04:20 +08:00
analytics-identity.test.ts feat(analytics): PostHog product analytics (P0 events, consent-gated, packaged) (#1428) 2026-05-12 22:32:42 +08:00
analytics-scrub.test.ts feat(analytics): PostHog product analytics (P0 events, consent-gated, packaged) (#1428) 2026-05-12 22:32:42 +08:00
api-attachment-context.test.ts Inline attached file context for BYOK chats (#1730) 2026-05-15 15:52:15 +08:00
App.test.ts fix(web): suppress autosave indicator for draft-only Connector key edits (#1232) 2026-05-11 20:52:45 +08:00
comments.test.ts feat(comments): add comment attachment API (#2869) 2026-05-25 07:24:21 +00:00
host-boundary.test.ts refactor desktop host bridge (#2246) 2026-05-19 18:27:05 +08:00
quickSwitcherRecents.test.ts feat(web): add Cmd/Ctrl+P quick file switcher (#556) 2026-05-06 10:31:50 +08:00
router-marketplace.test.ts [codex] Add global onboarding flow without AMR (#2272) 2026-05-19 22:00:40 +08:00
router.navigate.test.tsx fix(web/router): defer popstate dispatch to microtask (#2490) 2026-05-29 09:37:55 +00:00
router.test.ts Garnet hemisphere (#1702) 2026-05-14 21:12:50 +08:00
sidecar-proxy.test.ts Enable LAN web dev access (#1947) 2026-05-19 17:50:50 +08:00