Merge branch 'trunk' of github.com:woocommerce/woocommerce into fix/e2e-calc-shipping-tests

This commit is contained in:
Greg 2021-08-16 13:05:14 -06:00
commit f30a661921
17 changed files with 85 additions and 20 deletions

View File

@ -40,6 +40,7 @@ jobs:
E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }} E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }}
E2E_SLACK_CHANNEL: ${{ secrets.SMOKE_TEST_SLACK_CHANNEL }} E2E_SLACK_CHANNEL: ${{ secrets.SMOKE_TEST_SLACK_CHANNEL }}
UPDATE_WC: 1 UPDATE_WC: 1
DEFAULT_TIMEOUT_OVERRIDE: 120000
run: | run: |
npx wc-e2e test:e2e ./tests/e2e/specs/smoke-tests/update-woocommerce.js npx wc-e2e test:e2e ./tests/e2e/specs/smoke-tests/update-woocommerce.js
npx wc-e2e test:e2e npx wc-e2e test:e2e

View File

@ -41,6 +41,7 @@ jobs:
E2E_SLACK_CHANNEL: ${{ secrets.SMOKE_TEST_SLACK_CHANNEL }} E2E_SLACK_CHANNEL: ${{ secrets.SMOKE_TEST_SLACK_CHANNEL }}
TEST_RELEASE: 1 TEST_RELEASE: 1
UPDATE_WC: 1 UPDATE_WC: 1
DEFAULT_TIMEOUT_OVERRIDE: 120000
run: | run: |
npx wc-e2e test:e2e ./tests/e2e/specs/smoke-tests/update-woocommerce.js npx wc-e2e test:e2e ./tests/e2e/specs/smoke-tests/update-woocommerce.js
npx wc-e2e test:e2e npx wc-e2e test:e2e

View File

@ -25,7 +25,7 @@
* Dev - Apply `woocommerce_logout_default_redirect_url` filter to logout for custom endpoint. #29967 * Dev - Apply `woocommerce_logout_default_redirect_url` filter to logout for custom endpoint. #29967
* Dev - Added new `woocommerce_email_sent` hook. #30123 * Dev - Added new `woocommerce_email_sent` hook. #30123
**WooCommerce Admin - 2.5.0** **WooCommerce Admin - 2.5.0 & 2.5.1**
- Add - Add a delete option to completed tasks #7300 - Add - Add a delete option to completed tasks #7300
- Add - Add unit tests around extended payment gateway controller #7133 - Add - Add unit tests around extended payment gateway controller #7133
@ -79,6 +79,7 @@
- Fix - Fix analytics overview re-arrangement on initial load. #7475 - Fix - Fix analytics overview re-arrangement on initial load. #7475
- Fix - Fixes action button mis-alignment within card footer. #7412 - Fix - Fixes action button mis-alignment within card footer. #7412
- Fix - Fix up onboarding profiler not working when opted out of tracking - Fix - Fix up onboarding profiler not working when opted out of tracking
- Fix - Fix blank screen by setting a default value #7506
- Tweak - Remove performance indicators when Analytics Flag disabled #7234 - Tweak - Remove performance indicators when Analytics Flag disabled #7234
- Tweak - Change event name when installing Google Listings and Ads. #7276 - Tweak - Change event name when installing Google Listings and Ads. #7276
- Tweak - Removed unused feature flags #7233 and #7273 - Tweak - Removed unused feature flags #7233 and #7273

View File

@ -21,7 +21,7 @@
"pelago/emogrifier": "3.1.0", "pelago/emogrifier": "3.1.0",
"psr/container": "1.0.0", "psr/container": "1.0.0",
"woocommerce/action-scheduler": "3.2.1", "woocommerce/action-scheduler": "3.2.1",
"woocommerce/woocommerce-admin": "2.5.0", "woocommerce/woocommerce-admin": "2.5.1",
"woocommerce/woocommerce-blocks": "5.5.1" "woocommerce/woocommerce-blocks": "5.5.1"
}, },
"require-dev": { "require-dev": {

14
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "190546c0839729dcc8e8c9eb8268455e", "content-hash": "590e758559a0186574872d553d58c329",
"packages": [ "packages": [
{ {
"name": "automattic/jetpack-autoloader", "name": "automattic/jetpack-autoloader",
@ -532,16 +532,16 @@
}, },
{ {
"name": "woocommerce/woocommerce-admin", "name": "woocommerce/woocommerce-admin",
"version": "2.5.0", "version": "2.5.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/woocommerce/woocommerce-admin.git", "url": "https://github.com/woocommerce/woocommerce-admin.git",
"reference": "99a0bd3a48bf33a054efd3b0df29bf42766761f8" "reference": "093d698d770f49d41df8abe89a716dc897bb9e96"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/99a0bd3a48bf33a054efd3b0df29bf42766761f8", "url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/093d698d770f49d41df8abe89a716dc897bb9e96",
"reference": "99a0bd3a48bf33a054efd3b0df29bf42766761f8", "reference": "093d698d770f49d41df8abe89a716dc897bb9e96",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -596,9 +596,9 @@
"homepage": "https://github.com/woocommerce/woocommerce-admin", "homepage": "https://github.com/woocommerce/woocommerce-admin",
"support": { "support": {
"issues": "https://github.com/woocommerce/woocommerce-admin/issues", "issues": "https://github.com/woocommerce/woocommerce-admin/issues",
"source": "https://github.com/woocommerce/woocommerce-admin/tree/v2.5.0" "source": "https://github.com/woocommerce/woocommerce-admin/tree/v2.5.1"
}, },
"time": "2021-08-09T21:00:32+00:00" "time": "2021-08-16T14:31:33+00:00"
}, },
{ {
"name": "woocommerce/woocommerce-blocks", "name": "woocommerce/woocommerce-blocks",

View File

@ -226,7 +226,7 @@ final class WC_Cart_Totals {
$item->taxable = 'taxable' === $cart_item['data']->get_tax_status(); $item->taxable = 'taxable' === $cart_item['data']->get_tax_status();
$item->price_includes_tax = wc_prices_include_tax(); $item->price_includes_tax = wc_prices_include_tax();
$item->quantity = $cart_item['quantity']; $item->quantity = $cart_item['quantity'];
$item->price = wc_add_number_precision_deep( $cart_item['data']->get_price() * $cart_item['quantity'] ); $item->price = wc_add_number_precision_deep( (float) $cart_item['data']->get_price() * (float) $cart_item['quantity'] );
$item->product = $cart_item['data']; $item->product = $cart_item['data'];
$item->tax_rates = $this->get_item_tax_rates( $item ); $item->tax_rates = $this->get_item_tax_rates( $item );
$this->items[ $cart_item_key ] = $item; $this->items[ $cart_item_key ] = $item;

View File

@ -84,7 +84,7 @@ class WC_Discounts {
$item->object = $cart_item; $item->object = $cart_item;
$item->product = $cart_item['data']; $item->product = $cart_item['data'];
$item->quantity = $cart_item['quantity']; $item->quantity = $cart_item['quantity'];
$item->price = wc_add_number_precision_deep( $item->product->get_price() * $item->quantity ); $item->price = wc_add_number_precision_deep( (float) $item->product->get_price() * (float) $item->quantity );
$this->items[ $key ] = $item; $this->items[ $key ] = $item;
} }

View File

@ -3532,9 +3532,9 @@
"dev": true "dev": true
}, },
"path-parse": { "path-parse": {
"version": "1.0.6", "version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
"dev": true "dev": true
}, },
"performance-now": { "performance-now": {

View File

@ -8,6 +8,7 @@ import {
const config = require('config'); const config = require('config');
const { HTTPClientFactory } = require('@woocommerce/api'); const { HTTPClientFactory } = require('@woocommerce/api');
const { addConsoleSuppression, updateReadyPageStatus } = require( '@woocommerce/e2e-environment' ); const { addConsoleSuppression, updateReadyPageStatus } = require( '@woocommerce/e2e-environment' );
const { DEFAULT_TIMEOUT_OVERRIDE } = process.env;
// @todo: remove this once https://github.com/woocommerce/woocommerce-admin/issues/6992 has been addressed // @todo: remove this once https://github.com/woocommerce/woocommerce-admin/issues/6992 has been addressed
addConsoleSuppression( 'woocommerce_shared_settings' ); addConsoleSuppression( 'woocommerce_shared_settings' );
@ -38,6 +39,12 @@ async function trashExistingPosts() {
// other posts/comments/etc. aren't dirtying tests and tests don't depend on // other posts/comments/etc. aren't dirtying tests and tests don't depend on
// each other's side-effects. // each other's side-effects.
beforeAll(async () => { beforeAll(async () => {
if ( DEFAULT_TIMEOUT_OVERRIDE ) {
page.setDefaultNavigationTimeout( DEFAULT_TIMEOUT_OVERRIDE );
page.setDefaultTimeout( DEFAULT_TIMEOUT_OVERRIDE );
}
// Update the ready page to prevent concurrent test runs // Update the ready page to prevent concurrent test runs
await updateReadyPageStatus('draft'); await updateReadyPageStatus('draft');

View File

@ -1,12 +1,13 @@
# Unreleased # Unreleased
- `updateReadyPageStatus` utility to update the status of the ready page - `updateReadyPageStatus` utility to update the status of the ready page.
- Added plugin upload functionality util that provides a method to pull a plugin zip from a remote location - Added plugin upload functionality util that provides a method to pull a plugin zip from a remote location:
- `getRemotePluginZip( fileUrl )` to get the remote zip. Returns the filepath of the zip location. - `getRemotePluginZip( fileUrl )` to get the remote zip. Returns the filepath of the zip location.
- Added plugin zip utility functions: - Added plugin zip utility functions:
- `checkNestedZip( zipFilePath, savePath )` checks a plugin zip file for any nested zip files. If one is found, it is extracted. Returns the path where the zip file is located. - `checkNestedZip( zipFilePath, savePath )` checks a plugin zip file for any nested zip files. If one is found, it is extracted. Returns the path where the zip file is located.
- `downloadZip( fileUrl, downloadPath )` downloads a plugin zip file from a remote location to the provided path. - `downloadZip( fileUrl, downloadPath )` downloads a plugin zip file from a remote location to the provided path.
- Added `getLatestReleaseZipUrl( owner, repository, getPrerelease, perPage )` util function to get the latest release zip from a GitHub repository - Added `getLatestReleaseZipUrl( owner, repository, getPrerelease, perPage )` util function to get the latest release zip from a GitHub repository.
- Added `DEFAULT_TIMEOUT_OVERRIDE` that allows passing in a time in milliseconds to override the default Jest and Puppeteer timeouts.
# 0.2.2 # 0.2.2

View File

@ -87,6 +87,21 @@ await takeScreenshotFor( 'name of current step' );
Screenshots will be saved to `tests/e2e/screenshots`. This folder is cleared at the beginning of each test run. Screenshots will be saved to `tests/e2e/screenshots`. This folder is cleared at the beginning of each test run.
### Override default test timeout
To override the default timeout for the tests, you can use the `DEFAULT_TIMEOUT_OVERRIDE` flag and pass in a maximum timeout in milliseconds. For example, you can pass it in when running the tests from the command line:
```bash
DEFAULT_TIMEOUT_OVERRIDE=35000 npx wc-e2e test:e2e
```
This value will override the default Jest timeout as well as pass the timeout to the following Puppeteer methods:
* page.setDefaultTimeout();
* page.setDefaultNavigationTimeout();
For a list of the methods that the above timeout affects, please see the Puppeteer documentation for [`page.setDefaultTimeout()`](https://pptr.dev/#?product=Puppeteer&version=v10.2.0&show=api-pagesetdefaulttimeouttimeout) and [`page.setDefaultNavigationTimeout`](https://pptr.dev/#?product=Puppeteer&version=v10.2.0&show=api-pagesetdefaultnavigationtimeouttimeout) for more information.
### Jest Puppeteer Config ### Jest Puppeteer Config
The test sequencer uses the following default Puppeteer configuration: The test sequencer uses the following default Puppeteer configuration:

View File

@ -5,7 +5,7 @@ const program = require( 'commander' );
const path = require( 'path' ); const path = require( 'path' );
const fs = require( 'fs' ); const fs = require( 'fs' );
const { getAppRoot } = require( '../utils' ); const { getAppRoot } = require( '../utils' );
const { WC_E2E_SCREENSHOTS, JEST_PUPPETEER_CONFIG } = process.env; const { WC_E2E_SCREENSHOTS, JEST_PUPPETEER_CONFIG, DEFAULT_TIMEOUT_OVERRIDE } = process.env;
program program
.usage( '<file ...> [options]' ) .usage( '<file ...> [options]' )
@ -43,6 +43,10 @@ let testEnvVars = {
jest_test_timeout: program.dev ? 120000 : 30000, jest_test_timeout: program.dev ? 120000 : 30000,
}; };
if ( DEFAULT_TIMEOUT_OVERRIDE ) {
testEnvVars.jest_test_timeout = DEFAULT_TIMEOUT_OVERRIDE;
}
if ( ! JEST_PUPPETEER_CONFIG ) { if ( ! JEST_PUPPETEER_CONFIG ) {
// Use local Puppeteer config if there is one. // Use local Puppeteer config if there is one.
// Load test configuration file into an object. // Load test configuration file into an object.

View File

@ -41,4 +41,9 @@ utils.describeIf( UPDATE_WC )( 'WooCommerce plugin can be uploaded and activated
await merchant.uploadAndActivatePlugin( pluginPath, pluginName ); await merchant.uploadAndActivatePlugin( pluginPath, pluginName );
}); });
it( 'can run the database update', async () => {
// Check for, and run, the database upgrade if needed
await merchant.runDatabaseUpdate();
});
}); });

View File

@ -12,6 +12,7 @@
- Added `describeIf()` to conditionally run a test suite - Added `describeIf()` to conditionally run a test suite
- Added `itIf()` to conditionally run a test case. - Added `itIf()` to conditionally run a test case.
- Added merchant workflows around plugins: `uploadAndActivatePlugin()`, `activatePlugin()`, `deactivatePlugin()`, `deletePlugin()` - Added merchant workflows around plugins: `uploadAndActivatePlugin()`, `activatePlugin()`, `deactivatePlugin()`, `deletePlugin()`
- Added merchant workflows checking for a database update and performing the update if needed: `runDatabaseUpdate()`
- Added `deleteAllOrders()` that goes through and deletes all orders - Added `deleteAllOrders()` that goes through and deletes all orders
- Added `deleteAllShippingClasses()` which permanently deletes all shipping classes using the API - Added `deleteAllShippingClasses()` which permanently deletes all shipping classes using the API
- Added `statuses` optional parameter to `deleteAllRepositoryObjects()` to delete on specific statuses - Added `statuses` optional parameter to `deleteAllRepositoryObjects()` to delete on specific statuses

View File

@ -109,6 +109,7 @@ This package provides support for enabling retries in tests:
| `updateWordPress` | | Install pending WordPress updates on Dashboard -> Updates| | `updateWordPress` | | Install pending WordPress updates on Dashboard -> Updates|
| `updatePlugins` | | Install all pending plugin updates on Dashboard -> Updates| | `updatePlugins` | | Install all pending plugin updates on Dashboard -> Updates|
| `updateThemes` | | Install all pending theme updates on Dashboard -> Updates| | `updateThemes` | | Install all pending theme updates on Dashboard -> Updates|
| `runDatabaseUpdate` || Runs the database update if needed |
### Shopper `shopper` ### Shopper `shopper`
@ -133,7 +134,7 @@ This package provides support for enabling retries in tests:
| `removeFromCart` | `productTitle` | Remove a product from the cart on the cart page | | `removeFromCart` | `productTitle` | Remove a product from the cart on the cart page |
| `setCartQuantity` | `productTitle, quantityValue` | Change the quantity of a product on the cart page | | `setCartQuantity` | `productTitle, quantityValue` | Change the quantity of a product on the cart page |
| `searchForProduct` | | Searching for a product name and landing on its detail page | | `searchForProduct` | | Searching for a product name and landing on its detail page |
| `emptyCart` | | Removes any products and coupons that are in the cart | | `emptyCart` | | Removes any products and coupons that are in the cart |
### REST API `withRestApi` ### REST API `withRestApi`

View File

@ -2,7 +2,7 @@
"name": "@woocommerce/e2e-utils", "name": "@woocommerce/e2e-utils",
"version": "0.1.5", "version": "0.1.5",
"description": "End-To-End (E2E) test utils for WooCommerce", "description": "End-To-End (E2E) test utils for WooCommerce",
"homepage": "https://github.com/woocommerce/woocommerce/tree/trunk/tests/e2e-utils/README.md", "homepage": "https://github.com/woocommerce/woocommerce/tree/trunk/tests/e2e/utils/README.md",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/woocommerce/woocommerce.git" "url": "https://github.com/woocommerce/woocommerce.git"

View File

@ -373,6 +373,34 @@ const merchant = {
// Wait for Ajax calls to finish // Wait for Ajax calls to finish
await page.waitForResponse( response => response.status() === 200 ); await page.waitForResponse( response => response.status() === 200 );
},
/**
* Runs the database update if needed. For example, after uploading the WooCommerce plugin or updating WooCommerce.
*/
runDatabaseUpdate: async () => {
if ( await page.$( '.updated.woocommerce-message.wc-connect' ) !== null ) {
await expect( page ).toMatchElement( 'a.wc-update-now', { text: 'Update WooCommerce Database' } );
await expect( page ).toClick( 'a.wc-update-now' );
await page.waitForNavigation( { waitUntil: 'networkidle0' } );
await merchant.checkDatabaseUpdateComplete();
}
},
/**
* Checks if the database update is complete, if not, refresh the page until it is.
*/
checkDatabaseUpdateComplete: async () => {
await page.reload( { waitUntil: [ 'networkidle0', 'domcontentloaded'] } );
const thanksButtonSelector = 'a.components-button.is-primary';
if ( await page.$( thanksButtonSelector ) !== null ) {
await expect( page ).toMatchElement( thanksButtonSelector, { text: 'Thanks!' } );
await expect( page ).toClick( thanksButtonSelector );
} else {
await merchant.checkDatabaseUpdateComplete();
}
}, },
}; };