Skip to content

Commit fb599f1

Browse files
authored
E2E: Fixed addSavedCard and Rate Limit adding card too soon with 3DS cards (#11024)
1 parent e223120 commit fb599f1

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: dev
3+
4+
Fix flaky E2E test in addSavedCard function

tests/e2e/specs/wcpay/shopper/shopper-myaccount-saved-cards.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ test.describe( 'Shopper can save and delete cards', () => {
171171
await confirmCardAuthentication( shopperPage );
172172
}
173173

174-
// Take note of the time when we added this card
175-
cardTimingHelper.markCardAdded();
176-
177174
// waiting for the new page to be loaded, since there is a redirect happening after the submission..
178175
await shopperPage.waitForLoadState( 'networkidle' );
179176

@@ -183,6 +180,9 @@ test.describe( 'Shopper can save and delete cards', () => {
183180
)
184181
).toBeVisible();
185182

183+
// Take note of the time when we added this card
184+
cardTimingHelper.markCardAdded();
185+
186186
// Verify that the card was added
187187
await expect(
188188
shopperPage.getByText(

tests/e2e/utils/shopper.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,13 @@ export const addSavedCard = async (
587587
zipCode?: string
588588
) => {
589589
await page.getByRole( 'link', { name: 'Add payment method' } ).click();
590-
await page.waitForLoadState( 'networkidle' );
590+
591+
// Wait for the page to be stable
592+
// Use a more reliable approach than networkidle which can timeout
593+
await page.waitForLoadState( 'domcontentloaded' );
594+
// Ensure UI is not blocked
595+
await isUIUnblocked( page );
596+
591597
await page.getByText( 'Card', { exact: true } ).click();
592598
const frameHandle = page.getByTitle( 'Secure payment input frame' );
593599
const stripeFrame = frameHandle.contentFrame();

0 commit comments

Comments
 (0)