From 3099f672cb6645ed6202b62c0f8f3837265e95d4 Mon Sep 17 00:00:00 2001 From: James Allan Date: Mon, 24 May 2021 09:36:07 +1000 Subject: [PATCH 01/41] No longer load PayPal Standard on new installs --- includes/class-wc-payment-gateways.php | 16 +++++++- .../paypal/class-wc-gateway-paypal.php | 38 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-payment-gateways.php b/includes/class-wc-payment-gateways.php index c6114ef68c7..04520322ee0 100644 --- a/includes/class-wc-payment-gateways.php +++ b/includes/class-wc-payment-gateways.php @@ -78,9 +78,12 @@ class WC_Payment_Gateways { 'WC_Gateway_BACS', 'WC_Gateway_Cheque', 'WC_Gateway_COD', - 'WC_Gateway_Paypal', ); + if ( $this->should_load_paypal_standard() ) { + $load_gateways[] = 'WC_Gateway_Paypal'; + } + // Filter. $load_gateways = apply_filters( 'woocommerce_payment_gateways', $load_gateways ); @@ -219,4 +222,15 @@ class WC_Payment_Gateways { update_option( 'woocommerce_gateway_order', $order ); } + + /** + * Determines if PayPal Standard should be loaded. + * + * @since 5.5.0 + * @return bool Whether PayPal Standard should be loaded or not. + */ + protected function should_load_paypal_standard() { + $paypal = new WC_Gateway_Paypal(); + return $paypal->should_load(); + } } diff --git a/includes/gateways/paypal/class-wc-gateway-paypal.php b/includes/gateways/paypal/class-wc-gateway-paypal.php index 68a8095ad22..e6390151214 100644 --- a/includes/gateways/paypal/class-wc-gateway-paypal.php +++ b/includes/gateways/paypal/class-wc-gateway-paypal.php @@ -473,4 +473,42 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway { return $text; } + + /** + * Determines whether PayPal Standard should be loaded or not. + * + * By default PayPal Standard isn't loaded on new installs or on existing sites which haven't set up the gateway. + * + * @since 5.5.0 + * + * @return bool Whether PayPal Standard should be loaded. + */ + public function should_load() { + $option_key = '_should_load'; + $should_load = $this->get_option( $option_key ); + + if ( '' === $should_load ) { + + // New installs without PayPal Standard enabled don't load it. + if ( 'no' === $this->enabled && WC_Install::is_new_install() ) { + $should_load = false; + } else { + $should_load = true; + } + + $this->update_option( $option_key, wc_bool_to_string( $should_load ) ); + } else { + $should_load = wc_string_to_bool( $should_load ); + } + + /** + * Allow third-parties to filter whether PayPal Standard should be loaded or not. + * + * @since 5.5.0 + * + * @param bool $should_load Whether PayPal Standard should be loaded. + * @param WC_Gateway_Paypal $this The WC_Gateway_Paypal instance. + */ + return apply_filters( 'woocommerce_should_load_paypal_standard', $should_load, $this ); + } } From 7f4f165cc0ae5aabb6e6be2b8c6816cc5f019370 Mon Sep 17 00:00:00 2001 From: James Allan Date: Mon, 24 May 2021 09:38:38 +1000 Subject: [PATCH 02/41] Set the PayPal load flag on install --- includes/class-wc-install.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/includes/class-wc-install.php b/includes/class-wc-install.php index c4eddfa86c2..4ad4e557b2f 100644 --- a/includes/class-wc-install.php +++ b/includes/class-wc-install.php @@ -310,6 +310,7 @@ class WC_Install { self::create_files(); self::maybe_create_pages(); self::maybe_set_activation_transients(); + self::set_paypal_standard_load_eligibility(); self::update_wc_version(); self::maybe_update_db_version(); @@ -1622,6 +1623,16 @@ CREATE TABLE {$wpdb->prefix}wc_reserved_stock ( ob_end_clean(); } } + + /** + * Sets whether PayPal Standard will be loaded on install. + * + * @since 5.5.0 + */ + private static function set_paypal_standard_load_eligibility() { + // Initiating the payment gateways sets the flag. + WC()->payment_gateways(); + } } WC_Install::init(); From ed3c76bd1debcc1c463417d7fa90ca1f7bb4668b Mon Sep 17 00:00:00 2001 From: James Allan Date: Mon, 24 May 2021 11:26:49 +1000 Subject: [PATCH 03/41] Load PayPal Standard in unit tests --- tests/legacy/bootstrap.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/legacy/bootstrap.php b/tests/legacy/bootstrap.php index bfbcd11edeb..dbab8509f5c 100644 --- a/tests/legacy/bootstrap.php +++ b/tests/legacy/bootstrap.php @@ -58,6 +58,9 @@ class WC_Unit_Tests_Bootstrap { // load test function so tests_add_filter() is available. require_once $this->wp_tests_dir . '/includes/functions.php'; + // Always load PayPal Standard for unit tests. + tests_add_filter( 'woocommerce_should_load_paypal_standard', '__return_true' ); + // load WC. tests_add_filter( 'muplugins_loaded', array( $this, 'load_wc' ) ); From ddef1d8d95f3d05cb8d46a28583a2d244d7c3128 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Tue, 1 Jun 2021 20:03:25 +0800 Subject: [PATCH 04/41] updated property names to match those in API documentation --- tests/e2e/config/default.json | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/e2e/config/default.json b/tests/e2e/config/default.json index adb8538915e..09ade6121aa 100644 --- a/tests/e2e/config/default.json +++ b/tests/e2e/config/default.json @@ -16,6 +16,7 @@ }, "variable": { "name": "Variable Product with Three Attributes", + "type": "variable", "defaultAttributes": [ { "id": 0, @@ -32,8 +33,8 @@ { "id": 0, "name": "Colour", - "isVisibleOnProductPage": true, - "isForVariations": true, + "visible": true, + "variation": true, "options": [ "Red", "Green", @@ -44,8 +45,8 @@ { "id": 0, "name": "Size", - "isVisibleOnProductPage": true, - "isForVariations": true, + "visible": true, + "variation": true, "options": [ "Small", "Medium", @@ -56,8 +57,8 @@ { "id": 0, "name": "Logo", - "isVisibleOnProductPage": true, - "isForVariations": true, + "visible": true, + "variation": true, "options": [ "Woo", "WordPress" From a028973279ce19eb4b0e5e47ddaa236959a6f298 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Tue, 1 Jun 2021 20:04:04 +0800 Subject: [PATCH 05/41] Use api to create variable product --- tests/e2e/utils/src/components.js | 139 +++--------------------------- 1 file changed, 12 insertions(+), 127 deletions(-) diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index c5e3daf7f51..f173e9fff0f 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -18,13 +18,14 @@ import { waitForSelectorWithoutThrow, } from './page-utils'; import factories from './factories'; -import { Coupon } from '@woocommerce/api'; +import { Coupon, VariableProduct, ProductVariation } from '@woocommerce/api'; const client = factories.api.withDefaultPermalinks; const config = require( 'config' ); const simpleProductName = config.get( 'products.simple.name' ); const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99'; + /** * Verify and publish * @@ -222,135 +223,19 @@ const createSimpleProductWithCategory = async ( productName, productPrice, categ * Create variable product. */ const createVariableProduct = async () => { + // Create a Variable Product (no variations yet) + const defaultVariableProduct = config.get( 'products.variable' ); + const variableProductRepo = VariableProduct.restRepository( client ); + const variableProduct = await variableProductRepo.create( defaultVariableProduct ); - // We need to remove any listeners on the `dialog` event otherwise we can't catch the dialogs below - page.removeAllListeners('dialog'); - - // Go to "add product" page - await merchant.openNewProduct(); - - // Make sure we're on the add product page - await expect( page.title() ).resolves.toMatch( 'Add new product' ); - - // Set product data - await expect( page ).toFill( '#title', 'Variable Product with Three Variations' ); - await expect( page ).toSelect( '#product-type', 'Variable product' ); - - // Create attributes for variations - await clickTab( 'Attributes' ); - await expect( page ).toSelect( 'select[name="attribute_taxonomy"]', 'Custom product attribute' ); - - for ( let i = 0; i < 3; i++ ) { - await expect( page ).toClick( 'button.add_attribute', { text: 'Add' } ); - // Wait for attribute form to load - await uiUnblocked(); - - await page.focus( `input[name="attribute_names[${ i }]"]` ); - await expect( page ).toFill( `input[name="attribute_names[${ i }]"]`, 'attr #' + ( i + 1 ) ); - await expect( page ).toFill( `textarea[name="attribute_values[${ i }]"]`, 'val1 | val2' ); - await expect( page ).toClick( `input[name="attribute_variation[${ i }]"]` ); + // Create Variations + const defaultVariations = config.get( 'products.variations' ); + const variationsRepo = ProductVariation.restRepository( client ); + for( const variation of defaultVariations ){ + await variationsRepo.create( variableProduct.id, variation ); } - await expect( page ).toClick( 'button', { text: 'Save attributes' } ); - - // Wait for attribute form to save (triggers 2 UI blocks) - await uiUnblocked(); - await page.waitFor( 1000 ); - await uiUnblocked(); - - // Create variations from attributes - await clickTab( 'Variations' ); - await page.waitForSelector( 'select.variation_actions:not([disabled])' ); - await page.focus( 'select.variation_actions' ); - await expect( page ).toSelect( 'select.variation_actions', 'Create variations from all attributes' ); - - const firstDialog = await expect( page ).toDisplayDialog( async () => { - // Using this technique since toClick() isn't working. - // See: https://github.com/GoogleChrome/puppeteer/issues/1805#issuecomment-464802876 - page.$eval( 'a.do_variation_action', elem => elem.click() ); - - } ); - - expect( firstDialog.message() ).toMatch( 'Are you sure you want to link all variations?' ); - - const secondDialog = await expect( page ).toDisplayDialog( async () => { - await firstDialog.accept(); - } ); - - expect( secondDialog.message() ).toMatch( '8 variations added' ); - await secondDialog.dismiss(); - - // Set some variation data - await uiUnblocked(); - await uiUnblocked(); - - await page.waitForSelector( '.woocommerce_variation .handlediv' ); - - // Verify that variations were created - await Promise.all( [ - expect( page ).toMatchElement( 'select[name="attribute_attr-1[0]"]', { text: 'val1' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-2[0]"]', { text: 'val1' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-3[0]"]', { text: 'val1' } ), - - expect( page ).toMatchElement( 'select[name="attribute_attr-1[1]"]', { text: 'val1' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-2[1]"]', { text: 'val1' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-3[1]"]', { text: 'val2' } ), - - expect( page ).toMatchElement( 'select[name="attribute_attr-1[2]"]', { text: 'val1' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-2[2]"]', { text: 'val2' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-3[2]"]', { text: 'val1' } ), - - expect( page ).toMatchElement( 'select[name="attribute_attr-1[3]"]', { text: 'val1' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-2[3]"]', { text: 'val2' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-3[3]"]', { text: 'val2' } ), - - expect( page ).toMatchElement( 'select[name="attribute_attr-1[4]"]', { text: 'val2' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-2[4]"]', { text: 'val1' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-3[4]"]', { text: 'val1' } ), - - expect( page ).toMatchElement( 'select[name="attribute_attr-1[5]"]', { text: 'val2' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-2[5]"]', { text: 'val1' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-3[5]"]', { text: 'val2' } ), - - expect( page ).toMatchElement( 'select[name="attribute_attr-1[6]"]', { text: 'val2' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-2[6]"]', { text: 'val2' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-3[6]"]', { text: 'val1' } ), - - expect( page ).toMatchElement( 'select[name="attribute_attr-1[7]"]', { text: 'val2' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-2[7]"]', { text: 'val2' } ), - expect( page ).toMatchElement( 'select[name="attribute_attr-3[7]"]', { text: 'val2' } ), - ] ); - - await expect( page ).toClick( '.woocommerce_variation:nth-of-type(2) .handlediv' ); - await page.waitFor( 2000 ); - await page.focus( 'input[name="variable_is_virtual[0]"]' ); - await expect( page ).toClick( 'input[name="variable_is_virtual[0]"]' ); - await expect( page ).toFill( 'input[name="variable_regular_price[0]"]', '9.99' ); - - await expect( page ).toClick( '.woocommerce_variation:nth-of-type(3) .handlediv' ); - await page.waitFor( 2000 ); - await page.focus( 'input[name="variable_is_virtual[1]"]' ); - await expect( page ).toClick( 'input[name="variable_is_virtual[1]"]' ); - await expect( page ).toFill( 'input[name="variable_regular_price[1]"]', '11.99' ); - - await expect( page ).toClick( '.woocommerce_variation:nth-of-type(4) .handlediv' ); - await page.waitFor( 2000 ); - await page.focus( 'input[name="variable_manage_stock[2]"]' ); - await expect( page ).toClick( 'input[name="variable_manage_stock[2]"]' ); - await expect( page ).toFill( 'input[name="variable_regular_price[2]"]', '20' ); - await expect( page ).toFill( 'input[name="variable_weight[2]"]', '200' ); - await expect( page ).toFill( 'input[name="variable_length[2]"]', '10' ); - await expect( page ).toFill( 'input[name="variable_width[2]"]', '20' ); - await expect( page ).toFill( 'input[name="variable_height[2]"]', '15' ); - - await page.focus( 'button.save-variation-changes' ); - await expect( page ).toClick( 'button.save-variation-changes', { text: 'Save changes' } ); - - await verifyAndPublish( 'Product published.' ); - - const variablePostId = await page.$( '#post_ID' ); - let variablePostIdValue = ( await ( await variablePostId.getProperty( 'value' ) ).jsonValue() ); - return variablePostIdValue; + return variableProduct.id; }; /** From 2276f70fd2ab7cb4344c217615336c5698c04ed6 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Tue, 1 Jun 2021 20:06:00 +0800 Subject: [PATCH 06/41] Remove merchant login & logout steps surrounding createVariableProduct() --- .../core-tests/specs/shopper/front-end-single-product.test.js | 2 -- .../specs/shopper/front-end-variable-product-updates.test.js | 2 -- 2 files changed, 4 deletions(-) diff --git a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js index 8d6fc05e9bd..caf44c49945 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js @@ -45,9 +45,7 @@ const runSingleProductPageTest = () => { describe.skip('Variable Product Page', () => { beforeAll(async () => { - await merchant.login(); variablePostIdValue = await createVariableProduct(); - await merchant.logout(); }); it('should be able to add variation products to the cart', async () => { diff --git a/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js b/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js index 2cce3fd22b1..64a201e04fc 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js @@ -15,9 +15,7 @@ const cartDialogMessage = 'Please select some product options before adding this const runVariableProductUpdateTest = () => { describe('Shopper > Update variable product',() => { beforeAll(async () => { - await merchant.login(); variablePostIdValue = await createVariableProduct(); - await merchant.logout(); }); it('shopper can change variable attributes to the same value', async () => { From ee50c0d4b284ffdc2fc325d1e4cce835da999a4f Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Wed, 2 Jun 2021 16:43:55 +0800 Subject: [PATCH 07/41] Return variable product object from response --- tests/e2e/utils/src/components.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index f173e9fff0f..fc662bbe1f3 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -223,19 +223,19 @@ const createSimpleProductWithCategory = async ( productName, productPrice, categ * Create variable product. */ const createVariableProduct = async () => { - // Create a Variable Product (no variations yet) + // Create a variable product with attributes (no variations yet) const defaultVariableProduct = config.get( 'products.variable' ); const variableProductRepo = VariableProduct.restRepository( client ); const variableProduct = await variableProductRepo.create( defaultVariableProduct ); - // Create Variations + // Create variations for this product const defaultVariations = config.get( 'products.variations' ); const variationsRepo = ProductVariation.restRepository( client ); for( const variation of defaultVariations ){ await variationsRepo.create( variableProduct.id, variation ); } - return variableProduct.id; + return variableProduct; }; /** From c46a30be8ce4b81b15043e1bc5312c510943cba9 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Wed, 2 Jun 2021 18:43:38 +0800 Subject: [PATCH 08/41] Added logo attribute to variation --- tests/e2e/config/default.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/e2e/config/default.json b/tests/e2e/config/default.json index 09ade6121aa..682d09cc86d 100644 --- a/tests/e2e/config/default.json +++ b/tests/e2e/config/default.json @@ -78,6 +78,10 @@ { "name": "Colour", "option": "Red" + }, + { + "name": "Logo", + "option": "Woo" } ] }, @@ -91,6 +95,10 @@ { "name": "Colour", "option": "Green" + }, + { + "name": "Logo", + "option": "Woo" } ] }, @@ -104,6 +112,10 @@ { "name": "Colour", "option": "Blue" + }, + { + "name": "Logo", + "option": "Woo" } ] } From f616645f7b30afe52799eab50769ce65d6226071 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Wed, 2 Jun 2021 18:45:20 +0800 Subject: [PATCH 09/41] Select attributes based on what's written in default.json --- .../shopper/front-end-single-product.test.js | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js index caf44c49945..3e2ca448125 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js @@ -11,12 +11,20 @@ const { uiUnblocked } = require( '@woocommerce/e2e-utils' ); -let simplePostIdValue; -let variablePostIdValue; -let groupedPostIdValue; const config = require( 'config' ); + +// Variables for simple product +let simplePostIdValue; const simpleProductName = config.get( 'products.simple.name' ); +// Variables for variable product +let variableProduct; +const variations = config.get( 'products.variations' ); +const attributes = variations[0].attributes; + +// Variables for grouped product +let groupedPostIdValue; + const runSingleProductPageTest = () => { describe('Single Product Page', () => { beforeAll(async () => { @@ -43,28 +51,33 @@ const runSingleProductPageTest = () => { }); }); - describe.skip('Variable Product Page', () => { + describe('Variable Product Page', () => { beforeAll(async () => { - variablePostIdValue = await createVariableProduct(); + variableProduct = await createVariableProduct(); }); it('should be able to add variation products to the cart', async () => { // Add a product with one set of variations to cart - await shopper.goToProduct(variablePostIdValue); - await expect(page).toSelect('#attr-1', 'val1'); - await expect(page).toSelect('#attr-2', 'val1'); - await expect(page).toSelect('#attr-3', 'val1'); + await shopper.goToProduct( variableProduct.id ); + + for( const attr of attributes ){ + const selectElem = `#${attr.name.toLowerCase()}`; + const value = attr.option; + + await expect(page).toSelect(selectElem, value); + } + await shopper.addToCart(); await expect(page).toMatchElement('.woocommerce-message', {text: 'has been added to your cart.'}); // Verify cart contents await shopper.goToCart(); - await shopper.productIsInCart('Variable Product with Three Variations'); + await shopper.productIsInCart(variableProduct.name); }); it('should be able to remove variation products from the cart', async () => { // Remove items from cart - await shopper.removeFromCart('Variable Product with Three Variations'); + await shopper.removeFromCart(variableProduct.name); await uiUnblocked(); await expect(page).toMatchElement('.cart-empty', {text: 'Your cart is currently empty.'}); }); From 0a6d38fc6b4fcc32c7b38d9afcf3419961d7a668 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Wed, 2 Jun 2021 18:46:12 +0800 Subject: [PATCH 10/41] TODO: use factory instead --- tests/e2e/utils/src/components.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index fc662bbe1f3..afd88c4825a 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -223,6 +223,7 @@ const createSimpleProductWithCategory = async ( productName, productPrice, categ * Create variable product. */ const createVariableProduct = async () => { + // mytodo convert to factory // Create a variable product with attributes (no variations yet) const defaultVariableProduct = config.get( 'products.variable' ); const variableProductRepo = VariableProduct.restRepository( client ); From 46b5cf880301b00ce9c885dd7e2d9ffb3278ffa0 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Wed, 2 Jun 2021 21:12:31 +0800 Subject: [PATCH 11/41] Use factories object to create variable products --- .../shopper/front-end-single-product.test.js | 13 +++++---- tests/e2e/utils/src/components.js | 22 +++++++-------- tests/e2e/utils/src/factories.js | 4 +++ .../utils/src/factories/variable-product.js | 28 +++++++++++++++++++ tests/e2e/utils/src/factories/variation.js | 28 +++++++++++++++++++ 5 files changed, 78 insertions(+), 17 deletions(-) create mode 100644 tests/e2e/utils/src/factories/variable-product.js create mode 100644 tests/e2e/utils/src/factories/variation.js diff --git a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js index 3e2ca448125..e583a5e1f84 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js @@ -14,13 +14,14 @@ const { const config = require( 'config' ); // Variables for simple product -let simplePostIdValue; const simpleProductName = config.get( 'products.simple.name' ); +let simplePostIdValue; // Variables for variable product -let variableProduct; +const variableProductName = config.get( 'products.variable.name' ); const variations = config.get( 'products.variations' ); const attributes = variations[0].attributes; +let variableProductId; // Variables for grouped product let groupedPostIdValue; @@ -53,12 +54,12 @@ const runSingleProductPageTest = () => { describe('Variable Product Page', () => { beforeAll(async () => { - variableProduct = await createVariableProduct(); + variableProductId = await createVariableProduct(); }); it('should be able to add variation products to the cart', async () => { // Add a product with one set of variations to cart - await shopper.goToProduct( variableProduct.id ); + await shopper.goToProduct( variableProductId ); for( const attr of attributes ){ const selectElem = `#${attr.name.toLowerCase()}`; @@ -72,12 +73,12 @@ const runSingleProductPageTest = () => { // Verify cart contents await shopper.goToCart(); - await shopper.productIsInCart(variableProduct.name); + await shopper.productIsInCart(variableProductName); }); it('should be able to remove variation products from the cart', async () => { // Remove items from cart - await shopper.removeFromCart(variableProduct.name); + await shopper.removeFromCart(variableProductName); await uiUnblocked(); await expect(page).toMatchElement('.cart-empty', {text: 'Your cart is currently empty.'}); }); diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index afd88c4825a..23625f25788 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -18,7 +18,8 @@ import { waitForSelectorWithoutThrow, } from './page-utils'; import factories from './factories'; -import { Coupon, VariableProduct, ProductVariation } from '@woocommerce/api'; +import { Coupon, ProductVariation } from '@woocommerce/api'; +import { variableProductFactory } from './factories/variable-product'; const client = factories.api.withDefaultPermalinks; const config = require( 'config' ); @@ -221,22 +222,21 @@ const createSimpleProductWithCategory = async ( productName, productPrice, categ /** * Create variable product. + * + * @returns the ID of the variable product */ const createVariableProduct = async () => { - // mytodo convert to factory - // Create a variable product with attributes (no variations yet) - const defaultVariableProduct = config.get( 'products.variable' ); - const variableProductRepo = VariableProduct.restRepository( client ); - const variableProduct = await variableProductRepo.create( defaultVariableProduct ); - - // Create variations for this product + const variableProduct = await factories.products.variable.create(); const defaultVariations = config.get( 'products.variations' ); - const variationsRepo = ProductVariation.restRepository( client ); + for( const variation of defaultVariations ){ - await variationsRepo.create( variableProduct.id, variation ); + await factories.products.variation.create({ + productId: variableProduct.id, + variation: variation + }); } - return variableProduct; + return variableProduct.id; }; /** diff --git a/tests/e2e/utils/src/factories.js b/tests/e2e/utils/src/factories.js index 46f3b91f948..250076b14dc 100644 --- a/tests/e2e/utils/src/factories.js +++ b/tests/e2e/utils/src/factories.js @@ -1,6 +1,8 @@ import { HTTPClientFactory } from '@woocommerce/api'; const config = require( 'config' ); import { simpleProductFactory } from './factories/simple-product'; +import { variableProductFactory } from './factories/variable-product'; +import { variationFactory } from './factories/variation'; const apiUrl = config.get( 'url' ); const adminUsername = config.get( 'users.admin.username' ); @@ -20,6 +22,8 @@ const factories = { }, products: { simple: simpleProductFactory( withDefaultPermalinks ), + variable: variableProductFactory( withDefaultPermalinks ), + variation: variationFactory( withDefaultPermalinks ) }, }; diff --git a/tests/e2e/utils/src/factories/variable-product.js b/tests/e2e/utils/src/factories/variable-product.js new file mode 100644 index 00000000000..2a17c9e80cd --- /dev/null +++ b/tests/e2e/utils/src/factories/variable-product.js @@ -0,0 +1,28 @@ +import { VariableProduct } from '@woocommerce/api'; +import { Factory } from 'fishery'; +import config from 'config'; + +/** + * Creates a new factory for creating variable products. + * This factory will create a default variable product when `create()` is called without parameters. + * + * @param {HTTPClient} httpClient The HTTP client we will give the repository. + * @return {AsyncFactory} The factory for creating models. + */ +export function variableProductFactory(httpClient) { + const repository = VariableProduct.restRepository(httpClient); + const defaultVariableProduct = config.get('products.variable'); + + return Factory.define(({ params, onCreate }) => { + onCreate((model) => { + return repository.create(model); + }); + + return { + name: params.name ?? defaultVariableProduct.name, + type: 'variable', + defaultAttributes: params.defaultAttributes ?? defaultVariableProduct.defaultAttributes, + attributes: params.attributes ?? defaultVariableProduct.attributes + }; + }); +} diff --git a/tests/e2e/utils/src/factories/variation.js b/tests/e2e/utils/src/factories/variation.js new file mode 100644 index 00000000000..0da1248fd75 --- /dev/null +++ b/tests/e2e/utils/src/factories/variation.js @@ -0,0 +1,28 @@ +import { ProductVariation } from '@woocommerce/api'; +import { Factory } from 'fishery'; +import config from 'config'; + +/** + * Creates a new factory for creating a product variation. + * + * @param {HTTPClient} httpClient The HTTP client we will give the repository. + * @return {AsyncFactory} The factory for creating models. + */ +export function variationFactory(httpClient) { + const repository = ProductVariation.restRepository(httpClient); + const defaultVariations = config.get('products.variations'); + const defaultVariation = defaultVariations[0]; + + return Factory.define(({ params, onCreate }) => { + const { productId, variation } = params; + + onCreate((model) => { + return repository.create(productId, model); + }); + + return { + regularPrice: variation.regularPrice ?? defaultVariation.regularPrice, + attributes: variation.attributes ?? defaultVariation.attributes + }; + }); +} From b4fc1737bc0d3add2cd4ec85979f8ac000ee01e2 Mon Sep 17 00:00:00 2001 From: Brian Henry Date: Wed, 2 Jun 2021 23:39:48 -0700 Subject: [PATCH 12/41] Remove functionless ABSPATH check. Checking for ABSPATH is recommended so WordPress functions are not called before WordPress has been loaded. This does not apply to interfaces. --- includes/interfaces/class-wc-logger-interface.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/includes/interfaces/class-wc-logger-interface.php b/includes/interfaces/class-wc-logger-interface.php index 726b20cfe66..78b83df0ae6 100644 --- a/includes/interfaces/class-wc-logger-interface.php +++ b/includes/interfaces/class-wc-logger-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; // Exit if accessed directly. -} - /** * WC Logger Interface * From 28c2597b0fb868fde45b7f47992a7c0e37d32438 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Thu, 3 Jun 2021 19:16:20 +0800 Subject: [PATCH 13/41] Allow customization of variable product and variations --- tests/e2e/utils/src/components.js | 16 +++++++++------- .../e2e/utils/src/factories/variable-product.js | 11 +++++------ tests/e2e/utils/src/factories/variation.js | 7 ++----- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index 23625f25788..e5c7d134887 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -25,7 +25,8 @@ const client = factories.api.withDefaultPermalinks; const config = require( 'config' ); const simpleProductName = config.get( 'products.simple.name' ); const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99'; - +const defaultVariableProduct = config.get( 'products.variable' ); +const defaultVariations = config.get( 'products.variation' ); /** * Verify and publish @@ -223,16 +224,17 @@ const createSimpleProductWithCategory = async ( productName, productPrice, categ /** * Create variable product. * - * @returns the ID of the variable product + * @param varProduct Defaults to the variable product object in `default.json` + * @param variations Defaults to the variation object in `default.json` + * @returns the ID of the created variable product */ -const createVariableProduct = async () => { - const variableProduct = await factories.products.variable.create(); - const defaultVariations = config.get( 'products.variations' ); +const createVariableProduct = async ( varProduct = defaultVariableProduct, variations = defaultVariations ) => { + const variableProduct = await factories.products.variable.create( varProduct ); - for( const variation of defaultVariations ){ + for( const v of variations ){ await factories.products.variation.create({ productId: variableProduct.id, - variation: variation + variation: v }); } diff --git a/tests/e2e/utils/src/factories/variable-product.js b/tests/e2e/utils/src/factories/variable-product.js index 2a17c9e80cd..5080dbc0422 100644 --- a/tests/e2e/utils/src/factories/variable-product.js +++ b/tests/e2e/utils/src/factories/variable-product.js @@ -1,17 +1,16 @@ import { VariableProduct } from '@woocommerce/api'; import { Factory } from 'fishery'; -import config from 'config'; /** * Creates a new factory for creating variable products. - * This factory will create a default variable product when `create()` is called without parameters. + * This does not include creating product variations. + * Instead, use `variationFactory()` for that. * * @param {HTTPClient} httpClient The HTTP client we will give the repository. * @return {AsyncFactory} The factory for creating models. */ export function variableProductFactory(httpClient) { const repository = VariableProduct.restRepository(httpClient); - const defaultVariableProduct = config.get('products.variable'); return Factory.define(({ params, onCreate }) => { onCreate((model) => { @@ -19,10 +18,10 @@ export function variableProductFactory(httpClient) { }); return { - name: params.name ?? defaultVariableProduct.name, + name: params.name, type: 'variable', - defaultAttributes: params.defaultAttributes ?? defaultVariableProduct.defaultAttributes, - attributes: params.attributes ?? defaultVariableProduct.attributes + defaultAttributes: params.defaultAttributes, + attributes: params.attributes }; }); } diff --git a/tests/e2e/utils/src/factories/variation.js b/tests/e2e/utils/src/factories/variation.js index 0da1248fd75..39c9148a0de 100644 --- a/tests/e2e/utils/src/factories/variation.js +++ b/tests/e2e/utils/src/factories/variation.js @@ -1,6 +1,5 @@ import { ProductVariation } from '@woocommerce/api'; import { Factory } from 'fishery'; -import config from 'config'; /** * Creates a new factory for creating a product variation. @@ -10,8 +9,6 @@ import config from 'config'; */ export function variationFactory(httpClient) { const repository = ProductVariation.restRepository(httpClient); - const defaultVariations = config.get('products.variations'); - const defaultVariation = defaultVariations[0]; return Factory.define(({ params, onCreate }) => { const { productId, variation } = params; @@ -21,8 +18,8 @@ export function variationFactory(httpClient) { }); return { - regularPrice: variation.regularPrice ?? defaultVariation.regularPrice, - attributes: variation.attributes ?? defaultVariation.attributes + regularPrice: variation.regularPrice, + attributes: variation.attributes }; }); } From de56309f81631e021cf3e231d4b80084e32f0241 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Thu, 3 Jun 2021 19:20:59 +0800 Subject: [PATCH 14/41] REmove unnecessary imports --- tests/e2e/utils/src/components.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index e5c7d134887..e213383c9c3 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -18,8 +18,7 @@ import { waitForSelectorWithoutThrow, } from './page-utils'; import factories from './factories'; -import { Coupon, ProductVariation } from '@woocommerce/api'; -import { variableProductFactory } from './factories/variable-product'; +import { Coupon } from '@woocommerce/api'; const client = factories.api.withDefaultPermalinks; const config = require( 'config' ); From 95c088142beec4793e52c7e78c0b1e32b7f5b7aa Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Thu, 3 Jun 2021 20:06:50 +0800 Subject: [PATCH 15/41] Removed unnecessary 3rd attribute in default variations object --- tests/e2e/config/default.json | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/e2e/config/default.json b/tests/e2e/config/default.json index 682d09cc86d..09ade6121aa 100644 --- a/tests/e2e/config/default.json +++ b/tests/e2e/config/default.json @@ -78,10 +78,6 @@ { "name": "Colour", "option": "Red" - }, - { - "name": "Logo", - "option": "Woo" } ] }, @@ -95,10 +91,6 @@ { "name": "Colour", "option": "Green" - }, - { - "name": "Logo", - "option": "Woo" } ] }, @@ -112,10 +104,6 @@ { "name": "Colour", "option": "Blue" - }, - { - "name": "Logo", - "option": "Woo" } ] } From d2d660a8060f703465bce477b52aca6ddd0ab236 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Thu, 3 Jun 2021 13:02:19 -0300 Subject: [PATCH 16/41] Remove ASBPATH check from interfaces --- .../class-wc-abstract-order-data-store-interface.php | 4 ---- includes/interfaces/class-wc-coupon-data-store-interface.php | 4 ---- .../interfaces/class-wc-customer-data-store-interface.php | 4 ---- .../class-wc-customer-download-data-store-interface.php | 4 ---- .../class-wc-customer-download-log-data-store-interface.php | 4 ---- includes/interfaces/class-wc-importer-interface.php | 4 ---- includes/interfaces/class-wc-log-handler-interface.php | 4 ---- includes/interfaces/class-wc-object-data-store-interface.php | 4 ---- includes/interfaces/class-wc-order-data-store-interface.php | 4 ---- .../interfaces/class-wc-order-item-data-store-interface.php | 4 ---- .../class-wc-order-item-product-data-store-interface.php | 4 ---- .../class-wc-order-item-type-data-store-interface.php | 4 ---- .../interfaces/class-wc-order-refund-data-store-interface.php | 4 ---- .../class-wc-payment-token-data-store-interface.php | 4 ---- includes/interfaces/class-wc-product-data-store-interface.php | 4 ---- .../class-wc-product-variable-data-store-interface.php | 4 ---- includes/interfaces/class-wc-queue-interface.php | 4 ---- .../class-wc-shipping-zone-data-store-interface.php | 4 ---- .../interfaces/class-wc-webhooks-data-store-interface.php | 4 ---- 19 files changed, 76 deletions(-) diff --git a/includes/interfaces/class-wc-abstract-order-data-store-interface.php b/includes/interfaces/class-wc-abstract-order-data-store-interface.php index c043c34e214..6e2ca1f224d 100644 --- a/includes/interfaces/class-wc-abstract-order-data-store-interface.php +++ b/includes/interfaces/class-wc-abstract-order-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interfaces */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Order Data Store Interface * diff --git a/includes/interfaces/class-wc-coupon-data-store-interface.php b/includes/interfaces/class-wc-coupon-data-store-interface.php index 95256bcc00d..1cc0389ebce 100644 --- a/includes/interfaces/class-wc-coupon-data-store-interface.php +++ b/includes/interfaces/class-wc-coupon-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interfaces */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Coupon Data Store Interface * diff --git a/includes/interfaces/class-wc-customer-data-store-interface.php b/includes/interfaces/class-wc-customer-data-store-interface.php index d2601898516..f3df3083fea 100644 --- a/includes/interfaces/class-wc-customer-data-store-interface.php +++ b/includes/interfaces/class-wc-customer-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Customer Data Store Interface * diff --git a/includes/interfaces/class-wc-customer-download-data-store-interface.php b/includes/interfaces/class-wc-customer-download-data-store-interface.php index 4ef79c59395..81cde862794 100644 --- a/includes/interfaces/class-wc-customer-download-data-store-interface.php +++ b/includes/interfaces/class-wc-customer-download-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Customer Download Data Store Interface. * diff --git a/includes/interfaces/class-wc-customer-download-log-data-store-interface.php b/includes/interfaces/class-wc-customer-download-log-data-store-interface.php index 32c5b168c4f..662f22ef069 100644 --- a/includes/interfaces/class-wc-customer-download-log-data-store-interface.php +++ b/includes/interfaces/class-wc-customer-download-log-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Customer Download Log Data Store Interface. * diff --git a/includes/interfaces/class-wc-importer-interface.php b/includes/interfaces/class-wc-importer-interface.php index fa4317932b8..55f4cf64aca 100644 --- a/includes/interfaces/class-wc-importer-interface.php +++ b/includes/interfaces/class-wc-importer-interface.php @@ -6,10 +6,6 @@ * @version 3.1.0 */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC_Importer_Interface class. */ diff --git a/includes/interfaces/class-wc-log-handler-interface.php b/includes/interfaces/class-wc-log-handler-interface.php index d84e39720c8..f83828165e5 100644 --- a/includes/interfaces/class-wc-log-handler-interface.php +++ b/includes/interfaces/class-wc-log-handler-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; // Exit if accessed directly. -} - /** * WC Log Handler Interface * diff --git a/includes/interfaces/class-wc-object-data-store-interface.php b/includes/interfaces/class-wc-object-data-store-interface.php index f6f276aaae6..397aeb965cd 100644 --- a/includes/interfaces/class-wc-object-data-store-interface.php +++ b/includes/interfaces/class-wc-object-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Data Store Interface * diff --git a/includes/interfaces/class-wc-order-data-store-interface.php b/includes/interfaces/class-wc-order-data-store-interface.php index 6f00c8a3efe..18745176414 100644 --- a/includes/interfaces/class-wc-order-data-store-interface.php +++ b/includes/interfaces/class-wc-order-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Order Data Store Interface * diff --git a/includes/interfaces/class-wc-order-item-data-store-interface.php b/includes/interfaces/class-wc-order-item-data-store-interface.php index 68ba29b4013..b23f42727bd 100644 --- a/includes/interfaces/class-wc-order-item-data-store-interface.php +++ b/includes/interfaces/class-wc-order-item-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Order Item Data Store Interface * diff --git a/includes/interfaces/class-wc-order-item-product-data-store-interface.php b/includes/interfaces/class-wc-order-item-product-data-store-interface.php index f5cd402ea2f..654c408c364 100644 --- a/includes/interfaces/class-wc-order-item-product-data-store-interface.php +++ b/includes/interfaces/class-wc-order-item-product-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Order Item Data Store Interface * diff --git a/includes/interfaces/class-wc-order-item-type-data-store-interface.php b/includes/interfaces/class-wc-order-item-type-data-store-interface.php index 006a4e6b0d4..23693faf29e 100644 --- a/includes/interfaces/class-wc-order-item-type-data-store-interface.php +++ b/includes/interfaces/class-wc-order-item-type-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Order Item Data Store Interface * diff --git a/includes/interfaces/class-wc-order-refund-data-store-interface.php b/includes/interfaces/class-wc-order-refund-data-store-interface.php index b97864d06e3..1167e830943 100644 --- a/includes/interfaces/class-wc-order-refund-data-store-interface.php +++ b/includes/interfaces/class-wc-order-refund-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Order Refund Data Store Interface * diff --git a/includes/interfaces/class-wc-payment-token-data-store-interface.php b/includes/interfaces/class-wc-payment-token-data-store-interface.php index fb2a581e741..9fb64a29806 100644 --- a/includes/interfaces/class-wc-payment-token-data-store-interface.php +++ b/includes/interfaces/class-wc-payment-token-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Payment Token Data Store Interface * diff --git a/includes/interfaces/class-wc-product-data-store-interface.php b/includes/interfaces/class-wc-product-data-store-interface.php index 3e50cfedf14..4c1a68c94ec 100644 --- a/includes/interfaces/class-wc-product-data-store-interface.php +++ b/includes/interfaces/class-wc-product-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Product Data Store Interface * diff --git a/includes/interfaces/class-wc-product-variable-data-store-interface.php b/includes/interfaces/class-wc-product-variable-data-store-interface.php index b22893dc3a6..03b72b48a3e 100644 --- a/includes/interfaces/class-wc-product-variable-data-store-interface.php +++ b/includes/interfaces/class-wc-product-variable-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Product Variable Data Store Interface * diff --git a/includes/interfaces/class-wc-queue-interface.php b/includes/interfaces/class-wc-queue-interface.php index 5a960d383f7..3cfe06845ce 100644 --- a/includes/interfaces/class-wc-queue-interface.php +++ b/includes/interfaces/class-wc-queue-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; // Exit if accessed directly. -} - /** * WC Queue Interface * diff --git a/includes/interfaces/class-wc-shipping-zone-data-store-interface.php b/includes/interfaces/class-wc-shipping-zone-data-store-interface.php index 7009c5b7209..031e4048b3e 100644 --- a/includes/interfaces/class-wc-shipping-zone-data-store-interface.php +++ b/includes/interfaces/class-wc-shipping-zone-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WC Shipping Zone Data Store Interface. * diff --git a/includes/interfaces/class-wc-webhooks-data-store-interface.php b/includes/interfaces/class-wc-webhooks-data-store-interface.php index f0e2e729843..0f59d011d20 100644 --- a/includes/interfaces/class-wc-webhooks-data-store-interface.php +++ b/includes/interfaces/class-wc-webhooks-data-store-interface.php @@ -6,10 +6,6 @@ * @package WooCommerce\Interface */ -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - /** * WooCommerce Webhook data store interface. */ From 81e05acdd62c663591961ebf8cf8a72e3114a19f Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Sat, 5 Jun 2021 20:48:38 +0800 Subject: [PATCH 17/41] Use API to generate all possible variations --- tests/e2e/utils/src/components.js | 68 +++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index e213383c9c3..6c7f856fd44 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -24,8 +24,7 @@ const client = factories.api.withDefaultPermalinks; const config = require( 'config' ); const simpleProductName = config.get( 'products.simple.name' ); const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99'; -const defaultVariableProduct = config.get( 'products.variable' ); -const defaultVariations = config.get( 'products.variation' ); +const defaultVariableProduct = config.get('products.variable'); /** * Verify and publish @@ -222,22 +221,73 @@ const createSimpleProductWithCategory = async ( productName, productPrice, categ /** * Create variable product. - * + * * @param varProduct Defaults to the variable product object in `default.json` - * @param variations Defaults to the variation object in `default.json` * @returns the ID of the created variable product */ -const createVariableProduct = async ( varProduct = defaultVariableProduct, variations = defaultVariations ) => { - const variableProduct = await factories.products.variable.create( varProduct ); +const createVariableProduct = async (varProduct = defaultVariableProduct) => { + const { attributes } = varProduct; + const { id } = await factories.products.variable.create(varProduct); + const variations = []; + const buffer = []; // accumulated attributes while looping + const aIdx = 0; // attributes[] index - for( const v of variations ){ + // Create variation for all attributes + const createVariation = (aIdx) => { + const { name, options } = attributes[aIdx]; + const isLastAttribute = aIdx === attributes.length - 1; + + // Add each attribute value to the buffer. + options.forEach((opt) => { + buffer.push({ + name: name, + option: opt + }); + + if (isLastAttribute) { + // If this is the last attribute, it means the variation is now complete. + // Save whatever's been accumulated in the buffer to the `variations[]` array. + variations.push({ + attributes: [...buffer] + }); + } else { + // Otherwise, move to the next attribute first + // before proceeding to the next value in this attribute. + createVariation(aIdx + 1); + } + + buffer.pop(); + }); + }; + createVariation(aIdx); + + // Set some properties of 1st variation + variations[0].regularPrice = '9.99'; + variations[0].virtual = true; + + // Set some properties of 2nd variation + variations[1].regularPrice = '11.99'; + variations[1].virtual = true; + + // Set some properties of 3rd variation + variations[2].regularPrice = '20'; + variations[2].weight = '200'; + variations[2].dimensions = { + length: '10', + width: '20', + height: '15' + }; + variations[2].manage_stock = true; + + // Use API to create each variation + for (const v of variations) { await factories.products.variation.create({ - productId: variableProduct.id, + productId: id, variation: v }); } - return variableProduct.id; + return id; }; /** From ef90dc7ea3c849455c8fcfaefdd65762a8edd649 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Sat, 5 Jun 2021 20:49:43 +0800 Subject: [PATCH 18/41] REfactor first 2 tests --- ...front-end-variable-product-updates.test.js | 58 +++++++++++++++---- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js b/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js index 64a201e04fc..50606535673 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js @@ -4,13 +4,14 @@ */ const { shopper, - merchant, createVariableProduct, } = require( '@woocommerce/e2e-utils' ); +const config = require('config'); let variablePostIdValue; const cartDialogMessage = 'Please select some product options before adding this product to your cart.'; +const attributes = config.get( 'products.variable.attributes' ) const runVariableProductUpdateTest = () => { describe('Shopper > Update variable product',() => { @@ -20,25 +21,58 @@ const runVariableProductUpdateTest = () => { it('shopper can change variable attributes to the same value', async () => { await shopper.goToProduct(variablePostIdValue); - await expect(page).toSelect('#attr-1', 'val1'); - await expect(page).toSelect('#attr-2', 'val1'); - await expect(page).toSelect('#attr-3', 'val1'); - await expect(page).toMatchElement('.woocommerce-variation-price', { text: '9.99' }); + for (const a of attributes) { + const { name, options } = a; + const attrHTMLId = `#${name.toLowerCase()}`; + + await expect(page).toSelect(attrHTMLId, options[0]); + } + + await expect(page).toMatchElement('.woocommerce-variation-price', { + text: '9.99' + }); }); it('shopper can change attributes to combination with dimensions and weight', async () => { await shopper.goToProduct(variablePostIdValue); - await expect(page).toSelect('#attr-1', 'val1'); - await expect(page).toSelect('#attr-2', 'val2'); - await expect(page).toSelect('#attr-3', 'val1'); + await expect(page).toSelect( + `#${attributes[0].name.toLowerCase()}`, + attributes[0].options[0] + ); + await expect(page).toSelect( + `#${attributes[1].name.toLowerCase()}`, + attributes[1].options[1] + ); + await expect(page).toSelect( + `#${attributes[2].name.toLowerCase()}`, + attributes[2].options[0] + ); - await expect(page).toMatchElement('.woocommerce-variation-price', { text: '20.00' }); - await expect(page).toMatchElement('.woocommerce-variation-availability', { text: 'Out of stock' }); - await expect(page).toMatchElement('.woocommerce-product-attributes-item--weight', { text: '200 kg' }); - await expect(page).toMatchElement('.woocommerce-product-attributes-item--dimensions', { text: '10 × 20 × 15 cm' }); + await expect(page).toMatchElement('.woocommerce-variation-price', { + text: '20.00' + }); + await expect(page).toMatchElement( + '.woocommerce-variation-availability', + { + text: 'Out of stock' + } + ); + await expect(page).toMatchElement( + '.woocommerce-product-attributes-item--weight', + { + text: '200 kg' + } + ); + await expect( + page + ).toMatchElement( + '.woocommerce-product-attributes-item--dimensions', + { text: '10 × 20 × 15 cm' } + ); }); + // mytodo continue transforming from here it('shopper can change variable product attributes to variation with a different price', async () => { await shopper.goToProduct(variablePostIdValue); await expect(page).toSelect('#attr-1', 'val1'); From 6ab74bf811a3088e032bc2316ae44f630ab3aad7 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Sat, 5 Jun 2021 20:50:44 +0800 Subject: [PATCH 19/41] Fix variation factory to include all fields from params --- tests/e2e/utils/src/factories/variation.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/e2e/utils/src/factories/variation.js b/tests/e2e/utils/src/factories/variation.js index 39c9148a0de..4aed65ad353 100644 --- a/tests/e2e/utils/src/factories/variation.js +++ b/tests/e2e/utils/src/factories/variation.js @@ -17,9 +17,6 @@ export function variationFactory(httpClient) { return repository.create(productId, model); }); - return { - regularPrice: variation.regularPrice, - attributes: variation.attributes - }; + return variation; }); } From 779f618adf1294f02f6068bb639ab5c163828f0f Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Sun, 6 Jun 2021 01:07:19 +0800 Subject: [PATCH 20/41] Refactor steps --- ...front-end-variable-product-updates.test.js | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js b/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js index 50606535673..cb25df41929 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js @@ -72,37 +72,50 @@ const runVariableProductUpdateTest = () => { ); }); - // mytodo continue transforming from here it('shopper can change variable product attributes to variation with a different price', async () => { await shopper.goToProduct(variablePostIdValue); - await expect(page).toSelect('#attr-1', 'val1'); - await expect(page).toSelect('#attr-2', 'val1'); - await expect(page).toSelect('#attr-3', 'val2'); + await expect(page).toSelect( + `#${attributes[0].name.toLowerCase()}`, + attributes[0].options[0] + ); + await expect(page).toSelect( + `#${attributes[1].name.toLowerCase()}`, + attributes[1].options[0] + ); + await expect(page).toSelect( + `#${attributes[2].name.toLowerCase()}`, + attributes[2].options[1] + ); await expect(page).toMatchElement('.woocommerce-variation-price', { text: '11.99' }); }); it('shopper can reset variations', async () => { await shopper.goToProduct(variablePostIdValue); - await expect(page).toSelect('#attr-1', 'val1'); - await expect(page).toSelect('#attr-2', 'val2'); - await expect(page).toSelect('#attr-3', 'val1'); + await expect(page).toSelect( + `#${attributes[0].name.toLowerCase()}`, + attributes[0].options[0] + ); + await expect(page).toSelect( + `#${attributes[1].name.toLowerCase()}`, + attributes[1].options[1] + ); + await expect(page).toSelect( + `#${attributes[2].name.toLowerCase()}`, + attributes[2].options[0] + ); await expect(page).toClick('.reset_variations'); // Verify the reset by attempting to add the product to the cart - const couponDialog = await expect(page).toDisplayDialog(async () => { - await expect(page).toClick('.single_add_to_cart_button'); - }); - + const couponDialog = await expect(page).toDisplayDialog( + async () => { + await expect(page).toClick('.single_add_to_cart_button'); + } + ); expect(couponDialog.message()).toMatch(cartDialogMessage); - - // Accept the dialog - await couponDialog.accept(); }); - }); - }; module.exports = runVariableProductUpdateTest; From 61992e2d2ed1e20b65967e8625911ee0fc5281f5 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Mon, 7 Jun 2021 16:11:41 +0800 Subject: [PATCH 21/41] Minor doc change --- tests/e2e/utils/src/components.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index 6c7f856fd44..ac46875ee59 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -221,6 +221,7 @@ const createSimpleProductWithCategory = async ( productName, productPrice, categ /** * Create variable product. + * Also, create variations for all attributes. * * @param varProduct Defaults to the variable product object in `default.json` * @returns the ID of the created variable product From 21d037900a7f7fe1d0beeed6dffbee5331adfd9e Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Mon, 7 Jun 2021 17:41:36 +0800 Subject: [PATCH 22/41] Use API to create Grouped Products --- .../shopper/front-end-single-product.test.js | 2 - tests/e2e/utils/src/components.js | 38 +++++++------------ tests/e2e/utils/src/factories.js | 4 +- .../utils/src/factories/grouped-product.js | 26 +++++++++++++ 4 files changed, 43 insertions(+), 27 deletions(-) create mode 100644 tests/e2e/utils/src/factories/grouped-product.js diff --git a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js index e583a5e1f84..807486d863b 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js @@ -86,9 +86,7 @@ const runSingleProductPageTest = () => { describe('Grouped Product Page', () => { beforeAll(async () => { - await merchant.login(); groupedPostIdValue = await createGroupedProduct(); - await merchant.logout(); }); it('should be able to add grouped products to the cart', async () => { diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index ac46875ee59..00cdfb076b7 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -7,10 +7,8 @@ */ import { merchant, IS_RETEST_MODE } from './flows'; import { - clickTab, uiUnblocked, verifyCheckboxIsUnset, - selectOptionInSelect2, setCheckbox, unsetCheckbox, evalAndClick, @@ -293,37 +291,29 @@ const createVariableProduct = async (varProduct = defaultVariableProduct) => { /** * Create grouped product. + * + * @returns ID of the grouped product */ const createGroupedProduct = async () => { // Create two products to be linked in a grouped product after - await factories.products.simple.create( { + const simple1 = await factories.products.simple.create({ name: simpleProductName + ' 1', regularPrice: simpleProductPrice - } ); - await factories.products.simple.create( { + }); + const simple2 = await factories.products.simple.create({ name: simpleProductName + ' 2', regularPrice: simpleProductPrice - } ); + }); + const groupedProduct = { + name: 'Grouped Product', + type: 'grouped', + groupedProducts: [simple1.id, simple2.id] + }; - // Go to "add product" page - await merchant.openNewProduct(); + const { id } = await factories.products.grouped.create(groupedProduct); - // Make sure we're on the add product page - await expect( page.title() ).resolves.toMatch( 'Add new product' ); - - // Set product data and save the product - await expect( page ).toFill( '#title', 'Grouped Product' ); - await expect( page ).toSelect( '#product-type', 'Grouped product' ); - await clickTab( 'Linked Products' ); - await selectOptionInSelect2( simpleProductName + ' 1' ); - await selectOptionInSelect2( simpleProductName + ' 2' ); - await verifyAndPublish(); - - // Get product ID - const groupedPostId = await page.$( '#post_ID' ); - let groupedPostIdValue = ( await ( await groupedPostId.getProperty( 'value' ) ).jsonValue() ); - return groupedPostIdValue; -} + return id; +}; /** * Create a basic order with the provided order status. diff --git a/tests/e2e/utils/src/factories.js b/tests/e2e/utils/src/factories.js index 250076b14dc..4ebc5e38041 100644 --- a/tests/e2e/utils/src/factories.js +++ b/tests/e2e/utils/src/factories.js @@ -3,6 +3,7 @@ const config = require( 'config' ); import { simpleProductFactory } from './factories/simple-product'; import { variableProductFactory } from './factories/variable-product'; import { variationFactory } from './factories/variation'; +import { groupedProductFactory } from './factories/grouped-product'; const apiUrl = config.get( 'url' ); const adminUsername = config.get( 'users.admin.username' ); @@ -23,7 +24,8 @@ const factories = { products: { simple: simpleProductFactory( withDefaultPermalinks ), variable: variableProductFactory( withDefaultPermalinks ), - variation: variationFactory( withDefaultPermalinks ) + variation: variationFactory( withDefaultPermalinks ), + grouped: groupedProductFactory( withDefaultPermalinks ) }, }; diff --git a/tests/e2e/utils/src/factories/grouped-product.js b/tests/e2e/utils/src/factories/grouped-product.js new file mode 100644 index 00000000000..cb2315f586c --- /dev/null +++ b/tests/e2e/utils/src/factories/grouped-product.js @@ -0,0 +1,26 @@ +import { GroupedProduct } from '@woocommerce/api'; +import { Factory } from 'fishery'; + +/** + * Creates a new factory for creating variable products. + * This does not include creating product variations. + * Instead, use `variationFactory()` for that. + * + * @param {HTTPClient} httpClient The HTTP client we will give the repository. + * @return {AsyncFactory} The factory for creating models. + */ +export function groupedProductFactory(httpClient) { + const repository = GroupedProduct.restRepository(httpClient); + + return Factory.define(({ params, onCreate }) => { + onCreate((model) => { + return repository.create(model); + }); + + return { + name: params.name, + type: 'grouped', + groupedProducts: params.groupedProducts + }; + }); +} From 179bad04b8d3b6799a18b5fef2475c6dcadde302 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Mon, 7 Jun 2021 18:46:40 +0800 Subject: [PATCH 23/41] Fixed erroneous variables --- .../shopper/front-end-single-product.test.js | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js index 807486d863b..e7107f743fe 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js @@ -18,9 +18,7 @@ const simpleProductName = config.get( 'products.simple.name' ); let simplePostIdValue; // Variables for variable product -const variableProductName = config.get( 'products.variable.name' ); -const variations = config.get( 'products.variations' ); -const attributes = variations[0].attributes; +const defaultVariableProduct = config.get( 'products.variable' ); let variableProductId; // Variables for grouped product @@ -59,26 +57,29 @@ const runSingleProductPageTest = () => { it('should be able to add variation products to the cart', async () => { // Add a product with one set of variations to cart - await shopper.goToProduct( variableProductId ); - - for( const attr of attributes ){ - const selectElem = `#${attr.name.toLowerCase()}`; - const value = attr.option; + await shopper.goToProduct(variableProductId); + + for (const attr of defaultVariableProduct.attributes) { + const { name, options } = attr; + const selectElem = `#${name.toLowerCase()}`; + const value = options[0]; await expect(page).toSelect(selectElem, value); } - + await shopper.addToCart(); - await expect(page).toMatchElement('.woocommerce-message', {text: 'has been added to your cart.'}); + await expect(page).toMatchElement('.woocommerce-message', { + text: 'has been added to your cart.' + }); // Verify cart contents await shopper.goToCart(); - await shopper.productIsInCart(variableProductName); + await shopper.productIsInCart(defaultVariableProduct.name); }); it('should be able to remove variation products from the cart', async () => { // Remove items from cart - await shopper.removeFromCart(variableProductName); + await shopper.removeFromCart(defaultVariableProduct.name); await uiUnblocked(); await expect(page).toMatchElement('.cart-empty', {text: 'Your cart is currently empty.'}); }); From 47a3ea0077c319f39348a808df70b9ee547891e7 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Wed, 9 Jun 2021 15:55:47 +0800 Subject: [PATCH 24/41] Revert default.json --- tests/e2e/config/default.json | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/e2e/config/default.json b/tests/e2e/config/default.json index 09ade6121aa..adb8538915e 100644 --- a/tests/e2e/config/default.json +++ b/tests/e2e/config/default.json @@ -16,7 +16,6 @@ }, "variable": { "name": "Variable Product with Three Attributes", - "type": "variable", "defaultAttributes": [ { "id": 0, @@ -33,8 +32,8 @@ { "id": 0, "name": "Colour", - "visible": true, - "variation": true, + "isVisibleOnProductPage": true, + "isForVariations": true, "options": [ "Red", "Green", @@ -45,8 +44,8 @@ { "id": 0, "name": "Size", - "visible": true, - "variation": true, + "isVisibleOnProductPage": true, + "isForVariations": true, "options": [ "Small", "Medium", @@ -57,8 +56,8 @@ { "id": 0, "name": "Logo", - "visible": true, - "variation": true, + "isVisibleOnProductPage": true, + "isForVariations": true, "options": [ "Woo", "WordPress" From 78ef1e441157aaeac29292d37dfaa3d9767be21c Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Wed, 9 Jun 2021 15:55:58 +0800 Subject: [PATCH 25/41] Remove unnecessary import --- .../core-tests/specs/shopper/front-end-single-product.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js index e7107f743fe..c1e17687660 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js @@ -4,7 +4,6 @@ */ const { shopper, - merchant, createSimpleProduct, createVariableProduct, createGroupedProduct, From f2305a2486034d2cdebe0cee326e81b854add47c Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Wed, 9 Jun 2021 17:08:45 +0800 Subject: [PATCH 26/41] Fix instantiation of grouped product variables --- .../shopper/front-end-single-product.test.js | 64 ++++++++++++++----- tests/e2e/utils/src/components.js | 38 ++++++----- 2 files changed, 68 insertions(+), 34 deletions(-) diff --git a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js index c1e17687660..392d2adde06 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js @@ -21,6 +21,7 @@ const defaultVariableProduct = config.get( 'products.variable' ); let variableProductId; // Variables for grouped product +const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99'; let groupedPostIdValue; const runSingleProductPageTest = () => { @@ -86,7 +87,22 @@ const runSingleProductPageTest = () => { describe('Grouped Product Page', () => { beforeAll(async () => { - groupedPostIdValue = await createGroupedProduct(); + // Instantiate simple products to be grouped + const simple1 = { + name: simpleProductName + ' 1', + regularPrice: simpleProductPrice + }; + const simple2 = { + name: simpleProductName + ' 2', + regularPrice: simpleProductPrice + }; + + // Create grouped product + const groupedProduct = { + name: 'Grouped Product', + groupedProducts: [simple1, simple2] + }; + groupedPostIdValue = await createGroupedProduct(groupedProduct); }); it('should be able to add grouped products to the cart', async () => { @@ -94,37 +110,51 @@ const runSingleProductPageTest = () => { await shopper.goToProduct(groupedPostIdValue); await page.waitForSelector('form.grouped_form'); await shopper.addToCart(); - await expect(page).toMatchElement('.woocommerce-error', - {text: 'Please choose the quantity of items you wish to add to your cart…'}); + await expect(page).toMatchElement('.woocommerce-error', { + text: + 'Please choose the quantity of items you wish to add to your cart…' + }); const quantityFields = await page.$$('div.quantity input.qty'); - await quantityFields[0].click({clickCount: 3}); + await quantityFields[0].click({ clickCount: 3 }); await quantityFields[0].type('5'); - await quantityFields[1].click({clickCount: 3}); + await quantityFields[1].click({ clickCount: 3 }); await quantityFields[1].type('5'); await shopper.addToCart(); - await expect(page).toMatchElement('.woocommerce-message', - {text: '“'+simpleProductName+' 1” and “'+simpleProductName+' 2” have been added to your cart.'}); + await expect(page).toMatchElement('.woocommerce-message', { + text: + '“' + + simpleProductName + + ' 1” and “' + + simpleProductName + + ' 2” have been added to your cart.' + }); // Verify cart contents await shopper.goToCart(); - await shopper.productIsInCart(simpleProductName+' 1'); - await shopper.productIsInCart(simpleProductName+' 2'); + await shopper.productIsInCart(simpleProductName + ' 1'); + await shopper.productIsInCart(simpleProductName + ' 2'); }); it('should be able to remove grouped products from the cart', async () => { // Remove items from cart - await shopper.removeFromCart(simpleProductName+' 1'); + await shopper.removeFromCart(simpleProductName + ' 1'); await uiUnblocked(); - await expect(page).toMatchElement('.woocommerce-message', {text: '“'+simpleProductName+' 1” removed.'}); - await Promise.all( [ + await expect(page).toMatchElement('.woocommerce-message', { + text: '“' + simpleProductName + ' 1” removed.' + }); + await Promise.all([ // Reload page and perform item removal, since removeFromCart won't remove it when placed in a row page.reload(), - page.waitForNavigation( { waitUntil: 'networkidle0' } ), - ] ); - await shopper.removeFromCart(simpleProductName+' 2'); + page.waitForNavigation({ waitUntil: 'networkidle0' }) + ]); + await shopper.removeFromCart(simpleProductName + ' 2'); await uiUnblocked(); - await expect(page).toMatchElement('.woocommerce-message', {text: '“'+simpleProductName+' 2” removed.'}); - await expect(page).toMatchElement('.cart-empty', {text: 'Your cart is currently empty.'}); + await expect(page).toMatchElement('.woocommerce-message', { + text: '“' + simpleProductName + ' 2” removed.' + }); + await expect(page).toMatchElement('.cart-empty', { + text: 'Your cart is currently empty.' + }); }); }); }; diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index 00cdfb076b7..a6b2f8f6ae3 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -23,6 +23,7 @@ const config = require( 'config' ); const simpleProductName = config.get( 'products.simple.name' ); const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99'; const defaultVariableProduct = config.get('products.variable'); +const defaultGroupedProduct = config.get('products.grouped'); /** * Verify and publish @@ -226,7 +227,7 @@ const createSimpleProductWithCategory = async ( productName, productPrice, categ */ const createVariableProduct = async (varProduct = defaultVariableProduct) => { const { attributes } = varProduct; - const { id } = await factories.products.variable.create(varProduct); + const { id } = await factories.products.variable.create(varProduct); // create the variable product const variations = []; const buffer = []; // accumulated attributes while looping const aIdx = 0; // attributes[] index @@ -292,25 +293,28 @@ const createVariableProduct = async (varProduct = defaultVariableProduct) => { /** * Create grouped product. * + * @param groupedProduct Defaults to the grouped product object in `default.json` * @returns ID of the grouped product */ -const createGroupedProduct = async () => { - // Create two products to be linked in a grouped product after - const simple1 = await factories.products.simple.create({ - name: simpleProductName + ' 1', - regularPrice: simpleProductPrice - }); - const simple2 = await factories.products.simple.create({ - name: simpleProductName + ' 2', - regularPrice: simpleProductPrice - }); - const groupedProduct = { - name: 'Grouped Product', - type: 'grouped', - groupedProducts: [simple1.id, simple2.id] - }; +const createGroupedProduct = async (groupedProduct = defaultGroupedProduct) => { + const { name, groupedProducts } = groupedProduct; + const simpleProductIds = []; + let groupedProductRequest; - const { id } = await factories.products.grouped.create(groupedProduct); + // Using the api, create simple products to be grouped + for (const simpleProduct of groupedProducts) { + const { id } = await factories.products.simple.create(simpleProduct); + simpleProductIds.push(id); + } + + // Using the api, create the grouped product + groupedProductRequest = { + name: name, + groupedProducts: simpleProductIds + }; + const { id } = await factories.products.grouped.create( + groupedProductRequest + ); return id; }; From e5ed6dc81a32994eaf6804bc5df78db73bbbb43a Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Wed, 9 Jun 2021 17:38:20 +0800 Subject: [PATCH 27/41] Revert whitespaces for easier review --- .../shopper/front-end-single-product.test.js | 50 +++++++------------ ...front-end-variable-product-updates.test.js | 35 ++++--------- 2 files changed, 27 insertions(+), 58 deletions(-) diff --git a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js index 392d2adde06..b2ae86e4a04 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js @@ -68,9 +68,7 @@ const runSingleProductPageTest = () => { } await shopper.addToCart(); - await expect(page).toMatchElement('.woocommerce-message', { - text: 'has been added to your cart.' - }); + await expect(page).toMatchElement('.woocommerce-message', {text: 'has been added to your cart.'}); // Verify cart contents await shopper.goToCart(); @@ -110,51 +108,37 @@ const runSingleProductPageTest = () => { await shopper.goToProduct(groupedPostIdValue); await page.waitForSelector('form.grouped_form'); await shopper.addToCart(); - await expect(page).toMatchElement('.woocommerce-error', { - text: - 'Please choose the quantity of items you wish to add to your cart…' - }); + await expect(page).toMatchElement('.woocommerce-error', + {text: 'Please choose the quantity of items you wish to add to your cart…'}); const quantityFields = await page.$$('div.quantity input.qty'); - await quantityFields[0].click({ clickCount: 3 }); + await quantityFields[0].click({clickCount: 3}); await quantityFields[0].type('5'); - await quantityFields[1].click({ clickCount: 3 }); + await quantityFields[1].click({clickCount: 3}); await quantityFields[1].type('5'); await shopper.addToCart(); - await expect(page).toMatchElement('.woocommerce-message', { - text: - '“' + - simpleProductName + - ' 1” and “' + - simpleProductName + - ' 2” have been added to your cart.' - }); + await expect(page).toMatchElement('.woocommerce-message', + {text: '“'+simpleProductName+' 1” and “'+simpleProductName+' 2” have been added to your cart.'}); // Verify cart contents await shopper.goToCart(); - await shopper.productIsInCart(simpleProductName + ' 1'); - await shopper.productIsInCart(simpleProductName + ' 2'); + await shopper.productIsInCart(simpleProductName+' 1'); + await shopper.productIsInCart(simpleProductName+' 2'); }); it('should be able to remove grouped products from the cart', async () => { // Remove items from cart - await shopper.removeFromCart(simpleProductName + ' 1'); + await shopper.removeFromCart(simpleProductName+' 1'); await uiUnblocked(); - await expect(page).toMatchElement('.woocommerce-message', { - text: '“' + simpleProductName + ' 1” removed.' - }); - await Promise.all([ + await expect(page).toMatchElement('.woocommerce-message', {text: '“'+simpleProductName+' 1” removed.'}); + await Promise.all( [ // Reload page and perform item removal, since removeFromCart won't remove it when placed in a row page.reload(), - page.waitForNavigation({ waitUntil: 'networkidle0' }) - ]); - await shopper.removeFromCart(simpleProductName + ' 2'); + page.waitForNavigation( { waitUntil: 'networkidle0' } ), + ] ); + await shopper.removeFromCart(simpleProductName+' 2'); await uiUnblocked(); - await expect(page).toMatchElement('.woocommerce-message', { - text: '“' + simpleProductName + ' 2” removed.' - }); - await expect(page).toMatchElement('.cart-empty', { - text: 'Your cart is currently empty.' - }); + await expect(page).toMatchElement('.woocommerce-message', {text: '“'+simpleProductName+' 2” removed.'}); + await expect(page).toMatchElement('.cart-empty', {text: 'Your cart is currently empty.'}); }); }); }; diff --git a/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js b/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js index cb25df41929..8c0ac5a9c5f 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-variable-product-updates.test.js @@ -49,27 +49,11 @@ const runVariableProductUpdateTest = () => { attributes[2].options[0] ); - await expect(page).toMatchElement('.woocommerce-variation-price', { - text: '20.00' - }); - await expect(page).toMatchElement( - '.woocommerce-variation-availability', - { - text: 'Out of stock' - } - ); - await expect(page).toMatchElement( - '.woocommerce-product-attributes-item--weight', - { - text: '200 kg' - } - ); - await expect( - page - ).toMatchElement( - '.woocommerce-product-attributes-item--dimensions', - { text: '10 × 20 × 15 cm' } - ); + await expect(page).toMatchElement('.woocommerce-variation-price', { text: '20.00' }); + await expect(page).toMatchElement('.woocommerce-variation-availability', { text: 'Out of stock' }); + await expect(page).toMatchElement('.woocommerce-product-attributes-item--weight', { text: '200 kg' }); + await expect(page).toMatchElement('.woocommerce-product-attributes-item--dimensions', { text: '10 × 20 × 15 cm' }); + }); it('shopper can change variable product attributes to variation with a different price', async () => { @@ -108,14 +92,15 @@ const runVariableProductUpdateTest = () => { await expect(page).toClick('.reset_variations'); // Verify the reset by attempting to add the product to the cart - const couponDialog = await expect(page).toDisplayDialog( - async () => { + const couponDialog = await expect(page).toDisplayDialog(async () => { await expect(page).toClick('.single_add_to_cart_button'); - } - ); + }); + expect(couponDialog.message()).toMatch(cartDialogMessage); }); + }); + }; module.exports = runVariableProductUpdateTest; From 0cc9788ff6003bd3c9985527e5c4a9d9468949ac Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Wed, 9 Jun 2021 17:44:20 +0800 Subject: [PATCH 28/41] Relocated instantiation statements --- .../shopper/front-end-single-product.test.js | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js index b2ae86e4a04..d1473eb75a1 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-single-product.test.js @@ -22,6 +22,18 @@ let variableProductId; // Variables for grouped product const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99'; +const simple1 = { + name: simpleProductName + ' 1', + regularPrice: simpleProductPrice +}; +const simple2 = { + name: simpleProductName + ' 2', + regularPrice: simpleProductPrice +}; +const groupedProduct = { + name: 'Grouped Product', + groupedProducts: [simple1, simple2] +}; let groupedPostIdValue; const runSingleProductPageTest = () => { @@ -85,21 +97,6 @@ const runSingleProductPageTest = () => { describe('Grouped Product Page', () => { beforeAll(async () => { - // Instantiate simple products to be grouped - const simple1 = { - name: simpleProductName + ' 1', - regularPrice: simpleProductPrice - }; - const simple2 = { - name: simpleProductName + ' 2', - regularPrice: simpleProductPrice - }; - - // Create grouped product - const groupedProduct = { - name: 'Grouped Product', - groupedProducts: [simple1, simple2] - }; groupedPostIdValue = await createGroupedProduct(groupedProduct); }); From f28a1fdba6714fc305f9d27e3396a702155b270e Mon Sep 17 00:00:00 2001 From: Raluca Stan Date: Wed, 9 Jun 2021 14:46:46 +0300 Subject: [PATCH 29/41] Update WooCommerce blocks package to 5.3.0 --- composer.json | 2 +- composer.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 276a8a09036..9d2b4ea2408 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "psr/container": "1.0.0", "woocommerce/action-scheduler": "3.2.0", "woocommerce/woocommerce-admin": "2.3.1", - "woocommerce/woocommerce-blocks": "5.1.0" + "woocommerce/woocommerce-blocks": "5.3.0" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.4" diff --git a/composer.lock b/composer.lock index 15575a3419f..78040cf5730 100644 --- a/composer.lock +++ b/composer.lock @@ -584,7 +584,7 @@ }, { "name": "woocommerce/woocommerce-blocks", - "version": "v5.1.0", + "version": "v5.3.0", "source": { "type": "git", "url": "https://github.com/woocommerce/woocommerce-gutenberg-products-block.git", From 4803ebb441ac649e00ba3bd999412857abe7adff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Tue, 15 Jun 2021 11:57:44 +0200 Subject: [PATCH 30/41] Update WooCommerce blocks package to 5.3.1 --- composer.json | 2 +- composer.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 9d2b4ea2408..8df8848a89d 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "psr/container": "1.0.0", "woocommerce/action-scheduler": "3.2.0", "woocommerce/woocommerce-admin": "2.3.1", - "woocommerce/woocommerce-blocks": "5.3.0" + "woocommerce/woocommerce-blocks": "5.3.1" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.4" diff --git a/composer.lock b/composer.lock index 78040cf5730..0091b0486ef 100644 --- a/composer.lock +++ b/composer.lock @@ -584,16 +584,16 @@ }, { "name": "woocommerce/woocommerce-blocks", - "version": "v5.3.0", + "version": "v5.3.1", "source": { "type": "git", "url": "https://github.com/woocommerce/woocommerce-gutenberg-products-block.git", - "reference": "a4f168596f3832e161b26dec636b69293039ee51" + "reference": "28c7c4f9b5cace9098fb2246ff93abe110a26bca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/a4f168596f3832e161b26dec636b69293039ee51", - "reference": "a4f168596f3832e161b26dec636b69293039ee51", + "url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/28c7c4f9b5cace9098fb2246ff93abe110a26bca", + "reference": "28c7c4f9b5cace9098fb2246ff93abe110a26bca", "shasum": "" }, "require": { @@ -629,9 +629,9 @@ ], "support": { "issues": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues", - "source": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/tree/v5.1.0" + "source": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/tree/v5.3.1" }, - "time": "2021-05-10T15:01:42+00:00" + "time": "2021-06-15T09:12:48+00:00" } ], "packages-dev": [ From 84eaa48511fffc045188892673d692bc123b8e45 Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Thu, 20 May 2021 14:17:19 -0500 Subject: [PATCH 31/41] Update exporter to include download IDs for possible retention on import --- includes/export/class-wc-product-csv-exporter.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/includes/export/class-wc-product-csv-exporter.php b/includes/export/class-wc-product-csv-exporter.php index a2380da9bee..0be4abb9c4f 100644 --- a/includes/export/class-wc-product-csv-exporter.php +++ b/includes/export/class-wc-product-csv-exporter.php @@ -601,10 +601,13 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter { if ( $downloads ) { $i = 1; foreach ( $downloads as $download ) { + /* translators: %s: download number */ + $this->column_names[ 'downloads:id' . $i ] = sprintf( __( 'Download %d ID', 'woocommerce' ), $i ); /* translators: %s: download number */ $this->column_names[ 'downloads:name' . $i ] = sprintf( __( 'Download %d name', 'woocommerce' ), $i ); /* translators: %s: download number */ $this->column_names[ 'downloads:url' . $i ] = sprintf( __( 'Download %d URL', 'woocommerce' ), $i ); + $row[ 'downloads:id' . $i ] = $download->get_id(); $row[ 'downloads:name' . $i ] = $download->get_name(); $row[ 'downloads:url' . $i ] = $download->get_file(); $i++; From c67fda9552b26a904035a4f58de15637413f235a Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Fri, 21 May 2021 15:39:04 -0500 Subject: [PATCH 32/41] Update importer to grab downloads id from export file when updating rows --- .../class-wc-product-csv-importer-controller.php | 3 +++ includes/admin/importers/mappings/default.php | 1 + includes/import/class-wc-product-csv-importer.php | 11 +++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/includes/admin/importers/class-wc-product-csv-importer-controller.php b/includes/admin/importers/class-wc-product-csv-importer-controller.php index 0de82507fdc..b14ad20f453 100644 --- a/includes/admin/importers/class-wc-product-csv-importer-controller.php +++ b/includes/admin/importers/class-wc-product-csv-importer-controller.php @@ -566,6 +566,8 @@ class WC_Product_CSV_Importer_Controller { /* translators: %d: Attribute number */ __( 'Attribute %d default', 'woocommerce' ) => 'attributes:default', /* translators: %d: Download number */ + __( 'Download %d ID', 'woocommerce' ) => 'downloads:id', + /* translators: %d: Download number */ __( 'Download %d name', 'woocommerce' ) => 'downloads:name', /* translators: %d: Download number */ __( 'Download %d URL', 'woocommerce' ) => 'downloads:url', @@ -721,6 +723,7 @@ class WC_Product_CSV_Importer_Controller { 'downloads' => array( 'name' => __( 'Downloads', 'woocommerce' ), 'options' => array( + 'downloads:id' . $index => __( 'Download ID', 'woocommerce' ), 'downloads:name' . $index => __( 'Download name', 'woocommerce' ), 'downloads:url' . $index => __( 'Download URL', 'woocommerce' ), 'download_limit' => __( 'Download limit', 'woocommerce' ), diff --git a/includes/admin/importers/mappings/default.php b/includes/admin/importers/mappings/default.php index 4de9337d89c..0d9599da04c 100644 --- a/includes/admin/importers/mappings/default.php +++ b/includes/admin/importers/mappings/default.php @@ -102,6 +102,7 @@ function wc_importer_default_special_english_mappings( $mappings ) { 'Attribute %d visible' => 'attributes:visible', 'Attribute %d global' => 'attributes:taxonomy', 'Attribute %d default' => 'attributes:default', + 'Download %d ID' => 'downloads:id', 'Download %d name' => 'downloads:name', 'Download %d URL' => 'downloads:url', 'Meta: %s' => 'meta:', diff --git a/includes/import/class-wc-product-csv-importer.php b/includes/import/class-wc-product-csv-importer.php index c9c11f44684..78d65f789bb 100644 --- a/includes/import/class-wc-product-csv-importer.php +++ b/includes/import/class-wc-product-csv-importer.php @@ -894,6 +894,12 @@ class WC_Product_CSV_Importer extends WC_Product_Importer { } unset( $data[ $key ] ); + } elseif ( $this->starts_with( $key, 'downloads:id' ) ) { + if ( ! empty( $value ) ) { + $downloads[ str_replace( 'downloads:id', '', $key ) ]['id'] = $value; + } + unset( $data[ $key ] ); + } elseif ( $this->starts_with( $key, 'downloads:name' ) ) { if ( ! empty( $value ) ) { $downloads[ str_replace( 'downloads:name', '', $key ) ]['name'] = $value; @@ -935,8 +941,9 @@ class WC_Product_CSV_Importer extends WC_Product_Importer { } $data['downloads'][] = array( - 'name' => $file['name'] ? $file['name'] : wc_get_filename_from_url( $file['url'] ), - 'file' => $file['url'], + 'download_id' => isset( $file['id'] ) ? $file['id'] : null, + 'name' => $file['name'] ? $file['name'] : wc_get_filename_from_url( $file['url'] ), + 'file' => $file['url'], ); } } From 6e0e5548ecfbafd059a044a0bf526a0967d9ad70 Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Tue, 15 Jun 2021 10:18:54 -0500 Subject: [PATCH 33/41] Update legacy unit tests for download id changes to importer --- tests/legacy/unit-tests/importer/product.php | 8 ++++++-- tests/legacy/unit-tests/importer/sample.csv | 16 ++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/legacy/unit-tests/importer/product.php b/tests/legacy/unit-tests/importer/product.php index e55fdd79351..a77cc9fb2e2 100644 --- a/tests/legacy/unit-tests/importer/product.php +++ b/tests/legacy/unit-tests/importer/product.php @@ -84,6 +84,7 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case { 'Attribute 2 value(s)' => 'attributes:value2', 'Attribute 1 default' => 'attributes:default1', 'Attribute 2 default' => 'attributes:default2', + 'Download 1 ID' => 'downloads:id1', 'Download 1 name' => 'downloads:name1', 'Download 1 URL' => 'downloads:url1', ); @@ -238,6 +239,7 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case { '', '', '', + '', ), array( 'simple, downloadable, virtual', @@ -283,6 +285,7 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case { '180-Gram', '', '', + '4ff604c2-97bd-4869-938b-7798ba6648ab', 'Album flac', 'http://woo.dev/albums/album.flac', ), @@ -393,8 +396,9 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case { ), 'downloads' => array( array( - 'name' => 'Album flac', - 'file' => 'http://woo.dev/albums/album.flac', + 'name' => 'Album flac', + 'file' => 'http://woo.dev/albums/album.flac', + 'download_id' => '4ff604c2-97bd-4869-938b-7798ba6648ab', ), ), 'menu_order' => 1, diff --git a/tests/legacy/unit-tests/importer/sample.csv b/tests/legacy/unit-tests/importer/sample.csv index 00b323feaf3..607fb8c9247 100644 --- a/tests/legacy/unit-tests/importer/sample.csv +++ b/tests/legacy/unit-tests/importer/sample.csv @@ -1,8 +1,8 @@ -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 (kg),Length (cm),Width (cm),Height (cm),Allow customer reviews?,Purchase note,Sale price,Regular price,Categories,Tags,Shipping class,Images,Download limit,Download expiry days,Parent,Upsells,Cross-sells,Grouped products,External URL,BUTTON TEXT,Position,Attribute 1 Name,Attribute 1 Value(s),Attribute 2 name,Attribute 2 value(s),Attribute 1 default,Attribute 2 default,Download 1 name,Download 1 URL -simple,WOOLOGO,Woo Logo,1,,visible,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.","Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",2017-01-01,2030-01-01 0:00:00,taxable,standard,1,5,notify,1,1,1,20,40,1,Lorem ipsum dolor sit amet.,18,20,"Clothing, Clothing > T-shirts",,,"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_1_front.jpg, http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_1_back.jpg",,,,WOOALBUM,WOOALBUM,,,,0,Color,Red,,,,,, -"simple, downloadable, virtual",WOOALBUM,Woo Album #1,1,1,visible,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.","Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",,,taxable,standard,1,,,,,,,,1,Lorem ipsum dolor sit amet.,,5,"Music > Albums, Music",Woo,,"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_1_angle.jpg, http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_1_flat.jpg",10,90,,WOOLOGO,WOOLOGO,,,,1,Label,WooCommerce,Vinyl,180-Gram,,,Album flac,http://woo.dev/albums/album.flac -external,,WooCommerce Product CSV Suite,1,,visible,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.","Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",,,taxable,standard,1,,,,,,,,0,Lorem ipsum dolor sit amet.,,199,Software,WooCommerce,,,,,,,,,https://woocommerce.com/products/product-csv-import-suite/,Buy on WooCommerce.com,2,,,,,,,, -variable,WOOIDEA,Ship Your Idea,1,,visible,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.","Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",,,,,,,,,,,,,1,Lorem ipsum dolor sit amet.,,,"Clothing, Clothing > T-shirts",,,"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg, http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg, http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg, http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg",,,,,,,,,3,Color,"Black, Green",Size,"M, L",Green,L,, -variation,,,1,,visible,,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",,,taxable,standard,1,6,0,,1,2,25,55,,,,20,,,,http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg,,,WOOIDEA,,,,,,1,Color,Black,Size,M,,,, -variation,,,1,,visible,,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",,,taxable,standard,1,10,1,,1,2,25,55,,,17.99,20,,,,http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg,,,WOOIDEA,,,,,,2,Color,Green,Size,L,,,, -grouped,,Best Woo Products,1,1,visible,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.","Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",,,,,1,,,,,,,,,,,,"Clothing, Clothing > T-shirts, Music > Albums, Music",,,"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_1_front.jpg, http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_1_angle.jpg",,,,,,"WOOLOGO, WOOALBUM",,,4,,,,,,,, +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 (kg),Length (cm),Width (cm),Height (cm),Allow customer reviews?,Purchase note,Sale price,Regular price,Categories,Tags,Shipping class,Images,Download limit,Download expiry days,Parent,Upsells,Cross-sells,Grouped products,External URL,BUTTON TEXT,Position,Attribute 1 Name,Attribute 1 Value(s),Attribute 2 name,Attribute 2 value(s),Attribute 1 default,Attribute 2 default,Download 1 ID,Download 1 name,Download 1 URL +simple,WOOLOGO,Woo Logo,1,,visible,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.","Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",2017-01-01,2030-01-01 0:00:00,taxable,standard,1,5,notify,1,1,1,20,40,1,Lorem ipsum dolor sit amet.,18,20,"Clothing, Clothing > T-shirts",,,"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_1_front.jpg, http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_1_back.jpg",,,,WOOALBUM,WOOALBUM,,,,0,Color,Red,,,,,,, +"simple, downloadable, virtual",WOOALBUM,Woo Album #1,1,1,visible,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.","Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",,,taxable,standard,1,,,,,,,,1,Lorem ipsum dolor sit amet.,,5,"Music > Albums, Music",Woo,,"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_1_angle.jpg, http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_1_flat.jpg",10,90,,WOOLOGO,WOOLOGO,,,,1,Label,WooCommerce,Vinyl,180-Gram,,,4ff604c2-97bd-4869-938b-7798ba6648ab,Album flac,http://woo.dev/albums/album.flac +external,,WooCommerce Product CSV Suite,1,,visible,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.","Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",,,taxable,standard,1,,,,,,,,0,Lorem ipsum dolor sit amet.,,199,Software,WooCommerce,,,,,,,,,https://woocommerce.com/products/product-csv-import-suite/,Buy on WooCommerce.com,2,,,,,,,,, +variable,WOOIDEA,Ship Your Idea,1,,visible,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.","Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",,,,,,,,,,,,,1,Lorem ipsum dolor sit amet.,,,"Clothing, Clothing > T-shirts",,,"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg, http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg, http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg, http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg",,,,,,,,,3,Color,"Black, Green",Size,"M, L",Green,L,,, +variation,,,1,,visible,,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",,,taxable,standard,1,6,0,,1,2,25,55,,,,20,,,,http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg,,,WOOIDEA,,,,,,1,Color,Black,Size,M,,,,, +variation,,,1,,visible,,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",,,taxable,standard,1,10,1,,1,2,25,55,,,17.99,20,,,,http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg,,,WOOIDEA,,,,,,2,Color,Green,Size,L,,,,, +grouped,,Best Woo Products,1,1,visible,"Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.","Lorem ipsum dolor sit amet, at exerci civibus appetere sit, iuvaret hendrerit mea no. Eam integre feugait liberavisse an.",,,,,1,,,,,,,,,,,,"Clothing, Clothing > T-shirts, Music > Albums, Music",,,"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_1_front.jpg, http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_1_angle.jpg",,,,,,"WOOLOGO, WOOALBUM",,,4,,,,,,,,, From f9e59fc9a9f637516dfae21cb12e0efac489d044 Mon Sep 17 00:00:00 2001 From: roykho Date: Wed, 16 Jun 2021 11:53:09 -0700 Subject: [PATCH 34/41] At cancelled status for bulk actions closes #29928 --- includes/admin/list-tables/class-wc-admin-list-table-orders.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/admin/list-tables/class-wc-admin-list-table-orders.php b/includes/admin/list-tables/class-wc-admin-list-table-orders.php index 417f2819f1a..6c604088976 100644 --- a/includes/admin/list-tables/class-wc-admin-list-table-orders.php +++ b/includes/admin/list-tables/class-wc-admin-list-table-orders.php @@ -145,6 +145,7 @@ class WC_Admin_List_Table_Orders extends WC_Admin_List_Table { $actions['mark_processing'] = __( 'Change status to processing', 'woocommerce' ); $actions['mark_on-hold'] = __( 'Change status to on-hold', 'woocommerce' ); $actions['mark_completed'] = __( 'Change status to completed', 'woocommerce' ); + $actions['mark_cancelled'] = __( 'Change status to cancelled', 'woocommerce' ); if ( wc_string_to_bool( get_option( 'woocommerce_allow_bulk_remove_personal_data', 'no' ) ) ) { $actions['remove_personal_data'] = __( 'Remove personal data', 'woocommerce' ); From 381626069ec8480c4ed56572b5f0054ebc53ea7d Mon Sep 17 00:00:00 2001 From: vedanshujain Date: Thu, 17 Jun 2021 14:32:21 +0530 Subject: [PATCH 35/41] Load PayPal gateway directly to prevent potential gateway errors. `install()` method may be called before wc_version is set, this may cause unknown errors in 3PD gateways. So its safer to only load PayPal gateway directly. --- includes/class-wc-install.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-install.php b/includes/class-wc-install.php index 4ad4e557b2f..d489fcf333b 100644 --- a/includes/class-wc-install.php +++ b/includes/class-wc-install.php @@ -1631,7 +1631,9 @@ CREATE TABLE {$wpdb->prefix}wc_reserved_stock ( */ private static function set_paypal_standard_load_eligibility() { // Initiating the payment gateways sets the flag. - WC()->payment_gateways(); + if ( class_exists( 'WC_Gateway_Paypal' ) ) { + ( new WC_Gateway_Paypal() )->should_load(); + } } } From 532998b6e8fc159e222a93c8820f0971543c0527 Mon Sep 17 00:00:00 2001 From: vedanshujain Date: Thu, 17 Jun 2021 14:34:22 +0530 Subject: [PATCH 36/41] No need to check for Paypal standard since its removed. See #29971 but basically we want to remove PayPal standard in favor of PayPal checkout which has better experience. So this test is not valid anymore. --- .../core-tests/specs/shopper/front-end-checkout.test.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/e2e/core-tests/specs/shopper/front-end-checkout.test.js b/tests/e2e/core-tests/specs/shopper/front-end-checkout.test.js index 17e84c339c7..e5b1bf1e0ad 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-checkout.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-checkout.test.js @@ -66,14 +66,6 @@ const runCheckoutPageTest = () => { // Verify that settings have been saved await verifyCheckboxIsSet('#woocommerce_cod_enabled'); - // Enable PayPal payment method - await merchant.openSettings('checkout', 'paypal'); - await setCheckbox('#woocommerce_paypal_enabled'); - await settingsPageSaveChanges(); - - // Verify that settings have been saved - await verifyCheckboxIsSet('#woocommerce_paypal_enabled'); - await merchant.logout(); }); From 8fbb86e0963f6dd44f80596229ea79ef8cdccfc1 Mon Sep 17 00:00:00 2001 From: vedanshujain Date: Thu, 17 Jun 2021 15:11:42 +0530 Subject: [PATCH 37/41] Remove PayPal test since its removed by default now. --- tests/e2e/core-tests/specs/shopper/front-end-checkout.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/core-tests/specs/shopper/front-end-checkout.test.js b/tests/e2e/core-tests/specs/shopper/front-end-checkout.test.js index e5b1bf1e0ad..8d8b9588d29 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-checkout.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-checkout.test.js @@ -82,7 +82,6 @@ const runCheckoutPageTest = () => { await shopper.goToCheckout(); await shopper.productIsInCheckout(simpleProductName, `2`, twoProductPrice, twoProductPrice); - await expect(page).toClick('.wc_payment_method label', {text: 'PayPal'}); await expect(page).toClick('.wc_payment_method label', {text: 'Direct bank transfer'}); await expect(page).toClick('.wc_payment_method label', {text: 'Cash on delivery'}); }); From a9a2fb5f166ccab162275c0f62acab33c7e1c997 Mon Sep 17 00:00:00 2001 From: Ilyas Foo Date: Thu, 17 Jun 2021 14:53:49 +0800 Subject: [PATCH 38/41] Bump woocommerce-admin version to 2.4.0-rc.1 --- bin/composer/wp/composer.lock | 12 ++++++------ composer.json | 2 +- composer.lock | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/composer/wp/composer.lock b/bin/composer/wp/composer.lock index 0674d3f98fa..f65a90a5007 100644 --- a/bin/composer/wp/composer.lock +++ b/bin/composer/wp/composer.lock @@ -254,16 +254,16 @@ }, { "name": "rmccue/requests", - "version": "v1.8.0", + "version": "v1.8.1", "source": { "type": "git", "url": "https://github.com/WordPress/Requests.git", - "reference": "afbe4790e4def03581c4a0963a1e8aa01f6030f1" + "reference": "82e6936366eac3af4d836c18b9d8c31028fe4cd5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/Requests/zipball/afbe4790e4def03581c4a0963a1e8aa01f6030f1", - "reference": "afbe4790e4def03581c4a0963a1e8aa01f6030f1", + "url": "https://api.github.com/repos/WordPress/Requests/zipball/82e6936366eac3af4d836c18b9d8c31028fe4cd5", + "reference": "82e6936366eac3af4d836c18b9d8c31028fe4cd5", "shasum": "" }, "require": { @@ -308,9 +308,9 @@ ], "support": { "issues": "https://github.com/WordPress/Requests/issues", - "source": "https://github.com/WordPress/Requests/tree/v1.8.0" + "source": "https://github.com/WordPress/Requests/tree/v1.8.1" }, - "time": "2021-04-27T11:05:25+00:00" + "time": "2021-06-04T09:56:25+00:00" }, { "name": "symfony/finder", diff --git a/composer.json b/composer.json index 8df8848a89d..4fc88b8b3d6 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "pelago/emogrifier": "3.1.0", "psr/container": "1.0.0", "woocommerce/action-scheduler": "3.2.0", - "woocommerce/woocommerce-admin": "2.3.1", + "woocommerce/woocommerce-admin": "2.4.0-rc.1", "woocommerce/woocommerce-blocks": "5.3.1" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 0091b0486ef..5916b402e4b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "21b06e63b5f65deec4b635463a10402b", + "content-hash": "f8559beec5d404538c243359bad85998", "packages": [ { "name": "automattic/jetpack-autoloader", @@ -532,16 +532,16 @@ }, { "name": "woocommerce/woocommerce-admin", - "version": "2.3.1", + "version": "2.4.0-rc.1", "source": { "type": "git", "url": "https://github.com/woocommerce/woocommerce-admin.git", - "reference": "f28cf3f027e27a6679e4fa8173d8b6859ec84838" + "reference": "8535174d5326c74ddccb1d8f5ff3596cdc916a67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/f28cf3f027e27a6679e4fa8173d8b6859ec84838", - "reference": "f28cf3f027e27a6679e4fa8173d8b6859ec84838", + "url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/8535174d5326c74ddccb1d8f5ff3596cdc916a67", + "reference": "8535174d5326c74ddccb1d8f5ff3596cdc916a67", "shasum": "" }, "require": { @@ -578,9 +578,9 @@ "homepage": "https://github.com/woocommerce/woocommerce-admin", "support": { "issues": "https://github.com/woocommerce/woocommerce-admin/issues", - "source": "https://github.com/woocommerce/woocommerce-admin/tree/v2.3.1" + "source": "https://github.com/woocommerce/woocommerce-admin/tree/v2.4.0-rc.1" }, - "time": "2021-05-24T09:48:40+00:00" + "time": "2021-06-17T06:24:54+00:00" }, { "name": "woocommerce/woocommerce-blocks", From 44899677cf0fefcbd50957619e64c78b041f61b1 Mon Sep 17 00:00:00 2001 From: Ilyas Foo Date: Fri, 18 Jun 2021 14:40:15 +0800 Subject: [PATCH 39/41] Update to rc2 --- bin/composer/wp/composer.lock | 6 +---- composer.json | 2 +- composer.lock | 51 +++++------------------------------ 3 files changed, 9 insertions(+), 50 deletions(-) diff --git a/bin/composer/wp/composer.lock b/bin/composer/wp/composer.lock index f65a90a5007..08806cfd5e5 100644 --- a/bin/composer/wp/composer.lock +++ b/bin/composer/wp/composer.lock @@ -306,10 +306,6 @@ "iri", "sockets" ], - "support": { - "issues": "https://github.com/WordPress/Requests/issues", - "source": "https://github.com/WordPress/Requests/tree/v1.8.1" - }, "time": "2021-06-04T09:56:25+00:00" }, { @@ -612,5 +608,5 @@ "platform-overrides": { "php": "7.0" }, - "plugin-api-version": "2.0.0" + "plugin-api-version": "1.1.0" } diff --git a/composer.json b/composer.json index 4fc88b8b3d6..f1bb1a94606 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "pelago/emogrifier": "3.1.0", "psr/container": "1.0.0", "woocommerce/action-scheduler": "3.2.0", - "woocommerce/woocommerce-admin": "2.4.0-rc.1", + "woocommerce/woocommerce-admin": "2.4.0-rc.2", "woocommerce/woocommerce-blocks": "5.3.1" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 5916b402e4b..72facb2f192 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f8559beec5d404538c243359bad85998", + "content-hash": "6427ca1d82e637782404faeb3b988ec3", "packages": [ { "name": "automattic/jetpack-autoloader", @@ -51,9 +51,6 @@ "GPL-2.0-or-later" ], "description": "Creates a custom autoloader for a plugin or theme.", - "support": { - "source": "https://github.com/Automattic/jetpack-autoloader/tree/2.10.1" - }, "time": "2021-03-30T15:15:59+00:00" }, { @@ -85,9 +82,6 @@ "GPL-2.0-or-later" ], "description": "A wrapper for defining constants in a more testable way.", - "support": { - "source": "https://github.com/Automattic/jetpack-constants/tree/v1.5.1" - }, "time": "2020-10-28T19:00:31+00:00" }, { @@ -220,10 +214,6 @@ "zend", "zikula" ], - "support": { - "issues": "https://github.com/composer/installers/issues", - "source": "https://github.com/composer/installers/tree/v1.11.0" - }, "funding": [ { "url": "https://packagist.com", @@ -298,10 +288,6 @@ "geolocation", "maxmind" ], - "support": { - "issues": "https://github.com/maxmind/MaxMind-DB-Reader-php/issues", - "source": "https://github.com/maxmind/MaxMind-DB-Reader-php/tree/v1.6.0" - }, "time": "2019-12-19T22:59:03+00:00" }, { @@ -376,10 +362,6 @@ "email", "pre-processing" ], - "support": { - "issues": "https://github.com/MyIntervals/emogrifier/issues", - "source": "https://github.com/MyIntervals/emogrifier" - }, "time": "2019-12-26T19:37:31+00:00" }, { @@ -429,10 +411,6 @@ "container-interop", "psr" ], - "support": { - "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/master" - }, "time": "2017-02-14T16:28:37+00:00" }, { @@ -486,9 +464,6 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/css-selector/tree/master" - }, "time": "2017-05-01T15:01:29+00:00" }, { @@ -532,16 +507,16 @@ }, { "name": "woocommerce/woocommerce-admin", - "version": "2.4.0-rc.1", + "version": "2.4.0-rc.2", "source": { "type": "git", "url": "https://github.com/woocommerce/woocommerce-admin.git", - "reference": "8535174d5326c74ddccb1d8f5ff3596cdc916a67" + "reference": "ed72985cd459831c555dff2ff5f75111b6e210c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/8535174d5326c74ddccb1d8f5ff3596cdc916a67", - "reference": "8535174d5326c74ddccb1d8f5ff3596cdc916a67", + "url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/ed72985cd459831c555dff2ff5f75111b6e210c1", + "reference": "ed72985cd459831c555dff2ff5f75111b6e210c1", "shasum": "" }, "require": { @@ -576,11 +551,7 @@ ], "description": "A modern, javascript-driven WooCommerce Admin experience.", "homepage": "https://github.com/woocommerce/woocommerce-admin", - "support": { - "issues": "https://github.com/woocommerce/woocommerce-admin/issues", - "source": "https://github.com/woocommerce/woocommerce-admin/tree/v2.4.0-rc.1" - }, - "time": "2021-06-17T06:24:54+00:00" + "time": "2021-06-18T05:58:25+00:00" }, { "name": "woocommerce/woocommerce-blocks", @@ -627,10 +598,6 @@ "gutenberg", "woocommerce" ], - "support": { - "issues": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues", - "source": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/tree/v5.3.1" - }, "time": "2021-06-15T09:12:48+00:00" } ], @@ -679,10 +646,6 @@ "isolation", "tool" ], - "support": { - "issues": "https://github.com/bamarni/composer-bin-plugin/issues", - "source": "https://github.com/bamarni/composer-bin-plugin/tree/master" - }, "time": "2020-05-03T08:27:20+00:00" } ], @@ -698,5 +661,5 @@ "platform-overrides": { "php": "7.0" }, - "plugin-api-version": "2.0.0" + "plugin-api-version": "1.1.0" } From 639c091f614a15be17529fa0b2eea21bc85da539 Mon Sep 17 00:00:00 2001 From: Rodel Calasagsag Date: Fri, 18 Jun 2021 15:17:18 +0800 Subject: [PATCH 40/41] Added changelog in utils package --- tests/e2e/utils/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/e2e/utils/CHANGELOG.md b/tests/e2e/utils/CHANGELOG.md index 332eee4c055..01e698ec22e 100644 --- a/tests/e2e/utils/CHANGELOG.md +++ b/tests/e2e/utils/CHANGELOG.md @@ -1,5 +1,9 @@ # Unreleased +## Added + +- Factories for variable product, variation, and grouped product + # 0.1.5 ## Added From e0db9beb20e4ec423eb98a42cf5b46ee461097b0 Mon Sep 17 00:00:00 2001 From: Ilyas Foo Date: Fri, 18 Jun 2021 18:19:27 +0800 Subject: [PATCH 41/41] Add delay to reduce e2e test flakiness in OBW - Business Details --- tests/e2e/utils/src/components.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/e2e/utils/src/components.js b/tests/e2e/utils/src/components.js index c5e3daf7f51..47992f0bd37 100644 --- a/tests/e2e/utils/src/components.js +++ b/tests/e2e/utils/src/components.js @@ -135,6 +135,9 @@ const completeOnboardingWizard = async () => { // Business Details section + // Temporarily add delay to reduce test flakiness + await page.waitFor( 2000 ); + // Query for the s const selectControls = await page.$$( '.woocommerce-select-control' ); expect( selectControls ).toHaveLength( 2 );