2019-08-30 11:03:57 +00:00
|
|
|
/**
|
|
|
|
* @format
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { StoreOwnerFlow } from '../../utils/flows';
|
2019-10-25 11:56:55 +00:00
|
|
|
import { settingsPageSaveChanges, verifyValueOfInputField } from '../../utils';
|
2019-08-30 11:03:57 +00:00
|
|
|
|
|
|
|
describe( 'WooCommerce General Settings', () => {
|
|
|
|
beforeAll( async () => {
|
2019-11-24 13:08:48 +00:00
|
|
|
await StoreOwnerFlow.login();
|
2019-08-30 11:03:57 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'can update settings', async () => {
|
|
|
|
// 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' } );
|
|
|
|
|
|
|
|
// Set selling location to all countries first,
|
|
|
|
// so we can choose california as base location.
|
|
|
|
await expect( page ).toSelect( '#woocommerce_allowed_countries', 'Sell to all countries' );
|
|
|
|
await settingsPageSaveChanges();
|
2019-09-04 12:12:37 +00:00
|
|
|
|
|
|
|
// Verify that settings have been saved
|
|
|
|
await Promise.all( [
|
|
|
|
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
|
|
|
expect( page ).toMatchElement( '#woocommerce_allowed_countries', { text: 'Sell to all countries' } ),
|
|
|
|
] );
|
2019-08-30 11:03:57 +00:00
|
|
|
|
|
|
|
// Set base location with state CA.
|
|
|
|
await expect( page ).toSelect( 'select[name="woocommerce_default_country"]', 'United States (US) — California' );
|
|
|
|
await settingsPageSaveChanges();
|
2019-09-04 12:12:37 +00:00
|
|
|
|
|
|
|
// Verify that settings have been saved
|
|
|
|
await Promise.all( [
|
|
|
|
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
|
|
|
expect( page ).toMatchElement( 'select[name="woocommerce_default_country"]', { text: 'United States (US) — California' } ),
|
|
|
|
] );
|
2019-08-30 11:03:57 +00:00
|
|
|
|
|
|
|
// Set selling location to specific countries first, so we can choose U.S as base location (without state).
|
|
|
|
// This will makes specific countries option appears.
|
|
|
|
await expect( page ).toSelect( '#woocommerce_allowed_countries', 'Sell to specific countries' );
|
|
|
|
await expect( page ).toSelect( 'select[name="woocommerce_specific_allowed_countries[]"]', 'United States (US)' );
|
|
|
|
await settingsPageSaveChanges();
|
2019-09-04 12:12:37 +00:00
|
|
|
|
|
|
|
// Verify that settings have been saved
|
|
|
|
await Promise.all( [
|
|
|
|
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
|
|
|
expect( page ).toMatchElement( '#woocommerce_allowed_countries', { text: 'Sell to specific countries' } ),
|
|
|
|
expect( page ).toMatchElement( 'select[name="woocommerce_specific_allowed_countries[]"]', { text: 'United States (US)' } ),
|
|
|
|
] );
|
2019-08-30 11:03:57 +00:00
|
|
|
|
|
|
|
// Set currency options.
|
|
|
|
await expect( page ).toFill( '#woocommerce_price_thousand_sep', ',' );
|
|
|
|
await expect( page ).toFill( '#woocommerce_price_decimal_sep', '.' );
|
|
|
|
await expect( page ).toFill( '#woocommerce_price_num_decimals', '2' );
|
|
|
|
await settingsPageSaveChanges();
|
2019-09-04 12:12:37 +00:00
|
|
|
|
|
|
|
// Verify that settings have been saved
|
|
|
|
await Promise.all( [
|
|
|
|
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
|
|
|
verifyValueOfInputField( '#woocommerce_price_thousand_sep', ',' ),
|
|
|
|
verifyValueOfInputField( '#woocommerce_price_decimal_sep', '.' ),
|
|
|
|
verifyValueOfInputField( '#woocommerce_price_num_decimals', '2' ),
|
|
|
|
] );
|
2019-08-30 11:03:57 +00:00
|
|
|
} );
|
|
|
|
} );
|