2019-08-30 11:03:57 +00:00
|
|
|
/**
|
|
|
|
* @format
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { activatePlugin } from '@wordpress/e2e-test-utils';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { StoreOwnerFlow } from '../../utils/flows';
|
2019-09-04 12:12:37 +00:00
|
|
|
import { setCheckbox, settingsPageSaveChanges, unsetCheckbox, verifyCheckboxIsSet, verifyCheckboxIsUnset } from "../../utils";
|
2019-08-30 11:03:57 +00:00
|
|
|
|
|
|
|
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' );
|
2019-09-04 12:12:37 +00:00
|
|
|
await setCheckbox( '#woocommerce_downloads_require_login' );
|
|
|
|
await setCheckbox( '#woocommerce_downloads_grant_access_after_payment' );
|
2019-08-30 11:03:57 +00:00
|
|
|
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_file_download_method', { text: 'Redirect only' } ),
|
|
|
|
verifyCheckboxIsSet( '#woocommerce_downloads_require_login' ),
|
|
|
|
verifyCheckboxIsSet( '#woocommerce_downloads_grant_access_after_payment' ),
|
|
|
|
] );
|
2019-08-30 11:03:57 +00:00
|
|
|
|
|
|
|
await expect( page ).toSelect( '#woocommerce_file_download_method', 'Force downloads' );
|
2019-09-04 12:12:37 +00:00
|
|
|
await unsetCheckbox( '#woocommerce_downloads_require_login' );
|
|
|
|
await unsetCheckbox( '#woocommerce_downloads_grant_access_after_payment' );
|
2019-08-30 11:03:57 +00:00
|
|
|
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_file_download_method', { text: 'Force downloads' } ),
|
|
|
|
verifyCheckboxIsUnset( '#woocommerce_downloads_require_login' ),
|
|
|
|
verifyCheckboxIsUnset( '#woocommerce_downloads_grant_access_after_payment' ),
|
|
|
|
] );
|
2019-08-30 11:03:57 +00:00
|
|
|
} );
|
|
|
|
} );
|