From f6b4614225ea8645ed9949b17201ecb7e78aee16 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Tue, 9 Mar 2021 16:57:08 -0300 Subject: [PATCH 01/41] Return 0 if order isn't available --- includes/abstracts/abstract-wc-payment-gateway.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/abstracts/abstract-wc-payment-gateway.php b/includes/abstracts/abstract-wc-payment-gateway.php index fe29740e569..3dcc281464d 100644 --- a/includes/abstracts/abstract-wc-payment-gateway.php +++ b/includes/abstracts/abstract-wc-payment-gateway.php @@ -262,7 +262,9 @@ abstract class WC_Payment_Gateway extends WC_Settings_API { // Gets order total from "pay for order" page. if ( 0 < $order_id ) { $order = wc_get_order( $order_id ); - $total = (float) $order->get_total(); + if ( $order ) { + $total = (float) $order->get_total(); + } // Gets order total from cart/checkout. } elseif ( 0 < WC()->cart->total ) { From 3a629efc4bec16d4f59dee955e3c08fad2cad9ed Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Wed, 17 Mar 2021 13:20:46 -0300 Subject: [PATCH 02/41] Check if order exists while check if COD is available --- includes/gateways/cod/class-wc-gateway-cod.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/gateways/cod/class-wc-gateway-cod.php b/includes/gateways/cod/class-wc-gateway-cod.php index 33c17643bf0..f2bb24aa48e 100644 --- a/includes/gateways/cod/class-wc-gateway-cod.php +++ b/includes/gateways/cod/class-wc-gateway-cod.php @@ -132,7 +132,7 @@ class WC_Gateway_COD extends WC_Payment_Gateway { $order = wc_get_order( $order_id ); // Test if order needs shipping. - if ( 0 < count( $order->get_items() ) ) { + if ( $order && 0 < count( $order->get_items() ) ) { foreach ( $order->get_items() as $item ) { $_product = $item->get_product(); if ( $_product && $_product->needs_shipping() ) { From f73fdfa4f6c6301691adce75a91605e7e838cbae Mon Sep 17 00:00:00 2001 From: Veljko Date: Thu, 18 Mar 2021 12:11:38 +0100 Subject: [PATCH 03/41] First part of the test --- tests/e2e/core-tests/specs/index.js | 3 + .../wp-admin-product-import-csv.test.js | 65 +++++++++++++++++++ .../specs/wp-admin/test-product-import-csv.js | 6 ++ tests/e2e/utils/src/components.js | 2 +- tests/e2e/utils/src/flows/constants.js | 1 + tests/e2e/utils/src/flows/merchant.js | 9 ++- 6 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js create mode 100644 tests/e2e/specs/wp-admin/test-product-import-csv.js diff --git a/tests/e2e/core-tests/specs/index.js b/tests/e2e/core-tests/specs/index.js index 94b798f9400..3c5936ef582 100644 --- a/tests/e2e/core-tests/specs/index.js +++ b/tests/e2e/core-tests/specs/index.js @@ -35,6 +35,7 @@ const runProductEditDetailsTest = require( './merchant/wp-admin-product-edit-det const runProductSearchTest = require( './merchant/wp-admin-product-search.test' ); const runMerchantOrdersCustomerPaymentPage = require( './merchant/wp-admin-order-customer-payment-page.test' ); const runMerchantOrderEmailsTest = require( './merchant/wp-admin-order-emails.test' ); +const runImportProductsTest = require("./merchant/wp-admin-product-import-csv.test"); // REST API tests const runExternalProductAPITest = require( './api/external-product.test' ); @@ -77,6 +78,7 @@ const runMerchantTests = () => { runProductEditDetailsTest(); runProductSearchTest(); runMerchantOrdersCustomerPaymentPage(); + runImportProductsTest(); } const runApiTests = () => { @@ -124,4 +126,5 @@ module.exports = { runAddNewShippingZoneTest, runProductBrowseSearchSortTest, runApiTests, + runImportProductsTest, }; diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js new file mode 100644 index 00000000000..a50f1c72a67 --- /dev/null +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -0,0 +1,65 @@ +/* eslint-disable jest/no-export, jest/no-disabled-tests */ +/** + * Internal dependencies + */ + const { + moveAllItemsToTrash, + setCheckbox +} = require( '@woocommerce/e2e-utils' ); + +/** + * External dependencies + */ +const { + it, + describe, + afterEach +} = require( '@jest/globals' ); +const merchant = require('../../../utils/src/flows/merchant'); +const filePath = '../../../sample-data/sample_products.csv'; +const productNames = ["V-Neck T-Shirt", "Hoodie", "Hoodie with Logo", "T-Shirt", "Beanie", + "Belt", "Cap", "Sunglasses", "Hoodie with Pocket", "Hoodie with Zipper", "Long Sleeve Tee", + "Polo", "Album", "Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"].sort(); +const errorMessage = 'Invalid file type. The importer supports CSV and TXT file formats.'; + +const runImportProductsTest = () => { + describe('Import Products from a CSV file', () => { + beforeAll(async () => { + await merchant.login(); + await merchant.openImportProducts(); + }); + it('can upload the CSV file and import products', async () => { + // Verify error message if you go withot provided CSV file + await expect(page).toClick('button[value="Continue"]'); + await page.waitForSelector('div.error inline'); + await expect(page).toMatchElement('div.error inline > p', errorMessage); + + // Put the CSV products file and proceed further + const uploader = await page.$("input[type=file]"); + await uploader.uploadFile(filePath); + await setCheckbox('#woocommerce-importer-update-existing'); + await page.waitFor(2000); + await expect(page).toClick('button[value="Continue"]'); + + // Click on Run the importer + await page.waitForSelector('button[value="Run the importer"]'); + await expect(page).toClick('button[value="Run the importer"]'); + + // Waiting for importer to finish + await page.waitForSelector('section.woocommerce-importer-done', {visible:true, timeout: 60000}); + + // Click on view products + await page.waitForSelector('div.wc-actions a.button.button-primary'); + await expect(page).toClick('div.wc-actions a.button.button-primary'); + + // Getting product names + await page.waitForSelector('a.row-title'); + let linkTexts = await page.$$eval('a.row-title', elements => elements.map(item => item.innerHTML)); + + // Compare imported product names + await expect(productNames).toEqual(linkTexts.sort()); + }); + }); +}; + +module.exports = runImportProductsTest; diff --git a/tests/e2e/specs/wp-admin/test-product-import-csv.js b/tests/e2e/specs/wp-admin/test-product-import-csv.js new file mode 100644 index 00000000000..1eb5d972074 --- /dev/null +++ b/tests/e2e/specs/wp-admin/test-product-import-csv.js @@ -0,0 +1,6 @@ +/* + * Internal dependencies + */ +const { runImportProductsTest } = require( '@woocommerce/e2e-core-tests' ); + +runImportProductsTest(); diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index 7b26bbae682..6d5b5764448 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -546,6 +546,6 @@ export { createCoupon, addShippingZoneAndMethod, createSimpleProductWithCategory, - clickUpdateOrder, + clickUpdateOrder, deleteAllEmailLogs, }; diff --git a/tests/e2e/utils/src/flows/constants.js b/tests/e2e/utils/src/flows/constants.js index cb743536d2b..1cbe34aad51 100644 --- a/tests/e2e/utils/src/flows/constants.js +++ b/tests/e2e/utils/src/flows/constants.js @@ -17,6 +17,7 @@ export const WP_ADMIN_NEW_PRODUCT = baseUrl + 'wp-admin/post-new.php?post_type=p export const WP_ADMIN_WC_SETTINGS = baseUrl + 'wp-admin/admin.php?page=wc-settings&tab='; export const WP_ADMIN_PERMALINK_SETTINGS = baseUrl + 'wp-admin/options-permalink.php'; export const WP_ADMIN_NEW_SHIPPING_ZONE = baseUrl + 'wp-admin/admin.php?page=wc-settings&tab=shipping&zone_id=new'; +export const WP_ADMIN_IMPORT_PRODUCTS = baseUrl + 'wp-admin/edit.php?post_type=product&page=product_importer'; export const SHOP_PAGE = baseUrl + 'shop'; export const SHOP_PRODUCT_PAGE = baseUrl + '?p='; diff --git a/tests/e2e/utils/src/flows/merchant.js b/tests/e2e/utils/src/flows/merchant.js index c12fd64ed6f..c575023d619 100644 --- a/tests/e2e/utils/src/flows/merchant.js +++ b/tests/e2e/utils/src/flows/merchant.js @@ -19,7 +19,8 @@ const { WP_ADMIN_PLUGINS, WP_ADMIN_SETUP_WIZARD, WP_ADMIN_WC_SETTINGS, - WP_ADMIN_NEW_SHIPPING_ZONE + WP_ADMIN_NEW_SHIPPING_ZONE, + WP_ADMIN_IMPORT_PRODUCTS, } = require( './constants' ); const baseUrl = config.get( 'url' ); @@ -182,6 +183,12 @@ const merchant = { waitUntil: 'networkidle0', } ); }, + + openImportProducts: async () => { + await page.goto( WP_ADMIN_IMPORT_PRODUCTS , { + waitUntil: 'networkidle0', + } ); + }, }; module.exports = merchant; From 4f98833094365574efe4b5d08043722123935a6a Mon Sep 17 00:00:00 2001 From: Veljko Date: Thu, 18 Mar 2021 13:42:59 +0100 Subject: [PATCH 04/41] Add first test import products --- .../wp-admin-product-import-csv.test.js | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index a50f1c72a67..9dc1137b7ce 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -18,27 +18,25 @@ const { const merchant = require('../../../utils/src/flows/merchant'); const filePath = '../../../sample-data/sample_products.csv'; const productNames = ["V-Neck T-Shirt", "Hoodie", "Hoodie with Logo", "T-Shirt", "Beanie", - "Belt", "Cap", "Sunglasses", "Hoodie with Pocket", "Hoodie with Zipper", "Long Sleeve Tee", - "Polo", "Album", "Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"].sort(); + "Belt", "Cap", "Sunglasses", "Hoodie with Pocket", "Hoodie with Zipper", "Long Sleeve Tee", + "Polo", "Album", "Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"].sort(); const errorMessage = 'Invalid file type. The importer supports CSV and TXT file formats.'; const runImportProductsTest = () => { describe('Import Products from a CSV file', () => { beforeAll(async () => { - await merchant.login(); - await merchant.openImportProducts(); - }); + await merchant.login(); + await merchant.openImportProducts(); + }); it('can upload the CSV file and import products', async () => { - // Verify error message if you go withot provided CSV file - await expect(page).toClick('button[value="Continue"]'); - await page.waitForSelector('div.error inline'); - await expect(page).toMatchElement('div.error inline > p', errorMessage); + // Verify error message if you go withot provided CSV file + await expect(page).toClick('button[value="Continue"]'); + await page.waitForSelector('div.error'); + await expect(page).toMatchElement('div.error > p', errorMessage); // Put the CSV products file and proceed further const uploader = await page.$("input[type=file]"); await uploader.uploadFile(filePath); - await setCheckbox('#woocommerce-importer-update-existing'); - await page.waitFor(2000); await expect(page).toClick('button[value="Continue"]'); // Click on Run the importer @@ -47,10 +45,12 @@ const runImportProductsTest = () => { // Waiting for importer to finish await page.waitForSelector('section.woocommerce-importer-done', {visible:true, timeout: 60000}); + await page.waitForSelector('.woocommerce-importer-done'); + await expect(page).toMatchElement('.woocommerce-importer-done', {text: 'Import complete!'}); // Click on view products - await page.waitForSelector('div.wc-actions a.button.button-primary'); - await expect(page).toClick('div.wc-actions a.button.button-primary'); + await page.waitForSelector('div.wc-actions > a.button.button-primary'); + await expect(page).toClick('div.wc-actions > a.button.button-primary'); // Getting product names await page.waitForSelector('a.row-title'); From 26c7e238f694dfb6bc6d5014fb5b076cd180e6fc Mon Sep 17 00:00:00 2001 From: Mauricio Urrego Date: Thu, 18 Mar 2021 14:51:09 +0100 Subject: [PATCH 05/41] Avoids redirect caused by some custom permalink structures. --- includes/widgets/class-wc-widget-layered-nav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/widgets/class-wc-widget-layered-nav.php b/includes/widgets/class-wc-widget-layered-nav.php index 1ad76f4d633..6f79b88edcd 100644 --- a/includes/widgets/class-wc-widget-layered-nav.php +++ b/includes/widgets/class-wc-widget-layered-nav.php @@ -252,7 +252,7 @@ class WC_Widget_Layered_Nav extends WC_Widget { if ( '' === get_option( 'permalink_structure' ) ) { $form_action = remove_query_arg( array( 'page', 'paged' ), add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) ); } else { - $form_action = preg_replace( '%\/page/[0-9]+%', '', home_url( trailingslashit( $wp->request ) ) ); + $form_action = preg_replace( '%\/page/[0-9]+%', '', home_url( user_trailingslashit( $wp->request ) ) ); } echo '
'; From 9c32f421b70cc4852e92b450db276865ae8e993b Mon Sep 17 00:00:00 2001 From: Veljko Date: Thu, 18 Mar 2021 17:23:44 +0100 Subject: [PATCH 06/41] Add new scenario and update changelogs --- sample-data/sample_products_override.csv | 26 ++++++++ tests/e2e/core-tests/CHANGELOG.md | 1 + tests/e2e/core-tests/README.md | 1 + .../wp-admin-product-import-csv.test.js | 65 ++++++++++++++++--- tests/e2e/utils/README.md | 1 + 5 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 sample-data/sample_products_override.csv diff --git a/sample-data/sample_products_override.csv b/sample-data/sample_products_override.csv new file mode 100644 index 00000000000..6b880308a7a --- /dev/null +++ b/sample-data/sample_products_override.csv @@ -0,0 +1,26 @@ +ID,Type,SKU,Name,Published,"Is featured?","Visibility in catalog","Short description",Description,"Date sale price starts","Date sale price ends","Tax status","Tax class","In stock?",Stock,"Backorders allowed?","Sold individually?","Weight (lbs)","Length (in)","Width (in)","Height (in)","Allow customer reviews?","Purchase note","Sale price","Regular price",Categories,Tags,"Shipping class",Images,"Download limit","Download expiry days",Parent,"Grouped products",Upsells,Cross-sells,"External URL","Button text",Position,"Attribute 1 name","Attribute 1 value(s)","Attribute 1 visible","Attribute 1 global","Attribute 2 name","Attribute 2 value(s)","Attribute 2 visible","Attribute 2 global","Meta: _wpcom_is_markdown","Download 1 name","Download 1 URL","Download 2 name","Download 2 URL" +,variable,woo-vneck-tee,V-Neck T-Shirt Override,1,"1","visible","This is a variable product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0",".5","24","1","2","1",,,,Clothing > Tshirts,,,"https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/vneck-tee-2.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/vnech-tee-green-1.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/vnech-tee-blue-1.jpg",,,,,,,,,0,"Color","Blue, Green, Red","1","1","Size","Large, Medium, Small","1","1","1",,,, +,variable,woo-hoodie,Hoodie Override,1,"0","visible","This is a variable product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0","1.5","10","8","3","1",,,,Clothing > Hoodies,,,"https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-2.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-blue-1.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-green-1.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-with-logo-2.jpg",,,,,,,,,0,"Color","Blue, Green, Red","1","1","Logo","Yes, No","1","0","1",,,, +,simple,woo-hoodie-with-logo,Hoodie with Logo Override,1,"0","visible","This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0","2","10","6","3","1",,,"145",Clothing > Hoodies,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-with-logo-2.jpg,,,,,,,,,0,"Color","Blue","1","1",,,,,"1",,,, +,simple,woo-tshirt,T-Shirt Override,1,"0","visible","This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0",".8","8","6","1","1",,,"118",Clothing > Tshirts,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/tshirt-2.jpg,,,,,,,,,0,"Color","Gray","1","1",,,,,"1",,,, +,simple,woo-beanie,Beanie Override,1,"0","visible","This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0",".2","4","5",".5","1",,"118","120",Clothing > Accessories,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/beanie-2.jpg,,,,,,,,,0,"Color","Red","1","1",,,,,"1",,,, +,simple,woo-belt,Belt Override,1,"0","visible","This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0","1.2","12","2","1.5","1",,"155","165",Clothing > Accessories,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/belt-2.jpg,,,,,,,,,0,,,,,,,,,"1",,,, +,simple,woo-cap,Cap Override,1,"1","visible","This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0","0.6","8","6.5","4","1",,"116","118",Clothing > Accessories,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/cap-2.jpg,,,,,,,,,0,"Color","Yellow","1","1",,,,,"1",,,, +,simple,woo-sunglasses,Sunglasses Override,1,"1","visible","This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0",".2","4","1.4","1","1",,,"190",Clothing > Accessories,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/sunglasses-2.jpg,,,,,,,,,0,,,,,,,,,"1",,,, +,simple,woo-hoodie-with-pocket,Hoodie with Pocket Override,1,"1","hidden","This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0","3","10","8","2","1",,"135","145",Clothing > Hoodies,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-with-pocket-2.jpg,,,,,,,,,0,"Color","Gray","1","1",,,,,"1",,,, +,simple,woo-hoodie-with-zipper,Hoodie with Zipper Override,1,"1","visible","This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0","2","8","6","2","1",,,"145",Clothing > Hoodies,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-with-zipper-2.jpg,,,,,,,,,0,,,,,,,,,"1",,,, +,simple,woo-long-sleeve-tee,Long Sleeve Tee Override,1,"0","visible","This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0","1","7","5","1","1",,,"125",Clothing > Tshirts,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/long-sleeve-tee-2.jpg,,,,,,,,,0,"Color","Green","1","1",,,,,"1",,,, +,simple,woo-polo,Polo Override,1,"0","visible","This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0",".8","6","5","1","1",,,"120",Clothing > Tshirts,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/polo-2.jpg,,,,,,,,,0,"Color","Blue","1","1",,,,,"1",,,, +,"simple, downloadable, virtual",woo-album,Album Override,1,"0","visible","This is a simple, virtual product.","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,"taxable",,"1",,"0","0",,,,,"1",,,"115",Music,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/album-1.jpg,"1","1",,,,,,,0,,,,,,,,,"1","Single 1","https://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2017/08/single.jpg","Single 2","https://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2017/08/album.jpg" +,"simple, downloadable, virtual",woo-single,Single Override,1,"0","visible","This is a simple, virtual product.","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,"taxable",,"1",,"0","0",,,,,"1",,"12","13",Music,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/single-1.jpg,"1","1",,,,,,,0,,,,,,,,,"1","Single","https://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2017/08/single.jpg",, +,variation,woo-vneck-tee-red,V-Neck T-Shirt - Red Override,1,"0","visible",,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,"taxable",,"1",,"0","0",,,,,"0",,,"120",,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/vneck-tee-2.jpg,,,woo-vneck-tee,,,,,,0,"Color","Red",,"1","Size",,,"1",,,,, +,variation,woo-vneck-tee-green,V-Neck T-Shirt - Green Override,1,"0","visible",,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,"taxable",,"1",,"0","0",,,,,"0",,,"120",,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/vnech-tee-green-1.jpg,,,woo-vneck-tee,,,,,,0,"Color","Green",,"1","Size",,,"1",,,,, +,variation,woo-vneck-tee-blue,V-Neck T-Shirt - Blue Override,1,"0","visible",,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,"taxable",,"1",,"0","0",,,,,"0",,,"115",,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/vnech-tee-blue-1.jpg,,,woo-vneck-tee,,,,,,0,"Color","Blue",,"1","Size",,,"1",,,,, +,variation,woo-hoodie-red,"Hoodie - Red, No Override",1,"0","visible",,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,"taxable",,"1",,"0","0",,,,,"0",,"142","145",,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-2.jpg,,,woo-hoodie,,,,,,1,"Color","Red",,"1","Logo","No",,"0",,,,, +,variation,woo-hoodie-green,"Hoodie - Green, No Override",1,"0","visible",,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,"taxable",,"1",,"0","0",,,,,"0",,,"145",,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-green-1.jpg,,,woo-hoodie,,,,,,2,"Color","Green",,"1","Logo","No",,"0",,,,, +,variation,woo-hoodie-blue,"Hoodie - Blue, No Override",1,"0","visible",,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,"taxable",,"1",,"0","0",,,,,"0",,,"145",,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-blue-1.jpg,,,woo-hoodie,,,,,,3,"Color","Blue",,"1","Logo","No",,"0",,,,, +,simple,Woo-tshirt-logo,T-Shirt with Logo Override,1,"0","visible","This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0",".5","10","12",".5","1",,,"118",Clothing > Tshirts,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/t-shirt-with-logo-1.jpg,,,,,,,,,0,"Color","Gray","1","1",,,,,"1",,,, +,simple,Woo-beanie-logo,Beanie with Logo Override,1,"0","visible","This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0",".2","6","4","1","1",,"118","120",Clothing > Accessories,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/beanie-with-logo-1.jpg,,,,,,,,,0,"Color","Red","1","1",,,,,"1",,,, +,grouped,logo-collection,Logo Collection Override,1,"0","visible","This is a grouped product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0",,,,,"1",,,,Clothing,,,"https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/logo-1.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/beanie-with-logo-1.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/t-shirt-with-logo-1.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-with-logo-2.jpg",,,,"woo-hoodie-with-logo, woo-tshirt, woo-beanie",,,,,0,,,,,,,,,"1",,,, +,external,wp-pennant,WordPress Pennant Override,1,"0","visible","This is an external product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,"taxable",,"1",,"0","0",,,,,"1",,,"111.05",Decor,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/pennant-1.jpg,,,,,,,"https://mercantile.wordpress.org/product/wordpress-pennant/","Buy on the WordPress swag store!",0,,,,,,,,,"1",,,, +,variation,woo-hoodie-blue-logo,"Hoodie - Blue, Yes Override",1,"0","visible",,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,"taxable",,"1",,"0","0",,,,,"0",,,"145",,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-with-logo-2.jpg,,,woo-hoodie,,,,,,0,"Color","Blue",,"1","Logo","Yes",,"0",,,,, \ No newline at end of file diff --git a/tests/e2e/core-tests/CHANGELOG.md b/tests/e2e/core-tests/CHANGELOG.md index b4bf59d419a..7e6b088b854 100644 --- a/tests/e2e/core-tests/CHANGELOG.md +++ b/tests/e2e/core-tests/CHANGELOG.md @@ -27,6 +27,7 @@ - Merchant Settings Shipping Zones - Shopper Variable product info updates on different variations - Merchant order emails flow +- Merchant import products via CSV ## Fixed diff --git a/tests/e2e/core-tests/README.md b/tests/e2e/core-tests/README.md index 6c44e0993a1..25dd431c860 100644 --- a/tests/e2e/core-tests/README.md +++ b/tests/e2e/core-tests/README.md @@ -60,6 +60,7 @@ The functions to access the core tests are: - `runMerchantOrdersCustomerPaymentPage` - Merchant can visit the customer payment page - `runAddNewShippingZoneTest` - Merchant can create shipping zones and let shopper test them - `runMerchantOrderEmailsTest` - Merchant can receive order emails and resend emails by Order Actions + - `runImportProductsTest` - Merchant can import products via CSV file ### Shopper diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index 9dc1137b7ce..c725feb57f4 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -3,7 +3,7 @@ * Internal dependencies */ const { - moveAllItemsToTrash, + merchant, setCheckbox } = require( '@woocommerce/e2e-utils' ); @@ -12,23 +12,32 @@ */ const { it, - describe, - afterEach + describe } = require( '@jest/globals' ); -const merchant = require('../../../utils/src/flows/merchant'); + const filePath = '../../../sample-data/sample_products.csv'; +const filePathOverride = '../../../sample-data/sample_products_override.csv'; const productNames = ["V-Neck T-Shirt", "Hoodie", "Hoodie with Logo", "T-Shirt", "Beanie", "Belt", "Cap", "Sunglasses", "Hoodie with Pocket", "Hoodie with Zipper", "Long Sleeve Tee", "Polo", "Album", "Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"].sort(); +const productNamesOverride = ["V-Neck T-Shirt Override", "Hoodie Override", "Hoodie with Logo Override", + "T-Shirt Override", "Beanie Override", "Belt Override", "Cap Override", "Sunglasses Override", + "Hoodie with Pocket Override", "Hoodie with Zipper Override", "Long Sleeve Tee Override", + "Polo Override", "Album Override", "Single Override", "T-Shirt with Logo Override", "Beanie with Logo Override", + "Logo Collection Override", "WordPress Pennant Override"].sort(); +const productPrices = ["145", "118", "120", "118", "165", "155", "118", "116", "190", "145", "135", "145", "125", + "120", "115", "13", "12", "120", "120", "115", "145", "142", "145", "145", + "118","120", "118", "111.05", "145"].sort(); const errorMessage = 'Invalid file type. The importer supports CSV and TXT file formats.'; const runImportProductsTest = () => { describe('Import Products from a CSV file', () => { beforeAll(async () => { await merchant.login(); - await merchant.openImportProducts(); }); it('can upload the CSV file and import products', async () => { + await merchant.openImportProducts(); + // Verify error message if you go withot provided CSV file await expect(page).toClick('button[value="Continue"]'); await page.waitForSelector('div.error'); @@ -52,12 +61,52 @@ const runImportProductsTest = () => { await page.waitForSelector('div.wc-actions > a.button.button-primary'); await expect(page).toClick('div.wc-actions > a.button.button-primary'); - // Getting product names + // Gathering product names await page.waitForSelector('a.row-title'); - let linkTexts = await page.$$eval('a.row-title', elements => elements.map(item => item.innerHTML)); + let productTitles = await page.$$eval('a.row-title', + elements => elements.map(item => item.innerHTML)); // Compare imported product names - await expect(productNames).toEqual(linkTexts.sort()); + await expect(productNames).toEqual(productTitles.sort()); + }); + + it('can override the existing products via CSV import', async () => { + await merchant.openImportProducts(); + + // Put the CSV Override products file, set checkbox and proceed further + const uploader = await page.$("input[type=file]"); + await uploader.uploadFile(filePathOverride); + await setCheckbox('#woocommerce-importer-update-existing'); + await expect(page).toClick('button[value="Continue"]'); + + // Click on Run the importer + await page.waitForSelector('button[value="Run the importer"]'); + await expect(page).toClick('button[value="Run the importer"]'); + + // Waiting for importer to finish + await page.waitForSelector('section.woocommerce-importer-done', {visible:true, timeout: 60000}); + await page.waitForSelector('.woocommerce-importer-done'); + await expect(page).toMatchElement('.woocommerce-importer-done', {text: 'Import complete!'}); + + // Click on view products + await page.waitForSelector('div.wc-actions > a.button.button-primary'); + await expect(page).toClick('div.wc-actions > a.button.button-primary'); + + // Gathering product names + await page.waitForSelector('a.row-title'); + let productTitles = await page.$$eval('a.row-title', + elements => elements.map(item => item.innerHTML)); + + // Compare overriden product names + await expect(productNamesOverride).toEqual(productTitles.sort()); + + // Gathering product prices + await page.waitForSelector('td.price.column-price'); + let productPrices = await page.$$eval('td.price.column-price > .amount', + elements => elements.map(item => item.text)); + + // Compare overriden product prices + await expect(productPrices).toEqual(productPrices.sort()); }); }); }; diff --git a/tests/e2e/utils/README.md b/tests/e2e/utils/README.md index 23a5896be46..ed18de3266c 100644 --- a/tests/e2e/utils/README.md +++ b/tests/e2e/utils/README.md @@ -55,6 +55,7 @@ describe( 'Cart page', () => { | `runSetupWizard` | | Open the onboarding profiler | | `updateOrderStatus` | `orderId, status` | Update the status of an order | | `openEmailLog` | | Open the WP Mail Log page | +| `openImportProducts` | | Open the Import Products page | ### Shopper `shopper` From f39d7531f8e2e5d4a309a87e62ca3f62621c15c4 Mon Sep 17 00:00:00 2001 From: Veljko Date: Thu, 18 Mar 2021 18:02:42 +0100 Subject: [PATCH 07/41] Fix spaces in the code --- .../wp-admin-product-import-csv.test.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index c725feb57f4..67ddb1671e2 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -22,12 +22,12 @@ const productNames = ["V-Neck T-Shirt", "Hoodie", "Hoodie with Logo", "T-Shirt", "Polo", "Album", "Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"].sort(); const productNamesOverride = ["V-Neck T-Shirt Override", "Hoodie Override", "Hoodie with Logo Override", "T-Shirt Override", "Beanie Override", "Belt Override", "Cap Override", "Sunglasses Override", - "Hoodie with Pocket Override", "Hoodie with Zipper Override", "Long Sleeve Tee Override", + "Hoodie with Pocket Override", "Hoodie with Zipper Override", "Long Sleeve Tee Override", "Polo Override", "Album Override", "Single Override", "T-Shirt with Logo Override", "Beanie with Logo Override", - "Logo Collection Override", "WordPress Pennant Override"].sort(); + "Logo Collection Override", "WordPress Pennant Override"].sort(); const productPrices = ["145", "118", "120", "118", "165", "155", "118", "116", "190", "145", "135", "145", "125", - "120", "115", "13", "12", "120", "120", "115", "145", "142", "145", "145", - "118","120", "118", "111.05", "145"].sort(); + "120", "115", "13", "12", "120", "120", "115", "145", "142", "145", "145", + "118","120", "118", "111.05", "145"].sort(); const errorMessage = 'Invalid file type. The importer supports CSV and TXT file formats.'; const runImportProductsTest = () => { @@ -64,7 +64,7 @@ const runImportProductsTest = () => { // Gathering product names await page.waitForSelector('a.row-title'); let productTitles = await page.$$eval('a.row-title', - elements => elements.map(item => item.innerHTML)); + elements => elements.map(item => item.innerHTML)); // Compare imported product names await expect(productNames).toEqual(productTitles.sort()); @@ -95,18 +95,18 @@ const runImportProductsTest = () => { // Gathering product names await page.waitForSelector('a.row-title'); let productTitles = await page.$$eval('a.row-title', - elements => elements.map(item => item.innerHTML)); + elements => elements.map(item => item.innerHTML)); // Compare overriden product names await expect(productNamesOverride).toEqual(productTitles.sort()); - // Gathering product prices - await page.waitForSelector('td.price.column-price'); - let productPrices = await page.$$eval('td.price.column-price > .amount', - elements => elements.map(item => item.text)); + // Gathering product prices + await page.waitForSelector('td.price.column-price'); + let productPrices = await page.$$eval('td.price.column-price > .amount', + elements => elements.map(item => item.text)); - // Compare overriden product prices - await expect(productPrices).toEqual(productPrices.sort()); + // Compare overriden product prices + await expect(productPrices).toEqual(productPrices.sort()); }); }); }; From 1e9a4dd6babf476272ef899810d3fdf8b4ec31fe Mon Sep 17 00:00:00 2001 From: Veljko Date: Thu, 18 Mar 2021 21:35:07 +0100 Subject: [PATCH 08/41] Improve test scenario --- .../merchant/wp-admin-product-import-csv.test.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index 67ddb1671e2..159374e05f6 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -18,16 +18,16 @@ const { const filePath = '../../../sample-data/sample_products.csv'; const filePathOverride = '../../../sample-data/sample_products_override.csv'; const productNames = ["V-Neck T-Shirt", "Hoodie", "Hoodie with Logo", "T-Shirt", "Beanie", - "Belt", "Cap", "Sunglasses", "Hoodie with Pocket", "Hoodie with Zipper", "Long Sleeve Tee", - "Polo", "Album", "Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"].sort(); + "Belt", "Cap", "Sunglasses", "Hoodie with Pocket", "Hoodie with Zipper", "Long Sleeve Tee", "Polo", "Album", + "Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"].sort(); const productNamesOverride = ["V-Neck T-Shirt Override", "Hoodie Override", "Hoodie with Logo Override", "T-Shirt Override", "Beanie Override", "Belt Override", "Cap Override", "Sunglasses Override", "Hoodie with Pocket Override", "Hoodie with Zipper Override", "Long Sleeve Tee Override", "Polo Override", "Album Override", "Single Override", "T-Shirt with Logo Override", "Beanie with Logo Override", "Logo Collection Override", "WordPress Pennant Override"].sort(); -const productPrices = ["145", "118", "120", "118", "165", "155", "118", "116", "190", "145", "135", "145", "125", - "120", "115", "13", "12", "120", "120", "115", "145", "142", "145", "145", - "118","120", "118", "111.05", "145"].sort(); +const productPricesOverride = ["145", "118", "120", "118", "165", "155", "118", "116", "190", "145", + "135", "145", "125", "120", "115", "13", "12", "120", "120", "115", "145", "142", + "145", "145", "118","120", "118", "111.05", "145"].sort(); const errorMessage = 'Invalid file type. The importer supports CSV and TXT file formats.'; const runImportProductsTest = () => { @@ -67,7 +67,7 @@ const runImportProductsTest = () => { elements => elements.map(item => item.innerHTML)); // Compare imported product names - await expect(productNames).toEqual(productTitles.sort()); + expect(productNames).toContain(productTitles.sort()); }); it('can override the existing products via CSV import', async () => { @@ -98,7 +98,7 @@ const runImportProductsTest = () => { elements => elements.map(item => item.innerHTML)); // Compare overriden product names - await expect(productNamesOverride).toEqual(productTitles.sort()); + expect(productNamesOverride).toContain(productTitles.sort()); // Gathering product prices await page.waitForSelector('td.price.column-price'); @@ -106,7 +106,7 @@ const runImportProductsTest = () => { elements => elements.map(item => item.text)); // Compare overriden product prices - await expect(productPrices).toEqual(productPrices.sort()); + expect(productPricesOverride).toContain(productPrices.sort()); }); }); }; From cc5b57da94c640207d31b0972b58f2b6ae393820 Mon Sep 17 00:00:00 2001 From: Veljko Date: Thu, 18 Mar 2021 23:48:36 +0100 Subject: [PATCH 09/41] Fix test and correct scenario --- .../wp-admin-product-import-csv.test.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index 159374e05f6..ddff9113284 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -19,15 +19,15 @@ const filePath = '../../../sample-data/sample_products.csv'; const filePathOverride = '../../../sample-data/sample_products_override.csv'; const productNames = ["V-Neck T-Shirt", "Hoodie", "Hoodie with Logo", "T-Shirt", "Beanie", "Belt", "Cap", "Sunglasses", "Hoodie with Pocket", "Hoodie with Zipper", "Long Sleeve Tee", "Polo", "Album", - "Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"].sort(); + "Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"]; const productNamesOverride = ["V-Neck T-Shirt Override", "Hoodie Override", "Hoodie with Logo Override", "T-Shirt Override", "Beanie Override", "Belt Override", "Cap Override", "Sunglasses Override", "Hoodie with Pocket Override", "Hoodie with Zipper Override", "Long Sleeve Tee Override", "Polo Override", "Album Override", "Single Override", "T-Shirt with Logo Override", "Beanie with Logo Override", - "Logo Collection Override", "WordPress Pennant Override"].sort(); -const productPricesOverride = ["145", "118", "120", "118", "165", "155", "118", "116", "190", "145", - "135", "145", "125", "120", "115", "13", "12", "120", "120", "115", "145", "142", - "145", "145", "118","120", "118", "111.05", "145"].sort(); + "Logo Collection Override", "WordPress Pennant Override"]; +const productPricesOverride = ["$111.05", "$118.00", "$145.00", "$120.00", "$118.00", "$118.00", "$13.00", "$12.00", + "$115.00", "$120.00", "$125.00", "$145.00", "$145.00", "$135.00", "$190.00", "$118.00", "$116.00", + "$165.00", "$155.00", "$120.00", "$118.00", "$118.00", "$145.00", "$142.00", "$145.00", "$115.00", "$120.00"]; const errorMessage = 'Invalid file type. The importer supports CSV and TXT file formats.'; const runImportProductsTest = () => { @@ -63,11 +63,11 @@ const runImportProductsTest = () => { // Gathering product names await page.waitForSelector('a.row-title'); - let productTitles = await page.$$eval('a.row-title', + const productTitles = await page.$$eval('a.row-title', elements => elements.map(item => item.innerHTML)); // Compare imported product names - expect(productNames).toContain(productTitles.sort()); + expect(productTitles.sort()).toEqual(productNames.sort()); }); it('can override the existing products via CSV import', async () => { @@ -94,19 +94,19 @@ const runImportProductsTest = () => { // Gathering product names await page.waitForSelector('a.row-title'); - let productTitles = await page.$$eval('a.row-title', + const productTitles = await page.$$eval('a.row-title', elements => elements.map(item => item.innerHTML)); // Compare overriden product names - expect(productNamesOverride).toContain(productTitles.sort()); + expect(productTitles.sort()).toEqual(productNamesOverride.sort()); // Gathering product prices await page.waitForSelector('td.price.column-price'); - let productPrices = await page.$$eval('td.price.column-price > .amount', - elements => elements.map(item => item.text)); + const productPrices = await page.$$eval('.amount', + elements => elements.map(item => item.innerText)); // Compare overriden product prices - expect(productPricesOverride).toContain(productPrices.sort()); + expect(productPrices.sort()).toEqual(productPricesOverride.sort()); }); }); }; From fe51a15dcb4b7999477f76122ff6c2ebe2b9e54e Mon Sep 17 00:00:00 2001 From: Veljko Date: Fri, 19 Mar 2021 11:58:20 +0100 Subject: [PATCH 10/41] Add after all scenario --- tests/e2e/core-tests/specs/index.js | 2 +- .../merchant/wp-admin-product-import-csv.test.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/e2e/core-tests/specs/index.js b/tests/e2e/core-tests/specs/index.js index b2e1c69c552..87ac5c70668 100644 --- a/tests/e2e/core-tests/specs/index.js +++ b/tests/e2e/core-tests/specs/index.js @@ -64,6 +64,7 @@ const runShopperTests = () => { }; const runMerchantTests = () => { + runImportProductsTest(); runOrderSearchingTest(); runAddNewShippingZoneTest(); runCreateCouponTest(); @@ -80,7 +81,6 @@ const runMerchantTests = () => { runProductEditDetailsTest(); runProductSearchTest(); runMerchantOrdersCustomerPaymentPage(); - runImportProductsTest(); } const runApiTests = () => { diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index ddff9113284..21db05d46fb 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -4,7 +4,8 @@ */ const { merchant, - setCheckbox + setCheckbox, + moveAllItemsToTrash } = require( '@woocommerce/e2e-utils' ); /** @@ -108,6 +109,17 @@ const runImportProductsTest = () => { // Compare overriden product prices expect(productPrices.sort()).toEqual(productPricesOverride.sort()); }); + + afterAll(async () => { + // Remove all the imported products + await page.waitForSelector('#cb-select-all-1', {visible:true}); + await moveAllItemsToTrash(); + await page.waitForSelector('ul.subsubsub li.trash a', {visible:true}); + await page.click('ul.subsubsub li.trash a'); + await page.waitForSelector('#delete_all', {visible:true}); + await page.click('#delete_all'); + await page.waitForSelector('a.woocommerce-BlankState-cta.button-primary.button ~ a', {visible:true}); + }); }); }; From 783e232227dc0cc3c61fa00fd2ea89d23a0dd18e Mon Sep 17 00:00:00 2001 From: Veljko Date: Fri, 19 Mar 2021 13:04:00 +0100 Subject: [PATCH 11/41] Add removing products before all --- .../specs/merchant/wp-admin-product-import-csv.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index 21db05d46fb..23ad03fb1de 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -35,6 +35,8 @@ const runImportProductsTest = () => { describe('Import Products from a CSV file', () => { beforeAll(async () => { await merchant.login(); + await merchant.openAllProductsView(); + await moveAllItemsToTrash(); }); it('can upload the CSV file and import products', async () => { await merchant.openImportProducts(); From dc23f3a5229d6841351f6c0af54d418addfbf19b Mon Sep 17 00:00:00 2001 From: Veljko Date: Fri, 19 Mar 2021 13:50:23 +0100 Subject: [PATCH 12/41] Remove removing products from before all --- .../specs/merchant/wp-admin-product-import-csv.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index 23ad03fb1de..67bfcb850db 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -36,7 +36,6 @@ const runImportProductsTest = () => { beforeAll(async () => { await merchant.login(); await merchant.openAllProductsView(); - await moveAllItemsToTrash(); }); it('can upload the CSV file and import products', async () => { await merchant.openImportProducts(); From d578914a9d97c37e08e4552cb83e03c65aac8e25 Mon Sep 17 00:00:00 2001 From: Veljko Date: Fri, 19 Mar 2021 17:29:48 +0100 Subject: [PATCH 13/41] Remove after all scenario --- .../specs/merchant/wp-admin-product-import-csv.test.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index 67bfcb850db..8202ef20dac 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -109,17 +109,9 @@ const runImportProductsTest = () => { // Compare overriden product prices expect(productPrices.sort()).toEqual(productPricesOverride.sort()); - }); - afterAll(async () => { - // Remove all the imported products - await page.waitForSelector('#cb-select-all-1', {visible:true}); + // Move all imported products to trash await moveAllItemsToTrash(); - await page.waitForSelector('ul.subsubsub li.trash a', {visible:true}); - await page.click('ul.subsubsub li.trash a'); - await page.waitForSelector('#delete_all', {visible:true}); - await page.click('#delete_all'); - await page.waitForSelector('a.woocommerce-BlankState-cta.button-primary.button ~ a', {visible:true}); }); }); }; From dcee9ce10999f70680f7a6128fabf11f0f2f65ae Mon Sep 17 00:00:00 2001 From: Veljko Date: Tue, 23 Mar 2021 14:09:31 +0100 Subject: [PATCH 14/41] Created test data folder and moved csv file --- .../specs/merchant/wp-admin-product-import-csv.test.js | 2 +- .../e2e/core-tests/test-data}/sample_products_override.csv | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename {sample-data => tests/e2e/core-tests/test-data}/sample_products_override.csv (100%) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index 8202ef20dac..8654886973c 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -17,7 +17,7 @@ const { } = require( '@jest/globals' ); const filePath = '../../../sample-data/sample_products.csv'; -const filePathOverride = '../../../sample-data/sample_products_override.csv'; +const filePathOverride = '../../../tests/e2e/core-tests/test-data/sample_products_override.csv'; const productNames = ["V-Neck T-Shirt", "Hoodie", "Hoodie with Logo", "T-Shirt", "Beanie", "Belt", "Cap", "Sunglasses", "Hoodie with Pocket", "Hoodie with Zipper", "Long Sleeve Tee", "Polo", "Album", "Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"]; diff --git a/sample-data/sample_products_override.csv b/tests/e2e/core-tests/test-data/sample_products_override.csv similarity index 100% rename from sample-data/sample_products_override.csv rename to tests/e2e/core-tests/test-data/sample_products_override.csv From afd39e58660b8d7daba8ddda2eeeca7b4b47d323 Mon Sep 17 00:00:00 2001 From: Veljko Date: Thu, 25 Mar 2021 15:59:00 +0100 Subject: [PATCH 16/41] Added core tests root and updated test --- tests/e2e/core-tests/core-tests-root.js | 22 +++++++++++++++++++ .../wp-admin-product-import-csv.test.js | 7 ++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 tests/e2e/core-tests/core-tests-root.js diff --git a/tests/e2e/core-tests/core-tests-root.js b/tests/e2e/core-tests/core-tests-root.js new file mode 100644 index 00000000000..9e266b01283 --- /dev/null +++ b/tests/e2e/core-tests/core-tests-root.js @@ -0,0 +1,22 @@ +/** + * External dependencies + */ + const path = require( 'path' ); + + const getCoreTestsRoot = () => { + // Figure out where we're installed. + // Typically will be in node_modules/, but WooCommerce + // uses a local file path (tests/e2e/env). + let coreTestsPath = false; + const moduleDir = path.dirname( require.resolve( '@woocommerce/e2e-environment' ) ); + + if ( -1 < moduleDir.indexOf( 'node_modules' ) ) { + coreTestsPath = moduleDir.split( 'node_modules' )[ 0 ]; + } else if ( -1 < moduleDir.indexOf( 'tests/e2e/env' ) ) { + coreTestsPath = moduleDir.split( 'tests/e2e/env' )[ 0 ]; + } + + return coreTestsPath; + }; + + module.exports = getCoreTestsRoot; \ No newline at end of file diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index 8654886973c..31fdbf66d40 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -7,6 +7,7 @@ setCheckbox, moveAllItemsToTrash } = require( '@woocommerce/e2e-utils' ); +const getCoreTestsRoot = require( '../../core-tests-root' ); /** * External dependencies @@ -16,8 +17,10 @@ const { describe } = require( '@jest/globals' ); -const filePath = '../../../sample-data/sample_products.csv'; -const filePathOverride = '../../../tests/e2e/core-tests/test-data/sample_products_override.csv'; +const path = require( 'path' ); +const coreTestsPath = getCoreTestsRoot(); +const filePath = path.resolve( coreTestsPath, 'sample-data/sample_products.csv' ); +const filePathOverride = path.resolve( coreTestsPath, 'tests/e2e/core-tests/test-data/sample_products_override.csv' ); const productNames = ["V-Neck T-Shirt", "Hoodie", "Hoodie with Logo", "T-Shirt", "Beanie", "Belt", "Cap", "Sunglasses", "Hoodie with Pocket", "Hoodie with Zipper", "Long Sleeve Tee", "Polo", "Album", "Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"]; From 5b3bc1665dfb3e672f969af3a4028786a22e16c3 Mon Sep 17 00:00:00 2001 From: Veljko Date: Thu, 25 Mar 2021 18:12:54 +0100 Subject: [PATCH 17/41] Updated core-tests-root file --- tests/e2e/core-tests/core-tests-root.js | 16 ++++++++++------ .../merchant/wp-admin-product-import-csv.test.js | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/e2e/core-tests/core-tests-root.js b/tests/e2e/core-tests/core-tests-root.js index 9e266b01283..16a4d4eaa04 100644 --- a/tests/e2e/core-tests/core-tests-root.js +++ b/tests/e2e/core-tests/core-tests-root.js @@ -6,17 +6,21 @@ const getCoreTestsRoot = () => { // Figure out where we're installed. // Typically will be in node_modules/, but WooCommerce - // uses a local file path (tests/e2e/env). + // uses a local file path (tests/e2e/core-tests). let coreTestsPath = false; - const moduleDir = path.dirname( require.resolve( '@woocommerce/e2e-environment' ) ); + const moduleDir = path.dirname( require.resolve( '@woocommerce/e2e-core-tests' ) ); if ( -1 < moduleDir.indexOf( 'node_modules' ) ) { coreTestsPath = moduleDir.split( 'node_modules' )[ 0 ]; - } else if ( -1 < moduleDir.indexOf( 'tests/e2e/env' ) ) { - coreTestsPath = moduleDir.split( 'tests/e2e/env' )[ 0 ]; + } else if ( -1 < moduleDir.indexOf( 'tests/e2e/core-tests' ) ) { + coreTestsPath = moduleDir.split( 'tests/e2e/core-tests' )[ 0 ]; } - return coreTestsPath; + return { + appRoot: coreTestsPath, + packageRoot: moduleDir, + }; }; - module.exports = getCoreTestsRoot; \ No newline at end of file + module.exports = getCoreTestsRoot; + \ No newline at end of file diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index 31fdbf66d40..e9008325e9e 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -19,8 +19,8 @@ const { const path = require( 'path' ); const coreTestsPath = getCoreTestsRoot(); -const filePath = path.resolve( coreTestsPath, 'sample-data/sample_products.csv' ); -const filePathOverride = path.resolve( coreTestsPath, 'tests/e2e/core-tests/test-data/sample_products_override.csv' ); +const filePath = path.resolve( coreTestsPath.appRoot, 'sample-data/sample_products.csv' ); +const filePathOverride = path.resolve( coreTestsPath.packageRoot, 'test-data/sample_products_override.csv' ); const productNames = ["V-Neck T-Shirt", "Hoodie", "Hoodie with Logo", "T-Shirt", "Beanie", "Belt", "Cap", "Sunglasses", "Hoodie with Pocket", "Hoodie with Zipper", "Long Sleeve Tee", "Polo", "Album", "Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"]; From 18c500c24f70a8537a1e6106ffb78d1070d9e4d1 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Fri, 26 Mar 2021 16:33:44 -0300 Subject: [PATCH 18/41] add contributor feedback label action --- .github/workflows/update-feedback-labels.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/update-feedback-labels.yml diff --git a/.github/workflows/update-feedback-labels.yml b/.github/workflows/update-feedback-labels.yml new file mode 100644 index 00000000000..db89fdc3737 --- /dev/null +++ b/.github/workflows/update-feedback-labels.yml @@ -0,0 +1,18 @@ +name: 'Update contributor feedback labels on comment' +on: 'issue_comment' + +jobs: + feedback: + if: github.event.issue && contains(github.event.issue.labels.*.name, 'needs feedback') + runs-on: ubuntu-latest + steps: + - name: Add has feedback + uses: actions-ecosystem/action-add-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: 'has feedback' + - name: remove needs feedback + uses: actions-ecosystem/action-remove-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: 'needs feedback' From f0c164d2d49dfe13088bb0744f3a1c357c4a9204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9D=93=91=F0=9D=93=AA=F0=9D=93=BB=F0=9D=93=BB?= =?UTF-8?q?=F0=9D=94=82=20=F0=9D=93=97=F0=9D=93=BE=F0=9D=93=B0=F0=9D=93=B1?= =?UTF-8?q?=F0=9D=93=AE=F0=9D=93=BC?= <3594411+barryhughes@users.noreply.github.com> Date: Fri, 26 Mar 2021 17:08:37 -0700 Subject: [PATCH 19/41] Do not copy fields from the billing address to the shipping address. | #28759 --- includes/class-wc-customer.php | 19 +++ .../class-wc-customer-data-store-session.php | 5 +- ...ss-wc-customer-data-store-session-test.php | 114 ++++++++++++++++++ 3 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 tests/php/includes/data-stores/class-wc-customer-data-store-session-test.php diff --git a/includes/class-wc-customer.php b/includes/class-wc-customer.php index 3c5c53079f3..65abb9adf14 100644 --- a/includes/class-wc-customer.php +++ b/includes/class-wc-customer.php @@ -242,6 +242,25 @@ class WC_Customer extends WC_Legacy_Customer { return $this->get_calculated_shipping(); } + /** + * Indicates if the customer has a non-empty shipping address. + * + * Note that this does not indicate if the customer's shipping address + * is complete, only that one or more fields are populated. + * + * @return bool + */ + public function has_shipping_address() { + foreach ( $this->get_shipping() as $address_field ) { + // Trim guards against a case where a subset of saved shipping address fields contain whitespace. + if ( strlen( trim( $address_field ) ) > 0 ) { + return true; + } + } + + return false; + } + /** * Get if customer is VAT exempt? * diff --git a/includes/data-stores/class-wc-customer-data-store-session.php b/includes/data-stores/class-wc-customer-data-store-session.php index 4a2585d20ca..9b5d66ad4f9 100644 --- a/includes/data-stores/class-wc-customer-data-store-session.php +++ b/includes/data-stores/class-wc-customer-data-store-session.php @@ -126,12 +126,13 @@ class WC_Customer_Data_Store_Session extends WC_Data_Store_WP implements WC_Cust protected function set_defaults( &$customer ) { try { $default = wc_get_customer_default_location(); + $has_shipping_address = $customer->has_shipping_address(); if ( ! $customer->get_billing_country() ) { $customer->set_billing_country( $default['country'] ); } - if ( ! $customer->get_shipping_country() ) { + if ( ! $customer->get_shipping_country() && ! $has_shipping_address ) { $customer->set_shipping_country( $customer->get_billing_country() ); } @@ -139,7 +140,7 @@ class WC_Customer_Data_Store_Session extends WC_Data_Store_WP implements WC_Cust $customer->set_billing_state( $default['state'] ); } - if ( ! $customer->get_shipping_state() ) { + if ( ! $customer->get_shipping_state() && ! $has_shipping_address ) { $customer->set_shipping_state( $customer->get_billing_state() ); } diff --git a/tests/php/includes/data-stores/class-wc-customer-data-store-session-test.php b/tests/php/includes/data-stores/class-wc-customer-data-store-session-test.php new file mode 100644 index 00000000000..75ef103b8e0 --- /dev/null +++ b/tests/php/includes/data-stores/class-wc-customer-data-store-session-test.php @@ -0,0 +1,114 @@ +read( $customer ); + + if ( $states_should_match ) { + $this->assertEquals( $customer->get_shipping_state(), $customer->get_billing_state() ); + } else { + $this->assertNotEquals( $customer->get_shipping_state(), $customer->get_billing_state() ); + } + + if ( $countries_should_match ) { + $this->assertEquals( $customer->get_shipping_country(), $customer->get_billing_country() ); + } else { + $this->assertNotEquals( $customer->get_shipping_country(), $customer->get_billing_country() ); + } + } + + /** + * Customer objects with a mixture of billing and shipping addresses. + * + * Each inner dataset is organized as follows: + * + * [ + * (WC_Customer) $customer_object, + * (bool) $states_should_match, + * (bool) $countries_should_match, + * ] + * + * @return array[] + */ + public function provide_customers_with_different_addresses() { + $has_billing_address_only = new WC_Customer(); + $has_billing_address_only->set_email( 'wc-customer-test-01@test.user' ); + $has_billing_address_only->set_billing_address( '1234 Quality Lane' ); + $has_billing_address_only->set_billing_city( 'Testville' ); + $has_billing_address_only->set_billing_country( 'US' ); + $has_billing_address_only->set_billing_state( 'CA' ); + $has_billing_address_only->set_billing_postcode( '90123' ); + $has_billing_address_only->save(); + + $separate_billing_and_shipping_state_and_country = new WC_Customer(); + $separate_billing_and_shipping_state_and_country->set_email( 'wc-customer-test-02@test.user' ); + $separate_billing_and_shipping_state_and_country->set_billing_address( '4567 Scenario Street' ); + $separate_billing_and_shipping_state_and_country->set_billing_city( 'Unitly' ); + $separate_billing_and_shipping_state_and_country->set_billing_country( 'UK' ); + $separate_billing_and_shipping_state_and_country->set_billing_state( 'Computershire' ); + $separate_billing_and_shipping_state_and_country->set_billing_postcode( 'ZX1 2PQ' ); + $separate_billing_and_shipping_state_and_country->set_shipping_address( '8901 Situation Court' ); + $separate_billing_and_shipping_state_and_country->set_shipping_city( 'Endtoendly' ); + $separate_billing_and_shipping_state_and_country->set_shipping_country( 'CA' ); + $separate_billing_and_shipping_state_and_country->set_shipping_state( 'BC' ); + $separate_billing_and_shipping_state_and_country->set_shipping_postcode( 'A1B 2C3' ); + $separate_billing_and_shipping_state_and_country->save(); + + $separate_billing_state_same_country = new WC_Customer(); + $separate_billing_state_same_country->set_email( 'wc-customer-test-03@test.user' ); + $separate_billing_state_same_country->set_billing_address( '4567 Scenario Street' ); + $separate_billing_state_same_country->set_billing_city( 'Unitly' ); + $separate_billing_state_same_country->set_billing_country( 'UK' ); + $separate_billing_state_same_country->set_billing_state( 'Computershire' ); + $separate_billing_state_same_country->set_billing_postcode( 'ZX1 2PQ' ); + $separate_billing_state_same_country->set_shipping_address( '8901 Situation Court' ); + $separate_billing_state_same_country->set_shipping_city( 'Endtoendly' ); + $separate_billing_state_same_country->set_shipping_country( 'UK' ); + $separate_billing_state_same_country->set_shipping_state( 'Byteshire' ); + $separate_billing_state_same_country->set_shipping_postcode( 'RS1 2TU' ); + $separate_billing_state_same_country->save(); + + $shipping_address_is_effectively_empty = new WC_Customer(); + $shipping_address_is_effectively_empty->set_email( 'wc-customer-test-04@test.user' ); + $shipping_address_is_effectively_empty->set_shipping_address( ' ' ); + $shipping_address_is_effectively_empty->save(); + + return array( + 'has_billing_address_only' => array( + $has_billing_address_only, + true, + true, + ), + 'separate_billing_and_shipping_state_and_country' => array( + $separate_billing_and_shipping_state_and_country, + false, + false, + ), + 'separate_billing_state_same_country' => array( + $separate_billing_state_same_country, + false, + true, + ), + 'shipping_address_is_effectively_empty' => array( + $shipping_address_is_effectively_empty, + true, + true, + ), + ); + } +} From f5dfee102db5ee81904a5707031f809f7de32c1e Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 4 Apr 2021 00:18:27 +0200 Subject: [PATCH 20/41] fix typo --- includes/gateways/bacs/class-wc-gateway-bacs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/gateways/bacs/class-wc-gateway-bacs.php b/includes/gateways/bacs/class-wc-gateway-bacs.php index 3ec175dfd59..b93dd40316f 100644 --- a/includes/gateways/bacs/class-wc-gateway-bacs.php +++ b/includes/gateways/bacs/class-wc-gateway-bacs.php @@ -37,7 +37,7 @@ class WC_Gateway_BACS extends WC_Payment_Gateway { $this->icon = apply_filters( 'woocommerce_bacs_icon', '' ); $this->has_fields = false; $this->method_title = __( 'Direct bank transfer', 'woocommerce' ); - $this->method_description = __( 'Take payments in person via BACS. More commonly known as direct bank/wire transfer', 'woocommerce' ); + $this->method_description = __( 'Take payments in person via BACS. More commonly known as direct bank/wire transfer.', 'woocommerce' ); // Load the settings. $this->init_form_fields(); From 5b274fda874607e0334f54f75d768b727effe780 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 4 Apr 2021 01:11:04 +0200 Subject: [PATCH 21/41] add portugal states adding states based on #29206 --- i18n/states.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/i18n/states.php b/i18n/states.php index 6065e0771f8..ed3b748591f 100644 --- a/i18n/states.php +++ b/i18n/states.php @@ -1296,7 +1296,28 @@ return array( ), 'PL' => array(), 'PR' => array(), - 'PT' => array(), + 'PT' => array( // Portugal states. + 'PT-01' => __( 'Aveiro', 'woocommerce' ), + 'PT-02' => __( 'Beja', 'woocommerce' ), + 'PT-03' => __( 'Braga', 'woocommerce' ), + 'PT-04' => __( 'Bragança', 'woocommerce' ), + 'PT-05' => __( 'Castelo Branco', 'woocommerce' ), + 'PT-06' => __( 'Coimbra', 'woocommerce' ), + 'PT-07' => __( 'Évora', 'woocommerce' ), + 'PT-08' => __( 'Faro', 'woocommerce' ), + 'PT-09' => __( 'Guarda', 'woocommerce' ), + 'PT-10' => __( 'Leiria', 'woocommerce' ), + 'PT-11' => __( 'Lisboa', 'woocommerce' ), + 'PT-12' => __( 'Portalegre', 'woocommerce' ), + 'PT-13' => __( 'Porto', 'woocommerce' ), + 'PT-14' => __( 'Santarém', 'woocommerce' ), + 'PT-15' => __( 'Setúbal', 'woocommerce' ), + 'PT-16' => __( 'Viana do Castelo', 'woocommerce' ), + 'PT-17' => __( 'Vila Real', 'woocommerce' ), + 'PT-18' => __( 'Viseu', 'woocommerce' ), + 'PT-20' => __( 'Açores', 'woocommerce' ), + 'PT-30' => __( 'Madeira', 'woocommerce' ), + ), 'PY' => array( // Paraguay states. 'PY-ASU' => __( 'Asunción', 'woocommerce' ), 'PY-1' => __( 'Concepción', 'woocommerce' ), From 9c59b808209163e240ed3527e5992a3a18e7b67a Mon Sep 17 00:00:00 2001 From: roykho Date: Tue, 6 Apr 2021 11:37:52 -0700 Subject: [PATCH 22/41] Bump version for template closes #29595 --- templates/single-product/add-to-cart/grouped.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/single-product/add-to-cart/grouped.php b/templates/single-product/add-to-cart/grouped.php index 39df2ceb456..fb6fff7a6fc 100644 --- a/templates/single-product/add-to-cart/grouped.php +++ b/templates/single-product/add-to-cart/grouped.php @@ -12,7 +12,7 @@ * * @see https://docs.woocommerce.com/document/template-structure/ * @package WooCommerce\Templates - * @version 4.0.0 + * @version 4.8.0 */ defined( 'ABSPATH' ) || exit; From 2570510ff4ce5602827efffa720bd95ddee9b269 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 6 Apr 2021 22:17:49 +0200 Subject: [PATCH 23/41] Update states.php changes requested by claudiosanches and codesnif --- i18n/states.php | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/i18n/states.php b/i18n/states.php index ed3b748591f..83d64ba8856 100644 --- a/i18n/states.php +++ b/i18n/states.php @@ -534,7 +534,7 @@ return array( 'SO' => __( 'Sololá', 'woocommerce' ), 'SU' => __( 'Suchitepéquez', 'woocommerce' ), 'TO' => __( 'Totonicapán', 'woocommerce' ), - 'ZA' => __( 'Zacapa', 'woocommerce' ) + 'ZA' => __( 'Zacapa', 'woocommerce' ), ), 'HK' => array( // Hong Kong states. 'HONG KONG' => __( 'Hong Kong Island', 'woocommerce' ), @@ -1297,26 +1297,26 @@ return array( 'PL' => array(), 'PR' => array(), 'PT' => array( // Portugal states. - 'PT-01' => __( 'Aveiro', 'woocommerce' ), - 'PT-02' => __( 'Beja', 'woocommerce' ), - 'PT-03' => __( 'Braga', 'woocommerce' ), - 'PT-04' => __( 'Bragança', 'woocommerce' ), - 'PT-05' => __( 'Castelo Branco', 'woocommerce' ), - 'PT-06' => __( 'Coimbra', 'woocommerce' ), - 'PT-07' => __( 'Évora', 'woocommerce' ), - 'PT-08' => __( 'Faro', 'woocommerce' ), - 'PT-09' => __( 'Guarda', 'woocommerce' ), - 'PT-10' => __( 'Leiria', 'woocommerce' ), - 'PT-11' => __( 'Lisboa', 'woocommerce' ), - 'PT-12' => __( 'Portalegre', 'woocommerce' ), - 'PT-13' => __( 'Porto', 'woocommerce' ), - 'PT-14' => __( 'Santarém', 'woocommerce' ), - 'PT-15' => __( 'Setúbal', 'woocommerce' ), - 'PT-16' => __( 'Viana do Castelo', 'woocommerce' ), - 'PT-17' => __( 'Vila Real', 'woocommerce' ), - 'PT-18' => __( 'Viseu', 'woocommerce' ), - 'PT-20' => __( 'Açores', 'woocommerce' ), - 'PT-30' => __( 'Madeira', 'woocommerce' ), + 'pt01' => __( 'Aveiro', 'woocommerce' ), + 'pt02' => __( 'Beja', 'woocommerce' ), + 'pt03' => __( 'Braga', 'woocommerce' ), + 'pt04' => __( 'Bragança', 'woocommerce' ), + 'pt05' => __( 'Castelo Branco', 'woocommerce' ), + 'pt06' => __( 'Coimbra', 'woocommerce' ), + 'pt07' => __( 'Évora', 'woocommerce' ), + 'pt08' => __( 'Faro', 'woocommerce' ), + 'pt09' => __( 'Guarda', 'woocommerce' ), + 'pt10' => __( 'Leiria', 'woocommerce' ), + 'pt11' => __( 'Lisbon', 'woocommerce' ), + 'pt12' => __( 'Portalegre', 'woocommerce' ), + 'pt13' => __( 'Porto', 'woocommerce' ), + 'pt14' => __( 'Santarém', 'woocommerce' ), + 'pt15' => __( 'Setúbal', 'woocommerce' ), + 'pt16' => __( 'Viana do Castelo', 'woocommerce' ), + 'pt17' => __( 'Vila Real', 'woocommerce' ), + 'pt18' => __( 'Viseu', 'woocommerce' ), + 'pt20' => __( 'Azores', 'woocommerce' ), + 'pt30' => __( 'Madeira', 'woocommerce' ), ), 'PY' => array( // Paraguay states. 'PY-ASU' => __( 'Asunción', 'woocommerce' ), From e2820e90f9f7a4626fbf31f99db627dbdc530b39 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 6 Apr 2021 23:15:15 +0200 Subject: [PATCH 24/41] Update wc-formatting-functions.php add aria-hidden="true" on --- includes/wc-formatting-functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/wc-formatting-functions.php b/includes/wc-formatting-functions.php index a48b3df5937..264ad8fd62b 100644 --- a/includes/wc-formatting-functions.php +++ b/includes/wc-formatting-functions.php @@ -1265,7 +1265,7 @@ function wc_format_stock_quantity_for_display( $stock_quantity, $product ) { * @return string */ function wc_format_sale_price( $regular_price, $sale_price ) { - $price = '' . ( is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price ) . ' ' . ( is_numeric( $sale_price ) ? wc_price( $sale_price ) : $sale_price ) . ''; + $price = ' ' . ( is_numeric( $sale_price ) ? wc_price( $sale_price ) : $sale_price ) . ''; return apply_filters( 'woocommerce_format_sale_price', $price, $regular_price, $sale_price ); } From 6ca74affb0a08d40d52bb53a59a086b65a665a2e Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 6 Apr 2021 23:24:22 +0200 Subject: [PATCH 25/41] Update class-wc-order.php add aria-hidden="true" to --- includes/class-wc-order.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-order.php b/includes/class-wc-order.php index 516f905b10b..87bbc0b8835 100644 --- a/includes/class-wc-order.php +++ b/includes/class-wc-order.php @@ -179,7 +179,7 @@ class WC_Order extends WC_Abstract_Order { } if ( $total_refunded && $display_refunded ) { - $formatted_total = '' . wp_strip_all_tags( $formatted_total ) . ' ' . wc_price( $order_total - $total_refunded, array( 'currency' => $this->get_currency() ) ) . $tax_string . ''; + $formatted_total = ' ' . wc_price( $order_total - $total_refunded, array( 'currency' => $this->get_currency() ) ) . $tax_string . ''; } else { $formatted_total .= $tax_string; } From 913c46ac91284ded9139894aacede3ea15905287 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 6 Apr 2021 23:43:53 +0200 Subject: [PATCH 26/41] Update functions.php fix legacy test --- tests/legacy/unit-tests/formatting/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/legacy/unit-tests/formatting/functions.php b/tests/legacy/unit-tests/formatting/functions.php index aa071eeb685..533f5ed1a5a 100644 --- a/tests/legacy/unit-tests/formatting/functions.php +++ b/tests/legacy/unit-tests/formatting/functions.php @@ -926,7 +926,7 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case { * @since 3.3.0 */ public function test_wc_format_sale_price() { - $this->assertEquals( '£10.00 £5.00', wc_format_sale_price( '10', '5' ) ); + $this->assertEquals( ' £5.00', wc_format_sale_price( '10', '5' ) ); } /** From 50b882905fd19919a041a3fbcc20670227360167 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 6 Apr 2021 23:44:36 +0200 Subject: [PATCH 27/41] Update data.php fix legacy tests --- tests/legacy/unit-tests/product/data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/legacy/unit-tests/product/data.php b/tests/legacy/unit-tests/product/data.php index bcc5bd583fc..ba15c025c69 100644 --- a/tests/legacy/unit-tests/product/data.php +++ b/tests/legacy/unit-tests/product/data.php @@ -259,7 +259,7 @@ class WC_Tests_Product_Data extends WC_Unit_Test_Case { $product = wc_get_product( $product1_id ); $this->assertEquals( $product1_id, $product->get_id() ); - $this->assertEquals( '£10.00 £7.00', $product->get_price_html() ); + $this->assertEquals( ' £7.00', $product->get_price_html() ); $product = wc_get_product( $product2_id ); $this->assertEquals( $product2_id, $product->get_id() ); From 778cf448cb3e19df36c0f835761aff116e65b68a Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 6 Apr 2021 23:56:28 +0200 Subject: [PATCH 28/41] Update data.php fix legacy code test --- tests/legacy/unit-tests/product/data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/legacy/unit-tests/product/data.php b/tests/legacy/unit-tests/product/data.php index ba15c025c69..b3beb1f9f2a 100644 --- a/tests/legacy/unit-tests/product/data.php +++ b/tests/legacy/unit-tests/product/data.php @@ -263,7 +263,7 @@ class WC_Tests_Product_Data extends WC_Unit_Test_Case { $product = wc_get_product( $product2_id ); $this->assertEquals( $product2_id, $product->get_id() ); - $this->assertEquals( '£20.00 £16.00', $product->get_price_html() ); + $this->assertEquals( ' £16.00', $product->get_price_html() ); $product = wc_get_product( $product3_id ); $this->assertEquals( $product3_id, $product->get_id() ); From a37b2a7474bcf7737074e3c6804383fb8fc25b0d Mon Sep 17 00:00:00 2001 From: Nestor Soriano Date: Wed, 7 Apr 2021 09:59:56 +0200 Subject: [PATCH 29/41] Don't verify empty country codes on checkout PR #28849 introduced a verification of the posted country code on checkout, so an invalid code will throw an error. However there are cases when an empty code is legitimately received, for example when using Paypal checkout directly from the product page and the customer doesn't have an address in his Paypal profile. --- includes/class-wc-checkout.php | 2 +- tests/php/includes/class-wc-checkout-test.php | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index 4d92bbca60e..036c4ba612c 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -747,7 +747,7 @@ class WC_Checkout { $field_label = isset( $field['label'] ) ? $field['label'] : ''; if ( $validate_fieldset && - ( isset( $field['type'] ) && 'country' === $field['type'] ) && + ( isset( $field['type'] ) && 'country' === $field['type'] && '' !== $data[ $key ] ) && ! WC()->countries->country_exists( $data[ $key ] ) ) { /* translators: ISO 3166-1 alpha-2 country code */ $errors->add( $key . '_validation', sprintf( __( "'%s' is not a valid country code.", 'woocommerce' ), $data[ $key ] ) ); diff --git a/tests/php/includes/class-wc-checkout-test.php b/tests/php/includes/class-wc-checkout-test.php index 3a6867a1a5c..0a9b87a645f 100644 --- a/tests/php/includes/class-wc-checkout-test.php +++ b/tests/php/includes/class-wc-checkout-test.php @@ -93,6 +93,30 @@ class WC_Checkout_Test extends \WC_Unit_Test_Case { $this->assertEmpty( $errors->get_error_message( 'shipping_country_validation' ) ); } + /** + * @testdox 'validate_posted_data' doesn't add errors for empty billing/shipping countries. + * + * @testWith [true] + * [false] + * + * @param bool $ship_to_different_address True to simulate shipping to a different address than the billing address. + */ + public function test_validate_posted_data_does_not_add_error_for_empty_country( $ship_to_different_address ) { + $_POST = array( + 'billing_country' => '', + 'shipping_country' => '', + 'ship_to_different_address' => $ship_to_different_address, + ); + $data = $_POST; // phpcs:ignore WordPress.Security.NonceVerification.Missing + + $errors = new WP_Error(); + + $this->sut->validate_posted_data( $data, $errors ); + + $this->assertEmpty( $errors->get_error_message( 'billing_country_validation' ) ); + $this->assertEmpty( $errors->get_error_message( 'shipping_country_validation' ) ); + } + /** * @testdox 'validate_checkout' adds a "We don't ship to country X" error but only if the country exists. * From 43a2bb2a2496461f996cded221b4ecd72a922beb Mon Sep 17 00:00:00 2001 From: Nestor Soriano Date: Wed, 7 Apr 2021 15:35:28 +0200 Subject: [PATCH 30/41] Don't show the "WooCommerce Setup" widget in dashboard if WC Admin is disabled --- includes/admin/class-wc-admin-dashboard-setup.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/admin/class-wc-admin-dashboard-setup.php b/includes/admin/class-wc-admin-dashboard-setup.php index 0fb9f7cda83..580bdc00b2e 100644 --- a/includes/admin/class-wc-admin-dashboard-setup.php +++ b/includes/admin/class-wc-admin-dashboard-setup.php @@ -162,7 +162,9 @@ if ( ! class_exists( 'WC_Admin_Dashboard_Setup', false ) ) : * @return bool */ private function should_display_widget() { - return 'yes' !== get_option( 'woocommerce_task_list_complete' ) && 'yes' !== get_option( 'woocommerce_task_list_hidden' ); + return WC()->is_wc_admin_active() && + 'yes' !== get_option( 'woocommerce_task_list_complete' ) && + 'yes' !== get_option( 'woocommerce_task_list_hidden' ); } /** From 52ccacd094332b7cf13d37a9c3027c6baed5914d Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 7 Apr 2021 17:53:39 +0200 Subject: [PATCH 31/41] Update states.php change codes again --- i18n/states.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/i18n/states.php b/i18n/states.php index 83d64ba8856..641a6016758 100644 --- a/i18n/states.php +++ b/i18n/states.php @@ -1297,26 +1297,26 @@ return array( 'PL' => array(), 'PR' => array(), 'PT' => array( // Portugal states. - 'pt01' => __( 'Aveiro', 'woocommerce' ), - 'pt02' => __( 'Beja', 'woocommerce' ), - 'pt03' => __( 'Braga', 'woocommerce' ), - 'pt04' => __( 'Bragança', 'woocommerce' ), - 'pt05' => __( 'Castelo Branco', 'woocommerce' ), - 'pt06' => __( 'Coimbra', 'woocommerce' ), - 'pt07' => __( 'Évora', 'woocommerce' ), - 'pt08' => __( 'Faro', 'woocommerce' ), - 'pt09' => __( 'Guarda', 'woocommerce' ), - 'pt10' => __( 'Leiria', 'woocommerce' ), - 'pt11' => __( 'Lisbon', 'woocommerce' ), - 'pt12' => __( 'Portalegre', 'woocommerce' ), - 'pt13' => __( 'Porto', 'woocommerce' ), - 'pt14' => __( 'Santarém', 'woocommerce' ), - 'pt15' => __( 'Setúbal', 'woocommerce' ), - 'pt16' => __( 'Viana do Castelo', 'woocommerce' ), - 'pt17' => __( 'Vila Real', 'woocommerce' ), - 'pt18' => __( 'Viseu', 'woocommerce' ), - 'pt20' => __( 'Azores', 'woocommerce' ), - 'pt30' => __( 'Madeira', 'woocommerce' ), + 'PT-01' => __( 'Aveiro', 'woocommerce' ), + 'PT-02' => __( 'Beja', 'woocommerce' ), + 'PT-03' => __( 'Braga', 'woocommerce' ), + 'PT-04' => __( 'Bragança', 'woocommerce' ), + 'PT-05' => __( 'Castelo Branco', 'woocommerce' ), + 'PT-06' => __( 'Coimbra', 'woocommerce' ), + 'PT-07' => __( 'Évora', 'woocommerce' ), + 'PT-08' => __( 'Faro', 'woocommerce' ), + 'PT-09' => __( 'Guarda', 'woocommerce' ), + 'PT-10' => __( 'Leiria', 'woocommerce' ), + 'PT-11' => __( 'Lisbon', 'woocommerce' ), + 'PT-12' => __( 'Portalegre', 'woocommerce' ), + 'PT-13' => __( 'Porto', 'woocommerce' ), + 'PT-14' => __( 'Santarém', 'woocommerce' ), + 'PT-15' => __( 'Setúbal', 'woocommerce' ), + 'PT-16' => __( 'Viana do Castelo', 'woocommerce' ), + 'PT-17' => __( 'Vila Real', 'woocommerce' ), + 'PT-18' => __( 'Viseu', 'woocommerce' ), + 'PT-20' => __( 'Azores', 'woocommerce' ), + 'PT-30' => __( 'Madeira', 'woocommerce' ), ), 'PY' => array( // Paraguay states. 'PY-ASU' => __( 'Asunción', 'woocommerce' ), From d71fcfda9c580520832e8aa90eb4d46607da8f7b Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Wed, 7 Apr 2021 13:31:04 -0300 Subject: [PATCH 32/41] Update i18n/states.php --- i18n/states.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/states.php b/i18n/states.php index 641a6016758..99ee2aef131 100644 --- a/i18n/states.php +++ b/i18n/states.php @@ -1296,7 +1296,7 @@ return array( ), 'PL' => array(), 'PR' => array(), - 'PT' => array( // Portugal states. + 'PT' => array( // Portugal states. Ref: https://github.com/unicode-org/cldr/blob/release-38-1/common/subdivisions/en.xml#L4139-L4159 'PT-01' => __( 'Aveiro', 'woocommerce' ), 'PT-02' => __( 'Beja', 'woocommerce' ), 'PT-03' => __( 'Braga', 'woocommerce' ), From 1affe03ac675add8a79e8df7ffb5cb365e124253 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Wed, 7 Apr 2021 17:25:26 -0300 Subject: [PATCH 33/41] add conditions for github actions and open issues --- .github/workflows/update-feedback-labels.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-feedback-labels.yml b/.github/workflows/update-feedback-labels.yml index db89fdc3737..b353c28032d 100644 --- a/.github/workflows/update-feedback-labels.yml +++ b/.github/workflows/update-feedback-labels.yml @@ -3,7 +3,11 @@ on: 'issue_comment' jobs: feedback: - if: github.event.issue && contains(github.event.issue.labels.*.name, 'needs feedback') + if: | + github.actor != 'github-actions' && + github.event.issue && + github.event.issue.state == 'open' && + contains(github.event.issue.labels.*.name, 'needs feedback') runs-on: ubuntu-latest steps: - name: Add has feedback From 568e1e4f940e4d390fdd7e89ca9b70cdbaba43f4 Mon Sep 17 00:00:00 2001 From: Barry Hughes <3594411+barryhughes@users.noreply.github.com> Date: Wed, 7 Apr 2021 14:11:08 -0700 Subject: [PATCH 34/41] Add `@since` tag --- includes/class-wc-customer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/class-wc-customer.php b/includes/class-wc-customer.php index ef476d5f0e9..da549f99907 100644 --- a/includes/class-wc-customer.php +++ b/includes/class-wc-customer.php @@ -248,6 +248,8 @@ class WC_Customer extends WC_Legacy_Customer { * Note that this does not indicate if the customer's shipping address * is complete, only that one or more fields are populated. * + * @since 5.3.0 + * * @return bool */ public function has_shipping_address() { From 1cf6b9d39e7a74cb8da748731785f5dae3edec72 Mon Sep 17 00:00:00 2001 From: Nestor Soriano Date: Thu, 8 Apr 2021 09:31:51 +0200 Subject: [PATCH 35/41] Extra check for not showing the "WooCommerce Setup" widget in dashboard if WC Admin is disabled --- includes/admin/class-wc-admin-dashboard.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/admin/class-wc-admin-dashboard.php b/includes/admin/class-wc-admin-dashboard.php index 498eeee78ae..6357b46e8bd 100644 --- a/includes/admin/class-wc-admin-dashboard.php +++ b/includes/admin/class-wc-admin-dashboard.php @@ -63,6 +63,10 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) : * @return bool */ private function should_display_widget() { + if ( ! WC()->is_wc_admin_active() ) { + return false; + } + $has_permission = current_user_can( 'view_woocommerce_reports' ) || current_user_can( 'manage_woocommerce' ) || current_user_can( 'publish_shop_orders' ); $task_completed_or_hidden = 'yes' === get_option( 'woocommerce_task_list_complete' ) || 'yes' === get_option( 'woocommerce_task_list_hidden' ); return $task_completed_or_hidden && $has_permission; @@ -127,11 +131,11 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) : $reports = new WC_Admin_Report(); - $net_sales_link = 'admin.php?page=wc-reports&tab=orders&range=month'; + $net_sales_link = 'admin.php?page=wc-reports&tab=orders&range=month'; $top_seller_link = 'admin.php?page=wc-reports&tab=orders&report=sales_by_product&range=month&product_ids='; - $report_data = $is_wc_admin_disabled ? $this->get_sales_report_data() : $this->get_wc_admin_performance_data(); + $report_data = $is_wc_admin_disabled ? $this->get_sales_report_data() : $this->get_wc_admin_performance_data(); if ( ! $is_wc_admin_disabled ) { - $net_sales_link = 'admin.php?page=wc-admin&path=%2Fanalytics%2Frevenue&chart=net_revenue&orderby=net_revenue&period=month&compare=previous_period'; + $net_sales_link = 'admin.php?page=wc-admin&path=%2Fanalytics%2Frevenue&chart=net_revenue&orderby=net_revenue&period=month&compare=previous_period'; $top_seller_link = 'admin.php?page=wc-admin&filter=single_product&path=%2Fanalytics%2Fproducts&products='; } From 56d44cf989bb0835c665f851d9c19deb0611aa92 Mon Sep 17 00:00:00 2001 From: Nestor Soriano Date: Thu, 8 Apr 2021 16:16:50 +0200 Subject: [PATCH 36/41] Collapse changelogs for 5.2 beta and rc, add last minute entries --- changelog.txt | 42 +++++++++++++++--------------------------- readme.txt | 44 ++++++++++++++++---------------------------- 2 files changed, 31 insertions(+), 55 deletions(-) diff --git a/changelog.txt b/changelog.txt index d238a589df6..2a359f0798b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,33 +1,9 @@ == Changelog == -= 5.2.0 RC 2 2021-04-06 = += 5.2.0 2021-04-13 = **WooCommerce** -* Update - WooCommerce Admin package 2.1.5. #29577 - -**WooCommerce Admin - 2.1.5** - -* Tweak - Set international country feature flag off - -= 5.2.0 RC 2021-03-30 = - -**WooCommerce** - -* Update - WooCommerce Admin package 2.1.4. #29520 -* Fix - Don't remove existing coupons from order when an invalid REST API request for updating coupons is submitted. #29474 -* Fix - Wrong logic for including or excluding the payments step in the list of completed tasks in the onboarding wizard. #29518 - -**WooCommerce Admin - 2.1.4** - -* Fix - Adding New Zealand and Ireland to selective bundle option, previously missed. #6649 - -= 5.2.0 beta 2021-03-23 = - -**WooCommerce** - -* Update - WooCommerce Blocks package 4.7.0. #29406 -* Update - WooCommerce Admin package 2.1.3. #29283 * Add - Filter woocommerce_product_recount_terms to allow/prevent recounting of product terms. #29281 * Add - Result return array to the checkout_place_order_success callback to allow 3rd party to manipulate results. #29232 * Dev - Fix miscellaneous typos in docblocks. #29285 @@ -66,11 +42,21 @@ * Fix - Invalid refund amount error on $0 refund when number of decimals is equal to 0. #27277 * Fix - "Sale" badge misaligned on products when displaying 1 item per row. #29425 * Fix - Revert a replacement of wp_redirect to wp_safe_redirect in WC_Checkout::process_order_payment that caused issues in the default PayPal interface. #29459 +* Fix - Don't remove existing coupons from order when an invalid REST API request for updating coupons is submitted. #29474 +* Fix - Wrong logic for including or excluding the payments step in the list of completed tasks in the onboarding wizard. #29518 +* Fix - Error when loading the admin dashboard while the admin package was disabled. #29613 +* Fix - "'' is not a valid country code" error when no billing/shipping country specified (e.g. when using PayPal checkout). #29606 +* Fix - Sanitize tax class and display errors in admin while creating tax classes. +* Fix - Check if a verified product owner is required before placing a review. +* Fix - Make product name escaping consistent in the front-end. * Tweak - Added the Mercado Pago logo into the assets/images folder in order to use it in the payments setup task. #29365 * Tweak - Update the contributor guidelines. #29150 * Tweak - Introduced phone number input validation. #27242 +* Tweak - Escape short description. +* Update - WooCommerce Admin package 2.1.5. #29577 +* Update - WooCommerce Blocks package 4.7.0. #29406 -**WooCommerce Admin - 2.1.0 & 2.1.1 & 2.1.2 & 2.1.3** +**WooCommerce Admin - 2.1.0 & 2.1.1 & 2.1.2 & 2.1.3 & 2.1.4 & 2.1.5** * Add - Add navigation intro modal. #6367 * Add - CES track settings tab on updating settings #6368 @@ -97,6 +83,7 @@ * Fix - Add check for navigating being enabled. #6462 * Fix - Add customer name column to CSV export #6556 * Fix - Add guard to "Deactivate Plugin" note handlers to prevent fatal error. #6532 +* Fix - Adding New Zealand and Ireland to selective bundle option, previously missed. #6649 * Fix - Broken link anchors to online documentation. #6455 * Fix - Check if tax was successfully added before displaying notice #6229 * Fix - Correct a bug where the JP connection flow would not happen when installing JP in the OBW. #6521 @@ -120,11 +107,12 @@ * Tweak - New Settings: Turn off in dev mode #6348 * Tweak - Order and styles updates to nav footer #6373 * Tweak - Remove categories without menu items #6329 +* Tweak - Set international country feature flag off * Tweak - Set `is_deleted` from the database when instantiating a `Note` #6322 * Tweak - Update inline documentation for navigation Screen class #6173 * Tweak - Updates to copy and punctuation to be more conversational and consistent. #6298 -**WooCommerce Blocks - 4.5.0 & 4.6.0 & 4.7.0** +**WooCommerce Blocks - 4.5.0 & 4.6.0 & 4.7.0 & 4.7.1** * Enhancement - Login links on the checkout should use the account page. ([3844](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3844)) * Enhancement - Prevent checkout linking to trashed terms and policy pages. ([3843](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3843)) diff --git a/readme.txt b/readme.txt index 36501242837..f0f79180a2f 100644 --- a/readme.txt +++ b/readme.txt @@ -160,34 +160,10 @@ WooCommerce comes with some sample data you can use to see how products look; im == Changelog == -= 5.2.0 RC 2 2021-04-06 = += 5.2.0 2021-04-13 = **WooCommerce** -* Update - WooCommerce Admin package 2.1.5. #29577 - -**WooCommerce Admin - 2.1.5** - -* Tweak - Set international country feature flag off - -= 5.2.0 RC 2021-03-30 = - -**WooCommerce** - -* Update - WooCommerce Admin package 2.1.4. #29520 -* Fix - Don't remove existing coupons from order when an invalid REST API request for updating coupons is submitted. #29474 -* Fix - Wrong logic for including or excluding the payments step in the list of completed tasks in the onboarding wizard. #29518 - -**WooCommerce Admin - 2.1.4** - -* Fix - Adding New Zealand and Ireland to selective bundle option, previously missed. #6649 - -= 5.2.0 beta 2021-03-23 = - -**WooCommerce** - -* Update - WooCommerce Blocks package 4.7.0. #29406 -* Update - WooCommerce Admin package 2.1.3. #29283 * Add - Filter woocommerce_product_recount_terms to allow/prevent recounting of product terms. #29281 * Add - Result return array to the checkout_place_order_success callback to allow 3rd party to manipulate results. #29232 * Dev - Fix miscellaneous typos in docblocks. #29285 @@ -224,13 +200,23 @@ WooCommerce comes with some sample data you can use to see how products look; im * Fix - add validation of the posted country codes on checkout. #28849 * Fix - Correctly display pagination arrows on RTL languages. #28523 * Fix - Invalid refund amount error on $0 refund when number of decimals is equal to 0. #27277 -* Fix - Revert a replacement of wp_redirect to wp_safe_redirect in WC_Checkout::process_order_payment that caused issues in the default PayPal interface. #29459 * Fix - "Sale" badge misaligned on products when displaying 1 item per row. #29425 +* Fix - Revert a replacement of wp_redirect to wp_safe_redirect in WC_Checkout::process_order_payment that caused issues in the default PayPal interface. #29459 +* Fix - Don't remove existing coupons from order when an invalid REST API request for updating coupons is submitted. #29474 +* Fix - Wrong logic for including or excluding the payments step in the list of completed tasks in the onboarding wizard. #29518 +* Fix - Error when loading the admin dashboard while the admin package was disabled. #29613 +* Fix - "'' is not a valid country code" error when no billing/shipping country specified (e.g. when using PayPal checkout). #29606 +* Fix - Sanitize tax class and display errors in admin while creating tax classes. +* Fix - Check if a verified product owner is required before placing a review. +* Fix - Make product name escaping consistent in the front-end. * Tweak - Added the Mercado Pago logo into the assets/images folder in order to use it in the payments setup task. #29365 * Tweak - Update the contributor guidelines. #29150 * Tweak - Introduced phone number input validation. #27242 +* Tweak - Escape short description. +* Update - WooCommerce Admin package 2.1.5. #29577 +* Update - WooCommerce Blocks package 4.7.0. #29406 -**WooCommerce Admin - 2.1.0 & 2.1.1 & 2.1.2 & 2.1.3** +**WooCommerce Admin - 2.1.0 & 2.1.1 & 2.1.2 & 2.1.3 & 2.1.4 & 2.1.5** * Add - Add navigation intro modal. #6367 * Add - CES track settings tab on updating settings #6368 @@ -257,6 +243,7 @@ WooCommerce comes with some sample data you can use to see how products look; im * Fix - Add check for navigating being enabled. #6462 * Fix - Add customer name column to CSV export #6556 * Fix - Add guard to "Deactivate Plugin" note handlers to prevent fatal error. #6532 +* Fix - Adding New Zealand and Ireland to selective bundle option, previously missed. #6649 * Fix - Broken link anchors to online documentation. #6455 * Fix - Check if tax was successfully added before displaying notice #6229 * Fix - Correct a bug where the JP connection flow would not happen when installing JP in the OBW. #6521 @@ -280,11 +267,12 @@ WooCommerce comes with some sample data you can use to see how products look; im * Tweak - New Settings: Turn off in dev mode #6348 * Tweak - Order and styles updates to nav footer #6373 * Tweak - Remove categories without menu items #6329 +* Tweak - Set international country feature flag off * Tweak - Set `is_deleted` from the database when instantiating a `Note` #6322 * Tweak - Update inline documentation for navigation Screen class #6173 * Tweak - Updates to copy and punctuation to be more conversational and consistent. #6298 -**WooCommerce Blocks - 4.5.0 & 4.6.0 & 4.7.0** +**WooCommerce Blocks - 4.5.0 & 4.6.0 & 4.7.0 & 4.7.1** * Enhancement - Login links on the checkout should use the account page. ([3844](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3844)) * Enhancement - Prevent checkout linking to trashed terms and policy pages. ([3843](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3843)) From dddfe437f9c3d1e32db5f255a7c743cc70171d69 Mon Sep 17 00:00:00 2001 From: Nestor Soriano Date: Thu, 8 Apr 2021 16:18:03 +0200 Subject: [PATCH 37/41] Change stable tag in readme.txt to 5.2 --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index f0f79180a2f..050e4982b02 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: e-commerce, store, sales, sell, woo, shop, cart, checkout, downloadable, d Requires at least: 5.5 Tested up to: 5.7 Requires PHP: 7.0 -Stable tag: 5.1.0 +Stable tag: 5.2.0 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html From fc14a4e5daeabbd8a6c3c4cfa4655c3d1b5438d0 Mon Sep 17 00:00:00 2001 From: Veljko Date: Thu, 8 Apr 2021 17:20:03 +0200 Subject: [PATCH 38/41] Add missing beforeAll code --- .../specs/merchant/wp-admin-product-import-csv.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index e9008325e9e..96ddd8d2566 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -14,7 +14,8 @@ const getCoreTestsRoot = require( '../../core-tests-root' ); */ const { it, - describe + describe, + beforeAll, } = require( '@jest/globals' ); const path = require( 'path' ); From bc40163155a9eb23be957caadb8cc5d5b50cc0e4 Mon Sep 17 00:00:00 2001 From: Veljko Date: Thu, 8 Apr 2021 19:01:54 +0200 Subject: [PATCH 39/41] Make the test more granular --- .../merchant/wp-admin-product-import-csv.test.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index 96ddd8d2566..82754441c43 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -40,15 +40,16 @@ const runImportProductsTest = () => { beforeAll(async () => { await merchant.login(); await merchant.openAllProductsView(); - }); - it('can upload the CSV file and import products', async () => { await merchant.openImportProducts(); - - // Verify error message if you go withot provided CSV file + }); + it('should show error message if you go without providing CSV file', async () => { + // Verify error message if you go without providing CSV file await expect(page).toClick('button[value="Continue"]'); await page.waitForSelector('div.error'); await expect(page).toMatchElement('div.error > p', errorMessage); + }); + it('can upload the CSV file and import products', async () => { // Put the CSV products file and proceed further const uploader = await page.$("input[type=file]"); await uploader.uploadFile(filePath); @@ -62,7 +63,9 @@ const runImportProductsTest = () => { await page.waitForSelector('section.woocommerce-importer-done', {visible:true, timeout: 60000}); await page.waitForSelector('.woocommerce-importer-done'); await expect(page).toMatchElement('.woocommerce-importer-done', {text: 'Import complete!'}); + }); + it('can see and verify the uploaded products', async () => { // Click on view products await page.waitForSelector('div.wc-actions > a.button.button-primary'); await expect(page).toClick('div.wc-actions > a.button.button-primary'); @@ -70,7 +73,7 @@ const runImportProductsTest = () => { // Gathering product names await page.waitForSelector('a.row-title'); const productTitles = await page.$$eval('a.row-title', - elements => elements.map(item => item.innerHTML)); + elements => elements.map(item => item.innerHTML)); // Compare imported product names expect(productTitles.sort()).toEqual(productNames.sort()); @@ -93,7 +96,9 @@ const runImportProductsTest = () => { await page.waitForSelector('section.woocommerce-importer-done', {visible:true, timeout: 60000}); await page.waitForSelector('.woocommerce-importer-done'); await expect(page).toMatchElement('.woocommerce-importer-done', {text: 'Import complete!'}); + }); + it('can see and verify the uploaded overrode products', async () => { // Click on view products await page.waitForSelector('div.wc-actions > a.button.button-primary'); await expect(page).toClick('div.wc-actions > a.button.button-primary'); @@ -116,6 +121,7 @@ const runImportProductsTest = () => { // Move all imported products to trash await moveAllItemsToTrash(); + }); }); }; From 91a184dc77720506eb7d5ff1478147e3b71d33d3 Mon Sep 17 00:00:00 2001 From: raicem Date: Fri, 9 Apr 2021 09:39:49 +0300 Subject: [PATCH 40/41] Make the call to "wc_downloadable_file_permission" with the right product id With the PR #23188, "$product_id" variable become undefined. --- includes/class-wc-ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-ajax.php b/includes/class-wc-ajax.php index 10e27e7e2f4..b35d97d6590 100644 --- a/includes/class-wc-ajax.php +++ b/includes/class-wc-ajax.php @@ -810,7 +810,7 @@ class WC_AJAX { if ( ! empty( $files ) ) { foreach ( $files as $download_id => $file ) { - $inserted_id = wc_downloadable_file_permission( $download_id, $product_id, $order, $item->get_quantity(), $item ); + $inserted_id = wc_downloadable_file_permission( $download_id, $product->get_id(), $order, $item->get_quantity(), $item ); if ( $inserted_id ) { $download = new WC_Customer_Download( $inserted_id ); $loop ++; From bdd9fe7318264c12568d07ba0cbfffd7c757afdc Mon Sep 17 00:00:00 2001 From: Veljko Date: Fri, 9 Apr 2021 11:48:17 +0200 Subject: [PATCH 41/41] Add waitForNavigation on Continue clicking --- .../specs/merchant/wp-admin-product-import-csv.test.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js index 82754441c43..d3cb10e1b94 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-product-import-csv.test.js @@ -43,8 +43,11 @@ const runImportProductsTest = () => { await merchant.openImportProducts(); }); it('should show error message if you go without providing CSV file', async () => { - // Verify error message if you go without providing CSV file - await expect(page).toClick('button[value="Continue"]'); + // Verify the error message if you go without providing CSV file + await Promise.all( [ + page.click( 'button[value="Continue"]' ), + page.waitForNavigation( { waitUntil: 'networkidle0' } ), + ]); await page.waitForSelector('div.error'); await expect(page).toMatchElement('div.error > p', errorMessage); });