@@ -9,14 +9,36 @@ export default class KlarnaPaymentPage {
99 this . closeButton = page . getByLabel ( 'Close' ) ;
1010 this . confirmAndPayButton = page . getByTestId ( 'confirm-and-pay' ) ;
1111
12- this . chooseHowToPayDialog = page . getByRole ( 'dialog' , {
13- name : / c h o o s e h o w t o p a y / i,
14- } ) ;
15- this . cardRadioOption = page . getByRole ( 'radio' , { name : / ^ c a r d / i } ) ;
16- this . continueButton = page . getByRole ( 'button' , { name : / ^ c o n t i n u e $ / i } ) ;
12+ this . offersSelectorDialog = page . locator ( '#offers-selector-dialog' ) ;
13+ this . payInFullRadioOption = this . offersSelectorDialog
14+ . getByRole ( 'radio' , { name : / ^ p a y i n f u l l / i } )
15+ . first ( ) ;
16+ this . offersSelectorContinueButton = page . getByTestId (
17+ 'offers-selector-continue-button'
18+ ) ;
19+
20+ this . payNowSelectorDialog = page . locator (
21+ '#offers-selector-pay-now-selector-dialog'
22+ ) ;
23+ this . cardRadioOption = this . payNowSelectorDialog
24+ . getByRole ( 'radio' , { name : / ^ c a r d / i } )
25+ . first ( ) ;
26+ this . payNowSelectorContinueButton = page . getByTestId (
27+ 'offers-selector-pay-now-selector-continue-button'
28+ ) ;
29+
30+ this . threeDsSubmitButton = page
31+ . getByRole ( 'dialog' )
32+ . filter ( { has : page . locator ( 'iframe' ) } )
33+ . frameLocator ( 'iframe' )
34+ . getByRole ( 'button' , { name : / ^ s u b m i t $ / i } ) ;
1735 }
1836
19- async makeKlarnaPayment ( phoneNumber , paynow = false ) {
37+ async makeKlarnaPayment (
38+ phoneNumber ,
39+ paynow = false ,
40+ threeDsChallenge = paynow
41+ ) {
2042 await this . waitForKlarnaLoad ( ) ;
2143 await this . phoneNumberVerificationDialog . waitFor ( { state : 'attached' } ) ;
2244 await this . genericInputField . click ( ) ;
@@ -27,13 +49,20 @@ export default class KlarnaPaymentPage {
2749 await this . genericInputField . fill ( '111111' ) ;
2850
2951 if ( paynow ) {
30- await this . chooseHowToPayDialog . waitFor ( { state : 'visible' } ) ;
52+ await this . offersSelectorDialog . waitFor ( { state : 'visible' } ) ;
53+ await this . payInFullRadioOption . click ( ) ;
54+ await this . offersSelectorContinueButton . click ( ) ;
55+ await this . payNowSelectorDialog . waitFor ( { state : 'visible' } ) ;
3156 await this . cardRadioOption . click ( ) ;
32- await this . continueButton . click ( ) ;
57+ await this . payNowSelectorContinueButton . click ( ) ;
3358 }
3459
3560 await this . confirmAndPayButton . waitFor ( { state : 'visible' } ) ;
3661 await this . confirmAndPayButton . click ( ) ;
62+
63+ if ( threeDsChallenge ) {
64+ await this . threeDsSubmitButton . click ( ) ;
65+ }
3766 }
3867
3968 async cancelKlarnaPayment ( ) {
0 commit comments