open-design/e2e/ui
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
..
amr-login-pill.test.ts feat(runtimes): register AMR (vela) as an ACP stdio agent (#2355) 2026-05-28 05:09:55 +00:00
amr-logout-requires-relogin.test.ts feat(runtimes): register AMR (vela) as an ACP stdio agent (#2355) 2026-05-28 05:09:55 +00:00
amr-onboarding.test.ts feat(runtimes): register AMR (vela) as an ACP stdio agent (#2355) 2026-05-28 05:09:55 +00:00
amr-run-failure-recovery.test.ts feat(runtimes): register AMR (vela) as an ACP stdio agent (#2355) 2026-05-28 05:09:55 +00:00
api-empty-response.test.ts chore(e2e): improve test framework quality (#2305) 2026-05-23 00:24:32 +08:00
app-design-files.test.ts chore(e2e): improve test framework quality (#2305) 2026-05-23 00:24:32 +08:00
app-manual-edit.test.ts Add launch review regression coverage and stabilize daemon tests (#3207) 2026-05-29 02:39:33 +00:00
app-restoration.test.ts Add launch review regression coverage and stabilize daemon tests (#3207) 2026-05-29 02:39:33 +00:00
app.test.ts Add launch review regression coverage and stabilize daemon tests (#3207) 2026-05-29 02:39:33 +00:00
automations-page.test.ts Add launch review regression coverage and stabilize daemon tests (#3207) 2026-05-29 02:39:33 +00:00
chat-todo-autoscroll.test.ts fix(web): chat pane preserves scroll position when todo card grows (#2299) 2026-05-23 00:19:59 +08:00
critical-smoke.test.ts chore(e2e): improve test framework quality (#2305) 2026-05-23 00:24:32 +08:00
critique-theater.test.ts test(e2e): align entry coverage with redesigned flows (#2101) 2026-05-19 11:26:40 +08:00
design-files-view-state-persist.test.ts fix(web): persist design files view state across navigation (#2303) 2026-05-30 03:39:27 +00:00
design-systems-manager.test.ts Add launch review regression coverage and stabilize daemon tests (#3207) 2026-05-29 02:39:33 +00:00
diagnostics-export.test.ts Add launch review regression coverage and stabilize daemon tests (#3207) 2026-05-29 02:39:33 +00:00
entry-chrome-flows.test.ts feat(plugins): site-wide plugin detail pages, share-to-site links, landing deploy trigger (#2999) 2026-05-28 09:07:12 +00:00
entry-configuration-flows.test.ts test(e2e): harden extended coverage state assertions (#2245) 2026-05-20 16:21:01 +08:00
entry-topbar.test.ts test: expand home entry and html preview coverage (#2992) 2026-05-26 14:48:35 +00:00
home-hero-rail.test.ts test: expand home entry and html preview coverage (#2992) 2026-05-26 14:48:35 +00:00
project-management-flows.test.ts fix(web): restore changes silently dropped by PR #2461 sync merge (#3210) 2026-05-28 12:50:05 +00:00
real-daemon-run.test.ts Add launch review regression coverage and stabilize daemon tests (#3207) 2026-05-29 02:39:33 +00:00
settings-api-protocol.test.ts fix(web): restore changes silently dropped by PR #2461 sync merge (#3210) 2026-05-28 12:50:05 +00:00
settings-connectors-auth-happy-path.test.ts Add launch review regression coverage and stabilize daemon tests (#3207) 2026-05-29 02:39:33 +00:00
settings-connectors-auth-recovery.test.ts Add launch review regression coverage and stabilize daemon tests (#3207) 2026-05-29 02:39:33 +00:00
settings-design-systems.test.ts Add launch review regression coverage and stabilize daemon tests (#3207) 2026-05-29 02:39:33 +00:00
settings-hover-contrast.test.ts [codex] test(e2e): harden settings and entry regressions (#2578) 2026-05-22 10:04:12 +08:00
settings-local-cli-codex-fallback.test.ts Fix conflict resolution from c14baf07 2026-05-23 12:28:08 +08:00
settings-media-providers.test.ts [codex] test(e2e): harden settings and entry regressions (#2578) 2026-05-22 10:04:12 +08:00
settings-memory-routines.test.ts fix(web): restore changes silently dropped by PR #2461 sync merge (#3210) 2026-05-28 12:50:05 +00:00
visual-home.test.ts Consolidate chat comments preview on main (#2906) 2026-05-26 10:31:19 +00:00
workspace-keyboard-flows.test.ts Add launch review regression coverage and stabilize daemon tests (#3207) 2026-05-29 02:39:33 +00:00