Broke out install function

This commit is contained in:
Greg 2021-06-30 14:35:17 -06:00
parent 74a9e1b0ec
commit 5062c13f38
2 changed files with 39 additions and 32 deletions

View File

@ -104,7 +104,10 @@ This package provides support for enabling retries in tests:
| `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|
| `installAllUpdates` | | Install all pending updates on Dashboard -> Updates|
| `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|
### Shopper `shopper`

View File

@ -223,41 +223,45 @@ const merchant = {
} );
},
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' ),
installAllUpdates: async () => {
await merchant.updateWordPress();
await merchant.updatePlugins();
await merchant.updateThemes();
},
// The WordPress update can take some time, so setting a longer timeout here
page.waitForNavigation( { waitUntil: 'networkidle0', timeout: 100000 } ),
]);
}
}
updateWordPress: async () => {
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' ),
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' } ),
]);
}
// The WordPress update can take some time, so setting a longer timeout here
page.waitForNavigation( { waitUntil: 'networkidle0', timeout: 1000000 } ),
]);
}
},
updatePlugins: async () => {
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' } ),
]);
}
},
updateThemes: async () => {
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;