Added check out DB update and run if it exists

This commit is contained in:
Greg 2021-08-02 11:11:49 -06:00
parent 164e7e495c
commit 3f5420eb0d
4 changed files with 36 additions and 1 deletions

View File

@ -34,4 +34,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();
});
});

View File

@ -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()`
# 0.1.5

View File

@ -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`

View File

@ -374,6 +374,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();
}
},
};
module.exports = merchant;