From a1ec304f443f78ab4605f65637b021ff1789a121 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Wed, 14 Apr 2021 16:09:23 -0300 Subject: [PATCH 01/13] add waits for idle in add product to order --- tests/e2e/utils/src/components.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index c449622937b..d9297493aa4 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -430,11 +430,13 @@ const addProductToOrder = async ( orderId, productName ) => { await expect( page ).toClick( 'button.add-order-item' ); await page.waitForSelector( '.wc-backbone-modal-header' ); await expect( page ).toClick( '.wc-backbone-modal-content .wc-product-search' ); - await expect( page ).toFill( '#wc-backbone-modal-dialog + .select2-container .select2-search__field', productName ); + await expect( page ).toFill( + '#wc-backbone-modal-dialog + .select2-container .select2-search__field', + productName, + { waitUntil: 'networkidle0' } + ); await expect( page ).toClick( 'li[aria-selected="true"]' ); - await page.click( '.wc-backbone-modal-content #btn-ok' ); - - await uiUnblocked(); + await page.click( '.wc-backbone-modal-content #btn-ok', { waitUntil: 'networkidle0' } ); // Verify the product we added shows as a line item now await expect( page ).toMatchElement( '.wc-order-item-name', { text: productName } ); From a76b95e3dd0b58ccec661ce1c0c92dbd6611f741 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Mon, 19 Apr 2021 14:49:35 -0300 Subject: [PATCH 02/13] increase order filter test before all timeout --- .../specs/merchant/wp-admin-order-status-filters.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-order-status-filters.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-order-status-filters.test.js index e97a3a96a54..2870fe20830 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-order-status-filters.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-order-status-filters.test.js @@ -57,7 +57,7 @@ const runOrderStatusFiltersTest = () => { await createSimpleOrder(orderStatus.cancelled.description.text); await createSimpleOrder(orderStatus.refunded.description.text); await createSimpleOrder(orderStatus.failed.description.text); - }, 40000); + }, 60000); afterAll( async () => { // Make sure we're on the all orders view and cleanup the orders we created From 511d7ed0fe128ddbfb5a01e08fa04f56873c779f Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Mon, 19 Apr 2021 16:02:30 -0300 Subject: [PATCH 03/13] replace waitfor delay with network idle --- tests/e2e/utils/src/page-utils.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/e2e/utils/src/page-utils.js b/tests/e2e/utils/src/page-utils.js index 7e7648462e0..e8664456f6b 100644 --- a/tests/e2e/utils/src/page-utils.js +++ b/tests/e2e/utils/src/page-utils.js @@ -221,9 +221,8 @@ export const selectOptionInSelect2 = async ( value, selector = 'input.select2-se export const searchForOrder = async (value, orderId, customerName) => { await clearAndFillInput('#post-search-input', value); await expect(page).toMatchElement('#post-search-input', value); - await expect(page).toClick('#search-submit'); + await expect(page).toClick('#search-submit', { waitUntil: 'networkidle0' } ); await page.waitForSelector('#the-list'); - await page.waitFor(1000); await expect(page).toMatchElement('.order_number > a.order-view', {text: `#${orderId} ${customerName}`}); }; From 40e887103b7507ad41a2107c6ea2e5607dd34638 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Mon, 19 Apr 2021 16:51:46 -0300 Subject: [PATCH 04/13] add coupon debug screenshot --- .../specs/merchant/wp-admin-order-apply-coupon.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js index dc29a02a7b7..df2162474be 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js @@ -11,6 +11,8 @@ const { uiUnblocked, addProductToOrder, evalAndClick, + takeScreenshotFor, + sendFailedTestScreenshotToSlack, } = require( '@woocommerce/e2e-utils' ); const config = require( 'config' ); @@ -64,6 +66,12 @@ const runOrderApplyCouponTest = () => { }); it('can remove a coupon', async () => { + // Temporarily add screenshot + const screenshot = await takeScreenshotFor( 'before removing a coupon' ); + if ( screenshot.filePath ) { + await sendFailedTestScreenshotToSlack( screenshot.filePath ); + } + // Make sure we have a coupon on the page to use await page.waitForSelector('.wc-used-coupons'); await expect(page).toMatchElement('.wc_coupon_list li.code.editable', { text: couponCode.toLowerCase() }); From 5feb03e9a7d470dfffedb6783153a4d4d7d42efe Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Tue, 20 Apr 2021 13:32:14 -0300 Subject: [PATCH 05/13] export send to slack utils, add unblock check to variable product test --- tests/e2e/core-tests/specs/index.js | 2 +- .../merchant/wp-admin-order-apply-coupon.test.js | 4 +--- .../specs/merchant/wp-admin-product-new.test.js | 14 +++++++++++++- tests/e2e/env/CHANGELOG.md | 2 ++ tests/e2e/env/index.js | 2 ++ tests/e2e/env/src/slack/index.js | 4 +++- tests/e2e/env/src/slack/reporter.js | 9 +++++++-- 7 files changed, 29 insertions(+), 8 deletions(-) diff --git a/tests/e2e/core-tests/specs/index.js b/tests/e2e/core-tests/specs/index.js index 4380bb79d4f..a0eca5a730f 100644 --- a/tests/e2e/core-tests/specs/index.js +++ b/tests/e2e/core-tests/specs/index.js @@ -73,7 +73,7 @@ const runShopperTests = () => { runCheckoutCreateAccountTest(); runCheckoutLoginAccountTest(); runCartCalculateShippingTest(); - runCartRedirectionTest(); + runCartRedirectionTest(); runOrderEmailReceivingTest(); }; diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js index df2162474be..9664c149f26 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js @@ -11,9 +11,8 @@ const { uiUnblocked, addProductToOrder, evalAndClick, - takeScreenshotFor, - sendFailedTestScreenshotToSlack, } = require( '@woocommerce/e2e-utils' ); +const { takeScreenshotFor, sendFailedTestScreenshotToSlack } = require( '@woocommerce/e2e-environment' ); const config = require( 'config' ); const simpleProductName = config.get( 'products.simple.name' ); @@ -47,7 +46,6 @@ const runOrderApplyCouponTest = () => { const couponDialog = await expect(page).toDisplayDialog(async () => { await expect(page).toClick('button.add-coupon'); }); - expect(couponDialog.message()).toMatch(couponDialogMessage); // Accept the dialog with the coupon code diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-new.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-new.test.js index 5155fbae0b6..360bb7c8df2 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-new.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-new.test.js @@ -84,12 +84,19 @@ const runAddSimpleProductTest = () => { const runAddVariableProductTest = () => { describe('Add New Variable Product Page', () => { - it('can create product with variations', async () => { + beforeAll(async () => { + await merchant.login(); + }); + + it('can create variable product', async () => { await openNewProductAndVerify(); // Set product data await expect(page).toFill('#title', 'Variable Product with Three Variations'); await expect(page).toSelect('#product-type', 'Variable product'); + }); + + it('can create set variable product attributes', async () => { // Create attributes for variations await waitAndClick( page, '.attribute_tab a' ); @@ -111,7 +118,9 @@ const runAddVariableProductTest = () => { // Wait for attribute form to save (triggers 2 UI blocks) await uiUnblocked(); await uiUnblocked(); + }); + it('can create variable product variations', async () => { // Create variations from attributes await waitForSelector( page, '.variations_tab' ); await waitAndClick( page, '.variations_tab a' ); @@ -129,8 +138,11 @@ const runAddVariableProductTest = () => { // Set some variation data await uiUnblocked(); await uiUnblocked(); + }); + it('can create variation attributes', async () => { await waitAndClick( page, '.variations_tab a' ); + await uiUnblocked(); await waitForSelector( page, 'select[name="attribute_attr-1[0]"]', diff --git a/tests/e2e/env/CHANGELOG.md b/tests/e2e/env/CHANGELOG.md index 23718b7cd8d..bf567bbe49a 100644 --- a/tests/e2e/env/CHANGELOG.md +++ b/tests/e2e/env/CHANGELOG.md @@ -3,6 +3,8 @@ ## Added - `takeScreenshotFor` utility function to take screenshots within tests +- `sendFailedTestScreenshotToSlack` to send the screenshot to the configured Slack channel +- `sendFailedTestMessageToSlack` to send the context for screenshot to the configured Slack channel - `toBeInRange` expect numeric range matcher # 0.2.1 diff --git a/tests/e2e/env/index.js b/tests/e2e/env/index.js index 286f449ee03..d7289c77e66 100644 --- a/tests/e2e/env/index.js +++ b/tests/e2e/env/index.js @@ -5,6 +5,7 @@ const babelConfig = require( './babel.config' ); const esLintConfig = require( './.eslintrc.js' ); const allE2EConfig = require( './config' ); const allE2EUtils = require( './utils' ); +const slackUtils = require( './src/slack' ); /** * External dependencies */ @@ -16,4 +17,5 @@ module.exports = { ...allE2EConfig, ...allE2EUtils, ...allPuppeteerUtils, + ...slackUtils, }; diff --git a/tests/e2e/env/src/slack/index.js b/tests/e2e/env/src/slack/index.js index aeab8f42dd6..f03502673ed 100644 --- a/tests/e2e/env/src/slack/index.js +++ b/tests/e2e/env/src/slack/index.js @@ -1 +1,3 @@ -export * from './reporter'; +const slackUtils = require( './reporter' ); + +module.exports = slackUtils; diff --git a/tests/e2e/env/src/slack/reporter.js b/tests/e2e/env/src/slack/reporter.js index e3503f21de6..79655089a14 100644 --- a/tests/e2e/env/src/slack/reporter.js +++ b/tests/e2e/env/src/slack/reporter.js @@ -69,7 +69,7 @@ const initializeSlack = () => { * @param testName * @returns {Promise} */ -export async function sendFailedTestMessageToSlack( testName ) { +async function sendFailedTestMessageToSlack( testName ) { const { branch, commit, webUrl } = initializeSlack(); if ( ! branch ) { return; @@ -127,7 +127,7 @@ export async function sendFailedTestMessageToSlack( testName ) { * @param screenshotOfFailedTest * @returns {Promise} */ -export async function sendFailedTestScreenshotToSlack( screenshotOfFailedTest ) { +async function sendFailedTestScreenshotToSlack( screenshotOfFailedTest ) { const pr = initializeSlack(); if ( ! pr ) { return; @@ -154,3 +154,8 @@ export async function sendFailedTestScreenshotToSlack( screenshotOfFailedTest ) } } } + +module.exports = { + sendFailedTestMessageToSlack, + sendFailedTestScreenshotToSlack, +}; From 6ece4bc82d8555b7deb94f897982ac6b9259678a Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Tue, 20 Apr 2021 18:11:30 -0300 Subject: [PATCH 06/13] remove duplicate publish in product test --- .../specs/merchant/wp-admin-product-edit-details.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-edit-details.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-edit-details.test.js index 238fa9ba425..78e4fef92da 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-edit-details.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-edit-details.test.js @@ -35,7 +35,6 @@ const runProductEditDetailsTest = () => { await expect(page).toFill('#_regular_price', '100.05'); // Save the changes - await expect(page).toClick('#publish'); await verifyAndPublish('Product updated.'); await uiUnblocked(); From 64f15fc284ccb3e0963a57d6e08c50c46ca2d9f7 Mon Sep 17 00:00:00 2001 From: Veljko Date: Wed, 21 Apr 2021 14:52:29 +0200 Subject: [PATCH 07/13] Rename test scenario --- tests/e2e/core-tests/specs/shopper/front-end-cart.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/core-tests/specs/shopper/front-end-cart.test.js b/tests/e2e/core-tests/specs/shopper/front-end-cart.test.js index 2497d0a40f7..c9b221fc3cd 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-cart.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-cart.test.js @@ -36,7 +36,7 @@ const runCartPageTest = () => { await expect(page).toMatchElement('.cart-empty', {text: 'Your cart is currently empty.'}); }); - it('should add the product to the cart when "Add to cart" is clicked', async () => { + it('should add the product to the cart from the shop page', async () => { await shopper.goToShop(); await shopper.addToCartFromShopPage(simpleProductName); From c4074e7bf27ab09378f3416bfd319e3a03fb9012 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Wed, 21 Apr 2021 14:45:45 -0300 Subject: [PATCH 08/13] update order coupon test to use api, evalAndClick --- .../wp-admin-order-apply-coupon.test.js | 24 ++++-------- tests/e2e/utils/src/components.js | 38 +++++++++++-------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js index 9664c149f26..801a6f9aeca 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js @@ -28,29 +28,27 @@ const runOrderApplyCouponTest = () => { describe('WooCommerce Orders > Apply coupon', () => { beforeAll(async () => { await merchant.login(); - await Promise.all([ - await createSimpleProduct(), - couponCode = await createCoupon(), - orderId = await createSimpleOrder('Pending payment', simpleProductName), - await addProductToOrder(orderId, simpleProductName), + await createSimpleProduct(); + couponCode = await createCoupon(); + orderId = await createSimpleOrder('Pending payment', simpleProductName); + await addProductToOrder(orderId, simpleProductName); - // We need to remove any listeners on the `dialog` event otherwise we can't catch the dialog below - page.removeAllListeners('dialog'), - ]); + // We need to remove any listeners on the `dialog` event otherwise we can't catch the dialog below + await page.removeAllListeners('dialog'); // Make sure the simple product price is greater than the coupon amount await expect(Number(simpleProductPrice)).toBeGreaterThan(5.00); } ); it('can apply a coupon', async () => { + await page.waitForSelector('button.add-coupon'); const couponDialog = await expect(page).toDisplayDialog(async () => { - await expect(page).toClick('button.add-coupon'); + await evalAndClick('button.add-coupon'); }); expect(couponDialog.message()).toMatch(couponDialogMessage); // Accept the dialog with the coupon code await couponDialog.accept(couponCode); - await uiUnblocked(); // Verify the coupon list is showing @@ -64,12 +62,6 @@ const runOrderApplyCouponTest = () => { }); it('can remove a coupon', async () => { - // Temporarily add screenshot - const screenshot = await takeScreenshotFor( 'before removing a coupon' ); - if ( screenshot.filePath ) { - await sendFailedTestScreenshotToSlack( screenshot.filePath ); - } - // Make sure we have a coupon on the page to use await page.waitForSelector('.wc-used-coupons'); await expect(page).toMatchElement('.wc_coupon_list li.code.editable', { text: couponCode.toLowerCase() }); diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index 5d7fd143604..78d639ae114 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -17,7 +17,9 @@ import { clearAndFillInput, } from './page-utils'; import factories from './factories'; +import { Coupon } from '@woocommerce/api'; +const client = factories.api.withDefaultPermalinks; const config = require( 'config' ); const simpleProductName = config.get( 'products.simple.name' ); const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99'; @@ -452,23 +454,29 @@ const addProductToOrder = async ( orderId, productName ) => { * @param discountType Type of a coupon. Defaults to Fixed cart discount. */ const createCoupon = async ( couponAmount = '5', discountType = 'Fixed cart discount' ) => { - await merchant.openNewCoupon(); + let couponType; + switch ( discountType ) { + case "Fixed cart discount": + couponType = 'fixed_cart'; + break; + case "Fixed product discount": + couponType = 'fixed_product'; + break; + case "Percentage discount": + couponType = 'percent'; + break; + default: + return ''; + } // Fill in coupon code - let couponCode = 'Code-' + discountType + new Date().getTime().toString(); - await expect(page).toFill( '#title', couponCode ); - - // Set general coupon data - await clickTab( 'General' ); - await expect(page).toSelect( '#discount_type', discountType ); - await expect(page).toFill( '#coupon_amount', couponAmount ); - - // Publish coupon - await expect( page ).toClick( '#publish' ); - await page.waitForSelector( '.updated.notice' ); - - // Verify - await expect( page ).toMatchElement( '.updated.notice', { text: 'Coupon updated.' } ); + let couponCode = 'code-' + couponType + new Date().getTime().toString(); + const repository = Coupon.restRepository( client ); + await repository.create( { + code: couponCode, + discountType: couponType, + amount: couponAmount, + }); return couponCode; }; From 2511fce3a744bbb15c43f711828bbb7fea7f07b3 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Mon, 26 Apr 2021 10:41:46 -0300 Subject: [PATCH 09/13] remove unused product import function from jest setup script --- tests/e2e/env/src/setup/jest.setup.js | 31 --------------------------- 1 file changed, 31 deletions(-) diff --git a/tests/e2e/env/src/setup/jest.setup.js b/tests/e2e/env/src/setup/jest.setup.js index 2fca6769587..0e438dfff54 100644 --- a/tests/e2e/env/src/setup/jest.setup.js +++ b/tests/e2e/env/src/setup/jest.setup.js @@ -51,37 +51,6 @@ async function setupBrowser() { await setBrowserViewport( 'large' ); } -/** - * Navigates to woocommerce import page and imports sample products. - * - * @return {Promise} Promise resolving once products have been imported. - */ -async function importSampleProducts() { - await switchUserToAdmin(); - // Visit Import Products page. - await visitAdminPage( - 'edit.php', - 'post_type=product&page=product_importer' - ); - await page.click( 'a.woocommerce-importer-toggle-advanced-options' ); - await page.focus( '#woocommerce-importer-file-url' ); - // local path for sample data that is included with woo. - await page.keyboard.type( - 'wp-content/plugins/woocommerce/sample-data/sample_products.csv' - ); - await page.click( '.wc-actions .button-next' ); - await page.waitForSelector( '.wc-importer-mapping-table' ); - await page.select( - '.wc-importer-mapping-table tr:nth-child(29) select', - '' - ); - await page.click( '.wc-actions .button-next' ); - await page.waitForXPath( - "//*[@class='woocommerce-importer-done' and contains(., 'Import complete! ')]" - ); - await switchUserToTest(); -} - /** * Adds an event listener to the page to handle additions of page event * handlers, to assure that they are removed at test teardown. From df3d3f2a37a5166d046de835ca1569dfe943d13e Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Tue, 27 Apr 2021 13:50:39 -0300 Subject: [PATCH 10/13] return test name when there is no screenshot --- tests/e2e/env/utils/take-screenshot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/env/utils/take-screenshot.js b/tests/e2e/env/utils/take-screenshot.js index 634da95dfab..25ac2fca905 100644 --- a/tests/e2e/env/utils/take-screenshot.js +++ b/tests/e2e/env/utils/take-screenshot.js @@ -24,7 +24,7 @@ const takeScreenshotFor = async ( message ) => { }); } catch ( error ) { return { - title: 'no screenshot', + title, filePath: '', }; } From 6382ab0e66eee7ef61de1673dada6080606fdbab Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Tue, 27 Apr 2021 16:27:35 -0300 Subject: [PATCH 11/13] give cart and checkout coupon tests unique titles --- .../specs/shopper/front-end-cart-coupons.test.js | 10 +++++----- .../specs/shopper/front-end-checkout-coupons.test.js | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/e2e/core-tests/specs/shopper/front-end-cart-coupons.test.js b/tests/e2e/core-tests/specs/shopper/front-end-cart-coupons.test.js index 3e07011d800..c234767f3d6 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-cart-coupons.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-cart-coupons.test.js @@ -41,7 +41,7 @@ const runCartApplyCouponsTest = () => { await shopper.goToCart(); }); - it('allows customer to apply fixed cart coupon', async () => { + it('allows cart to apply fixed cart coupon', async () => { await applyCoupon(couponFixedCart); await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon code applied successfully.'}); @@ -52,7 +52,7 @@ const runCartApplyCouponsTest = () => { await removeCoupon(couponFixedCart); }); - it('allows customer to apply percentage coupon', async () => { + it('allows cart to apply percentage coupon', async () => { await applyCoupon(couponPercentage); await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon code applied successfully.'}); @@ -63,7 +63,7 @@ const runCartApplyCouponsTest = () => { await removeCoupon(couponPercentage); }); - it('allows customer to apply fixed product coupon', async () => { + it('allows cart to apply fixed product coupon', async () => { await applyCoupon(couponFixedProduct); await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon code applied successfully.'}); @@ -74,7 +74,7 @@ const runCartApplyCouponsTest = () => { await removeCoupon(couponFixedProduct); }); - it('prevents customer applying same coupon twice', async () => { + it('prevents cart applying same coupon twice', async () => { await applyCoupon(couponFixedCart); await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon code applied successfully.'}); await applyCoupon(couponFixedCart); @@ -84,7 +84,7 @@ const runCartApplyCouponsTest = () => { await expect(page).toMatchElement('.order-total .amount', {text: '$4.99'}); }); - it('allows customer to apply multiple coupons', async () => { + it('allows cart to apply multiple coupons', async () => { await applyCoupon(couponFixedProduct); await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon code applied successfully.'}); diff --git a/tests/e2e/core-tests/specs/shopper/front-end-checkout-coupons.test.js b/tests/e2e/core-tests/specs/shopper/front-end-checkout-coupons.test.js index 9b009823b96..5722a4f1956 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-checkout-coupons.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-checkout-coupons.test.js @@ -41,7 +41,7 @@ const runCheckoutApplyCouponsTest = () => { await shopper.goToCheckout(); }); - it('allows customer to apply fixed cart coupon', async () => { + it('allows checkout to apply fixed cart coupon', async () => { await applyCoupon(couponFixedCart); await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon code applied successfully.'}); @@ -54,7 +54,7 @@ const runCheckoutApplyCouponsTest = () => { await removeCoupon(couponFixedCart); }); - it('allows customer to apply percentage coupon', async () => { + it('allows checkout to apply percentage coupon', async () => { await applyCoupon(couponPercentage); await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon code applied successfully.'}); @@ -64,7 +64,7 @@ const runCheckoutApplyCouponsTest = () => { await removeCoupon(couponPercentage); }); - it('allows customer to apply fixed product coupon', async () => { + it('allows checkout to apply fixed product coupon', async () => { await applyCoupon(couponFixedProduct); await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon code applied successfully.'}); @@ -75,7 +75,7 @@ const runCheckoutApplyCouponsTest = () => { await removeCoupon(couponFixedProduct); }); - it('prevents customer applying same coupon twice', async () => { + it('prevents checkout applying same coupon twice', async () => { await applyCoupon(couponFixedCart); await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon code applied successfully.'}); await applyCoupon(couponFixedCart); @@ -85,7 +85,7 @@ const runCheckoutApplyCouponsTest = () => { await expect(page).toMatchElement('.order-total .amount', {text: '$4.99'}); }); - it('allows customer to apply multiple coupons', async () => { + it('allows checkout to apply multiple coupons', async () => { await applyCoupon(couponFixedProduct); await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon code applied successfully.'}); @@ -94,7 +94,7 @@ const runCheckoutApplyCouponsTest = () => { await expect(page).toMatchElement('.order-total .amount', {text: '$0.00'}); }); - it('restores cart total when coupons are removed', async () => { + it('restores checkout total when coupons are removed', async () => { await removeCoupon(couponFixedCart); await removeCoupon(couponFixedProduct); await expect(page).toMatchElement('.order-total .amount', {text: '$9.99'}); From 0d7388e9d44dd870f46660f652316453ada08bcb Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Tue, 27 Apr 2021 17:45:21 -0300 Subject: [PATCH 12/13] update for feedback, better wait impementation --- .../specs/merchant/wp-admin-order-apply-coupon.test.js | 1 - tests/e2e/utils/src/components.js | 9 +++------ tests/e2e/utils/src/page-utils.js | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js index 801a6f9aeca..22622ccbb90 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-order-apply-coupon.test.js @@ -12,7 +12,6 @@ const { addProductToOrder, evalAndClick, } = require( '@woocommerce/e2e-utils' ); -const { takeScreenshotFor, sendFailedTestScreenshotToSlack } = require( '@woocommerce/e2e-environment' ); const config = require( 'config' ); const simpleProductName = config.get( 'products.simple.name' ); diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index 78d639ae114..d974ac1d7e9 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -435,11 +435,8 @@ const addProductToOrder = async ( orderId, productName ) => { await expect( page ).toClick( 'button.add-order-item' ); await page.waitForSelector( '.wc-backbone-modal-header' ); await expect( page ).toClick( '.wc-backbone-modal-content .wc-product-search' ); - await expect( page ).toFill( - '#wc-backbone-modal-dialog + .select2-container .select2-search__field', - productName, - { waitUntil: 'networkidle0' } - ); + await expect( page ).toFill('#wc-backbone-modal-dialog + .select2-container .select2-search__field', productName); + await page.waitForSelector( 'li[aria-selected="true"]', { timeout: 10000 } ); await expect( page ).toClick( 'li[aria-selected="true"]' ); await page.click( '.wc-backbone-modal-content #btn-ok', { waitUntil: 'networkidle0' } ); @@ -466,7 +463,7 @@ const createCoupon = async ( couponAmount = '5', discountType = 'Fixed cart disc couponType = 'percent'; break; default: - return ''; + couponType = discountType; } // Fill in coupon code diff --git a/tests/e2e/utils/src/page-utils.js b/tests/e2e/utils/src/page-utils.js index a3b6ff82765..158bb2cf293 100644 --- a/tests/e2e/utils/src/page-utils.js +++ b/tests/e2e/utils/src/page-utils.js @@ -221,8 +221,8 @@ export const selectOptionInSelect2 = async ( value, selector = 'input.select2-se export const searchForOrder = async (value, orderId, customerName) => { await clearAndFillInput('#post-search-input', value); await expect(page).toMatchElement('#post-search-input', value); - await expect(page).toClick('#search-submit', { waitUntil: 'networkidle0' } ); - await page.waitForSelector('#the-list'); + await expect(page).toClick('#search-submit' ); + await page.waitForSelector('#the-list', { timeout: 10000 } ); await expect(page).toMatchElement('.order_number > a.order-view', {text: `#${orderId} ${customerName}`}); }; From ee6acc5fb6f6064ee82da179e78948020a0e5726 Mon Sep 17 00:00:00 2001 From: Joshua Flowers Date: Thu, 29 Apr 2021 10:36:43 -0400 Subject: [PATCH 13/13] Bump WooCommerce Admin version to 2.2.2 --- composer.json | 2 +- composer.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 10c9be56a53..4daa8132829 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "pelago/emogrifier": "3.1.0", "psr/container": "1.0.0", "woocommerce/action-scheduler": "3.1.6", - "woocommerce/woocommerce-admin": "2.2.2-rc.1", + "woocommerce/woocommerce-admin": "2.2.2", "woocommerce/woocommerce-blocks": "4.9.1" }, "require-dev": { diff --git a/composer.lock b/composer.lock index e74cb27df92..57039bbbbce 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "be33d948ed1d2ee3a7a23ef657f3148d", + "content-hash": "a604678b268820c78736d599e1eb6726", "packages": [ { "name": "automattic/jetpack-autoloader", @@ -503,16 +503,16 @@ }, { "name": "woocommerce/woocommerce-admin", - "version": "2.2.2-rc.1", + "version": "2.2.2", "source": { "type": "git", "url": "https://github.com/woocommerce/woocommerce-admin.git", - "reference": "0d305d1716481a0cc2010ec7b0a608a2d3c8ebe4" + "reference": "161e6afa01a3fb69533cfa2b245a71df7512ec3f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/0d305d1716481a0cc2010ec7b0a608a2d3c8ebe4", - "reference": "0d305d1716481a0cc2010ec7b0a608a2d3c8ebe4", + "url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/161e6afa01a3fb69533cfa2b245a71df7512ec3f", + "reference": "161e6afa01a3fb69533cfa2b245a71df7512ec3f", "shasum": "" }, "require": { @@ -544,7 +544,7 @@ ], "description": "A modern, javascript-driven WooCommerce Admin experience.", "homepage": "https://github.com/woocommerce/woocommerce-admin", - "time": "2021-04-28T19:39:33+00:00" + "time": "2021-04-29T14:11:48+00:00" }, { "name": "woocommerce/woocommerce-blocks",