From a160771d5d2ba206cb55f508407e1c53d8090b38 Mon Sep 17 00:00:00 2001 From: Siddharth Thevaril Date: Wed, 11 Dec 2024 21:21:43 +0530 Subject: [PATCH 1/4] move to @woocommerce/e2e-utils-playwright --- tests/e2e/utils/index.js | 59 ++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/tests/e2e/utils/index.js b/tests/e2e/utils/index.js index f2a92b4..ee62a7a 100644 --- a/tests/e2e/utils/index.js +++ b/tests/e2e/utils/index.js @@ -4,6 +4,10 @@ import { expect, Page } from '@playwright/test'; import moment from 'moment'; import { pluginConfig } from '../config'; +import { + fillBillingCheckoutBlocks, + getOrderIdFromUrl, +} from '@woocommerce/e2e-utils-playwright'; /** * Internal dependencies @@ -326,40 +330,31 @@ export async function addToCart(page) { * @param {Object} customerDetails Customer billing details */ export async function blockFillBillingDetails(page, customerDetails) { - await page.waitForTimeout(3000); const card = await page.locator('.wc-block-components-address-card'); if (await card.isVisible()) { await card.locator('.wc-block-components-address-card__edit').click(); } await page.locator('#email').fill(customerDetails.email); - await page.locator('#billing-first_name').fill(customerDetails.firstname); - await page.locator('#billing-last_name').fill(customerDetails.lastname); - await page - .locator('#billing-country') - .selectOption(customerDetails.country); - await page - .locator('#billing-address_1') - .fill(customerDetails.addressfirstline); - if ( - await page - .locator('.wc-block-components-address-form__address_2-toggle') - .isVisible() - ) { - await page - .locator('.wc-block-components-address-form__address_2-toggle') - .click(); - } - await page - .locator('#billing-address_2') - .fill(customerDetails.addresssecondline); - await page.locator('#billing-city').fill(customerDetails.city); - if (customerDetails.state) { - await page - .locator('#billing-state') - .selectOption(customerDetails.state); - } - await page.locator('#billing-postcode').fill(customerDetails.postcode); - await page.locator('#billing-postcode').blur(); + + await fillBillingCheckoutBlocks( + page, + { + country: customerDetails.country, + firstName: customerDetails.firstname, + lastName: customerDetails.lastname, + address: customerDetails.addressfirstline, + zip: customerDetails.postcode, + city: customerDetails.city, + state: customerDetails.state ?? null + } + ); + await page.getByLabel( 'Add a note to your order' ).check(); + await page + .getByPlaceholder( + 'Notes about your order', + { exact: false } + ) + .fill( 'This is to avoid flakiness' ); await page.waitForLoadState('networkidle'); } @@ -379,10 +374,8 @@ export async function placeOrder(page, isBlock = false) { await expect( page.getByRole('heading', { name: 'Order received' }) ).toBeVisible(); - const orderId = await page - .locator('li.woocommerce-order-overview__order strong') - .textContent(); - return orderId; + + return await getOrderIdFromUrl( page ); } /** From 4259a4ffcd0e6349cf9e68670a954e2ad595d0eb Mon Sep 17 00:00:00 2001 From: Siddharth Thevaril Date: Wed, 11 Dec 2024 21:22:39 +0530 Subject: [PATCH 2/4] commit package --- package-lock.json | 17 +++++++++++++++++ package.json | 1 + 2 files changed, 18 insertions(+) diff --git a/package-lock.json b/package-lock.json index 565a14f..618f0ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "devDependencies": { "@playwright/test": "^1.44.0", "@woocommerce/dependency-extraction-webpack-plugin": "^3.0.1", + "@woocommerce/e2e-utils-playwright": "^0.2.0", "@woocommerce/eslint-plugin": "^2.2.0", "@woocommerce/woocommerce-rest-api": "^1.0.1", "@wordpress/env": "^9.10.0", @@ -4667,6 +4668,16 @@ "integrity": "sha512-hFzejhs28f70sGnutcsRS459MnAsjRVI85RgPAL1KQIZEpjiDitc27CZv4IgOtaR86vrqOVlu9vJNew2XyTH4g==", "dev": true }, + "node_modules/@woocommerce/e2e-utils-playwright": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@woocommerce/e2e-utils-playwright/-/e2e-utils-playwright-0.2.0.tgz", + "integrity": "sha512-fyiCQwDrLBmlIJedJg4fztOvSBVfOnXK4iO7zr5RUA1cDwR7Ax4fXekGvK9pqZlHK/VABf2IcIfoPMIXbJVY+w==", + "dev": true, + "engines": { + "node": "^20.11.1", + "pnpm": "9.1.3" + } + }, "node_modules/@woocommerce/eslint-plugin": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@woocommerce/eslint-plugin/-/eslint-plugin-2.2.0.tgz", @@ -25565,6 +25576,12 @@ } } }, + "@woocommerce/e2e-utils-playwright": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@woocommerce/e2e-utils-playwright/-/e2e-utils-playwright-0.2.0.tgz", + "integrity": "sha512-fyiCQwDrLBmlIJedJg4fztOvSBVfOnXK4iO7zr5RUA1cDwR7Ax4fXekGvK9pqZlHK/VABf2IcIfoPMIXbJVY+w==", + "dev": true + }, "@woocommerce/eslint-plugin": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@woocommerce/eslint-plugin/-/eslint-plugin-2.2.0.tgz", diff --git a/package.json b/package.json index 7ab48f1..d7dd358 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "devDependencies": { "@playwright/test": "^1.44.0", "@woocommerce/dependency-extraction-webpack-plugin": "^3.0.1", + "@woocommerce/e2e-utils-playwright": "^0.2.0", "@woocommerce/eslint-plugin": "^2.2.0", "@woocommerce/woocommerce-rest-api": "^1.0.1", "@wordpress/env": "^9.10.0", From eee18e188f0093d9c0dd99e2e137bbc984b25175 Mon Sep 17 00:00:00 2001 From: Siddharth Thevaril Date: Tue, 31 Dec 2024 16:16:10 +0530 Subject: [PATCH 3/4] update e2e package --- package-lock.json | 15 ++++++++------- package.json | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 618f0ad..3f18922 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "devDependencies": { "@playwright/test": "^1.44.0", "@woocommerce/dependency-extraction-webpack-plugin": "^3.0.1", - "@woocommerce/e2e-utils-playwright": "^0.2.0", + "@woocommerce/e2e-utils-playwright": "^0.2.1", "@woocommerce/eslint-plugin": "^2.2.0", "@woocommerce/woocommerce-rest-api": "^1.0.1", "@wordpress/env": "^9.10.0", @@ -4669,10 +4669,11 @@ "dev": true }, "node_modules/@woocommerce/e2e-utils-playwright": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@woocommerce/e2e-utils-playwright/-/e2e-utils-playwright-0.2.0.tgz", - "integrity": "sha512-fyiCQwDrLBmlIJedJg4fztOvSBVfOnXK4iO7zr5RUA1cDwR7Ax4fXekGvK9pqZlHK/VABf2IcIfoPMIXbJVY+w==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@woocommerce/e2e-utils-playwright/-/e2e-utils-playwright-0.2.1.tgz", + "integrity": "sha512-YdcUPOMXAF145J+3dm2mEaKlpzH3OByHtyAmiU2Qx2Tll+x06iTB8V4r3quHh+ErtLDU8K9Oh3Olf0wFZosf/A==", "dev": true, + "license": "GPL-3.0+", "engines": { "node": "^20.11.1", "pnpm": "9.1.3" @@ -25577,9 +25578,9 @@ } }, "@woocommerce/e2e-utils-playwright": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@woocommerce/e2e-utils-playwright/-/e2e-utils-playwright-0.2.0.tgz", - "integrity": "sha512-fyiCQwDrLBmlIJedJg4fztOvSBVfOnXK4iO7zr5RUA1cDwR7Ax4fXekGvK9pqZlHK/VABf2IcIfoPMIXbJVY+w==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@woocommerce/e2e-utils-playwright/-/e2e-utils-playwright-0.2.1.tgz", + "integrity": "sha512-YdcUPOMXAF145J+3dm2mEaKlpzH3OByHtyAmiU2Qx2Tll+x06iTB8V4r3quHh+ErtLDU8K9Oh3Olf0wFZosf/A==", "dev": true }, "@woocommerce/eslint-plugin": { diff --git a/package.json b/package.json index d7dd358..acaf8db 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "devDependencies": { "@playwright/test": "^1.44.0", "@woocommerce/dependency-extraction-webpack-plugin": "^3.0.1", - "@woocommerce/e2e-utils-playwright": "^0.2.0", + "@woocommerce/e2e-utils-playwright": "^0.2.1", "@woocommerce/eslint-plugin": "^2.2.0", "@woocommerce/woocommerce-rest-api": "^1.0.1", "@wordpress/env": "^9.10.0", From 63208b274c8d067a96713a76e3dfbffdae03036e Mon Sep 17 00:00:00 2001 From: Siddharth Thevaril Date: Tue, 31 Dec 2024 18:18:37 +0530 Subject: [PATCH 4/4] make site live --- tests/e2e/bin/initialize.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/bin/initialize.sh b/tests/e2e/bin/initialize.sh index dd1b199..0e924d3 100755 --- a/tests/e2e/bin/initialize.sh +++ b/tests/e2e/bin/initialize.sh @@ -16,6 +16,7 @@ wp-env run tests-cli wp wc tool run install_pages --user=1 wp-env run tests-cli wp option update woocommerce_currency "USD" wp-env run tests-cli wp option update woocommerce_default_country "US:CA" wp-env run tests-cli wp wc payment_gateway update cod --enabled=true --user=1 +wp-env run tests-cli wp option update woocommerce_coming_soon "no" wp-env run tests-cli wp user create customer customer@bookingstestsuite.com --user_pass=password --role=customer