@@ -586,6 +586,7 @@ export const addSavedCard = async (
586
586
country : string ,
587
587
zipCode ?: string
588
588
) => {
589
+ await page . getByRole ( 'link' , { name : 'Add payment method' } ) . click ( ) ;
589
590
await page . waitForLoadState ( 'networkidle' ) ;
590
591
await page . getByText ( 'Card' , { exact : true } ) . click ( ) ;
591
592
const frameHandle = page . getByTitle ( 'Secure payment input frame' ) ;
@@ -609,53 +610,18 @@ export const addSavedCard = async (
609
610
if ( zip ) await zip . fill ( zipCode ?? '90210' ) ;
610
611
611
612
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 } ) ;
638
613
} ;
639
614
640
615
export const deleteSavedCard = async (
641
616
page : Page ,
642
617
card : typeof config . cards . basic
643
618
) => {
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
-
650
619
const row = page . getByRole ( 'row' , { name : card . label } ) . first ( ) ;
651
- await expect ( row ) . toBeVisible ( { timeout : 10000 } ) ;
620
+ await expect ( row ) . toBeVisible ( { timeout : 100 } ) ;
652
621
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 } ) ;
655
624
await button . click ( ) ;
656
-
657
- // Wait for the deletion to complete
658
- await page . waitForLoadState ( 'networkidle' ) ;
659
625
} ;
660
626
661
627
export const selectSavedCardOnCheckout = async (
@@ -667,29 +633,20 @@ export const selectSavedCardOnCheckout = async (
667
633
`${ card . label } (expires ${ card . expires . month } /${ card . expires . year } )`
668
634
)
669
635
. first ( ) ;
670
- await expect ( option ) . toBeVisible ( { timeout : 10000 } ) ;
636
+ await expect ( option ) . toBeVisible ( { timeout : 100 } ) ;
671
637
await option . click ( ) ;
672
638
} ;
673
639
674
640
export const setDefaultPaymentMethod = async (
675
641
page : Page ,
676
642
card : typeof config . cards . basic
677
643
) => {
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
-
684
644
const row = page . getByRole ( 'row' , { name : card . label } ) . first ( ) ;
685
- await expect ( row ) . toBeVisible ( { timeout : 10000 } ) ;
645
+ await expect ( row ) . toBeVisible ( { timeout : 100 } ) ;
686
646
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 } ) ;
689
649
await button . click ( ) ;
690
-
691
- // Wait for the action to complete
692
- await page . waitForLoadState ( 'networkidle' ) ;
693
650
} ;
694
651
695
652
export const removeCoupon = async ( page : Page ) => {
0 commit comments