Files
supabase/apps/studio/tests/features
Alaister Young bfaf6bd593 fix(studio): get unit tests passing on React 19 / TanStack branch
The React 19 bump exposed four React-version-sensitive patterns that
were silently fine on 18:

- useStateTransition: React 18+ auto-batches dispatch SUBMIT and the
  mutation's dispatch ERROR across the intervening awaits, collapsing
  editing → submitting → error into a single render where the
  submitting tick is never observed. Relax the check to fire on entry
  into newTest from any state other than newTest, which is a strict
  superset of the old prevTest → newTest condition for our reducers
  (success/error are only reachable from submitting anyway).

- useSupportForm: seed defaultValues from window.location.search
  synchronously via useMemo instead of patching them in a useEffect
  setValue. The old flow flipped the category Radix Select from
  uncontrolled to controlled mid-mount, which on React 19 spuriously
  emits onValueChange('') (radix-ui/primitives#3381) and clears the
  field. The new flow keeps the Select controlled from first paint.

- EditSecretModal test: switch the post-dialog getByLabelText to
  findByLabelText. The vault list query opens the dialog but the
  decrypted-value query resolves on a separate render tick under
  React 19's scheduling, so the form fields appear one tick after the
  skeleton.

- LogsPreviewer test: use addEventListener instead of assigning
  loadOlder.onclick = vi.fn(). React 19 reassigns .onclick on managed
  elements as part of its event wiring, clobbering the direct-property
  spy before the assertion runs.

No changes to vitest config or shared test setup — both Next.js and
TanStack Start setups still share the same Vitest plumbing.
2026-05-11 17:21:52 +08:00
..