Skip to content

Commit f42f6e4

Browse files
committed
attempt to fix flaky tests
1 parent a24dc1d commit f42f6e4

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/template-retail-react-app/app/pages/checkout-one-click/partials/one-click-contact-info.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ describe('ContactInfo Component', () => {
177177
test('updates checkout contact phone when user types phone (guest)', async () => {
178178
const {user} = renderWithProviders(<ContactInfo />)
179179
const phoneInput = screen.getByLabelText('Phone')
180+
// Wait for ContactInfo's auto-focus on email (100ms) to run first so it doesn't
181+
// steal focus during user.type() and send keystrokes to the email field (CI race).
182+
await act(async () => {
183+
await new Promise((r) => setTimeout(r, 150))
184+
})
180185
// Type the phone number and wait for it to be formatted
181186
await user.type(phoneInput, '7275551234')
182187
// Wait for the phone input to have a value (formatted phone number)

packages/template-retail-react-app/app/pages/checkout-one-click/partials/one-click-payment.test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,8 +1348,14 @@ describe('Payment Component', () => {
13481348
}
13491349
]
13501350
}
1351-
render(<TestWrapper isRegistered={true} customerData={customerWithSaved} />)
1352-
// Wait for form to appear (auto-apply may temporarily hide it)
1351+
// Use isEditing so auto-apply is skipped and the form stays visible (avoids CI race)
1352+
render(
1353+
<TestWrapper
1354+
isRegistered={true}
1355+
customerData={customerWithSaved}
1356+
isEditing={true}
1357+
/>
1358+
)
13531359
await screen.findByTestId('payment-form')
13541360
await user.click(screen.getByText('Select Saved'))
13551361
// If no error thrown, the path executed successfully
@@ -1383,11 +1389,13 @@ describe('Payment Component', () => {
13831389
}
13841390
]
13851391
}
1392+
// Use isEditing so auto-apply is skipped and the form stays visible (avoids CI race)
13861393
render(
13871394
<TestWrapper
13881395
basketData={pickupBasket}
13891396
isRegistered={true}
13901397
customerData={customerWithSaved}
1398+
isEditing={true}
13911399
/>
13921400
)
13931401
await screen.findByTestId('payment-form')

0 commit comments

Comments
 (0)