Skip to content

Commit d89a547

Browse files
committed
Attempt fix saved card tests
1 parent e3088f0 commit d89a547

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,14 @@ test.describe( 'Shopper can save and delete cards', () => {
251251
async () => {
252252
await goToMyAccount( shopperPage, 'payment-methods' );
253253

254+
// Verify both cards are visible before trying to delete them
255+
await expect(
256+
shopperPage.getByText( card.label )
257+
).toBeVisible( { timeout: 10000 } );
258+
await expect(
259+
shopperPage.getByText( card2.label )
260+
).toBeVisible( { timeout: 10000 } );
261+
254262
await deleteSavedCard( shopperPage, card );
255263
await expect(
256264
shopperPage.getByText( 'Payment method deleted.' )

tests/e2e/utils/shopper.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,21 @@ export const deleteSavedCard = async (
616616
page: Page,
617617
card: typeof config.cards.basic
618618
) => {
619+
// First, let's check if the card is visible on the page
620+
const cardText = page.getByText( card.label );
621+
const isCardVisible = await cardText.isVisible();
622+
623+
if ( ! isCardVisible ) {
624+
throw new Error(
625+
`Card with label "${ card.label }" is not visible on the page`
626+
);
627+
}
628+
619629
const row = page.getByRole( 'row', { name: card.label } ).first();
620-
await expect( row ).toBeVisible( { timeout: 100 } );
630+
await expect( row ).toBeVisible( { timeout: 5000 } );
621631
const button = row.getByRole( 'link', { name: 'Delete' } );
622-
await expect( button ).toBeVisible( { timeout: 100 } );
623-
await expect( button ).toBeEnabled( { timeout: 100 } );
632+
await expect( button ).toBeVisible( { timeout: 5000 } );
633+
await expect( button ).toBeEnabled( { timeout: 5000 } );
624634
await button.click();
625635
};
626636

@@ -633,7 +643,7 @@ export const selectSavedCardOnCheckout = async (
633643
`${ card.label } (expires ${ card.expires.month }/${ card.expires.year })`
634644
)
635645
.first();
636-
await expect( option ).toBeVisible( { timeout: 100 } );
646+
await expect( option ).toBeVisible( { timeout: 5000 } );
637647
await option.click();
638648
};
639649

@@ -642,10 +652,10 @@ export const setDefaultPaymentMethod = async (
642652
card: typeof config.cards.basic
643653
) => {
644654
const row = page.getByRole( 'row', { name: card.label } ).first();
645-
await expect( row ).toBeVisible( { timeout: 100 } );
655+
await expect( row ).toBeVisible( { timeout: 5000 } );
646656
const button = row.getByRole( 'link', { name: 'Make default' } );
647-
await expect( button ).toBeVisible( { timeout: 100 } );
648-
await expect( button ).toBeEnabled( { timeout: 100 } );
657+
await expect( button ).toBeVisible( { timeout: 5000 } );
658+
await expect( button ).toBeEnabled( { timeout: 5000 } );
649659
await button.click();
650660
};
651661

0 commit comments

Comments
 (0)