Add e2e tests
This commit is contained in:
parent
61e0a51854
commit
b6611fb7c1
|
@ -24,12 +24,7 @@ export class WcHomescreen extends BasePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
async possiblyDismissWelcomeModal(): Promise< void > {
|
async possiblyDismissWelcomeModal(): Promise< void > {
|
||||||
const modalText = 'Welcome to your WooCommerce store’s online HQ!';
|
const modal = await this.isWelcomeModalVisible();
|
||||||
const modal = await waitForElementByTextWithoutThrow(
|
|
||||||
'h2',
|
|
||||||
modalText,
|
|
||||||
10
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( modal ) {
|
if ( modal ) {
|
||||||
await this.clickButtonWithText( 'Next' );
|
await this.clickButtonWithText( 'Next' );
|
||||||
|
@ -41,6 +36,17 @@ export class WcHomescreen extends BasePage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async isWelcomeModalVisible(): Promise< boolean > {
|
||||||
|
const modalText = 'Welcome to your WooCommerce store’s online HQ!';
|
||||||
|
const modal = await waitForElementByTextWithoutThrow(
|
||||||
|
'h2',
|
||||||
|
modalText,
|
||||||
|
10
|
||||||
|
);
|
||||||
|
return modal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async getTaskList(): Promise< Array< string | null > > {
|
async getTaskList(): Promise< Array< string | null > > {
|
||||||
await page.waitForSelector(
|
await page.waitForSelector(
|
||||||
'.woocommerce-task-card .woocommerce-task-list__item-title'
|
'.woocommerce-task-card .woocommerce-task-list__item-title'
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/**
|
||||||
|
* External dependencies
|
||||||
|
*/
|
||||||
|
import { withRestApi } from '@woocommerce/e2e-utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal dependencies
|
||||||
|
*/
|
||||||
|
import { Login } from '../../pages/Login';
|
||||||
|
import { OnboardingWizard } from '../../pages/OnboardingWizard';
|
||||||
|
import { WcHomescreen } from '../../pages/WcHomescreen';
|
||||||
|
import {
|
||||||
|
removeAllOrders,
|
||||||
|
unhideTaskList,
|
||||||
|
runActionScheduler,
|
||||||
|
updateOption,
|
||||||
|
resetWooCommerceState,
|
||||||
|
} from '../../fixtures';
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
|
const { afterAll, beforeAll, describe, it } = require( '@jest/globals' );
|
||||||
|
/* eslint-enable @typescript-eslint/no-var-requires */
|
||||||
|
|
||||||
|
const testAdminHomescreenWelcomeModal = () => {
|
||||||
|
describe( 'Homescreen welcome modal', () => {
|
||||||
|
const profileWizard = new OnboardingWizard( page );
|
||||||
|
const homeScreen = new WcHomescreen( page );
|
||||||
|
const login = new Login( page );
|
||||||
|
|
||||||
|
beforeAll( async () => {
|
||||||
|
await login.login();
|
||||||
|
await resetWooCommerceState();
|
||||||
|
await profileWizard.navigate();
|
||||||
|
await profileWizard.skipStoreSetup();
|
||||||
|
} );
|
||||||
|
|
||||||
|
afterAll( async () => {
|
||||||
|
await withRestApi.deleteAllProducts();
|
||||||
|
await removeAllOrders();
|
||||||
|
await unhideTaskList( 'setup' );
|
||||||
|
await runActionScheduler();
|
||||||
|
await updateOption( 'woocommerce_task_list_hidden', 'no' );
|
||||||
|
await login.logout();
|
||||||
|
} );
|
||||||
|
|
||||||
|
it( 'should not show welcome modal', async () => {
|
||||||
|
await homeScreen.isDisplayed();
|
||||||
|
await expect( homeScreen.isWelcomeModalVisible() ).resolves.toBe(
|
||||||
|
false
|
||||||
|
);
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = { testAdminHomescreenWelcomeModal };
|
|
@ -0,0 +1,5 @@
|
||||||
|
const {
|
||||||
|
testAdminHomescreenWelcomeModal,
|
||||||
|
} = require( '@woocommerce/admin-e2e-tests' );
|
||||||
|
|
||||||
|
testAdminHomescreenWelcomeModal();
|
Loading…
Reference in New Issue