Add e2e tests

This commit is contained in:
Fernando Marichal 2022-04-06 13:07:02 -03:00
parent 61e0a51854
commit b6611fb7c1
3 changed files with 72 additions and 6 deletions

View File

@ -24,12 +24,7 @@ export class WcHomescreen extends BasePage {
}
async possiblyDismissWelcomeModal(): Promise< void > {
const modalText = 'Welcome to your WooCommerce stores online HQ!';
const modal = await waitForElementByTextWithoutThrow(
'h2',
modalText,
10
);
const modal = await this.isWelcomeModalVisible();
if ( modal ) {
await this.clickButtonWithText( 'Next' );
@ -41,6 +36,17 @@ export class WcHomescreen extends BasePage {
}
}
async isWelcomeModalVisible(): Promise< boolean > {
const modalText = 'Welcome to your WooCommerce stores online HQ!';
const modal = await waitForElementByTextWithoutThrow(
'h2',
modalText,
10
);
return modal;
}
async getTaskList(): Promise< Array< string | null > > {
await page.waitForSelector(
'.woocommerce-task-card .woocommerce-task-list__item-title'

View File

@ -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 };

View File

@ -0,0 +1,5 @@
const {
testAdminHomescreenWelcomeModal,
} = require( '@woocommerce/admin-e2e-tests' );
testAdminHomescreenWelcomeModal();