diff --git a/tests/e2e-tests/specs/wp-admin/wp-admin-settings-general.test.js b/tests/e2e-tests/specs/wp-admin/wp-admin-settings-general.test.js new file mode 100644 index 00000000000..e7efe100d8e --- /dev/null +++ b/tests/e2e-tests/specs/wp-admin/wp-admin-settings-general.test.js @@ -0,0 +1,76 @@ +/** + * @format + */ + +/** + * External dependencies + */ +import { activatePlugin } from '@wordpress/e2e-test-utils'; + +/** + * Internal dependencies + */ +import { StoreOwnerFlow } from '../../utils/flows'; +import { settingsPageSaveChanges, verifyValueOfInputField } from '../../utils'; + +describe( 'WooCommerce General Settings', () => { + beforeAll( async () => { + await activatePlugin( 'woocommerce' ); + } ); + + 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(); + + // 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' } ), + ] ); + + // Set base location with state CA. + await expect( page ).toSelect( 'select[name="woocommerce_default_country"]', 'United States (US) — California' ); + await settingsPageSaveChanges(); + + // 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' } ), + ] ); + + // 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(); + + // 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)' } ), + ] ); + + // 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(); + + // 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' ), + ] ); + } ); +} ); diff --git a/tests/e2e-tests/specs/wp-admin/wp-admin-settings-product.test.js b/tests/e2e-tests/specs/wp-admin/wp-admin-settings-product.test.js new file mode 100644 index 00000000000..9ca6d9659c4 --- /dev/null +++ b/tests/e2e-tests/specs/wp-admin/wp-admin-settings-product.test.js @@ -0,0 +1,55 @@ +/** + * @format + */ + +/** + * External dependencies + */ +import { activatePlugin } from '@wordpress/e2e-test-utils'; + +/** + * Internal dependencies + */ +import { StoreOwnerFlow } from '../../utils/flows'; +import { setCheckbox, settingsPageSaveChanges, unsetCheckbox, verifyCheckboxIsSet, verifyCheckboxIsUnset } from "../../utils"; + +describe( 'WooCommerce Products > Downloadable Products Settings', () => { + beforeAll( async () => { + await activatePlugin( 'woocommerce' ); + } ); + + it( 'can update settings', async () => { + // Go to downloadable products settings page + await StoreOwnerFlow.openSettings( 'products', 'downloadable' ); + + // Make sure the product tab is active + await expect( page ).toMatchElement( 'a.nav-tab-active', { text: 'Products' } ); + await expect( page ).toMatchElement( 'ul.subsubsub > li > a.current', { text: 'Downloadable products' } ); + + await expect( page ).toSelect( '#woocommerce_file_download_method', 'Redirect only' ); + await setCheckbox( '#woocommerce_downloads_require_login' ); + await setCheckbox( '#woocommerce_downloads_grant_access_after_payment' ); + await settingsPageSaveChanges(); + + // Verify that settings have been saved + await Promise.all( [ + expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ), + expect( page ).toMatchElement( '#woocommerce_file_download_method', { text: 'Redirect only' } ), + verifyCheckboxIsSet( '#woocommerce_downloads_require_login' ), + verifyCheckboxIsSet( '#woocommerce_downloads_grant_access_after_payment' ), + ] ); + + await expect( page ).toSelect( '#woocommerce_file_download_method', 'Force downloads' ); + await unsetCheckbox( '#woocommerce_downloads_require_login' ); + await unsetCheckbox( '#woocommerce_downloads_grant_access_after_payment' ); + await settingsPageSaveChanges(); + + // Verify that settings have been saved + await Promise.all( [ + expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ), + expect( page ).toMatchElement( '#woocommerce_file_download_method', { text: 'Force downloads' } ), + verifyCheckboxIsUnset( '#woocommerce_downloads_require_login' ), + verifyCheckboxIsUnset( '#woocommerce_downloads_grant_access_after_payment' ), + ] ); + } ); +} );