mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Set checkout page before block/classic tests
This commit is contained in:
parent
e2e2897714
commit
54e740e396
5 changed files with 98 additions and 57 deletions
|
@ -3,8 +3,10 @@ PPCP_E2E_WP_DIR=${ROOT_DIR}/.ddev/wordpress
|
||||||
BASEURL="https://woocommerce-paypal-payments.ddev.site"
|
BASEURL="https://woocommerce-paypal-payments.ddev.site"
|
||||||
|
|
||||||
CHECKOUT_URL="/checkout"
|
CHECKOUT_URL="/checkout"
|
||||||
|
CHECKOUT_PAGE_ID=7
|
||||||
CART_URL="/cart"
|
CART_URL="/cart"
|
||||||
BLOCK_CHECKOUT_URL="/checkout-block"
|
BLOCK_CHECKOUT_URL="/checkout-block"
|
||||||
|
BLOCK_CHECKOUT_PAGE_ID=22
|
||||||
BLOCK_CART_URL="/cart-block"
|
BLOCK_CART_URL="/cart-block"
|
||||||
|
|
||||||
PRODUCT_URL="/product/prod"
|
PRODUCT_URL="/product/prod"
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
"prearchive": "rm -rf $npm_package_name.zip",
|
"prearchive": "rm -rf $npm_package_name.zip",
|
||||||
"archive": "zip -r $npm_package_name.zip . -x **.git/\\* **node_modules/\\*",
|
"archive": "zip -r $npm_package_name.zip . -x **.git/\\* **node_modules/\\*",
|
||||||
"postarchive": "yarn run archive:cleanup && rm -rf $npm_package_name && unzip $npm_package_name.zip -d $npm_package_name && rm $npm_package_name.zip && zip -r $npm_package_name.zip $npm_package_name && rm -rf $npm_package_name",
|
"postarchive": "yarn run archive:cleanup && rm -rf $npm_package_name && unzip $npm_package_name.zip -d $npm_package_name && rm $npm_package_name.zip && zip -r $npm_package_name.zip $npm_package_name && rm -rf $npm_package_name",
|
||||||
"archive:cleanup": "zip -d $npm_package_name.zip .env* .ddev/\\* \\*.idea/\\* .editorconfig tests/\\* .github/\\* .psalm/\\* wordpress_org_assets/\\* \\*.DS_Store \\*README.md \\*.gitattributes \\*.gitignore \\*composer.json \\*composer.lock patchwork.json phpunit.xml.dist .phpunit.result.cache phpcs.xml* psalm*.xml* playwright.config.js \\*.babelrc \\*package.json \\*webpack.config.js \\*yarn.lock \\*.travis.yml\\"
|
"archive:cleanup": "zip -d $npm_package_name.zip .env* .ddev/\\* \\*.idea/\\* .editorconfig tests/\\* .github/\\* .psalm/\\* wordpress_org_assets/\\* \\*.DS_Store \\*README.md \\*.gitattributes \\*.gitignore \\*composer.json \\*composer.lock patchwork.json phpunit.xml.dist .phpunit.result.cache phpcs.xml* psalm*.xml* playwright.config.js wp-cli.yml \\*.babelrc \\*package.json \\*webpack.config.js \\*yarn.lock \\*.travis.yml\\"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"wp_org_slug": "woocommerce-paypal-payments"
|
"wp_org_slug": "woocommerce-paypal-payments"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const {test, expect} = require('@playwright/test');
|
const {test, expect} = require('@playwright/test');
|
||||||
|
const {serverExec} = require("./utils/server");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
CUSTOMER_EMAIL,
|
CUSTOMER_EMAIL,
|
||||||
|
@ -9,8 +10,10 @@ const {
|
||||||
PRODUCT_URL,
|
PRODUCT_URL,
|
||||||
PRODUCT_ID,
|
PRODUCT_ID,
|
||||||
CHECKOUT_URL,
|
CHECKOUT_URL,
|
||||||
|
CHECKOUT_PAGE_ID,
|
||||||
CART_URL,
|
CART_URL,
|
||||||
BLOCK_CHECKOUT_URL,
|
BLOCK_CHECKOUT_URL,
|
||||||
|
BLOCK_CHECKOUT_PAGE_ID,
|
||||||
BLOCK_CART_URL,
|
BLOCK_CART_URL,
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
|
||||||
|
@ -91,77 +94,85 @@ async function completeBlockContinuation(page) {
|
||||||
await expectOrderReceivedPage(page);
|
await expectOrderReceivedPage(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
test('PayPal button place order from Product page', async ({page}) => {
|
test.describe('Classic checkout', () => {
|
||||||
|
test.beforeAll(async ({ browser }) => {
|
||||||
|
await serverExec('wp option update woocommerce_checkout_page_id ' + CHECKOUT_PAGE_ID);
|
||||||
|
});
|
||||||
|
|
||||||
await page.goto(PRODUCT_URL);
|
test('PayPal button place order from Product page', async ({page}) => {
|
||||||
|
await page.goto(PRODUCT_URL);
|
||||||
|
|
||||||
const popup = await openPaypalPopup(page);
|
const popup = await openPaypalPopup(page);
|
||||||
|
|
||||||
await loginIntoPaypal(popup);
|
await loginIntoPaypal(popup);
|
||||||
|
|
||||||
await completePaypalPayment(popup);
|
await completePaypalPayment(popup);
|
||||||
|
|
||||||
await fillCheckoutForm(page);
|
await fillCheckoutForm(page);
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForNavigation(),
|
page.waitForNavigation(),
|
||||||
page.locator('#place_order').click(),
|
page.locator('#place_order').click(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await expectOrderReceivedPage(page);
|
await expectOrderReceivedPage(page);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Advanced Credit and Debit Card (ACDC) place order from Checkout page', async ({page}) => {
|
||||||
|
await page.goto(PRODUCT_URL);
|
||||||
|
await page.locator('.single_add_to_cart_button').click();
|
||||||
|
|
||||||
|
await page.goto(CHECKOUT_URL);
|
||||||
|
await fillCheckoutForm(page);
|
||||||
|
|
||||||
|
await page.click("text=Credit Cards");
|
||||||
|
|
||||||
|
const creditCardNumber = page.frameLocator('#braintree-hosted-field-number').locator('#credit-card-number');
|
||||||
|
await creditCardNumber.fill(CREDIT_CARD_NUMBER);
|
||||||
|
|
||||||
|
const expirationDate = page.frameLocator('#braintree-hosted-field-expirationDate').locator('#expiration');
|
||||||
|
await expirationDate.fill(CREDIT_CARD_EXPIRATION);
|
||||||
|
|
||||||
|
const cvv = page.frameLocator('#braintree-hosted-field-cvv').locator('#cvv');
|
||||||
|
await cvv.fill(CREDIT_CARD_CVV);
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForNavigation(),
|
||||||
|
page.locator('.ppcp-dcc-order-button').click(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await expectOrderReceivedPage(page);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Advanced Credit and Debit Card (ACDC) place order from Checkout page', async ({page}) => {
|
test.describe('Block checkout', () => {
|
||||||
|
test.beforeAll(async ({browser}) => {
|
||||||
|
await serverExec('wp option update woocommerce_checkout_page_id ' + BLOCK_CHECKOUT_PAGE_ID);
|
||||||
|
});
|
||||||
|
|
||||||
await page.goto(PRODUCT_URL);
|
test('PayPal express block checkout', async ({page}) => {
|
||||||
await page.locator('.single_add_to_cart_button').click();
|
await page.goto('?add-to-cart=' + PRODUCT_ID);
|
||||||
|
|
||||||
await page.goto(CHECKOUT_URL);
|
await page.goto(BLOCK_CHECKOUT_URL)
|
||||||
await fillCheckoutForm(page);
|
|
||||||
|
|
||||||
await page.click("text=Credit Cards");
|
const popup = await openPaypalPopup(page);
|
||||||
|
|
||||||
const creditCardNumber = page.frameLocator('#braintree-hosted-field-number').locator('#credit-card-number');
|
await loginIntoPaypal(popup);
|
||||||
await creditCardNumber.fill(CREDIT_CARD_NUMBER);
|
|
||||||
|
|
||||||
const expirationDate = page.frameLocator('#braintree-hosted-field-expirationDate').locator('#expiration');
|
await completePaypalPayment(popup);
|
||||||
await expirationDate.fill(CREDIT_CARD_EXPIRATION);
|
|
||||||
|
|
||||||
const cvv = page.frameLocator('#braintree-hosted-field-cvv').locator('#cvv');
|
await completeBlockContinuation(page);
|
||||||
await cvv.fill(CREDIT_CARD_CVV);
|
});
|
||||||
|
|
||||||
await Promise.all([
|
test('PayPal express block cart', async ({page}) => {
|
||||||
page.waitForNavigation(),
|
await page.goto(BLOCK_CART_URL + '?add-to-cart=' + PRODUCT_ID)
|
||||||
page.locator('.ppcp-dcc-order-button').click(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
await expectOrderReceivedPage(page);
|
const popup = await openPaypalPopup(page);
|
||||||
});
|
|
||||||
|
await loginIntoPaypal(popup);
|
||||||
test('PayPal express block checkout', async ({page}) => {
|
|
||||||
|
await completePaypalPayment(popup);
|
||||||
await page.goto('?add-to-cart=' + PRODUCT_ID);
|
|
||||||
|
await completeBlockContinuation(page);
|
||||||
await page.goto(BLOCK_CHECKOUT_URL)
|
});
|
||||||
|
|
||||||
const popup = await openPaypalPopup(page);
|
|
||||||
|
|
||||||
await loginIntoPaypal(popup);
|
|
||||||
|
|
||||||
await completePaypalPayment(popup);
|
|
||||||
|
|
||||||
await completeBlockContinuation(page);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('PayPal express block cart', async ({page}) => {
|
|
||||||
|
|
||||||
await page.goto(BLOCK_CART_URL + '?add-to-cart=' + PRODUCT_ID)
|
|
||||||
|
|
||||||
const popup = await openPaypalPopup(page);
|
|
||||||
|
|
||||||
await loginIntoPaypal(popup);
|
|
||||||
|
|
||||||
await completePaypalPayment(popup);
|
|
||||||
|
|
||||||
await completeBlockContinuation(page);
|
|
||||||
});
|
});
|
||||||
|
|
27
tests/playwright/utils/server.js
Normal file
27
tests/playwright/utils/server.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
const { exec } = require('node:child_process');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the command on the server (inside DDEV). Can be called inside and outside DDEV.
|
||||||
|
*/
|
||||||
|
export const serverExec = async (cmd) => {
|
||||||
|
const isDdev = process.env.IS_DDEV_PROJECT === 'true';
|
||||||
|
if (!isDdev) {
|
||||||
|
cmd = 'ddev exec ' + cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(cmd);
|
||||||
|
|
||||||
|
return new Promise((resolve) => exec(cmd, (error, stdout, stderr) => {
|
||||||
|
if (stderr) {
|
||||||
|
console.error(stderr);
|
||||||
|
}
|
||||||
|
if (stdout) {
|
||||||
|
console.log(stdout);
|
||||||
|
}
|
||||||
|
if (error) {
|
||||||
|
throw error;
|
||||||
|
} else {
|
||||||
|
resolve(stdout);
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
1
wp-cli.yml
Normal file
1
wp-cli.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
path: .ddev/wordpress/
|
Loading…
Add table
Add a link
Reference in a new issue