diff --git a/.github/workflows/smoke-test-daily.yml b/.github/workflows/smoke-test-daily.yml index b3468b1135c..671b88f158f 100644 --- a/.github/workflows/smoke-test-daily.yml +++ b/.github/workflows/smoke-test-daily.yml @@ -40,6 +40,7 @@ jobs: E2E_SLACK_TOKEN: ${{ secrets.SMOKE_TEST_SLACK_TOKEN }} E2E_SLACK_CHANNEL: ${{ secrets.SMOKE_TEST_SLACK_CHANNEL }} UPDATE_WC: 1 + DEFAULT_TIMEOUT_OVERRIDE: 120000 run: | npx wc-e2e test:e2e ./tests/e2e/specs/smoke-tests/update-woocommerce.js npx wc-e2e test:e2e diff --git a/.github/workflows/smoke-test-release.yml b/.github/workflows/smoke-test-release.yml index 83e0f287ac2..960f193b518 100644 --- a/.github/workflows/smoke-test-release.yml +++ b/.github/workflows/smoke-test-release.yml @@ -41,6 +41,7 @@ jobs: E2E_SLACK_CHANNEL: ${{ secrets.SMOKE_TEST_SLACK_CHANNEL }} TEST_RELEASE: 1 UPDATE_WC: 1 + DEFAULT_TIMEOUT_OVERRIDE: 120000 run: | npx wc-e2e test:e2e ./tests/e2e/specs/smoke-tests/update-woocommerce.js npx wc-e2e test:e2e diff --git a/changelog.txt b/changelog.txt index f6530befb10..1efc063b75a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -25,7 +25,7 @@ * Dev - Apply `woocommerce_logout_default_redirect_url` filter to logout for custom endpoint. #29967 * 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 unit tests around extended payment gateway controller #7133 @@ -79,6 +79,7 @@ - Fix - Fix analytics overview re-arrangement on initial load. #7475 - Fix - Fixes action button mis-alignment within card footer. #7412 - 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 - Change event name when installing Google Listings and Ads. #7276 - Tweak - Removed unused feature flags #7233 and #7273 diff --git a/composer.json b/composer.json index 163be402e97..e41e7b360ed 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.1", - "woocommerce/woocommerce-admin": "2.5.0", + "woocommerce/woocommerce-admin": "2.5.1", "woocommerce/woocommerce-blocks": "5.5.1" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 1bc91459280..b3a4dfc25c7 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": "190546c0839729dcc8e8c9eb8268455e", + "content-hash": "590e758559a0186574872d553d58c329", "packages": [ { "name": "automattic/jetpack-autoloader", @@ -532,16 +532,16 @@ }, { "name": "woocommerce/woocommerce-admin", - "version": "2.5.0", + "version": "2.5.1", "source": { "type": "git", "url": "https://github.com/woocommerce/woocommerce-admin.git", - "reference": "99a0bd3a48bf33a054efd3b0df29bf42766761f8" + "reference": "093d698d770f49d41df8abe89a716dc897bb9e96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/99a0bd3a48bf33a054efd3b0df29bf42766761f8", - "reference": "99a0bd3a48bf33a054efd3b0df29bf42766761f8", + "url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/093d698d770f49d41df8abe89a716dc897bb9e96", + "reference": "093d698d770f49d41df8abe89a716dc897bb9e96", "shasum": "" }, "require": { @@ -596,9 +596,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.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", diff --git a/includes/class-wc-cart-totals.php b/includes/class-wc-cart-totals.php index 54afe9827ca..87464c756a7 100644 --- a/includes/class-wc-cart-totals.php +++ b/includes/class-wc-cart-totals.php @@ -226,7 +226,7 @@ final class WC_Cart_Totals { $item->taxable = 'taxable' === $cart_item['data']->get_tax_status(); $item->price_includes_tax = wc_prices_include_tax(); $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->tax_rates = $this->get_item_tax_rates( $item ); $this->items[ $cart_item_key ] = $item; diff --git a/includes/class-wc-discounts.php b/includes/class-wc-discounts.php index 522495fee8d..8b2c5b4aabc 100644 --- a/includes/class-wc-discounts.php +++ b/includes/class-wc-discounts.php @@ -84,7 +84,7 @@ class WC_Discounts { $item->object = $cart_item; $item->product = $cart_item['data']; $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; } diff --git a/tests/e2e/api/package-lock.json b/tests/e2e/api/package-lock.json index 579b4399c2f..6b0ed650a71 100644 --- a/tests/e2e/api/package-lock.json +++ b/tests/e2e/api/package-lock.json @@ -3532,9 +3532,9 @@ "dev": true }, "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "performance-now": { diff --git a/tests/e2e/config/jest.setup.js b/tests/e2e/config/jest.setup.js index 28ae1fb2ab6..f219ddbb54d 100644 --- a/tests/e2e/config/jest.setup.js +++ b/tests/e2e/config/jest.setup.js @@ -8,6 +8,7 @@ import { const config = require('config'); const { HTTPClientFactory } = require('@woocommerce/api'); 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 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 // each other's side-effects. 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 await updateReadyPageStatus('draft'); diff --git a/tests/e2e/env/CHANGELOG.md b/tests/e2e/env/CHANGELOG.md index 430535092db..69b47c445ad 100644 --- a/tests/e2e/env/CHANGELOG.md +++ b/tests/e2e/env/CHANGELOG.md @@ -1,12 +1,13 @@ # Unreleased -- `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 +- `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: - `getRemotePluginZip( fileUrl )` to get the remote zip. Returns the filepath of the zip location. - 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. - `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 diff --git a/tests/e2e/env/README.md b/tests/e2e/env/README.md index 6420d746d5e..a9e2e1ece71 100644 --- a/tests/e2e/env/README.md +++ b/tests/e2e/env/README.md @@ -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. +### 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 The test sequencer uses the following default Puppeteer configuration: diff --git a/tests/e2e/env/bin/e2e-test-integration.js b/tests/e2e/env/bin/e2e-test-integration.js index 46d457d974b..3cae8875e5e 100755 --- a/tests/e2e/env/bin/e2e-test-integration.js +++ b/tests/e2e/env/bin/e2e-test-integration.js @@ -5,7 +5,7 @@ const program = require( 'commander' ); const path = require( 'path' ); const fs = require( 'fs' ); 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 .usage( ' [options]' ) @@ -43,6 +43,10 @@ let testEnvVars = { jest_test_timeout: program.dev ? 120000 : 30000, }; +if ( DEFAULT_TIMEOUT_OVERRIDE ) { + testEnvVars.jest_test_timeout = DEFAULT_TIMEOUT_OVERRIDE; +} + if ( ! JEST_PUPPETEER_CONFIG ) { // Use local Puppeteer config if there is one. // Load test configuration file into an object. diff --git a/tests/e2e/specs/smoke-tests/update-woocommerce.js b/tests/e2e/specs/smoke-tests/update-woocommerce.js index a6c2794b884..1aef2383a4e 100644 --- a/tests/e2e/specs/smoke-tests/update-woocommerce.js +++ b/tests/e2e/specs/smoke-tests/update-woocommerce.js @@ -41,4 +41,9 @@ utils.describeIf( UPDATE_WC )( 'WooCommerce plugin can be uploaded and activated await merchant.uploadAndActivatePlugin( pluginPath, pluginName ); }); + it( 'can run the database update', async () => { + // Check for, and run, the database upgrade if needed + await merchant.runDatabaseUpdate(); + }); + }); diff --git a/tests/e2e/utils/CHANGELOG.md b/tests/e2e/utils/CHANGELOG.md index f8eb9031a5d..5c6140aec0b 100644 --- a/tests/e2e/utils/CHANGELOG.md +++ b/tests/e2e/utils/CHANGELOG.md @@ -12,6 +12,7 @@ - Added `describeIf()` to conditionally run a test suite - Added `itIf()` to conditionally run a test case. - 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 `deleteAllShippingClasses()` which permanently deletes all shipping classes using the API - Added `statuses` optional parameter to `deleteAllRepositoryObjects()` to delete on specific statuses diff --git a/tests/e2e/utils/README.md b/tests/e2e/utils/README.md index 4bc56544746..5d1cc3831d7 100644 --- a/tests/e2e/utils/README.md +++ b/tests/e2e/utils/README.md @@ -109,6 +109,7 @@ This package provides support for enabling retries in tests: | `updateWordPress` | | Install pending WordPress updates on Dashboard -> Updates| | `updatePlugins` | | Install all pending plugin updates on Dashboard -> Updates| | `updateThemes` | | Install all pending theme updates on Dashboard -> Updates| +| `runDatabaseUpdate` || Runs the database update if needed | ### 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 | | `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 | -| `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` diff --git a/tests/e2e/utils/package.json b/tests/e2e/utils/package.json index 89994c56a72..644c2129559 100644 --- a/tests/e2e/utils/package.json +++ b/tests/e2e/utils/package.json @@ -2,7 +2,7 @@ "name": "@woocommerce/e2e-utils", "version": "0.1.5", "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": { "type": "git", "url": "https://github.com/woocommerce/woocommerce.git" diff --git a/tests/e2e/utils/src/flows/merchant.js b/tests/e2e/utils/src/flows/merchant.js index c025d18ca29..eead6d9779d 100644 --- a/tests/e2e/utils/src/flows/merchant.js +++ b/tests/e2e/utils/src/flows/merchant.js @@ -373,6 +373,34 @@ const merchant = { // Wait for Ajax calls to finish 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(); + } }, };