Skip to content

Add test for ProductUpdateController form state preservation - #361

Open
mnindrazaka wants to merge 1 commit into
mainfrom
claude/product-update-form-bug-aoqepv
Open

Add test for ProductUpdateController form state preservation#361
mnindrazaka wants to merge 1 commit into
mainfrom
claude/product-update-form-bug-aoqepv

Conversation

@mnindrazaka

Copy link
Copy Markdown
Collaborator

Summary

Added a test case for useProductUpdateController to verify that user input is preserved when a background refetch occurs during form editing.

Key Changes

  • Added ProductUpdateController.test.tsx with a test that validates form state preservation during concurrent operations
  • Test verifies that when a user is editing the product name field and a background refetch is triggered (e.g., from a variant deletion), the user's typed input is not overwritten by the refetched data

Implementation Details

  • Uses renderHook and act from @testing-library/react to test the custom hook in isolation
  • Mocks the toast controller dependency to avoid side effects
  • Simulates the user editing flow: initial load → user types → background fetch triggered → fetch completes
  • Asserts that the form value remains "My Typed Name" after the refetch completes, ensuring the form state is not clobbered by the background data refresh
  • Uses flushPromises utility to properly await async operations within the hook

https://claude.ai/code/session_01Lf13QXF7eFkx1c9KJcbnwS

Adds a regression test for the exact bug class fixed by PR #348/#349
(useForm({ values }) forcing the update form to re-sync from fetched
data on every render, silently discarding in-progress edits). This
locks in the current defaultValues + one-shot reset behavior for
ProductUpdateController specifically, since the fix was applied via a
broad refactor across 17 controllers and had no per-controller test
coverage.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lf13QXF7eFkx1c9KJcbnwS
@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gatherloop-pos Ready Ready Preview Aug 26, 2026 1:14pm

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.

2 participants