2021-03-17 19:22:09 +00:00
|
|
|
import { Page } from 'puppeteer';
|
2021-04-05 00:09:36 +00:00
|
|
|
import { BenefitsSection } from '../sections/onboarding/BenefitsSection';
|
|
|
|
import { BusinessSection } from '../sections/onboarding/BusinessSection';
|
|
|
|
import { IndustrySection } from '../sections/onboarding/IndustrySection';
|
|
|
|
import { ProductTypeSection } from '../sections/onboarding/ProductTypesSection';
|
|
|
|
import { StoreDetailsSection } from '../sections/onboarding/StoreDetailsSection';
|
|
|
|
import { ThemeSection } from '../sections/onboarding/ThemeSection';
|
|
|
|
import { BasePage } from './BasePage';
|
|
|
|
|
|
|
|
export class OnboardingWizard extends BasePage {
|
|
|
|
url = 'wp-admin/admin.php?page=wc-admin&path=/setup-wizard';
|
2021-03-17 19:22:09 +00:00
|
|
|
|
|
|
|
storeDetails: StoreDetailsSection;
|
|
|
|
industry: IndustrySection;
|
|
|
|
productTypes: ProductTypeSection;
|
|
|
|
business: BusinessSection;
|
|
|
|
themes: ThemeSection;
|
|
|
|
benefits: BenefitsSection;
|
|
|
|
|
|
|
|
constructor( page: Page ) {
|
2021-04-05 00:09:36 +00:00
|
|
|
super( page );
|
2021-03-17 19:22:09 +00:00
|
|
|
this.storeDetails = new StoreDetailsSection( page );
|
|
|
|
this.industry = new IndustrySection( page );
|
|
|
|
this.productTypes = new ProductTypeSection( page );
|
|
|
|
this.business = new BusinessSection( page );
|
|
|
|
this.themes = new ThemeSection( page );
|
|
|
|
this.benefits = new BenefitsSection( page );
|
|
|
|
}
|
|
|
|
|
2021-04-05 00:09:36 +00:00
|
|
|
async skipStoreSetup() {
|
|
|
|
await this.clickButtonWithText( 'Skip setup store details' );
|
|
|
|
await this.optionallySelectUsageTracking( false );
|
2021-03-17 19:22:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async continue() {
|
2021-04-05 00:09:36 +00:00
|
|
|
await this.clickButtonWithText( 'Continue' );
|
2021-03-17 19:22:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async optionallySelectUsageTracking( select = false ) {
|
|
|
|
const usageTrackingHeader = await this.page.waitForSelector(
|
|
|
|
'.components-modal__header-heading',
|
|
|
|
{
|
2021-04-05 00:09:36 +00:00
|
|
|
timeout: 5000,
|
2021-03-17 19:22:09 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
if ( ! usageTrackingHeader ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
'.components-modal__header-heading',
|
|
|
|
{
|
|
|
|
text: 'Build a better WooCommerce',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// Query for primary buttons: "Continue" and "Yes, count me in"
|
|
|
|
const primaryButtons = await this.page.$$( 'button.is-primary' );
|
|
|
|
expect( primaryButtons ).toHaveLength( 2 );
|
|
|
|
|
|
|
|
if ( select ) {
|
2021-04-05 00:09:36 +00:00
|
|
|
await this.clickButtonWithText( 'Yes, count me in' );
|
2021-03-17 19:22:09 +00:00
|
|
|
} else {
|
2021-04-05 00:09:36 +00:00
|
|
|
await this.clickButtonWithText( 'No thanks' );
|
2021-03-17 19:22:09 +00:00
|
|
|
}
|
2021-04-05 00:09:36 +00:00
|
|
|
|
2021-03-17 19:22:09 +00:00
|
|
|
this.page.waitForNavigation( {
|
|
|
|
waitUntil: 'networkidle0',
|
|
|
|
timeout: 2000,
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
}
|