From e82f1ea98f500ca9f8748c4bcc0c12054f2378bb Mon Sep 17 00:00:00 2001 From: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com> Date: Tue, 13 Aug 2024 10:28:21 +0100 Subject: [PATCH] [e2e tests] Add hpos disabled environment and tag tests (#50448) --- .../changelog/e2e-add-hpos-disabled-env | 4 + plugins/woocommerce/package.json | 14 +- .../envs/default-hpos-disabled/env-setup.sh | 5 + .../playwright.config.js | 20 + .../tests/merchant/create-order.spec.js | 2 +- .../merchant/customer-payment-page.spec.js | 2 +- .../tests/merchant/order-bulk-edit.spec.js | 2 +- .../tests/merchant/order-coupon.spec.js | 2 +- .../e2e-pw/tests/merchant/order-edit.spec.js | 4 +- .../tests/merchant/order-emails.spec.js | 2 +- .../tests/merchant/order-refund.spec.js | 4 +- .../tests/merchant/order-search.spec.js | 2 +- .../merchant/order-status-filter.spec.js | 2 +- .../cart-checkout-block-calculate-tax.spec.js | 2 +- .../cart-checkout-calculate-tax.spec.js | 2 +- .../shopper/cart-checkout-coupons.spec.js | 2 +- .../cart-checkout-restricted-coupons.spec.js | 2 +- .../tests/shopper/checkout-block.spec.js | 2 +- .../tests/shopper/checkout-login.spec.js | 2 +- .../e2e-pw/tests/shopper/checkout.spec.js | 952 +++++++++--------- .../shopper/my-account-pay-order.spec.js | 2 +- .../shopper/order-email-receiving.spec.js | 2 +- 22 files changed, 545 insertions(+), 488 deletions(-) create mode 100644 plugins/woocommerce/changelog/e2e-add-hpos-disabled-env create mode 100755 plugins/woocommerce/tests/e2e-pw/envs/default-hpos-disabled/env-setup.sh create mode 100644 plugins/woocommerce/tests/e2e-pw/envs/default-hpos-disabled/playwright.config.js diff --git a/plugins/woocommerce/changelog/e2e-add-hpos-disabled-env b/plugins/woocommerce/changelog/e2e-add-hpos-disabled-env new file mode 100644 index 00000000000..7f88973e400 --- /dev/null +++ b/plugins/woocommerce/changelog/e2e-add-hpos-disabled-env @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +E2E tests: add hpos-disabled env and tagged tests with hpos tag diff --git a/plugins/woocommerce/package.json b/plugins/woocommerce/package.json index dadc6f811c4..37a8dc9c0be 100644 --- a/plugins/woocommerce/package.json +++ b/plugins/woocommerce/package.json @@ -329,14 +329,8 @@ { "name": "Core e2e tests - HPOS disabled", "testType": "e2e", - "command": "test:e2e", - "shardingArguments": [ - "--shard=1/5", - "--shard=2/5", - "--shard=3/5", - "--shard=4/5", - "--shard=5/5" - ], + "command": "test:e2e:with-env default-hpos-disabled --project=ui", + "shardingArguments": [], "events": [ "daily-checks", "release-checks" @@ -349,7 +343,7 @@ } }, "report": { - "resultsBlobName": "core-e2e-reports-non-hpos", + "resultsBlobName": "core-e2e-reports-hpos-disabled", "resultsPath": "tests/e2e-pw/test-results", "allure": true } @@ -443,7 +437,7 @@ { "name": "Core API tests - HPOS disabled", "testType": "api", - "command": "test:api", + "command": "test:e2e:with-env default-hpos-disabled --project=api", "optional": false, "changes": [ "client/admin/config/*.json", diff --git a/plugins/woocommerce/tests/e2e-pw/envs/default-hpos-disabled/env-setup.sh b/plugins/woocommerce/tests/e2e-pw/envs/default-hpos-disabled/env-setup.sh new file mode 100755 index 00000000000..2900abc5127 --- /dev/null +++ b/plugins/woocommerce/tests/e2e-pw/envs/default-hpos-disabled/env-setup.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -eo pipefail + +echo "Default environment setup." diff --git a/plugins/woocommerce/tests/e2e-pw/envs/default-hpos-disabled/playwright.config.js b/plugins/woocommerce/tests/e2e-pw/envs/default-hpos-disabled/playwright.config.js new file mode 100644 index 00000000000..d3270371c1c --- /dev/null +++ b/plugins/woocommerce/tests/e2e-pw/envs/default-hpos-disabled/playwright.config.js @@ -0,0 +1,20 @@ +let config = require( '../../playwright.config.js' ); + +process.env.USE_WP_ENV = 'true'; +process.env.DISABLE_HPOS = '1'; + +config = { + ...config, + projects: [ + { + name: 'ui', + grep: /@hpos/, + }, + { + name: 'api', + testMatch: '**/api-tests/**', + }, + ], +}; + +module.exports = config; diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-order.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-order.spec.js index 0b58a38a655..aa33c49f167 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-order.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-order.spec.js @@ -48,7 +48,7 @@ let simpleProductId, test.describe( 'WooCommerce Orders > Add new order', - { tag: '@services' }, + { tag: [ '@services', '@hpos' ] }, () => { test.use( { storageState: process.env.ADMINSTATE } ); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-payment-page.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-payment-page.spec.js index a0cdf958383..7aceae0f0fd 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-payment-page.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-payment-page.spec.js @@ -7,7 +7,7 @@ const productPrice = '15.99'; test.describe( 'WooCommerce Merchant Flow: Orders > Customer Payment Page', - { tag: [ '@payments', '@services' ] }, + { tag: [ '@payments', '@services', '@hpos' ] }, () => { test.use( { storageState: process.env.ADMINSTATE } ); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-bulk-edit.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-bulk-edit.spec.js index 99b5a38b5d5..f6faa6d70b1 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-bulk-edit.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-bulk-edit.spec.js @@ -1,7 +1,7 @@ const { test, expect } = require( '@playwright/test' ); const wcApi = require( '@woocommerce/woocommerce-rest-api' ).default; -test.describe( 'Bulk edit orders', { tag: '@services' }, () => { +test.describe( 'Bulk edit orders', { tag: [ '@services', '@hpos' ] }, () => { test.use( { storageState: process.env.ADMINSTATE } ); let orderId1, orderId2, orderId3, orderId4, orderId5; diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-coupon.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-coupon.spec.js index 72f2ee5a3c9..190b8cbf1cb 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-coupon.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-coupon.spec.js @@ -11,7 +11,7 @@ const discountedPrice = ( productPrice - couponAmount ).toString(); test.describe( 'WooCommerce Orders > Apply Coupon', - { tag: '@services' }, + { tag: [ '@services', '@hpos' ] }, () => { test.use( { storageState: process.env.ADMINSTATE } ); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-edit.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-edit.spec.js index 9590b322210..d5ff5e5ccbc 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-edit.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-edit.spec.js @@ -2,7 +2,7 @@ const { test, expect } = require( '@playwright/test' ); const wcApi = require( '@woocommerce/woocommerce-rest-api' ).default; const uuid = require( 'uuid' ); -test.describe( 'Edit order', { tag: '@services' }, () => { +test.describe( 'Edit order', { tag: [ '@services', '@hpos' ] }, () => { test.use( { storageState: process.env.ADMINSTATE } ); let orderId, orderToCancel; @@ -286,7 +286,7 @@ test.describe( 'Edit order', { tag: '@services' }, () => { test.describe( 'Edit order > Downloadable product permissions', - { tag: '@services' }, + { tag: [ '@services', '@hpos' ] }, () => { test.use( { storageState: process.env.ADMINSTATE } ); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js index 4ea006ff882..27c6b7ea7cd 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js @@ -5,7 +5,7 @@ const wcApi = require( '@woocommerce/woocommerce-rest-api' ).default; test.describe( 'Merchant > Order Action emails received', - { tag: '@services' }, + { tag: [ '@services', '@hpos' ] }, () => { test.use( { storageState: process.env.ADMINSTATE } ); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-refund.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-refund.spec.js index f5ef9df88d2..9aa6798d653 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-refund.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-refund.spec.js @@ -3,7 +3,7 @@ const wcApi = require( '@woocommerce/woocommerce-rest-api' ).default; test.describe.serial( 'WooCommerce Orders > Refund an order', - { tag: '@payments' }, + { tag: [ '@payments', '@hpos' ] }, () => { let productId, orderId, currencySymbol; @@ -147,7 +147,7 @@ test.describe.serial( test.describe( 'WooCommerce Orders > Refund and restock an order item', - { tag: [ '@payments', '@services' ] }, + { tag: [ '@payments', '@services', '@hpos' ] }, () => { let productWithStockId, productWithNoStockId, orderId; diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-search.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-search.spec.js index 06639ea7300..96b3b703e26 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-search.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-search.spec.js @@ -71,7 +71,7 @@ const deleteCustomer = async ( api ) => { test.describe( 'WooCommerce Orders > Search orders', - { tag: '@services' }, + { tag: [ '@services', '@hpos' ] }, () => { test.use( { storageState: process.env.ADMINSTATE } ); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-status-filter.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-status-filter.spec.js index 56b9a3fc9f5..31030d379ef 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-status-filter.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-status-filter.spec.js @@ -17,7 +17,7 @@ const orderStatus = [ test.describe( 'WooCommerce Orders > Filter Order by Status', - { tag: '@services' }, + { tag: [ '@services', '@hpos' ] }, () => { test.use( { storageState: process.env.ADMINSTATE } ); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-block-calculate-tax.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-block-calculate-tax.spec.js index 3770d57b751..f449ebe1b3a 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-block-calculate-tax.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-block-calculate-tax.spec.js @@ -38,7 +38,7 @@ let productId, test.describe( 'Shopper Cart & Checkout Block Tax Display', - { tag: [ '@payments', '@services' ] }, + { tag: [ '@payments', '@services', '@hpos' ] }, () => { test.use( { storageState: process.env.ADMINSTATE } ); test.beforeAll( async ( { baseURL } ) => { diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-calculate-tax.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-calculate-tax.spec.js index 4888e1bb8a9..bfcc1218a69 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-calculate-tax.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-calculate-tax.spec.js @@ -24,7 +24,7 @@ let productId, test.describe.serial( 'Tax rates in the cart and checkout', - { tag: [ '@payments', '@services' ] }, + { tag: [ '@payments', '@services', '@hpos' ] }, () => { test.beforeAll( async ( { baseURL } ) => { const api = new wcApi( { diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-coupons.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-coupons.spec.js index 233fba40077..813b3623236 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-coupons.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-coupons.spec.js @@ -26,7 +26,7 @@ const totals = [ '$15.00', '$10.00', '$13.00' ]; test.describe( 'Cart & Checkout applying coupons', - { tag: [ '@payments', '@services' ] }, + { tag: [ '@payments', '@services', '@hpos' ] }, () => { let firstProductId; const couponBatchId = []; diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-restricted-coupons.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-restricted-coupons.spec.js index 0286be4e16a..a67bdadb715 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-restricted-coupons.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/shopper/cart-checkout-restricted-coupons.spec.js @@ -10,7 +10,7 @@ const excludedCategoryName = 'Excluded Category'; test.describe( 'Cart & Checkout Restricted Coupons', - { tag: [ '@payments', '@services' ] }, + { tag: [ '@payments', '@services', '@hpos' ] }, () => { let firstProductId, secondProductId, diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-block.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-block.spec.js index 24ce0cb50f6..0ab550a7831 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-block.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-block.spec.js @@ -57,7 +57,7 @@ const test = baseTest.extend( { test.describe( 'Checkout Block page', - { tag: [ '@payments', '@services' ] }, + { tag: [ '@payments', '@services', '@hpos' ] }, () => { test.beforeAll( async ( { baseURL } ) => { const api = new wcApi( { diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-login.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-login.spec.js index e12282fae26..1eaadf1a5dd 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-login.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout-login.spec.js @@ -24,7 +24,7 @@ const customer = { test.describe( 'Shopper Checkout Login Account', - { tag: [ '@payments', '@services' ] }, + { tag: [ '@payments', '@services', '@hpos' ] }, () => { let productId, orderId, shippingZoneId, customerId; diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout.spec.js index 1c0b5aa222c..6b2ed97ba03 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/shopper/checkout.spec.js @@ -8,299 +8,152 @@ const { getOrderIdFromUrl } = require( '../../utils/order' ); const guestEmail = 'checkout-guest@example.com'; -test.describe( 'Checkout page', { tag: [ '@payments', '@services' ] }, () => { - const singleProductPrice = '9.99'; - const simpleProductName = 'Checkout Page Product'; - const twoProductPrice = ( singleProductPrice * 2 ).toString(); - const threeProductPrice = ( singleProductPrice * 3 ).toString(); +test.describe( + 'Checkout page', + { tag: [ '@payments', '@services', '@hpos' ] }, + () => { + const singleProductPrice = '9.99'; + const simpleProductName = 'Checkout Page Product'; + const twoProductPrice = ( singleProductPrice * 2 ).toString(); + const threeProductPrice = ( singleProductPrice * 3 ).toString(); - let guestOrderId, customerOrderId, productId, shippingZoneId; + let guestOrderId, customerOrderId, productId, shippingZoneId; - test.beforeAll( async ( { baseURL } ) => { - const api = new wcApi( { - url: baseURL, - consumerKey: process.env.CONSUMER_KEY, - consumerSecret: process.env.CONSUMER_SECRET, - version: 'wc/v3', - } ); - // ensure store address is US - await api.post( 'settings/general/batch', { - update: [ - { - id: 'woocommerce_store_address', - value: 'addr 1', - }, - { - id: 'woocommerce_store_city', - value: 'San Francisco', - }, - { - id: 'woocommerce_default_country', - value: 'US:CA', - }, - { - id: 'woocommerce_store_postcode', - value: '94107', - }, - ], - } ); - // add product - await api - .post( 'products', { - name: simpleProductName, - type: 'simple', - regular_price: singleProductPrice, - } ) - .then( ( response ) => { - productId = response.data.id; + test.beforeAll( async ( { baseURL } ) => { + const api = new wcApi( { + url: baseURL, + consumerKey: process.env.CONSUMER_KEY, + consumerSecret: process.env.CONSUMER_SECRET, + version: 'wc/v3', } ); - // add a shipping zone and method - await api - .post( 'shipping/zones', { - name: 'Free Shipping Oregon', - } ) - .then( ( response ) => { - shippingZoneId = response.data.id; + // ensure store address is US + await api.post( 'settings/general/batch', { + update: [ + { + id: 'woocommerce_store_address', + value: 'addr 1', + }, + { + id: 'woocommerce_store_city', + value: 'San Francisco', + }, + { + id: 'woocommerce_default_country', + value: 'US:CA', + }, + { + id: 'woocommerce_store_postcode', + value: '94107', + }, + ], + } ); + // add product + await api + .post( 'products', { + name: simpleProductName, + type: 'simple', + regular_price: singleProductPrice, + } ) + .then( ( response ) => { + productId = response.data.id; + } ); + // add a shipping zone and method + await api + .post( 'shipping/zones', { + name: 'Free Shipping Oregon', + } ) + .then( ( response ) => { + shippingZoneId = response.data.id; + } ); + await api.put( `shipping/zones/${ shippingZoneId }/locations`, [ + { + code: 'US:OR', + type: 'state', + }, + ] ); + await api.post( `shipping/zones/${ shippingZoneId }/methods`, { + method_id: 'free_shipping', } ); - await api.put( `shipping/zones/${ shippingZoneId }/locations`, [ - { - code: 'US:OR', - type: 'state', - }, - ] ); - await api.post( `shipping/zones/${ shippingZoneId }/methods`, { - method_id: 'free_shipping', } ); - } ); - test.afterAll( async ( { baseURL } ) => { - const api = new wcApi( { - url: baseURL, - consumerKey: process.env.CONSUMER_KEY, - consumerSecret: process.env.CONSUMER_SECRET, - version: 'wc/v3', + test.afterAll( async ( { baseURL } ) => { + const api = new wcApi( { + url: baseURL, + consumerKey: process.env.CONSUMER_KEY, + consumerSecret: process.env.CONSUMER_SECRET, + version: 'wc/v3', + } ); + await api.delete( `products/${ productId }`, { + force: true, + } ); + await api.delete( `shipping/zones/${ shippingZoneId }`, { + force: true, + } ); + await api.put( 'payment_gateways/bacs', { + enabled: false, + } ); + await api.put( 'payment_gateways/cod', { + enabled: false, + } ); + // delete the orders we created + if ( guestOrderId ) { + await api.delete( `orders/${ guestOrderId }`, { force: true } ); + } + if ( customerOrderId ) { + await api.delete( `orders/${ customerOrderId }`, { + force: true, + } ); + } } ); - await api.delete( `products/${ productId }`, { - force: true, + + test.beforeEach( async ( { context, baseURL } ) => { + // Shopping cart is very sensitive to cookies, so be explicit + await context.clearCookies(); + const api = new wcApi( { + url: baseURL, + consumerKey: process.env.CONSUMER_KEY, + consumerSecret: process.env.CONSUMER_SECRET, + version: 'wc/v3', + } ); + // enable bank transfers and COD for payment + await api.put( 'payment_gateways/bacs', { + enabled: true, + } ); + await api.put( 'payment_gateways/cod', { + enabled: true, + } ); } ); - await api.delete( `shipping/zones/${ shippingZoneId }`, { - force: true, + + test( 'should display cart items in order review', async ( { + page, + } ) => { + await addAProductToCart( page, productId ); + + await page.goto( '/checkout/' ); + + await expect( page.locator( 'td.product-name' ) ).toContainText( + simpleProductName + ); + await expect( + page.locator( 'strong.product-quantity' ) + ).toContainText( '1' ); + let totalPrice = await page + .getByRole( 'row', { name: 'Total' } ) + .last() + .locator( 'td' ) + .textContent(); + totalPrice = Number( totalPrice.replace( /\$([\d.]+).*/, '$1' ) ); + await expect( totalPrice ).toBeGreaterThanOrEqual( + Number( singleProductPrice ) + ); } ); - await api.put( 'payment_gateways/bacs', { - enabled: false, - } ); - await api.put( 'payment_gateways/cod', { - enabled: false, - } ); - // delete the orders we created - if ( guestOrderId ) { - await api.delete( `orders/${ guestOrderId }`, { force: true } ); - } - if ( customerOrderId ) { - await api.delete( `orders/${ customerOrderId }`, { force: true } ); - } - } ); - test.beforeEach( async ( { context, baseURL } ) => { - // Shopping cart is very sensitive to cookies, so be explicit - await context.clearCookies(); - const api = new wcApi( { - url: baseURL, - consumerKey: process.env.CONSUMER_KEY, - consumerSecret: process.env.CONSUMER_SECRET, - version: 'wc/v3', - } ); - // enable bank transfers and COD for payment - await api.put( 'payment_gateways/bacs', { - enabled: true, - } ); - await api.put( 'payment_gateways/cod', { - enabled: true, - } ); - } ); - - test( 'should display cart items in order review', async ( { page } ) => { - await addAProductToCart( page, productId ); - - await page.goto( '/checkout/' ); - - await expect( page.locator( 'td.product-name' ) ).toContainText( - simpleProductName - ); - await expect( page.locator( 'strong.product-quantity' ) ).toContainText( - '1' - ); - let totalPrice = await page - .getByRole( 'row', { name: 'Total' } ) - .last() - .locator( 'td' ) - .textContent(); - totalPrice = Number( totalPrice.replace( /\$([\d.]+).*/, '$1' ) ); - await expect( totalPrice ).toBeGreaterThanOrEqual( - Number( singleProductPrice ) - ); - } ); - - test( 'allows customer to choose available payment methods', async ( { - page, - } ) => { - // this time we're going to add two products to the cart - await addProductsToCart( page, simpleProductName, '2' ); - - await page.goto( '/checkout/' ); - await expect( page.locator( 'strong.product-quantity' ) ).toContainText( - '2' - ); - let totalPrice = await page - .getByRole( 'row', { name: 'Total' } ) - .last() - .locator( 'td' ) - .textContent(); - totalPrice = Number( totalPrice.replace( /\$([\d.]+).*/, '$1' ) ); - await expect( totalPrice ).toBeGreaterThanOrEqual( - Number( twoProductPrice ) - ); - - // check the payment methods - await expect( page.locator( '#payment_method_bacs' ) ).toBeEnabled(); - await expect( page.locator( '#payment_method_cod' ) ).toBeEnabled(); - } ); - - test( 'allows customer to fill billing details', async ( { page } ) => { - // this time we're going to add three products to the cart - await addProductsToCart( page, simpleProductName, '3' ); - - await page.goto( '/checkout/' ); - await expect( page.locator( 'strong.product-quantity' ) ).toContainText( - '3' - ); - let totalPrice = await page - .getByRole( 'row', { name: 'Total' } ) - .last() - .locator( 'td' ) - .textContent(); - totalPrice = Number( totalPrice.replace( /\$([\d.]+).*/, '$1' ) ); - await expect( totalPrice ).toBeGreaterThanOrEqual( - Number( threeProductPrice ) - ); - - // asserting that you can fill in the billing details - await expect( page.locator( '#billing_first_name' ) ).toBeEditable(); - await expect( page.locator( '#billing_last_name' ) ).toBeEditable(); - await expect( page.locator( '#billing_company' ) ).toBeEditable(); - await expect( page.locator( '#billing_country' ) ).toBeEnabled(); - await expect( page.locator( '#billing_address_1' ) ).toBeEditable(); - await expect( page.locator( '#billing_address_2' ) ).toBeEditable(); - await expect( page.locator( '#billing_city' ) ).toBeEditable(); - await expect( page.locator( '#billing_state' ) ).toBeEnabled(); - await expect( page.locator( '#billing_postcode' ) ).toBeEditable(); - await expect( page.locator( '#billing_phone' ) ).toBeEditable(); - await expect( page.locator( '#billing_email' ) ).toBeEditable(); - } ); - - test( 'warn when customer is missing required details', async ( { - page, - } ) => { - await addAProductToCart( page, productId ); - - await page.goto( '/checkout/' ); - - // first try submitting the form with no fields complete - await page.getByRole( 'button', { name: 'Place order' } ).click(); - await expect( - page.locator( 'form[name="checkout"]' ).getByRole( 'alert' ) - ).toBeVisible(); - await expect( - page.getByText( 'Billing First name is a required field.' ) - ).toBeVisible(); - await expect( - page.getByText( 'Billing Last name is a required field.' ) - ).toBeVisible(); - await expect( - page.getByText( 'Billing Street address is a required field.' ) - ).toBeVisible(); - await expect( - page.getByText( 'Billing Town / City is a required field.' ) - ).toBeVisible(); - await expect( - page.getByText( 'Billing ZIP Code is a required field.' ) - ).toBeVisible(); - await expect( - page.getByText( 'Billing Phone is a required field.' ) - ).toBeVisible(); - await expect( - page.getByText( 'Billing Email address is a required field.' ) - ).toBeVisible(); - - // toggle ship to different address, fill out billing info and confirm error shown - await page.getByText( 'Ship to a different address?' ).click(); - await page.locator( '#billing_first_name' ).fill( 'Homer' ); - await page.locator( '#billing_last_name' ).fill( 'Simpson' ); - await page - .locator( '#billing_address_1' ) - .fill( '123 Evergreen Terrace' ); - await page.locator( '#billing_city' ).fill( 'Springfield' ); - await page.locator( '#billing_country' ).selectOption( 'US' ); - await page.locator( '#billing_state' ).selectOption( 'OR' ); - await page.locator( '#billing_postcode' ).fill( '97403' ); - await page.locator( '#billing_phone' ).fill( '555 555-5555' ); - await page.locator( '#billing_email' ).fill( customer.email ); - await page.getByRole( 'button', { name: 'Place order' } ).click(); - - await expect( - page.getByText( 'Shipping First name is a required field.' ) - ).toBeVisible(); - await expect( - page.getByText( 'Shipping Last name is a required field.' ) - ).toBeVisible(); - await expect( - page.getByText( 'Shipping Street address is a required field.' ) - ).toBeVisible(); - await expect( - page.getByText( 'Shipping Town / City is a required field.' ) - ).toBeVisible(); - await expect( - page.getByText( 'Shipping ZIP Code is a required field.' ) - ).toBeVisible(); - } ); - - test( 'allows customer to fill shipping details', async ( { page } ) => { - await addProductsToCart( page, simpleProductName, '2' ); - - await page.goto( '/checkout/' ); - await expect( page.locator( 'strong.product-quantity' ) ).toContainText( - '2' - ); - let totalPrice = await page - .getByRole( 'row', { name: 'Total' } ) - .last() - .locator( 'td' ) - .textContent(); - totalPrice = Number( totalPrice.replace( /\$([\d.]+).*/, '$1' ) ); - await expect( totalPrice ).toBeGreaterThanOrEqual( - Number( twoProductPrice ) - ); - - await page.locator( '#ship-to-different-address' ).click(); - - // asserting that you can fill in the shipping details - await expect( page.locator( '#shipping_first_name' ) ).toBeEditable(); - await expect( page.locator( '#shipping_last_name' ) ).toBeEditable(); - await expect( page.locator( '#shipping_company' ) ).toBeEditable(); - await expect( page.locator( '#shipping_country' ) ).toBeEnabled(); - await expect( page.locator( '#shipping_address_1' ) ).toBeEditable(); - await expect( page.locator( '#shipping_address_2' ) ).toBeEditable(); - await expect( page.locator( '#shipping_city' ) ).toBeEditable(); - await expect( page.locator( '#shipping_state' ) ).toBeEnabled(); - await expect( page.locator( '#shipping_postcode' ) ).toBeEditable(); - } ); - - test( 'allows guest customer to place an order', async ( { page } ) => { - await test.step( 'Add 2 products to the cart', async () => { + test( 'allows customer to choose available payment methods', async ( { + page, + } ) => { + // this time we're going to add two products to the cart await addProductsToCart( page, simpleProductName, '2' ); - } ); - await test.step( 'Go to checkout and confirm that products and totals are as expected', async () => { await page.goto( '/checkout/' ); await expect( page.locator( 'strong.product-quantity' ) @@ -313,116 +166,390 @@ test.describe( 'Checkout page', { tag: [ '@payments', '@services' ] }, () => { totalPrice = Number( totalPrice.replace( /\$([\d.]+).*/, '$1' ) ); await expect( totalPrice ).toBeGreaterThanOrEqual( Number( twoProductPrice ) - ); // account for taxes or shipping that may be present + ); + + // check the payment methods + await expect( + page.locator( '#payment_method_bacs' ) + ).toBeEnabled(); + await expect( page.locator( '#payment_method_cod' ) ).toBeEnabled(); } ); - await test.step( 'Complete the checkout form', async () => { - await page - .getByRole( 'textbox', { name: 'First name *' } ) - .fill( 'Lisa' ); - await page - .getByRole( 'textbox', { name: 'Last name *' } ) - .fill( 'Simpson' ); - await page - .getByRole( 'textbox', { name: 'Street address *' } ) - .fill( '123 Evergreen Terrace' ); - await page - .getByRole( 'textbox', { name: 'Town / City *' } ) - .fill( 'Springfield' ); - await page.locator( '#billing_state' ).selectOption( 'OR' ); - await page - .getByRole( 'textbox', { name: 'ZIP Code *' } ) - .fill( '97403' ); - await page.getByLabel( 'Phone *' ).fill( '555 555-5555' ); - await page.getByLabel( 'Email address *' ).fill( guestEmail ); + test( 'allows customer to fill billing details', async ( { page } ) => { + // this time we're going to add three products to the cart + await addProductsToCart( page, simpleProductName, '3' ); - await page.getByText( 'Cash on delivery' ).click(); + await page.goto( '/checkout/' ); + await expect( + page.locator( 'strong.product-quantity' ) + ).toContainText( '3' ); + let totalPrice = await page + .getByRole( 'row', { name: 'Total' } ) + .last() + .locator( 'td' ) + .textContent(); + totalPrice = Number( totalPrice.replace( /\$([\d.]+).*/, '$1' ) ); + await expect( totalPrice ).toBeGreaterThanOrEqual( + Number( threeProductPrice ) + ); + // asserting that you can fill in the billing details + await expect( + page.locator( '#billing_first_name' ) + ).toBeEditable(); + await expect( page.locator( '#billing_last_name' ) ).toBeEditable(); + await expect( page.locator( '#billing_company' ) ).toBeEditable(); + await expect( page.locator( '#billing_country' ) ).toBeEnabled(); + await expect( page.locator( '#billing_address_1' ) ).toBeEditable(); + await expect( page.locator( '#billing_address_2' ) ).toBeEditable(); + await expect( page.locator( '#billing_city' ) ).toBeEditable(); + await expect( page.locator( '#billing_state' ) ).toBeEnabled(); + await expect( page.locator( '#billing_postcode' ) ).toBeEditable(); + await expect( page.locator( '#billing_phone' ) ).toBeEditable(); + await expect( page.locator( '#billing_email' ) ).toBeEditable(); + } ); + + test( 'warn when customer is missing required details', async ( { + page, + } ) => { + await addAProductToCart( page, productId ); + + await page.goto( '/checkout/' ); + + // first try submitting the form with no fields complete await page.getByRole( 'button', { name: 'Place order' } ).click(); + await expect( + page.locator( 'form[name="checkout"]' ).getByRole( 'alert' ) + ).toBeVisible(); + await expect( + page.getByText( 'Billing First name is a required field.' ) + ).toBeVisible(); + await expect( + page.getByText( 'Billing Last name is a required field.' ) + ).toBeVisible(); + await expect( + page.getByText( 'Billing Street address is a required field.' ) + ).toBeVisible(); + await expect( + page.getByText( 'Billing Town / City is a required field.' ) + ).toBeVisible(); + await expect( + page.getByText( 'Billing ZIP Code is a required field.' ) + ).toBeVisible(); + await expect( + page.getByText( 'Billing Phone is a required field.' ) + ).toBeVisible(); + await expect( + page.getByText( 'Billing Email address is a required field.' ) + ).toBeVisible(); + + // toggle ship to different address, fill out billing info and confirm error shown + await page.getByText( 'Ship to a different address?' ).click(); + await page.locator( '#billing_first_name' ).fill( 'Homer' ); + await page.locator( '#billing_last_name' ).fill( 'Simpson' ); + await page + .locator( '#billing_address_1' ) + .fill( '123 Evergreen Terrace' ); + await page.locator( '#billing_city' ).fill( 'Springfield' ); + await page.locator( '#billing_country' ).selectOption( 'US' ); + await page.locator( '#billing_state' ).selectOption( 'OR' ); + await page.locator( '#billing_postcode' ).fill( '97403' ); + await page.locator( '#billing_phone' ).fill( '555 555-5555' ); + await page.locator( '#billing_email' ).fill( customer.email ); + await page.getByRole( 'button', { name: 'Place order' } ).click(); + + await expect( + page.getByText( 'Shipping First name is a required field.' ) + ).toBeVisible(); + await expect( + page.getByText( 'Shipping Last name is a required field.' ) + ).toBeVisible(); + await expect( + page.getByText( 'Shipping Street address is a required field.' ) + ).toBeVisible(); + await expect( + page.getByText( 'Shipping Town / City is a required field.' ) + ).toBeVisible(); + await expect( + page.getByText( 'Shipping ZIP Code is a required field.' ) + ).toBeVisible(); } ); - await test.step( 'Load the order confirmation page, extract order number', async () => { + test( 'allows customer to fill shipping details', async ( { + page, + } ) => { + await addProductsToCart( page, simpleProductName, '2' ); + + await page.goto( '/checkout/' ); + await expect( + page.locator( 'strong.product-quantity' ) + ).toContainText( '2' ); + let totalPrice = await page + .getByRole( 'row', { name: 'Total' } ) + .last() + .locator( 'td' ) + .textContent(); + totalPrice = Number( totalPrice.replace( /\$([\d.]+).*/, '$1' ) ); + await expect( totalPrice ).toBeGreaterThanOrEqual( + Number( twoProductPrice ) + ); + + await page.locator( '#ship-to-different-address' ).click(); + + // asserting that you can fill in the shipping details + await expect( + page.locator( '#shipping_first_name' ) + ).toBeEditable(); + await expect( + page.locator( '#shipping_last_name' ) + ).toBeEditable(); + await expect( page.locator( '#shipping_company' ) ).toBeEditable(); + await expect( page.locator( '#shipping_country' ) ).toBeEnabled(); + await expect( + page.locator( '#shipping_address_1' ) + ).toBeEditable(); + await expect( + page.locator( '#shipping_address_2' ) + ).toBeEditable(); + await expect( page.locator( '#shipping_city' ) ).toBeEditable(); + await expect( page.locator( '#shipping_state' ) ).toBeEnabled(); + await expect( page.locator( '#shipping_postcode' ) ).toBeEditable(); + } ); + + test( 'allows guest customer to place an order', async ( { page } ) => { + await test.step( 'Add 2 products to the cart', async () => { + await addProductsToCart( page, simpleProductName, '2' ); + } ); + + await test.step( 'Go to checkout and confirm that products and totals are as expected', async () => { + await page.goto( '/checkout/' ); + await expect( + page.locator( 'strong.product-quantity' ) + ).toContainText( '2' ); + let totalPrice = await page + .getByRole( 'row', { name: 'Total' } ) + .last() + .locator( 'td' ) + .textContent(); + totalPrice = Number( + totalPrice.replace( /\$([\d.]+).*/, '$1' ) + ); + await expect( totalPrice ).toBeGreaterThanOrEqual( + Number( twoProductPrice ) + ); // account for taxes or shipping that may be present + } ); + + await test.step( 'Complete the checkout form', async () => { + await page + .getByRole( 'textbox', { name: 'First name *' } ) + .fill( 'Lisa' ); + await page + .getByRole( 'textbox', { name: 'Last name *' } ) + .fill( 'Simpson' ); + await page + .getByRole( 'textbox', { name: 'Street address *' } ) + .fill( '123 Evergreen Terrace' ); + await page + .getByRole( 'textbox', { name: 'Town / City *' } ) + .fill( 'Springfield' ); + await page.locator( '#billing_state' ).selectOption( 'OR' ); + await page + .getByRole( 'textbox', { name: 'ZIP Code *' } ) + .fill( '97403' ); + await page.getByLabel( 'Phone *' ).fill( '555 555-5555' ); + await page.getByLabel( 'Email address *' ).fill( guestEmail ); + + await page.getByText( 'Cash on delivery' ).click(); + + await page + .getByRole( 'button', { name: 'Place order' } ) + .click(); + } ); + + await test.step( 'Load the order confirmation page, extract order number', async () => { + await expect( + page.getByText( 'Your order has been received' ) + ).toBeVisible(); + + guestOrderId = getOrderIdFromUrl( page ); + } ); + + await test.step( 'Simulate cookies cleared, but within 10 minute grace period', async () => { + // Let's simulate a new browser context (by dropping all cookies), and reload the page. This approximates a + // scenario where the server can no longer identify the shopper. However, so long as we are within the 10 minute + // grace period following initial order placement, the 'order received' page should still be rendered. + await page.context().clearCookies(); + await page.reload(); + await expect( + page.getByText( 'Your order has been received' ) + ).toBeVisible(); + } ); + + await test.step( 'Simulate cookies cleared, outside 10 minute window', async () => { + // Let's simulate a scenario where the 10 minute grace period has expired. This time, we expect the shopper to + // be presented with a request to verify their email address. + await setFilterValue( + page, + 'woocommerce_order_email_verification_grace_period', + 0 + ); + await page.waitForTimeout( 2000 ); // needs some time before reload for change to take effect. + await page.reload( { waitForLoadState: 'networkidle' } ); + await expect( + page.getByText( + /confirm the email address linked to the order | verify the email address associated / + ) + ).toBeVisible(); + } ); + + await test.step( 'Supply incorrect email address for the order, error', async () => { + // Supplying an email address other than the actual order billing email address will take them back to the same + // page with an error message. + await page + .getByLabel( 'Email address' ) + .fill( 'incorrect@email.address' ); + await page + .getByRole( 'button', { name: /Verify|Confirm/ } ) + .click(); + await expect( + page.getByText( + /confirm the email address linked to the order | verify the email address associated / + ) + ).toBeVisible(); + await expect( + page.getByText( + 'We were unable to verify the email address' + ) + ).toBeVisible(); + } ); + + await test.step( 'Supply the correct email address for the order, display order confirmation', async () => { + // However if they supply the *correct* billing email address, they should see the order received page again. + await page.getByLabel( 'Email address' ).fill( guestEmail ); + await page + .getByRole( 'button', { name: /Verify|Confirm/ } ) + .click(); + await expect( + page.getByText( 'Your order has been received' ) + ).toBeVisible(); + } ); + + await test.step( 'Confirm order details on the backend (as a merchant)', async () => { + await page.goto( 'wp-login.php' ); + await page + .locator( 'input[name="log"]' ) + .fill( admin.username ); + await page + .locator( 'input[name="pwd"]' ) + .fill( admin.password ); + await page.locator( 'text=Log In' ).click(); + + // load the order placed as a guest + await page.goto( + `wp-admin/post.php?post=${ guestOrderId }&action=edit` + ); + + await expect( + page.getByRole( 'heading', { + name: `Order #${ guestOrderId } details`, + } ) + ).toBeVisible(); + await expect( + page.locator( '.wc-order-item-name' ) + ).toContainText( simpleProductName ); + await expect( + page.locator( 'td.quantity >> nth=0' ) + ).toContainText( '2' ); + await expect( + page.locator( 'td.item_cost >> nth=0' ) + ).toContainText( singleProductPrice ); + await expect( + page.locator( 'td.line_cost >> nth=0' ) + ).toContainText( twoProductPrice ); + await clearFilters( page ); + } ); + } ); + + test( 'allows existing customer to place order', async ( { page } ) => { + await page.goto( 'my-account/' ); + await page + .locator( 'input[name="username"]' ) + .fill( customer.username ); + await page + .locator( 'input[name="password"]' ) + .fill( customer.password ); + await page.locator( 'text=Log In' ).click(); + await expect( + page.getByText( + `Hello ${ customer.first_name } ${ customer.last_name }` + ) + ).toBeVisible(); + + await addProductsToCart( page, simpleProductName, '2' ); + + await page.goto( '/checkout/' ); + await expect( + page.locator( 'strong.product-quantity' ) + ).toContainText( '2' ); + let totalPrice = await page + .getByRole( 'row', { name: 'Total' } ) + .last() + .locator( 'td' ) + .textContent(); + totalPrice = Number( totalPrice.replace( /\$([\d.]+).*/, '$1' ) ); + await expect( totalPrice ).toBeGreaterThanOrEqual( + Number( twoProductPrice ) + ); + + await page.locator( '#billing_first_name' ).fill( 'Homer' ); + await page.locator( '#billing_last_name' ).fill( 'Simpson' ); + await page + .locator( '#billing_address_1' ) + .fill( '123 Evergreen Terrace' ); + await page.locator( '#billing_city' ).fill( 'Springfield' ); + await page.locator( '#billing_country' ).selectOption( 'US' ); + await page.locator( '#billing_state' ).selectOption( 'OR' ); + await page.locator( '#billing_postcode' ).fill( '97403' ); + await page.locator( '#billing_phone' ).fill( '555 555-5555' ); + await page.locator( '#billing_email' ).fill( customer.email ); + + await page.locator( 'text=Cash on delivery' ).click(); + await expect( + page.locator( 'div.payment_method_cod' ) + ).toBeVisible(); + + await page.locator( 'text=Place order' ).click(); + await expect( page.getByText( 'Your order has been received' ) ).toBeVisible(); - guestOrderId = getOrderIdFromUrl( page ); - } ); + customerOrderId = getOrderIdFromUrl( page ); - await test.step( 'Simulate cookies cleared, but within 10 minute grace period', async () => { - // Let's simulate a new browser context (by dropping all cookies), and reload the page. This approximates a - // scenario where the server can no longer identify the shopper. However, so long as we are within the 10 minute - // grace period following initial order placement, the 'order received' page should still be rendered. + // Effect a log out/simulate a new browsing session by dropping all cookies. await page.context().clearCookies(); await page.reload(); - await expect( - page.getByText( 'Your order has been received' ) - ).toBeVisible(); - } ); - await test.step( 'Simulate cookies cleared, outside 10 minute window', async () => { - // Let's simulate a scenario where the 10 minute grace period has expired. This time, we expect the shopper to - // be presented with a request to verify their email address. - await setFilterValue( - page, - 'woocommerce_order_email_verification_grace_period', - 0 - ); - await page.waitForTimeout( 2000 ); // needs some time before reload for change to take effect. - await page.reload( { waitForLoadState: 'networkidle' } ); + // Now we are logged out, return to the confirmation page: we should be asked to log back in. await expect( page.getByText( - /confirm the email address linked to the order | verify the email address associated / + /Log in here to view your order|log in to your account to view this order/ ) ).toBeVisible(); - } ); - await test.step( 'Supply incorrect email address for the order, error', async () => { - // Supplying an email address other than the actual order billing email address will take them back to the same - // page with an error message. - await page - .getByLabel( 'Email address' ) - .fill( 'incorrect@email.address' ); - await page - .getByRole( 'button', { name: /Verify|Confirm/ } ) - .click(); - await expect( - page.getByText( - /confirm the email address linked to the order | verify the email address associated / - ) - ).toBeVisible(); - await expect( - page.getByText( 'We were unable to verify the email address' ) - ).toBeVisible(); - } ); - - await test.step( 'Supply the correct email address for the order, display order confirmation', async () => { - // However if they supply the *correct* billing email address, they should see the order received page again. - await page.getByLabel( 'Email address' ).fill( guestEmail ); - await page - .getByRole( 'button', { name: /Verify|Confirm/ } ) - .click(); - await expect( - page.getByText( 'Your order has been received' ) - ).toBeVisible(); - } ); - - await test.step( 'Confirm order details on the backend (as a merchant)', async () => { - await page.goto( 'wp-login.php' ); + // Switch to admin user. + await page.goto( 'wp-login.php?loggedout=true' ); await page.locator( 'input[name="log"]' ).fill( admin.username ); await page.locator( 'input[name="pwd"]' ).fill( admin.password ); await page.locator( 'text=Log In' ).click(); - // load the order placed as a guest + // load the order placed as a customer await page.goto( - `wp-admin/post.php?post=${ guestOrderId }&action=edit` + `wp-admin/post.php?post=${ customerOrderId }&action=edit` ); - await expect( - page.getByRole( 'heading', { - name: `Order #${ guestOrderId } details`, - } ) - ).toBeVisible(); + page.locator( 'h2.woocommerce-order-data__heading' ) + ).toContainText( `Order #${ customerOrderId } details` ); await expect( page.locator( '.wc-order-item-name' ) ).toContainText( simpleProductName ); @@ -435,99 +562,6 @@ test.describe( 'Checkout page', { tag: [ '@payments', '@services' ] }, () => { await expect( page.locator( 'td.line_cost >> nth=0' ) ).toContainText( twoProductPrice ); - await clearFilters( page ); } ); - } ); - - test( 'allows existing customer to place order', async ( { page } ) => { - await page.goto( 'my-account/' ); - await page - .locator( 'input[name="username"]' ) - .fill( customer.username ); - await page - .locator( 'input[name="password"]' ) - .fill( customer.password ); - await page.locator( 'text=Log In' ).click(); - await expect( - page.getByText( - `Hello ${ customer.first_name } ${ customer.last_name }` - ) - ).toBeVisible(); - - await addProductsToCart( page, simpleProductName, '2' ); - - await page.goto( '/checkout/' ); - await expect( page.locator( 'strong.product-quantity' ) ).toContainText( - '2' - ); - let totalPrice = await page - .getByRole( 'row', { name: 'Total' } ) - .last() - .locator( 'td' ) - .textContent(); - totalPrice = Number( totalPrice.replace( /\$([\d.]+).*/, '$1' ) ); - await expect( totalPrice ).toBeGreaterThanOrEqual( - Number( twoProductPrice ) - ); - - await page.locator( '#billing_first_name' ).fill( 'Homer' ); - await page.locator( '#billing_last_name' ).fill( 'Simpson' ); - await page - .locator( '#billing_address_1' ) - .fill( '123 Evergreen Terrace' ); - await page.locator( '#billing_city' ).fill( 'Springfield' ); - await page.locator( '#billing_country' ).selectOption( 'US' ); - await page.locator( '#billing_state' ).selectOption( 'OR' ); - await page.locator( '#billing_postcode' ).fill( '97403' ); - await page.locator( '#billing_phone' ).fill( '555 555-5555' ); - await page.locator( '#billing_email' ).fill( customer.email ); - - await page.locator( 'text=Cash on delivery' ).click(); - await expect( page.locator( 'div.payment_method_cod' ) ).toBeVisible(); - - await page.locator( 'text=Place order' ).click(); - - await expect( - page.getByText( 'Your order has been received' ) - ).toBeVisible(); - - customerOrderId = getOrderIdFromUrl( page ); - - // Effect a log out/simulate a new browsing session by dropping all cookies. - await page.context().clearCookies(); - await page.reload(); - - // Now we are logged out, return to the confirmation page: we should be asked to log back in. - await expect( - page.getByText( - /Log in here to view your order|log in to your account to view this order/ - ) - ).toBeVisible(); - - // Switch to admin user. - await page.goto( 'wp-login.php?loggedout=true' ); - await page.locator( 'input[name="log"]' ).fill( admin.username ); - await page.locator( 'input[name="pwd"]' ).fill( admin.password ); - await page.locator( 'text=Log In' ).click(); - - // load the order placed as a customer - await page.goto( - `wp-admin/post.php?post=${ customerOrderId }&action=edit` - ); - await expect( - page.locator( 'h2.woocommerce-order-data__heading' ) - ).toContainText( `Order #${ customerOrderId } details` ); - await expect( page.locator( '.wc-order-item-name' ) ).toContainText( - simpleProductName - ); - await expect( page.locator( 'td.quantity >> nth=0' ) ).toContainText( - '2' - ); - await expect( page.locator( 'td.item_cost >> nth=0' ) ).toContainText( - singleProductPrice - ); - await expect( page.locator( 'td.line_cost >> nth=0' ) ).toContainText( - twoProductPrice - ); - } ); -} ); + } +); diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shopper/my-account-pay-order.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/my-account-pay-order.spec.js index cb0b119625e..233ccd2c533 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/shopper/my-account-pay-order.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/shopper/my-account-pay-order.spec.js @@ -10,7 +10,7 @@ const customer = { test.describe( 'Customer can pay for their order through My Account', - { tag: [ '@payments', '@services' ] }, + { tag: [ '@payments', '@services', '@hpos' ] }, () => { let productId, orderId; diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shopper/order-email-receiving.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shopper/order-email-receiving.spec.js index af7a80f8dc3..c653f8066e0 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/shopper/order-email-receiving.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/shopper/order-email-receiving.spec.js @@ -22,7 +22,7 @@ const storeName = 'WooCommerce Core E2E Test Suite'; test.describe( 'Shopper Order Email Receiving', - { tag: [ '@payments', '@services' ] }, + { tag: [ '@payments', '@services', '@hpos' ] }, () => { test.use( { storageState: process.env.ADMINSTATE } );