2020-09-04 02:31:09 +00:00
|
|
|
/**
|
|
|
|
* @format
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2021-03-08 14:23:39 +00:00
|
|
|
import {
|
|
|
|
setCheckboxToUnchecked,
|
|
|
|
clickContinue,
|
|
|
|
getElementByText,
|
|
|
|
} from './utils';
|
2020-10-29 18:51:37 +00:00
|
|
|
import { waitForElementCount } from '../../utils/lib';
|
2020-09-04 02:31:09 +00:00
|
|
|
const config = require( 'config' );
|
|
|
|
|
2021-01-06 22:08:57 +00:00
|
|
|
async function fillOutDropdowns() {
|
2020-09-04 02:31:09 +00:00
|
|
|
// Query for the <SelectControl>s
|
|
|
|
await waitForElementCount( page, '.woocommerce-select-control', 2 );
|
|
|
|
const selectControls = await page.$$( '.woocommerce-select-control' );
|
|
|
|
|
|
|
|
// Fill the number of products you plan to sell
|
|
|
|
await selectControls[ 0 ].click();
|
2020-10-29 18:51:37 +00:00
|
|
|
await page.waitForSelector( '.woocommerce-select-control__listbox' );
|
2020-09-04 02:31:09 +00:00
|
|
|
await expect( page ).toClick( '.woocommerce-select-control__option', {
|
|
|
|
text: config.get( 'onboardingwizard.numberofproducts' ),
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Fill currently selling elsewhere
|
2021-03-08 14:23:39 +00:00
|
|
|
const value = await page.evaluate( () => {
|
|
|
|
const inputs = document.querySelectorAll(
|
|
|
|
'.woocommerce-select-control .woocommerce-select-control__control-input'
|
|
|
|
);
|
|
|
|
return inputs[ 1 ].value;
|
2020-09-04 02:31:09 +00:00
|
|
|
} );
|
2021-03-08 14:23:39 +00:00
|
|
|
if ( value !== config.get( 'onboardingwizard.sellingelsewhere' ) ) {
|
|
|
|
await selectControls[ 1 ].click();
|
|
|
|
await page.waitForSelector( '.woocommerce-select-control__listbox' );
|
|
|
|
await expect( page ).toClick( '.woocommerce-select-control__option', {
|
|
|
|
text: config.get( 'onboardingwizard.sellingelsewhere' ),
|
|
|
|
} );
|
|
|
|
}
|
2021-01-06 22:08:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function completeBusinessSection() {
|
|
|
|
await fillOutDropdowns();
|
2020-09-04 02:31:09 +00:00
|
|
|
|
|
|
|
// Site is in US so the "Install recommended free business features"
|
|
|
|
// checkbox is present, uncheck it.
|
2021-03-08 14:23:39 +00:00
|
|
|
const installFeaturesCheckboxes = await page.$$(
|
|
|
|
'.woocommerce-profile-wizard__benefit .components-form-toggle__input'
|
2020-09-04 02:31:09 +00:00
|
|
|
);
|
2021-03-08 14:23:39 +00:00
|
|
|
// Uncheck all checkboxes, to avoid installing plugins
|
|
|
|
for ( const checkbox of installFeaturesCheckboxes ) {
|
|
|
|
await setCheckboxToUnchecked( checkbox );
|
|
|
|
}
|
2020-09-04 02:31:09 +00:00
|
|
|
|
|
|
|
await clickContinue();
|
|
|
|
}
|
2021-01-06 22:08:57 +00:00
|
|
|
|
|
|
|
export async function completeSelectiveBundleInstallBusinessDetailsTab() {
|
|
|
|
await fillOutDropdowns();
|
|
|
|
|
|
|
|
await page.click( 'button.is-primary' );
|
|
|
|
}
|
2021-03-08 14:23:39 +00:00
|
|
|
|
|
|
|
export async function unselectAllFeaturesAndContinue(
|
|
|
|
shouldWCPayBeListed = true
|
|
|
|
) {
|
|
|
|
const expandButtonSelector =
|
|
|
|
'.woocommerce-admin__business-details__selective-extensions-bundle__expand';
|
|
|
|
await page.waitForSelector( expandButtonSelector );
|
|
|
|
await page.click( expandButtonSelector );
|
|
|
|
|
|
|
|
// Confirm that expanding the list shows all the extensions available to install.
|
|
|
|
await waitForElementCount(
|
|
|
|
page,
|
|
|
|
'.components-checkbox-control__input',
|
2021-03-17 08:22:33 +00:00
|
|
|
shouldWCPayBeListed ? 10 : 7
|
2021-03-08 14:23:39 +00:00
|
|
|
);
|
|
|
|
const wcPayLabel = await getElementByText( 'a', 'WooCommerce Payments' );
|
|
|
|
if ( shouldWCPayBeListed ) {
|
|
|
|
expect( wcPayLabel ).toBeDefined();
|
|
|
|
} else {
|
|
|
|
expect( wcPayLabel ).toBeUndefined();
|
|
|
|
}
|
|
|
|
|
|
|
|
const allCheckboxes = await page.$$(
|
|
|
|
'.components-checkbox-control__input'
|
|
|
|
);
|
|
|
|
|
|
|
|
// Uncheck all checkboxes, to avoid installing plugins
|
|
|
|
for ( const checkbox of allCheckboxes ) {
|
|
|
|
await setCheckboxToUnchecked( checkbox );
|
|
|
|
}
|
|
|
|
|
|
|
|
await page.click( 'button.is-primary' );
|
|
|
|
}
|