From 903b86677c8e389d94356eee31d336a2cb617e7b Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Fri, 9 Oct 2020 10:31:45 -0300 Subject: [PATCH 01/22] add readme to core tests package --- tests/e2e/core-tests/README.md | 100 +++++++++++++++++++++++++++++++++ tests/e2e/core-tests/index.js | 42 +------------- 2 files changed, 102 insertions(+), 40 deletions(-) create mode 100644 tests/e2e/core-tests/README.md diff --git a/tests/e2e/core-tests/README.md b/tests/e2e/core-tests/README.md new file mode 100644 index 00000000000..a277f9853de --- /dev/null +++ b/tests/e2e/core-tests/README.md @@ -0,0 +1,100 @@ +# WooCommerce Core End to End Test Suite + +This package contains the automated end-to-end tests for WooCommerce. + +## Table of contents + +- [Pre-requisites](#pre-requisites) +- [Setting up core tests](#setting-up-core-tests) +- [Test functions](#test-functions) + - [Activation and setup](#activation-and-setup) + - [Merchant](#merchant) + - [Shopper](#shopper) +- [Contributing a new test](#contributing-a-new-test) + +## Pre-requisites + +### Setting up the test environment + +Follow [E2E setup instructions](https://github.com/woocommerce/woocommerce/test/e2e/README.md). + +### Setting up core tests + +- Create the folder `tests/e2e/specs` in your repository if it does not exist. +- To add a core test to your test suite, create a new `.test.js` file within `tests/e2e/specs` . Example code to run all the shopper tests: +```js + +const { runShopperTests } = require( '@woocommerce/e2e-core-tests' ); + +runShopperTests(); + +``` + +## Test functions + +The functions to access the core tests are: + +### Activation and setup + +- `runSetupOnboardingTests` - Run all setup and onboarding tests +- `runActivationTest` - Merchant can activate WooCommerce +- `runOnboardingFlowTest` - Merchant can complete onboarding flow +- `runTaskListTest` - Merchant can complete onboarding task list +- `runInitialStoreSettingsTest` - Merchant can complete initial settings + +### Merchant + +- `runMerchantTests` - Run all merchant tests +- `runCreateCouponTest` - Merchant can create coupon +- `runCreateOrderTest` - Merchant can create order +- `runAddSimpleProductTest` - Merchant can create a simple product +- `runAddVariableProductTest` - Merchant can create a variable product +- `runUpdateGeneralSettingsTest` - Merchant can update general settings +- `runProductSettingsTest` - Merchant can update product settings +- `runTaxSettingsTest` - Merchant can update tax settings + +### Shopper + +- `runShopperTests` - Run all shopper tests +- `runCartPageTest` - Shopper can view and update cart +- `runCheckoutPageTest` - Shopper can complete checkout +- `runMyAccountPageTest` - Shopper can access my account page +- `runSingleProductPageTest` - Shopper can view single product page + +## Contributing a new test + +- In your branch create a new `example-test-name.test.js` under the `tests/e2e/core-tests/specs` folder. +- Jest does not allow its global functions to be accessed outside the jest environment. To allow the test code to be published in a package import any jest global functions used in your test +```js +const { + it, + describe, + beforeAll, +} = require( '@jest/globals' ); +``` +- Wrap your test in a function and export it +```js +const runExampleTestName = () => { + describe('Example test', () => { + beforeAll(async () => { + // ... + }); + + it('do some example action', async () => { + // ... + }); + // ... + }); +}); + +module.exports = runExampleTestName; +``` +- Add your test to `tests/e2e/core-tests/specs/index.js` +```js +const runExampleTestName = require( './grouping/example-test-name.test' ); +// ... +module.exports = { +// ... + runExampleTestName, +} +``` diff --git a/tests/e2e/core-tests/index.js b/tests/e2e/core-tests/index.js index b4c4e6d2aa9..9fd036edd21 100644 --- a/tests/e2e/core-tests/index.js +++ b/tests/e2e/core-tests/index.js @@ -1,44 +1,6 @@ /* * Internal dependencies */ -const { - runActivationTest, - runOnboardingFlowTest, - runTaskListTest, - runInitialStoreSettingsTest, - runSetupOnboardingTests, - runCartPageTest, - runCheckoutPageTest, - runMyAccountPageTest, - runSingleProductPageTest, - runShopperTests, - runCreateCouponTest, - runCreateOrderTest, - runAddSimpleProductTest, - runAddVariableProductTest, - runUpdateGeneralSettingsTest, - runProductSettingsTest, - runTaxSettingsTest, - runMerchantTests, -} = require( './specs' ); +const allSpecs = require( './specs' ); -module.exports = { - runActivationTest, - runOnboardingFlowTest, - runTaskListTest, - runInitialStoreSettingsTest, - runSetupOnboardingTests, - runCartPageTest, - runCheckoutPageTest, - runMyAccountPageTest, - runSingleProductPageTest, - runShopperTests, - runCreateCouponTest, - runCreateOrderTest, - runAddSimpleProductTest, - runAddVariableProductTest, - runUpdateGeneralSettingsTest, - runProductSettingsTest, - runTaxSettingsTest, - runMerchantTests, -}; +module.exports = allSpecs; From 8c73c5f2f80244865ca6773dcb22ff4c30a97256 Mon Sep 17 00:00:00 2001 From: roykho Date: Mon, 19 Oct 2020 06:47:16 -0700 Subject: [PATCH 02/22] Replace jQuery.ready function with recommended way since jQuery 3.0 closes #27945 --- includes/class-wc-shortcodes.php | 2 +- includes/customizer/class-wc-shop-customizer.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-shortcodes.php b/includes/class-wc-shortcodes.php index 705b57d3e92..1fdebe7ca35 100644 --- a/includes/class-wc-shortcodes.php +++ b/includes/class-wc-shortcodes.php @@ -565,7 +565,7 @@ class WC_Shortcodes { $single_product = new WP_Query( $args ); ?>