Skip to content

Commit 6bda9b4

Browse files
committed
Undo changes to saved card tests
1 parent 2c75f07 commit 6bda9b4

File tree

2 files changed

+8
-59
lines changed

2 files changed

+8
-59
lines changed

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
selectSavedCardOnCheckout,
1818
setDefaultPaymentMethod,
1919
setupProductCheckout,
20-
verifySavedCardIsDisplayed,
2120
} from '../../../utils/shopper';
2221

2322
type TestVariablesType = {
@@ -236,9 +235,6 @@ test.describe( 'Shopper can save and delete cards', () => {
236235
// Take note of the time when we added this card
237236
cardTimingHelper.markCardAdded();
238237

239-
// Verify the card was properly added and is visible
240-
await verifySavedCardIsDisplayed( shopperPage, card2 );
241-
242238
await setDefaultPaymentMethod( shopperPage, card2 );
243239
// Verify that the card was set as default
244240
await expect(
@@ -255,10 +251,6 @@ test.describe( 'Shopper can save and delete cards', () => {
255251
async () => {
256252
await goToMyAccount( shopperPage, 'payment-methods' );
257253

258-
// Verify both cards are visible before trying to delete them
259-
await verifySavedCardIsDisplayed( shopperPage, card );
260-
await verifySavedCardIsDisplayed( shopperPage, card2 );
261-
262254
await deleteSavedCard( shopperPage, card );
263255
await expect(
264256
shopperPage.getByText( 'Payment method deleted.' )

tests/e2e/utils/shopper.ts

Lines changed: 8 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ export const addSavedCard = async (
586586
country: string,
587587
zipCode?: string
588588
) => {
589+
await page.getByRole( 'link', { name: 'Add payment method' } ).click();
589590
await page.waitForLoadState( 'networkidle' );
590591
await page.getByText( 'Card', { exact: true } ).click();
591592
const frameHandle = page.getByTitle( 'Secure payment input frame' );
@@ -609,53 +610,18 @@ export const addSavedCard = async (
609610
if ( zip ) await zip.fill( zipCode ?? '90210' );
610611

611612
await page.getByRole( 'button', { name: 'Add payment method' } ).click();
612-
613-
// Wait for the card to be processed and saved
614-
await page.waitForLoadState( 'networkidle' );
615-
// Additional wait to ensure the card is fully saved
616-
await page.waitForTimeout( 3000 );
617-
};
618-
619-
export const verifySavedCardIsDisplayed = async (
620-
page: Page,
621-
card: typeof config.cards.basic
622-
) => {
623-
// Wait for the page to be fully loaded
624-
await page.waitForLoadState( 'networkidle' );
625-
626-
// Wait a bit more for any dynamic content to load
627-
await page.waitForTimeout( 2000 );
628-
629-
// Verify the card label is visible
630-
await expect( page.getByText( card.label ) ).toBeVisible( {
631-
timeout: 10000,
632-
} );
633-
634-
// Verify the card expiration is visible
635-
await expect(
636-
page.getByText( `${ card.expires.month }/${ card.expires.year }` )
637-
).toBeVisible( { timeout: 10000 } );
638613
};
639614

640615
export const deleteSavedCard = async (
641616
page: Page,
642617
card: typeof config.cards.basic
643618
) => {
644-
// Wait for the page to be fully loaded
645-
await page.waitForLoadState( 'networkidle' );
646-
647-
// Wait a bit more for any dynamic content to load
648-
await page.waitForTimeout( 2000 );
649-
650619
const row = page.getByRole( 'row', { name: card.label } ).first();
651-
await expect( row ).toBeVisible( { timeout: 10000 } );
620+
await expect( row ).toBeVisible( { timeout: 100 } );
652621
const button = row.getByRole( 'link', { name: 'Delete' } );
653-
await expect( button ).toBeVisible( { timeout: 10000 } );
654-
await expect( button ).toBeEnabled( { timeout: 10000 } );
622+
await expect( button ).toBeVisible( { timeout: 100 } );
623+
await expect( button ).toBeEnabled( { timeout: 100 } );
655624
await button.click();
656-
657-
// Wait for the deletion to complete
658-
await page.waitForLoadState( 'networkidle' );
659625
};
660626

661627
export const selectSavedCardOnCheckout = async (
@@ -667,29 +633,20 @@ export const selectSavedCardOnCheckout = async (
667633
`${ card.label } (expires ${ card.expires.month }/${ card.expires.year })`
668634
)
669635
.first();
670-
await expect( option ).toBeVisible( { timeout: 10000 } );
636+
await expect( option ).toBeVisible( { timeout: 100 } );
671637
await option.click();
672638
};
673639

674640
export const setDefaultPaymentMethod = async (
675641
page: Page,
676642
card: typeof config.cards.basic
677643
) => {
678-
// Wait for the page to be fully loaded
679-
await page.waitForLoadState( 'networkidle' );
680-
681-
// Wait a bit more for any dynamic content to load
682-
await page.waitForTimeout( 2000 );
683-
684644
const row = page.getByRole( 'row', { name: card.label } ).first();
685-
await expect( row ).toBeVisible( { timeout: 10000 } );
645+
await expect( row ).toBeVisible( { timeout: 100 } );
686646
const button = row.getByRole( 'link', { name: 'Make default' } );
687-
await expect( button ).toBeVisible( { timeout: 10000 } );
688-
await expect( button ).toBeEnabled( { timeout: 10000 } );
647+
await expect( button ).toBeVisible( { timeout: 100 } );
648+
await expect( button ).toBeEnabled( { timeout: 100 } );
689649
await button.click();
690-
691-
// Wait for the action to complete
692-
await page.waitForLoadState( 'networkidle' );
693650
};
694651

695652
export const removeCoupon = async ( page: Page ) => {

0 commit comments

Comments
 (0)