@@ -8,21 +8,19 @@ import config from 'config';
8
8
*/
9
9
import { merchantWCP , shopperWCP } from '../../../utils/flows' ;
10
10
import {
11
- confirmCardAuthentication ,
12
- fillCardDetails ,
13
11
setupProductCheckout ,
14
12
selectGiropayOnCheckout ,
15
13
completeGiropayPayment ,
16
14
} from '../../../utils/payments' ;
17
- import { uiUnblocked } from '@woocommerce/e2e-utils/build/page-utils' ;
18
15
const { shopper, merchant } = require ( '@woocommerce/e2e-utils' ) ;
19
16
20
17
const UPE_METHOD_CHECKBOXES = [
21
- '#inspector-checkbox-control-7' , // giropay
18
+ "//label[contains(text(), 'giropay')]/preceding-sibling::span/input[@type='checkbox']" ,
19
+ "//label[contains(text(), 'Bancontact')]/preceding-sibling::span/input[@type='checkbox']" ,
20
+ "//label[contains(text(), 'EPS')]/preceding-sibling::span/input[@type='checkbox']" ,
21
+ "//label[contains(text(), 'iDEAL')]/preceding-sibling::span/input[@type='checkbox']" ,
22
+ "//label[contains(text(), 'Sofort')]/preceding-sibling::span/input[@type='checkbox']" ,
22
23
] ;
23
- const card = config . get ( 'cards.basic' ) ;
24
- const card2 = config . get ( 'cards.basic2' ) ;
25
- const MIN_WAIT_TIME_BETWEEN_PAYMENT_METHODS = 20000 ;
26
24
27
25
describe ( 'Enabled UPE with deferred intent creation' , ( ) => {
28
26
beforeAll ( async ( ) => {
@@ -53,144 +51,5 @@ describe( 'Enabled UPE with deferred intent creation', () => {
53
51
} ) ;
54
52
await expect ( page ) . toMatch ( 'Order received' ) ;
55
53
} ) ;
56
-
57
- it ( 'should successfully place order with the default card' , async ( ) => {
58
- await setupProductCheckout (
59
- config . get ( 'addresses.customer.billing' )
60
- ) ;
61
- await fillCardDetails ( page , card ) ;
62
- await shopper . placeOrder ( ) ;
63
- await expect ( page ) . toMatch ( 'Order received' ) ;
64
- } ) ;
65
-
66
- it ( 'should process a payment with authentication for the 3DS card' , async ( ) => {
67
- await setupProductCheckout (
68
- config . get ( 'addresses.customer.billing' )
69
- ) ;
70
- await fillCardDetails ( page , config . get ( 'cards.3ds' ) ) ;
71
- await shopper . placeOrder ( ) ;
72
- await confirmCardAuthentication ( page , '3DS' ) ;
73
- await page . waitForNavigation ( {
74
- waitUntil : 'networkidle0' ,
75
- } ) ;
76
- await expect ( page ) . toMatch ( 'Order received' ) ;
77
- } ) ;
78
-
79
- it ( 'should successfully save the card' , async ( ) => {
80
- await setupProductCheckout (
81
- config . get ( 'addresses.customer.billing' )
82
- ) ;
83
- await fillCardDetails ( page , card ) ;
84
- await shopperWCP . toggleSavePaymentMethod ( ) ;
85
- await shopper . placeOrder ( ) ;
86
- await expect ( page ) . toMatch ( 'Order received' ) ;
87
-
88
- // validate that the payment method has been added to the customer.
89
- await shopperWCP . goToPaymentMethods ( ) ;
90
- await expect ( page ) . toMatch ( card . label ) ;
91
- await expect ( page ) . toMatch (
92
- `${ card . expires . month } /${ card . expires . year } `
93
- ) ;
94
- } ) ;
95
-
96
- it ( 'should process a payment with the saved card' , async ( ) => {
97
- await setupProductCheckout (
98
- config . get ( 'addresses.customer.billing' )
99
- ) ;
100
- await shopper . goToCheckout ( ) ;
101
- await uiUnblocked ( ) ;
102
- await shopperWCP . selectSavedPaymentMethod (
103
- `${ card . label } (expires ${ card . expires . month } /${ card . expires . year } )`
104
- ) ;
105
- await shopper . placeOrder ( ) ;
106
- await expect ( page ) . toMatch ( 'Order received' ) ;
107
- } ) ;
108
-
109
- it ( 'should delete the card' , async ( ) => {
110
- await shopperWCP . goToPaymentMethods ( ) ;
111
- await shopperWCP . deleteSavedPaymentMethod ( card . label ) ;
112
- await expect ( page ) . toMatch ( 'Payment method deleted' ) ;
113
- } ) ;
114
-
115
- it ( 'should not allow guest user to save the card' , async ( ) => {
116
- await shopperWCP . logout ( ) ;
117
- await setupProductCheckout (
118
- config . get ( 'addresses.customer.billing' )
119
- ) ;
120
-
121
- await expect ( page ) . not . toMatchElement (
122
- 'input#wc-woocommerce_payments-new-payment-method'
123
- ) ;
124
- await shopper . login ( ) ;
125
- } ) ;
126
- } ) ;
127
-
128
- describe ( 'My Account' , ( ) => {
129
- let timeAdded ;
130
-
131
- it ( 'should add the card as a new payment method' , async ( ) => {
132
- await shopperWCP . goToPaymentMethods ( ) ;
133
- await shopperWCP . addNewPaymentMethod ( 'basic' , card ) ;
134
-
135
- // Take note of the time when we added this card
136
- timeAdded = Date . now ( ) ;
137
-
138
- // Verify that the card was added
139
- await expect ( page ) . not . toMatch (
140
- 'You cannot add a new payment method so soon after the previous one. Please wait for 20 seconds.'
141
- ) ;
142
- await expect ( page ) . toMatch ( 'Payment method successfully added' ) ;
143
- await expect ( page ) . toMatch (
144
- `${ card . expires . month } /${ card . expires . year } `
145
- ) ;
146
- await waitTwentySecondsSinceLastCardAdded ( ) ;
147
- } ) ;
148
-
149
- it ( 'should be able to set payment method as default' , async ( ) => {
150
- await shopperWCP . goToPaymentMethods ( ) ;
151
- await shopperWCP . addNewPaymentMethod ( 'basic2' , card2 ) ;
152
- // Take note of the time when we added this card
153
- timeAdded = Date . now ( ) ;
154
-
155
- // Verify that the card was added
156
- await expect ( page ) . not . toMatch (
157
- 'You cannot add a new payment method so soon after the previous one. Please wait for 20 seconds.'
158
- ) ;
159
- await expect ( page ) . toMatch ( 'Payment method successfully added' ) ;
160
- await expect ( page ) . toMatch (
161
- `${ card2 . expires . month } /${ card2 . expires . year } `
162
- ) ;
163
- await shopperWCP . setDefaultPaymentMethod ( card2 . label ) ;
164
- // Verify that the card was set as default
165
- await expect ( page ) . toMatch (
166
- 'This payment method was successfully set as your default.'
167
- ) ;
168
- } ) ;
169
-
170
- it ( 'should be able to delete cards' , async ( ) => {
171
- await shopperWCP . deleteSavedPaymentMethod ( card . label ) ;
172
- await expect ( page ) . toMatch ( 'Payment method deleted.' ) ;
173
-
174
- await shopperWCP . deleteSavedPaymentMethod ( card2 . label ) ;
175
- await expect ( page ) . toMatch ( 'Payment method deleted.' ) ;
176
- } ) ;
177
-
178
- afterAll ( async ( ) => {
179
- await waitTwentySecondsSinceLastCardAdded ( ) ;
180
- } ) ;
181
-
182
- async function waitTwentySecondsSinceLastCardAdded ( ) {
183
- // Make sure that at least 20s had already elapsed since the last card was added.
184
- // Otherwise, you will get the error message,
185
- // "You cannot add a new payment method so soon after the previous one."
186
- const timeTestFinished = Date . now ( ) ;
187
- const elapsedWaitTime = timeTestFinished - timeAdded ;
188
- const remainingWaitTime =
189
- MIN_WAIT_TIME_BETWEEN_PAYMENT_METHODS > elapsedWaitTime
190
- ? MIN_WAIT_TIME_BETWEEN_PAYMENT_METHODS - elapsedWaitTime
191
- : 0 ;
192
-
193
- await new Promise ( ( r ) => setTimeout ( r , remainingWaitTime ) ) ;
194
- }
195
54
} ) ;
196
55
} ) ;
0 commit comments