2020-09-04 02:31:09 +00:00
|
|
|
/**
|
|
|
|
* @format
|
|
|
|
*/
|
2021-03-17 19:22:09 +00:00
|
|
|
import {
|
|
|
|
clearAndFillInput,
|
|
|
|
verifyValueOfInputField,
|
|
|
|
} from '@woocommerce/e2e-utils';
|
2020-09-04 02:31:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { StoreOwnerFlow } from '../../utils/flows';
|
2021-03-17 19:22:09 +00:00
|
|
|
import { WcSettings } from '../../models/WcSettings';
|
|
|
|
import { WpSettings } from '../../models/WpSettings';
|
2020-09-04 02:31:09 +00:00
|
|
|
|
|
|
|
describe( 'Store owner can login and make sure WooCommerce is activated', () => {
|
|
|
|
it( 'can login', async () => {
|
|
|
|
await StoreOwnerFlow.login();
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'can make sure WooCommerce is activated. If not, activate it', async () => {
|
|
|
|
const slug = 'woocommerce';
|
|
|
|
await StoreOwnerFlow.openPlugins();
|
|
|
|
const disableLink = await page.$(
|
|
|
|
`tr[data-slug="${ slug }"] .deactivate a`
|
|
|
|
);
|
|
|
|
if ( disableLink ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
await page.click( `tr[data-slug="${ slug }"] .activate a` );
|
|
|
|
|
2020-10-29 18:51:37 +00:00
|
|
|
await page.waitForSelector( `tr[data-slug="${ slug }"] .deactivate a` );
|
2020-09-04 02:31:09 +00:00
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
|
|
|
describe( 'Store owner can finish initial store setup', () => {
|
|
|
|
it( 'can enable tax rates and calculations', async () => {
|
2021-03-17 19:22:09 +00:00
|
|
|
const wcSettings = new WcSettings( page );
|
2020-09-04 02:31:09 +00:00
|
|
|
|
2021-03-17 19:22:09 +00:00
|
|
|
// Go to general settings page
|
|
|
|
await wcSettings.open();
|
2020-09-04 02:31:09 +00:00
|
|
|
|
2021-03-17 19:22:09 +00:00
|
|
|
await wcSettings.enableTaxRates();
|
2020-09-04 02:31:09 +00:00
|
|
|
|
2021-03-17 19:22:09 +00:00
|
|
|
await wcSettings.saveSettings();
|
2020-09-04 02:31:09 +00:00
|
|
|
|
|
|
|
// Verify that settings have been saved
|
2021-03-17 19:22:09 +00:00
|
|
|
const taxRate = await wcSettings.getTaxRateValue();
|
|
|
|
expect( taxRate ).toEqual( true );
|
2020-09-04 02:31:09 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'can configure permalink settings', async () => {
|
2021-03-17 19:22:09 +00:00
|
|
|
const wpSettings = new WpSettings( page );
|
2020-09-04 02:31:09 +00:00
|
|
|
// Go to Permalink Settings page
|
2021-03-17 19:22:09 +00:00
|
|
|
await wpSettings.openPermalinkSettings();
|
2020-09-04 02:31:09 +00:00
|
|
|
|
|
|
|
// Select "Post name" option in common settings section
|
2021-03-17 19:22:09 +00:00
|
|
|
await page.click( 'input[value="/%postname%/"]' );
|
2020-09-04 02:31:09 +00:00
|
|
|
|
|
|
|
// Select "Custom base" in product permalinks section
|
|
|
|
await page.click( '#woocommerce_custom_selection' );
|
|
|
|
|
|
|
|
// Fill custom base slug to use
|
2021-03-17 19:22:09 +00:00
|
|
|
await clearAndFillInput( '#woocommerce_permalink_structure', '' );
|
|
|
|
await page.type( '#woocommerce_permalink_structure', '/product/' );
|
2020-09-04 02:31:09 +00:00
|
|
|
|
2021-03-17 19:22:09 +00:00
|
|
|
await wpSettings.saveSettings();
|
2020-09-04 02:31:09 +00:00
|
|
|
|
|
|
|
// 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/'
|
|
|
|
),
|
|
|
|
] );
|
|
|
|
} );
|
|
|
|
} );
|