Skip to content

Commit ca4f96a

Browse files
Fix dynamic select storybook test failure
- Modified `useOnFormValueChange` hook to correctly track `prevValue` using `useRef`. - Updated `AutoCalculation` story to use `waitFor` instead of `setTimeout` to prevent CI race conditions. - Updated `selectRadixOption` test helper to blur the trigger after selection (click on body) to simulate "clicking off" and ensure onBlur events fire.
1 parent 50eb85d commit ca4f96a

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

apps/docs/src/remix-hook-form/use-on-form-value-change.stories.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,17 +347,15 @@ export const AutoCalculation: Story = {
347347
await userEvent.type(quantityInput, '2');
348348

349349
// Total should update to 200.00
350-
await new Promise((resolve) => setTimeout(resolve, 100));
351-
expect(totalInput).toHaveValue('200.00');
350+
await waitFor(() => expect(totalInput).toHaveValue('200.00'));
352351

353352
// Add discount
354353
const discountInput = canvas.getByLabelText(/discount/i);
355354
await userEvent.clear(discountInput);
356355
await userEvent.type(discountInput, '10');
357356

358357
// Total should update to 180.00 (200 - 10%)
359-
await new Promise((resolve) => setTimeout(resolve, 100));
360-
expect(totalInput).toHaveValue('180.00');
358+
await waitFor(() => expect(totalInput).toHaveValue('180.00'));
361359

362360
// Submit form
363361
const submitButton = canvas.getByRole('button', { name: /submit order/i });

0 commit comments

Comments
 (0)