2021-11-25 17:05:40 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
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' } ),
|
|
|
|
] );
|
|
|
|
|
|
|
|
// Click sub-menu item and wait for the page to finish loading
|
|
|
|
await Promise.all( [
|
|
|
|
page.click( subMenuElement ),
|
|
|
|
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
|
|
|
] );
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement( 'h1', {
|
|
|
|
text: subMenuText,
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
// eslint-disable-next-line jest/no-export
|
|
|
|
module.exports = runPageLoadTest;
|