2019-08-30 11:03:57 +00:00
|
|
|
/**
|
|
|
|
* @format
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { StoreOwnerFlow } from '../../utils/flows';
|
2019-11-24 13:08:48 +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 () => {
|
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 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' } );
|
|
|
|
|
2020-02-07 14:28:06 +00:00
|
|
|
await expect( page ).toSelect( '#woocommerce_file_download_method', 'Redirect only (Insecure)' );
|
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.' } ),
|
2020-02-07 14:09:56 +00:00
|
|
|
expect( page ).toMatchElement( '#woocommerce_file_download_method', { text: 'Redirect only (Insecure)' } ),
|
2019-09-04 12:12:37 +00:00
|
|
|
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
|
|
|
} );
|
|
|
|
} );
|