2019-11-24 13:08:48 +00:00
|
|
|
/**
|
|
|
|
* @format
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { StoreOwnerFlow } from '../../utils/flows';
|
2020-03-27 21:45:20 +00:00
|
|
|
import { completeOldSetupWizard, completeOnboardingWizard } from '../../utils/components';
|
2019-11-23 17:40:29 +00:00
|
|
|
import {
|
|
|
|
permalinkSettingsPageSaveChanges,
|
|
|
|
setCheckbox,
|
|
|
|
settingsPageSaveChanges,
|
|
|
|
verifyCheckboxIsSet,
|
|
|
|
verifyCheckboxIsUnset, verifyValueOfInputField
|
2019-11-30 22:07:29 +00:00
|
|
|
} from '../../utils';
|
2019-11-23 17:40:29 +00:00
|
|
|
|
2019-12-02 11:21:01 +00:00
|
|
|
const config = require( 'config' );
|
|
|
|
|
2019-11-23 17:40:29 +00:00
|
|
|
describe( 'Store owner can login and make sure WooCommerce is activated', () => {
|
|
|
|
|
2019-12-06 15:06:48 +00:00
|
|
|
it( 'can login', async () => {
|
2019-11-23 17:40:29 +00:00
|
|
|
await StoreOwnerFlow.login();
|
2019-11-24 11:38:13 +00:00
|
|
|
} );
|
2019-11-23 17:40:29 +00:00
|
|
|
|
2019-12-06 15:06:48 +00:00
|
|
|
it( 'can make sure WooCommerce is activated. If not, activate it', async () => {
|
2019-11-23 17:40:29 +00:00
|
|
|
const slug = 'woocommerce';
|
2019-11-24 13:49:39 +00:00
|
|
|
await StoreOwnerFlow.openPlugins();
|
2019-11-24 11:38:13 +00:00
|
|
|
const disableLink = await page.$( `tr[data-slug="${ slug }"] .deactivate a` );
|
|
|
|
if ( disableLink ) {
|
2019-11-23 17:40:29 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-11-24 11:38:13 +00:00
|
|
|
await page.click( `tr[data-slug="${ slug }"] .activate a` );
|
|
|
|
await page.waitForSelector( `tr[data-slug="${ slug }"] .deactivate a` );
|
2019-11-30 22:07:29 +00:00
|
|
|
} );
|
2019-11-23 17:40:29 +00:00
|
|
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
describe( 'Store owner can go through store Setup Wizard', () => {
|
|
|
|
|
2019-12-06 15:06:48 +00:00
|
|
|
it( 'can start Setup Wizard when visiting the site for the first time. Skip all other times.', async () => {
|
|
|
|
// Check if Setup Wizard Notice is visible on the screen.
|
|
|
|
// If yes - proceed with Setup Wizard, if not - skip Setup Wizard (already been completed).
|
|
|
|
const setupWizardNotice = await Promise.race( [
|
|
|
|
new Promise( resolve => setTimeout( () => resolve(), 1000 ) ), // resolves without value after 1s
|
|
|
|
page.waitForSelector('.updated.woocommerce-message.wc-connect', { visible: true } )
|
|
|
|
] );
|
|
|
|
if ( setupWizardNotice ) {
|
|
|
|
await StoreOwnerFlow.runSetupWizard();
|
2020-03-27 21:45:20 +00:00
|
|
|
await completeOnboardingWizard();
|
2019-12-06 15:06:48 +00:00
|
|
|
}
|
|
|
|
} );
|
2019-11-23 17:40:29 +00:00
|
|
|
} );
|
|
|
|
|
2020-03-31 04:32:42 +00:00
|
|
|
describe( 'Store owner can go through setup Task List', () => {
|
|
|
|
it( 'can setup shipping', async () => {
|
|
|
|
// Query for all tasks on the list
|
|
|
|
const taskListItems = await page.$$( '.woocommerce-list__item-title' );
|
2020-03-31 14:00:43 +00:00
|
|
|
expect( taskListItems ).toHaveLength( 5 );
|
2020-03-31 04:32:42 +00:00
|
|
|
|
|
|
|
await Promise.all( [
|
|
|
|
// Click on "Set up shipping" task to move to the next step
|
2020-03-31 14:00:43 +00:00
|
|
|
taskListItems[2].click(),
|
2020-03-31 04:32:42 +00:00
|
|
|
|
|
|
|
// Wait for shipping setup section to load
|
|
|
|
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
|
|
|
] );
|
|
|
|
|
2020-04-27 18:22:23 +00:00
|
|
|
// Query for store location fields
|
|
|
|
const storeLocationFields = await page.$$( '.components-text-control__input' );
|
2020-04-27 19:29:09 +00:00
|
|
|
expect( storeLocationFields ).toHaveLength( 4 );
|
|
|
|
|
2020-04-27 18:22:23 +00:00
|
|
|
// Wait for "Continue" button to become active
|
|
|
|
await page.waitForSelector( 'button.is-primary:not(:disabled)' );
|
|
|
|
// Click on "Continue" button to move to the shipping cost section
|
|
|
|
await page.click( 'button.is-primary' );
|
|
|
|
|
2020-04-27 19:29:09 +00:00
|
|
|
// Wait for "Proceed" button to become active
|
2020-03-31 04:32:42 +00:00
|
|
|
await page.waitForSelector( 'button.is-primary:not(:disabled)' );
|
2020-04-27 20:30:50 +00:00
|
|
|
await page.waitFor( 3000 );
|
2020-03-31 04:32:42 +00:00
|
|
|
|
2020-04-27 19:29:09 +00:00
|
|
|
// Click on "Proceed" button to save shipping settings
|
2020-03-31 04:32:42 +00:00
|
|
|
await page.click( 'button.is-primary' );
|
|
|
|
await page.waitFor( 3000 );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
2019-11-23 17:40:29 +00:00
|
|
|
describe( 'Store owner can finish initial store setup', () => {
|
|
|
|
|
2019-12-06 15:06:48 +00:00
|
|
|
it( 'can enable tax rates and calculations', async () => {
|
2019-11-23 17:40:29 +00:00
|
|
|
// Go to general settings page
|
|
|
|
await StoreOwnerFlow.openSettings( 'general' );
|
|
|
|
|
|
|
|
// Make sure the general tab is active
|
|
|
|
await expect( page ).toMatchElement( 'a.nav-tab-active', { text: 'General' } );
|
|
|
|
|
|
|
|
// Enable tax rates and calculations
|
|
|
|
await setCheckbox( '#woocommerce_calc_taxes' );
|
|
|
|
|
|
|
|
await settingsPageSaveChanges();
|
|
|
|
|
|
|
|
// Verify that settings have been saved
|
|
|
|
await Promise.all( [
|
|
|
|
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
|
|
|
verifyCheckboxIsSet( '#woocommerce_calc_taxes' ),
|
|
|
|
] );
|
2019-11-30 22:07:29 +00:00
|
|
|
} );
|
2019-11-23 17:40:29 +00:00
|
|
|
|
2019-12-06 15:06:48 +00:00
|
|
|
it( 'can configure permalink settings', async () => {
|
2019-11-24 11:38:13 +00:00
|
|
|
// Go to Permalink Settings page
|
2019-11-23 17:40:29 +00:00
|
|
|
await StoreOwnerFlow.openPermalinkSettings();
|
2019-11-24 11:38:13 +00:00
|
|
|
|
|
|
|
// Select "Post name" option in common settings section
|
2019-11-23 17:40:29 +00:00
|
|
|
await page.click( 'input[value="/%postname%/"]', { text: ' Post name' } );
|
2019-11-24 11:38:13 +00:00
|
|
|
|
|
|
|
// Select "Custom base" in product permalinks section
|
2019-11-23 17:40:29 +00:00
|
|
|
await page.click( '#woocommerce_custom_selection' );
|
2019-11-24 11:38:13 +00:00
|
|
|
|
|
|
|
// Fill custom base slug to use
|
2019-11-23 17:40:29 +00:00
|
|
|
await expect( page ).toFill( '#woocommerce_permalink_structure', '/product/' );
|
|
|
|
|
|
|
|
await permalinkSettingsPageSaveChanges();
|
|
|
|
|
|
|
|
// Verify that settings have been saved
|
|
|
|
await Promise.all( [
|
|
|
|
expect( page ).toMatchElement( '#setting-error-settings_updated', { text: 'Permalink structure updated.' } ),
|
|
|
|
verifyValueOfInputField( '#permalink_structure', '/%postname%/' ),
|
|
|
|
verifyValueOfInputField( '#woocommerce_permalink_structure', '/product/' ),
|
|
|
|
] );
|
2019-11-30 22:07:29 +00:00
|
|
|
} );
|
2019-11-23 17:40:29 +00:00
|
|
|
} );
|