2020-09-29 19:16:43 +00:00
|
|
|
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
2020-10-20 14:25:36 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
const { HTTPClientFactory } = require( '@woocommerce/api' );
|
|
|
|
const {
|
|
|
|
it,
|
|
|
|
describe,
|
|
|
|
} = require( '@jest/globals' );
|
|
|
|
|
2020-09-29 19:16:43 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
const {
|
2020-12-22 13:59:16 +00:00
|
|
|
merchant,
|
2020-09-29 19:16:43 +00:00
|
|
|
permalinkSettingsPageSaveChanges,
|
|
|
|
setCheckbox,
|
|
|
|
settingsPageSaveChanges,
|
|
|
|
verifyCheckboxIsSet,
|
|
|
|
verifyValueOfInputField
|
|
|
|
} = require( '@woocommerce/e2e-utils' );
|
|
|
|
|
2020-10-13 20:25:28 +00:00
|
|
|
const {
|
2020-11-04 18:56:48 +00:00
|
|
|
getTestConfig,
|
2020-10-13 20:25:28 +00:00
|
|
|
waitAndClick
|
|
|
|
} = require( '@woocommerce/e2e-environment' );
|
|
|
|
|
2020-09-29 19:16:43 +00:00
|
|
|
const runInitialStoreSettingsTest = () => {
|
|
|
|
describe('Store owner can finish initial store setup', () => {
|
2021-05-21 11:27:50 +00:00
|
|
|
beforeAll(async () => {
|
|
|
|
await merchant.login();
|
|
|
|
});
|
2020-09-29 19:16:43 +00:00
|
|
|
|
|
|
|
it('can enable tax rates and calculations', async () => {
|
|
|
|
// Go to general settings page
|
2020-12-22 13:59:16 +00:00
|
|
|
await merchant.openSettings('general');
|
2020-09-29 19:16:43 +00:00
|
|
|
|
|
|
|
// 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'),
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can configure permalink settings', async () => {
|
|
|
|
// Go to Permalink Settings page
|
2020-12-22 13:59:16 +00:00
|
|
|
await merchant.openPermalinkSettings();
|
2020-09-29 19:16:43 +00:00
|
|
|
|
|
|
|
// Select "Post name" option in common settings section
|
|
|
|
await page.click('input[value="/%postname%/"]', {text: ' Post name'});
|
|
|
|
|
|
|
|
// Select "Custom base" in product permalinks section
|
2020-10-13 20:25:28 +00:00
|
|
|
await waitAndClick( page, '#woocommerce_custom_selection' );
|
2020-09-29 19:16:43 +00:00
|
|
|
|
|
|
|
// Fill custom base slug to use
|
|
|
|
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/'),
|
|
|
|
]);
|
|
|
|
});
|
2020-11-04 18:56:48 +00:00
|
|
|
|
|
|
|
it( 'can use api with pretty permalinks', async () => {
|
|
|
|
const testConfig = getTestConfig();
|
|
|
|
const admin = testConfig.users.admin;
|
|
|
|
const client = HTTPClientFactory.build( testConfig.url )
|
|
|
|
.withBasicAuth( admin.username, admin.password )
|
|
|
|
.withIndexPermalinks()
|
|
|
|
.create();
|
|
|
|
|
|
|
|
const response = await client.get( '/wc/v3/products' );
|
|
|
|
expect( response.statusCode ).toBe( 200 );
|
|
|
|
});
|
2020-09-29 19:16:43 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = runInitialStoreSettingsTest;
|