woocommerce/tests/e2e-tests/utils/index.js

39 lines
827 B
JavaScript
Raw Normal View History

/**
* Internal dependencies
*/
const flows = require( './flows' );
/**
* Click a tab (on post type edit screen).
*
* @param {string} tabName Tab label.
*/
const clickTab = async ( tabName ) => {
await expect( page ).toClick( '.wc-tabs > li > a', { text: tabName } );
};
/**
* Save changes on a WooCommerce settings page.
*/
const settingsPageSaveChanges = async () => {
await page.focus( 'button.woocommerce-save-button' );
await Promise.all( [
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
page.click( 'button.woocommerce-save-button' ),
] );
};
/**
* Wait for UI blocking to end.
*/
const uiUnblocked = async () => {
await page.waitForFunction( () => ! Boolean( document.querySelector( '.blockUI' ) ) );
};
module.exports = {
...flows,
clickTab,
settingsPageSaveChanges,
uiUnblocked,
};