Merge pull request #24538 from woocommerce/new/wp-admin-settings-gen-product-e2e-test

Add 2 new Puppeteer e2e tests: settings general & product
This commit is contained in:
Julia Amosova 2019-10-25 14:13:04 +02:00 committed by GitHub
commit 2132981871
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 131 additions and 0 deletions

View File

@ -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' ),
] );
} );
} );

View File

@ -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' ),
] );
} );
} );