From 372064c49feb3c57a870ccdba84f7baf575f977f Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 15 Jun 2021 16:28:10 -0600 Subject: [PATCH] Added flows for updating WP, themes, and plugins --- tests/e2e/utils/CHANGELOG.md | 6 ++++ tests/e2e/utils/README.md | 3 ++ tests/e2e/utils/src/flows/constants.js | 1 + tests/e2e/utils/src/flows/merchant.js | 47 ++++++++++++++++++++++++-- 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/tests/e2e/utils/CHANGELOG.md b/tests/e2e/utils/CHANGELOG.md index 332eee4c055..8f5ba3ad79e 100644 --- a/tests/e2e/utils/CHANGELOG.md +++ b/tests/e2e/utils/CHANGELOG.md @@ -1,5 +1,11 @@ # Unreleased +- Added new constant for WordPress update page `WP_ADMIN_WP_UPDATES` +- Added new merchant flow for `openWordPressUpdatesPage()` +- Added new merchant flows: + - `openWordPressUpdatesPage()` + - `installAllUpdates()` + # 0.1.5 ## Added diff --git a/tests/e2e/utils/README.md b/tests/e2e/utils/README.md index b6e75546e91..f37fae044fe 100644 --- a/tests/e2e/utils/README.md +++ b/tests/e2e/utils/README.md @@ -44,6 +44,7 @@ This package provides support for enabling retries in tests: - `WP_ADMIN_LOGIN` - WordPress login - `WP_ADMIN_DASHBOARD` - WordPress dashboard +- `WP_ADMIN_WP_UPDATES` - WordPress updates - `WP_ADMIN_PLUGINS` - Plugin list - `WP_ADMIN_PERMALINK_SETTINGS` - Permalink settings - `WP_ADMIN_ALL_USERS_VIEW` - WordPress user list @@ -102,6 +103,8 @@ This package provides support for enabling retries in tests: | `openAllUsersView` | | Open the All Users page | | `openImportProducts` | | Open the Import Products page | | `openExtensions` | | Go to WooCommerce -> Extensions | +| `openWordPressUpdatesPage` | | Go to Dashboard -> Updates | +| `installAllUpdates` | `updateWordPress`, `updatePlugins`, `updateThemes` | Install all pending updates on Dashboard -> Updates| ### Shopper `shopper` diff --git a/tests/e2e/utils/src/flows/constants.js b/tests/e2e/utils/src/flows/constants.js index 70e1e8f4fc3..141554b0160 100644 --- a/tests/e2e/utils/src/flows/constants.js +++ b/tests/e2e/utils/src/flows/constants.js @@ -10,6 +10,7 @@ const baseUrl = config.get( 'url' ); */ export const WP_ADMIN_LOGIN = baseUrl + 'wp-login.php'; export const WP_ADMIN_DASHBOARD = baseUrl + 'wp-admin/'; +export const WP_ADMIN_WP_UPDATES = WP_ADMIN_DASHBOARD + 'update-core.php'; export const WP_ADMIN_PLUGINS = WP_ADMIN_DASHBOARD + 'plugins.php'; export const WP_ADMIN_PERMALINK_SETTINGS = WP_ADMIN_DASHBOARD + 'options-permalink.php'; export const WP_ADMIN_ALL_USERS_VIEW = WP_ADMIN_DASHBOARD + 'users.php'; diff --git a/tests/e2e/utils/src/flows/merchant.js b/tests/e2e/utils/src/flows/merchant.js index aa78a709f8e..2e58d9ee614 100644 --- a/tests/e2e/utils/src/flows/merchant.js +++ b/tests/e2e/utils/src/flows/merchant.js @@ -6,7 +6,7 @@ const config = require( 'config' ); /** * Internal dependencies */ -const { clearAndFillInput } = require( '../page-utils' ); +const { clearAndFillInput, setCheckbox } = require( '../page-utils' ); const { WP_ADMIN_ALL_ORDERS_VIEW, WP_ADMIN_ALL_PRODUCTS_VIEW, @@ -25,6 +25,7 @@ const { WP_ADMIN_ANALYTICS_PAGES, WP_ADMIN_ALL_USERS_VIEW, WP_ADMIN_IMPORT_PRODUCTS, + WP_ADMIN_WP_UPDATES, IS_RETEST_MODE, } = require( './constants' ); @@ -210,11 +211,53 @@ const merchant = { } ); }, - openImportProducts: async () => { + openImportProducts: async () => { await page.goto( WP_ADMIN_IMPORT_PRODUCTS , { waitUntil: 'networkidle0', } ); }, + + openWordPressUpdatesPage: async () => { + await page.goto( WP_ADMIN_WP_UPDATES, { + waitUntil: 'networkidle0', + } ); + }, + + installAllUpdates: async ( updateWordPress = true, updatePlugins = true, updateThemes = true ) => { + if ( updateWordPress ) { + await merchant.openWordPressUpdatesPage(); + if ( null !== await page.$( 'form[action="update-core.php?action=do-core-upgrade"][name="upgrade"]' ) ) { + await Promise.all([ + expect( page ).toClick( 'input.button-primary' ), + + // The WordPress update can take some time, so setting a longer timeout here + page.waitForNavigation( { waitUntil: 'networkidle0', timeout: 100000 } ), + ]); + } + } + + if ( updatePlugins ) { + await merchant.openWordPressUpdatesPage(); + if ( null !== await page.$( 'form[action="update-core.php?action=do-plugin-upgrade"][name="upgrade-plugins"]' ) ) { + await setCheckbox( '#plugins-select-all' ); + await Promise.all([ + expect( page ).toClick( '#upgrade-plugins' ), + page.waitForNavigation( { waitUntil: 'networkidle0' } ), + ]); + } + } + + if ( updateThemes ) { + await merchant.openWordPressUpdatesPage(); + if (null !== await page.$( 'form[action="update-core.php?action=do-theme-upgrade"][name="upgrade-themes"]' )) { + await setCheckbox( '#themes-select-all' ); + await Promise.all([ + expect( page ).toClick( '#upgrade-themes' ), + page.waitForNavigation( { waitUntil: 'networkidle0' } ), + ]); + } + } + }, }; module.exports = merchant;