@@ -476,10 +476,24 @@ export const fillACHBankDetails = async ( page ) => {
476
476
// Click "Connect Account" button.
477
477
await frame . getByTestId ( 'select-button' ) . click ( ) ;
478
478
479
- // Skip link registration
480
- await frame . getByTestId ( 'link-not-now-button' ) . click ( ) ;
479
+ // Link registration button may or may not appear.
480
+ await Promise . race ( [
481
+ frame
482
+ . getByTestId ( 'link-not-now-button' )
483
+ . waitFor ( {
484
+ state : 'visible' ,
485
+ timeout : 5000 ,
486
+ } )
487
+ . then ( async ( ) => {
488
+ await frame . getByTestId ( 'link-not-now-button' ) . click ( ) ;
489
+ } ) ,
490
+
491
+ frame . getByTestId ( 'done-button' ) . waitFor ( {
492
+ state : 'visible' ,
493
+ timeout : 5000 ,
494
+ } ) ,
495
+ ] ) ;
481
496
482
- // Click "Done" button.
483
497
await frame . getByTestId ( 'done-button' ) . click ( ) ;
484
498
} ;
485
499
@@ -905,16 +919,24 @@ export const setupAffirmCheckout = async ( page, checkoutType = 'blocks' ) => {
905
919
const affirmLabel = page . locator ( 'label' , { hasText : 'Affirm' } ) ;
906
920
await affirmLabel . waitFor ( { state : 'visible' } ) ;
907
921
await affirmLabel . click ( ) ;
908
- await page . waitForSelector (
909
- '#radio-control-wc-payment-method-options-stripe_affirm__content'
910
- ) ;
922
+ await expect (
923
+ page
924
+ . frameLocator (
925
+ '#radio-control-wc-payment-method-options-stripe_affirm__content iframe[name^="__privateStripeFrame"]'
926
+ )
927
+ . getByTestId ( 'next-action-text' )
928
+ ) . toBeVisible ( ) ;
911
929
} else {
912
930
const affirmLabel = page . getByText ( 'Affirm' ) ;
913
931
await affirmLabel . waitFor ( { state : 'visible' } ) ;
914
932
await affirmLabel . click ( ) ;
915
- await page . waitForSelector (
916
- '.payment_method_stripe_affirm iframe[src*="elements-inner-payment"]'
917
- ) ;
933
+ await expect (
934
+ page
935
+ . frameLocator (
936
+ '.payment_method_stripe_affirm iframe[src*="elements-inner-payment"]'
937
+ )
938
+ . getByTestId ( 'next-action-text' )
939
+ ) . toBeVisible ( ) ;
918
940
}
919
941
} ;
920
942
@@ -943,15 +965,23 @@ export const setupKlarnaCheckout = async ( page, checkoutType = 'blocks' ) => {
943
965
const klarnaLabel = page . locator ( 'label' , { hasText : 'Klarna' } ) ;
944
966
await klarnaLabel . waitFor ( { state : 'visible' } ) ;
945
967
await klarnaLabel . click ( ) ;
946
- await page . waitForSelector (
947
- '#radio-control-wc-payment-method-options-stripe_klarna__content'
948
- ) ;
968
+ await expect (
969
+ page
970
+ . frameLocator (
971
+ '#radio-control-wc-payment-method-options-stripe_klarna__content iframe[name^="__privateStripeFrame"]'
972
+ )
973
+ . getByTestId ( 'next-action-text' )
974
+ ) . toBeVisible ( ) ;
949
975
} else {
950
976
const klarnaLabel = page . getByText ( 'Klarna' ) ;
951
977
await klarnaLabel . waitFor ( { state : 'visible' } ) ;
952
978
await klarnaLabel . click ( ) ;
953
- await page . waitForSelector (
954
- '.payment_method_stripe_klarna iframe[src*="elements-inner-payment"]'
955
- ) ;
979
+ await expect (
980
+ page
981
+ . frameLocator (
982
+ '.payment_method_stripe_klarna iframe[src*="elements-inner-payment"]'
983
+ )
984
+ . getByTestId ( 'next-action-text' )
985
+ ) . toBeVisible ( ) ;
956
986
}
957
987
} ;
0 commit comments