-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Timur Karimov
committed
Jan 9, 2024
1 parent
0fdc27d
commit 37a37ea
Showing
2 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
tests/e2e/specs/upe-split/shopper/shopper-bnpls-checkout.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
const { shopper, merchant } = require( '@woocommerce/e2e-utils' ); | ||
import config from 'config'; | ||
import { uiUnblocked } from '@woocommerce/e2e-utils/build/page-utils'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { merchantWCP, shopperWCP } from '../../../utils/flows'; | ||
import { setupProductCheckout } from '../../../utils/payments'; | ||
|
||
const bnplProviders = [ [ 'Affirm' ], [ 'Afterpay' ] ]; | ||
|
||
const UPE_METHOD_CHECKBOXES = [ | ||
"//label[contains(text(), 'Affirm')]/preceding-sibling::span/input[@type='checkbox']", // affirm | ||
"//label[contains(text(), 'Afterpay')]/preceding-sibling::span/input[@type='checkbox']", // afterpay | ||
]; | ||
|
||
describe( 'BNPL checkout', () => { | ||
beforeAll( async () => { | ||
await merchant.login(); | ||
await merchantWCP.enablePaymentMethod( UPE_METHOD_CHECKBOXES ); | ||
await merchant.logout(); | ||
await shopper.login(); | ||
await shopperWCP.changeAccountCurrencyTo( 'USD' ); | ||
} ); | ||
|
||
afterAll( async () => { | ||
await shopperWCP.logout(); | ||
await merchant.login(); | ||
await merchantWCP.disablePaymentMethod( UPE_METHOD_CHECKBOXES ); | ||
await merchant.logout(); | ||
} ); | ||
|
||
describe.each( bnplProviders )( 'Checkout with %s', ( providerName ) => { | ||
beforeEach( async () => { | ||
await setupProductCheckout( | ||
config.get( 'addresses.customer.billing' ), | ||
[ [ 'Beanie', 3 ] ] | ||
); | ||
} ); | ||
|
||
it( `should successfully place order with ${ providerName }`, async () => { | ||
await uiUnblocked(); | ||
// Select BNPL provider as payment method. | ||
const xPathPaymentMethodSelector = `//*[@id='payment']/ul/li/label[contains(text(), '${ providerName }')]`; | ||
await page.waitForXPath( xPathPaymentMethodSelector ); | ||
const [ paymentMethodLabel ] = await page.$x( | ||
xPathPaymentMethodSelector | ||
); | ||
await paymentMethodLabel.click(); | ||
await shopper.placeOrder(); | ||
|
||
// Authorize payment with Stripe. | ||
// This XPath selector matches the Authorize Payment button, that is either a button or an anchor. | ||
const xPathAuthorizePaymentButton = `//*[self::button or self::a][contains(text(), 'Authorize Test Payment')]`; | ||
await page.waitForXPath( xPathAuthorizePaymentButton ); | ||
const [ stripeButton ] = await page.$x( | ||
xPathAuthorizePaymentButton | ||
); | ||
await stripeButton.click(); | ||
|
||
// Wait for the order confirmation page to load. | ||
await page.waitForNavigation( { | ||
waitUntil: 'networkidle0', | ||
} ); | ||
await expect( page ).toMatch( 'Order received' ); | ||
} ); | ||
} ); | ||
} ); |
63 changes: 63 additions & 0 deletions
63
tests/e2e/specs/upe-split/shopper/shopper-deferred-intent-creation-upe-enabled.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import config from 'config'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { merchantWCP, shopperWCP } from '../../../utils/flows'; | ||
import { | ||
setupProductCheckout, | ||
selectGiropayOnCheckout, | ||
completeGiropayPayment, | ||
} from '../../../utils/payments'; | ||
const { shopper, merchant } = require( '@woocommerce/e2e-utils' ); | ||
|
||
const UPE_METHOD_CHECKBOXES = [ | ||
"//label[contains(text(), 'giropay')]/preceding-sibling::span/input[@type='checkbox']", | ||
"//label[contains(text(), 'Bancontact')]/preceding-sibling::span/input[@type='checkbox']", | ||
"//label[contains(text(), 'EPS')]/preceding-sibling::span/input[@type='checkbox']", | ||
"//label[contains(text(), 'iDEAL')]/preceding-sibling::span/input[@type='checkbox']", | ||
"//label[contains(text(), 'Sofort')]/preceding-sibling::span/input[@type='checkbox']", | ||
]; | ||
|
||
describe( 'Enabled UPE with deferred intent creation', () => { | ||
beforeAll( async () => { | ||
await merchant.login(); | ||
await merchantWCP.enablePaymentMethod( UPE_METHOD_CHECKBOXES ); | ||
await merchant.logout(); | ||
await shopper.login(); | ||
console.log( 'a' ); | ||
} ); | ||
|
||
afterAll( async () => { | ||
await shopperWCP.logout(); | ||
await merchant.login(); | ||
await merchantWCP.disablePaymentMethod( UPE_METHOD_CHECKBOXES ); | ||
await merchant.logout(); | ||
} ); | ||
|
||
describe( 'Enabled UPE with deferred intent creation', () => { | ||
it( 'should successfully place order with Giropay', async () => { | ||
console.log( 'b' ); | ||
await shopperWCP.goToShopWithCurrency( 'EUR' ); | ||
console.log( 'c' ); | ||
await setupProductCheckout( | ||
config.get( 'addresses.customer.billing' ) | ||
); | ||
console.log( 'd' ); | ||
await selectGiropayOnCheckout( page ); | ||
console.log( 'e' ); | ||
await shopper.placeOrder(); | ||
console.log( 'f' ); | ||
await completeGiropayPayment( page, 'success' ); | ||
console.log( 'g' ); | ||
await page.waitForNavigation( { | ||
waitUntil: 'networkidle0', | ||
} ); | ||
console.log( 'h' ); | ||
await expect( page ).toMatch( 'Order received' ); | ||
} ); | ||
} ); | ||
} ); |