Merge pull request #25482 from woocommerce/fix/cart-e2e-test
Fix failing cart e2e test: fix setup wizard logic if new onboarding is presented
This commit is contained in:
commit
a9a64fcee0
|
@ -6,6 +6,7 @@
|
|||
* Internal dependencies
|
||||
*/
|
||||
import { StoreOwnerFlow } from '../../utils/flows';
|
||||
import { completeOldSetupWizard } from '../../utils/components';
|
||||
import {
|
||||
permalinkSettingsPageSaveChanges,
|
||||
setCheckbox,
|
||||
|
@ -60,149 +61,11 @@ describe( 'Store owner can go through store Setup Wizard', () => {
|
|||
// Click on "Continue with the old setup wizard" footer link to start the old setup wizard
|
||||
page.$eval( '.wc-setup-footer-links', elem => elem.click() ),
|
||||
|
||||
// Wait for the Payment section to load
|
||||
// Wait for the store setup section to load
|
||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
] );
|
||||
} else {
|
||||
|
||||
// Fill out store setup section details
|
||||
// Select country where the store is located
|
||||
await expect( page ).toSelect( 'select[name="store_country"]', config.get( 'addresses.admin.store.country' ) );
|
||||
// Fill store's address - first line
|
||||
await expect( page ).toFill( '#store_address', config.get( 'addresses.admin.store.addressfirstline' ) );
|
||||
|
||||
// Fill store's address - second line
|
||||
await expect( page ).toFill( '#store_address_2', config.get( 'addresses.admin.store.addresssecondline' ) );
|
||||
|
||||
// Fill the city where the store is located
|
||||
await expect( page ).toFill( '#store_city', config.get( 'addresses.admin.store.city' ) );
|
||||
|
||||
// Select the state where the store is located
|
||||
await expect( page ).toSelect( 'select[name="store_state"]', config.get( 'addresses.admin.store.state') );
|
||||
|
||||
// Fill postcode of the store
|
||||
await expect( page ).toFill( '#store_postcode', config.get( 'addresses.admin.store.postcode' ) );
|
||||
|
||||
// Select currency and type of products to sell details
|
||||
await expect( page ).toSelect( 'select[name="currency_code"]', '\n' +
|
||||
'\t\t\t\t\t\tUnited States (US) dollar ($ USD)\t\t\t\t\t' );
|
||||
await expect( page ).toSelect( 'select[name="product_type"]', 'I plan to sell both physical and digital products' );
|
||||
|
||||
// Verify that checkbox next to "I will also be selling products or services in person." is not selected
|
||||
await verifyCheckboxIsUnset( '#woocommerce_sell_in_person' );
|
||||
|
||||
// Click on "Let's go!" button to move to the next step
|
||||
await page.$eval( 'button[name=save_step]', elem => elem.click() );
|
||||
|
||||
// Wait for usage tracking pop-up window to appear
|
||||
await page.waitForSelector( '#wc-backbone-modal-dialog' );
|
||||
await expect( page ).toMatchElement(
|
||||
'.wc-backbone-modal-header', { text: 'Help improve WooCommerce with usage tracking' }
|
||||
);
|
||||
|
||||
await page.waitForSelector( '#wc_tracker_checkbox_dialog' );
|
||||
|
||||
// Verify that checkbox next to "Enable usage tracking and help improve WooCommerce" is not selected
|
||||
await verifyCheckboxIsUnset( '#wc_tracker_checkbox_dialog' );
|
||||
|
||||
await Promise.all( [
|
||||
// Click on "Continue" button to move to the next step
|
||||
page.$eval( '#wc_tracker_submit', elem => elem.click() ),
|
||||
|
||||
// Wait for the Payment section to load
|
||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
] );
|
||||
|
||||
// Fill out payment section details
|
||||
// Turn off Stripe account toggle
|
||||
await page.click( '.wc-wizard-service-toggle' );
|
||||
|
||||
await Promise.all( [
|
||||
// Click on "Continue" button to move to the next step
|
||||
page.click( 'button[name=save_step]', { text: 'Continue' } ),
|
||||
|
||||
// Wait for the Shipping section to load
|
||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
] );
|
||||
|
||||
// Fill out shipping section details
|
||||
// Turn off WooCommerce Shipping option
|
||||
await page.$eval( '#wc_recommended_woocommerce_services', elem => elem.click() );
|
||||
|
||||
await page.waitForSelector( 'select[name="shipping_zones[domestic][method]"]' );
|
||||
await page.waitForSelector( 'select[name="shipping_zones[intl][method]"]' );
|
||||
|
||||
// Select Flat Rate shipping method for domestic shipping zone
|
||||
await page.evaluate( () => {
|
||||
document.querySelector( 'select[name="shipping_zones[domestic][method]"] > option:nth-child(1)' ).selected = true;
|
||||
let element = document.querySelector( 'select[name="shipping_zones[domestic][method]"]' );
|
||||
let event = new Event( 'change', { bubbles: true } );
|
||||
event.simulated = true;
|
||||
element.dispatchEvent( event );
|
||||
} );
|
||||
|
||||
await page.$eval( 'input[name="shipping_zones[domestic][flat_rate][cost]"]', e => e.setAttribute( 'value', '10.00' ) );
|
||||
|
||||
// Select Flat Rate shipping method for the rest of the world shipping zone
|
||||
await page.evaluate( () => {
|
||||
document.querySelector( 'select[name="shipping_zones[intl][method]"] > option:nth-child(1)' ).selected = true;
|
||||
let element = document.querySelector( 'select[name="shipping_zones[intl][method]"]' );
|
||||
let event = new Event( 'change', { bubbles: true } );
|
||||
event.simulated = true;
|
||||
element.dispatchEvent( event );
|
||||
} );
|
||||
|
||||
await page.$eval( 'input[name="shipping_zones[intl][flat_rate][cost]"]', e => e.setAttribute( 'value', '20.00' ) );
|
||||
|
||||
// Select product weight and product dimensions options
|
||||
await expect( page ).toSelect( 'select[name="weight_unit"]', 'Pounds' );
|
||||
await expect( page ).toSelect( 'select[name="dimension_unit"]', 'Inches' );
|
||||
|
||||
await Promise.all( [
|
||||
// Click on "Continue" button to move to the next step
|
||||
page.click( 'button[name=save_step]', { text: 'Continue' } ),
|
||||
|
||||
// Wait for the Recommended section to load
|
||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
] );
|
||||
|
||||
// Fill out recommended section details
|
||||
// Turn off Storefront Theme option
|
||||
// await page.waitForSelector( '#wc_recommended_storefront_theme', { visible: true } );
|
||||
// await page.$eval( '#wc_recommended_storefront_theme', elem => elem.click() );
|
||||
|
||||
// Turn off Automated Taxes option
|
||||
await page.waitForSelector( '#wc_recommended_automated_taxes', { visible: true } );
|
||||
await page.$eval( '#wc_recommended_automated_taxes', elem => elem.click() );
|
||||
|
||||
// Turn off WooCommerce Admin option
|
||||
await page.waitForSelector( '#wc_recommended_wc_admin', { visible: true } );
|
||||
await page.$eval( '#wc_recommended_wc_admin', elem => elem.click() );
|
||||
|
||||
// Turn off Mailchimp option
|
||||
await page.waitForSelector( '#wc_recommended_mailchimp', { visible: true } );
|
||||
await page.$eval( '#wc_recommended_mailchimp', elem => elem.click() );
|
||||
|
||||
// Turn off Facebook option
|
||||
await page.waitForSelector( '#wc_recommended_facebook', { visible: true } );
|
||||
await page.$eval( '#wc_recommended_facebook', elem => elem.click() );
|
||||
|
||||
await Promise.all( [
|
||||
// Click on "Continue" button to move to the next step
|
||||
page.click( 'button[name=save_step]', { text: 'Continue' } ),
|
||||
|
||||
// Wait for the Jetpack section to load
|
||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
] );
|
||||
|
||||
// Skip activate Jetpack section
|
||||
// Click on "Skip this step" in order to skip Jetpack installation
|
||||
await page.click( '.wc-setup-footer-links' );
|
||||
|
||||
// Finish Setup Wizard - Ready! section
|
||||
// Visit Dashboard
|
||||
await StoreOwnerFlow.openDashboard();
|
||||
}
|
||||
await completeOldSetupWizard();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { StoreOwnerFlow } from "./flows";
|
||||
import { clickTab, uiUnblocked } from "./index";
|
||||
import { StoreOwnerFlow } from './flows';
|
||||
import { clickTab, uiUnblocked, verifyCheckboxIsUnset } from './index';
|
||||
|
||||
const config = require( 'config' );
|
||||
const simpleProductName = config.get( 'products.simple.name' );
|
||||
|
@ -23,6 +23,149 @@ const verifyAndPublish = async () => {
|
|||
await expect( page ).toMatchElement( '.updated.notice', { text: 'Product published.' } );
|
||||
};
|
||||
|
||||
/**
|
||||
* Complete old setup wizard.
|
||||
*/
|
||||
const completeOldSetupWizard = async () => {
|
||||
// Fill out store setup section details
|
||||
// Select country where the store is located
|
||||
await expect( page ).toSelect( 'select[name="store_country"]', config.get( 'addresses.admin.store.country' ) );
|
||||
// Fill store's address - first line
|
||||
await expect( page ).toFill( '#store_address', config.get( 'addresses.admin.store.addressfirstline' ) );
|
||||
|
||||
// Fill store's address - second line
|
||||
await expect( page ).toFill( '#store_address_2', config.get( 'addresses.admin.store.addresssecondline' ) );
|
||||
|
||||
// Fill the city where the store is located
|
||||
await expect( page ).toFill( '#store_city', config.get( 'addresses.admin.store.city' ) );
|
||||
|
||||
// Select the state where the store is located
|
||||
await expect( page ).toSelect( 'select[name="store_state"]', config.get( 'addresses.admin.store.state') );
|
||||
|
||||
// Fill postcode of the store
|
||||
await expect( page ).toFill( '#store_postcode', config.get( 'addresses.admin.store.postcode' ) );
|
||||
|
||||
// Select currency and type of products to sell details
|
||||
await expect( page ).toSelect( 'select[name="currency_code"]', '\n' +
|
||||
'\t\t\t\t\t\tUnited States (US) dollar ($ USD)\t\t\t\t\t' );
|
||||
await expect( page ).toSelect( 'select[name="product_type"]', 'I plan to sell both physical and digital products' );
|
||||
|
||||
// Verify that checkbox next to "I will also be selling products or services in person." is not selected
|
||||
await verifyCheckboxIsUnset( '#woocommerce_sell_in_person' );
|
||||
|
||||
// Click on "Let's go!" button to move to the next step
|
||||
await page.$eval( 'button[name=save_step]', elem => elem.click() );
|
||||
|
||||
// Wait for usage tracking pop-up window to appear
|
||||
await page.waitForSelector( '#wc-backbone-modal-dialog' );
|
||||
await expect( page ).toMatchElement(
|
||||
'.wc-backbone-modal-header', { text: 'Help improve WooCommerce with usage tracking' }
|
||||
);
|
||||
|
||||
await page.waitForSelector( '#wc_tracker_checkbox_dialog' );
|
||||
|
||||
// Verify that checkbox next to "Enable usage tracking and help improve WooCommerce" is not selected
|
||||
await verifyCheckboxIsUnset( '#wc_tracker_checkbox_dialog' );
|
||||
|
||||
await Promise.all( [
|
||||
// Click on "Continue" button to move to the next step
|
||||
page.$eval( '#wc_tracker_submit', elem => elem.click() ),
|
||||
|
||||
// Wait for the Payment section to load
|
||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
] );
|
||||
|
||||
// Fill out payment section details
|
||||
// Turn off Stripe account toggle
|
||||
await page.click( '.wc-wizard-service-toggle' );
|
||||
|
||||
await Promise.all( [
|
||||
// Click on "Continue" button to move to the next step
|
||||
page.click( 'button[name=save_step]', { text: 'Continue' } ),
|
||||
|
||||
// Wait for the Shipping section to load
|
||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
] );
|
||||
|
||||
// Fill out shipping section details
|
||||
// Turn off WooCommerce Shipping option
|
||||
await page.$eval( '#wc_recommended_woocommerce_services', elem => elem.click() );
|
||||
|
||||
await page.waitForSelector( 'select[name="shipping_zones[domestic][method]"]' );
|
||||
await page.waitForSelector( 'select[name="shipping_zones[intl][method]"]' );
|
||||
|
||||
// Select Flat Rate shipping method for domestic shipping zone
|
||||
await page.evaluate( () => {
|
||||
document.querySelector( 'select[name="shipping_zones[domestic][method]"] > option:nth-child(1)' ).selected = true;
|
||||
let element = document.querySelector( 'select[name="shipping_zones[domestic][method]"]' );
|
||||
let event = new Event( 'change', { bubbles: true } );
|
||||
event.simulated = true;
|
||||
element.dispatchEvent( event );
|
||||
} );
|
||||
|
||||
await page.$eval( 'input[name="shipping_zones[domestic][flat_rate][cost]"]', e => e.setAttribute( 'value', '10.00' ) );
|
||||
|
||||
// Select Flat Rate shipping method for the rest of the world shipping zone
|
||||
await page.evaluate( () => {
|
||||
document.querySelector( 'select[name="shipping_zones[intl][method]"] > option:nth-child(1)' ).selected = true;
|
||||
let element = document.querySelector( 'select[name="shipping_zones[intl][method]"]' );
|
||||
let event = new Event( 'change', { bubbles: true } );
|
||||
event.simulated = true;
|
||||
element.dispatchEvent( event );
|
||||
} );
|
||||
|
||||
await page.$eval( 'input[name="shipping_zones[intl][flat_rate][cost]"]', e => e.setAttribute( 'value', '20.00' ) );
|
||||
|
||||
// Select product weight and product dimensions options
|
||||
await expect( page ).toSelect( 'select[name="weight_unit"]', 'Pounds' );
|
||||
await expect( page ).toSelect( 'select[name="dimension_unit"]', 'Inches' );
|
||||
|
||||
await Promise.all( [
|
||||
// Click on "Continue" button to move to the next step
|
||||
page.click( 'button[name=save_step]', { text: 'Continue' } ),
|
||||
|
||||
// Wait for the Recommended section to load
|
||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
] );
|
||||
|
||||
// Fill out recommended section details
|
||||
// Turn off Storefront Theme option
|
||||
// await page.waitForSelector( '#wc_recommended_storefront_theme', { visible: true } );
|
||||
// await page.$eval( '#wc_recommended_storefront_theme', elem => elem.click() );
|
||||
|
||||
// Turn off Automated Taxes option
|
||||
await page.waitForSelector( '#wc_recommended_automated_taxes', { visible: true } );
|
||||
await page.$eval( '#wc_recommended_automated_taxes', elem => elem.click() );
|
||||
|
||||
// Turn off WooCommerce Admin option
|
||||
await page.waitForSelector( '#wc_recommended_wc_admin', { visible: true } );
|
||||
await page.$eval( '#wc_recommended_wc_admin', elem => elem.click() );
|
||||
|
||||
// Turn off Mailchimp option
|
||||
await page.waitForSelector( '#wc_recommended_mailchimp', { visible: true } );
|
||||
await page.$eval( '#wc_recommended_mailchimp', elem => elem.click() );
|
||||
|
||||
// Turn off Facebook option
|
||||
await page.waitForSelector( '#wc_recommended_facebook', { visible: true } );
|
||||
await page.$eval( '#wc_recommended_facebook', elem => elem.click() );
|
||||
|
||||
await Promise.all( [
|
||||
// Click on "Continue" button to move to the next step
|
||||
page.click( 'button[name=save_step]', { text: 'Continue' } ),
|
||||
|
||||
// Wait for the Jetpack section to load
|
||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
] );
|
||||
|
||||
// Skip activate Jetpack section
|
||||
// Click on "Skip this step" in order to skip Jetpack installation
|
||||
await page.click( '.wc-setup-footer-links' );
|
||||
|
||||
// Finish Setup Wizard - Ready! section
|
||||
// Visit Dashboard
|
||||
await StoreOwnerFlow.openDashboard();
|
||||
} ;
|
||||
|
||||
/**
|
||||
* Create simple product.
|
||||
*/
|
||||
|
@ -176,4 +319,4 @@ const createVariableProduct = async () => {
|
|||
return variablePostIdValue;
|
||||
};
|
||||
|
||||
export { createSimpleProduct, createVariableProduct };
|
||||
export { completeOldSetupWizard, createSimpleProduct, createVariableProduct };
|
||||
|
|
Loading…
Reference in New Issue