2021-11-25 17:05:40 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2021-12-23 18:47:03 +00:00
|
|
|
const { merchant } = require( '@woocommerce/e2e-utils' );
|
2021-11-25 18:20:36 +00:00
|
|
|
const { MENUS } = require( '../data/elements' );
|
2021-11-25 17:05:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
const { it, describe, beforeAll } = require( '@jest/globals' );
|
|
|
|
|
|
|
|
const runPageLoadTest = () => {
|
2021-11-25 18:20:36 +00:00
|
|
|
describe.each( MENUS )(
|
2021-11-25 17:05:40 +00:00
|
|
|
' %s > Opening Top Level Pages',
|
|
|
|
( menuTitle, menuElement, subMenus ) => {
|
|
|
|
beforeAll( async () => {
|
|
|
|
await merchant.login();
|
|
|
|
} );
|
|
|
|
|
2021-11-26 19:01:32 +00:00
|
|
|
afterAll( async () => {
|
|
|
|
await merchant.logout();
|
|
|
|
} );
|
|
|
|
|
2021-11-25 17:05:40 +00:00
|
|
|
it.each( subMenus )(
|
|
|
|
'can see %s page properly',
|
|
|
|
async ( subMenuTitle, subMenuElement, subMenuText ) => {
|
|
|
|
// Go to Top Level Menu
|
|
|
|
await Promise.all( [
|
|
|
|
page.click( menuElement ),
|
|
|
|
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
2021-12-22 17:59:38 +00:00
|
|
|
merchant.dismissOnboardingWizard(),
|
|
|
|
merchant.collapseAdminMenu( false ),
|
2021-11-25 17:05:40 +00:00
|
|
|
] );
|
|
|
|
|
|
|
|
// Click sub-menu item and wait for the page to finish loading
|
2021-12-22 17:59:38 +00:00
|
|
|
if ( subMenuElement.length ) {
|
|
|
|
await Promise.all([
|
|
|
|
page.click( subMenuElement ),
|
|
|
|
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
|
|
|
] );
|
|
|
|
}
|
2021-11-25 17:05:40 +00:00
|
|
|
|
|
|
|
await expect( page ).toMatchElement( 'h1', {
|
|
|
|
text: subMenuText,
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
// eslint-disable-next-line jest/no-export
|
|
|
|
module.exports = runPageLoadTest;
|