2019-08-29 16:09:42 +00:00
|
|
|
/**
|
|
|
|
* @format
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { StoreOwnerFlow } from '../../utils/flows';
|
2019-11-24 13:08:48 +00:00
|
|
|
import { clickTab, verifyPublishAndTrash } from '../../utils';
|
2019-08-29 16:09:42 +00:00
|
|
|
|
|
|
|
describe( 'Add New Coupon Page', () => {
|
|
|
|
beforeAll( async () => {
|
2019-11-24 13:08:48 +00:00
|
|
|
await StoreOwnerFlow.login();
|
2019-08-29 16:09:42 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'can create new coupon', async () => {
|
|
|
|
// Go to "add coupon" page
|
|
|
|
await StoreOwnerFlow.openNewCoupon();
|
|
|
|
|
|
|
|
// Make sure we're on the add coupon page
|
|
|
|
await expect( page.title() ).resolves.toMatch( 'Add new coupon' );
|
|
|
|
|
|
|
|
// Fill in coupon code and description
|
|
|
|
await expect( page ).toFill( '#title', 'code-' + new Date().getTime().toString() );
|
|
|
|
await expect( page ).toFill( '#woocommerce-coupon-description', 'test coupon' );
|
|
|
|
|
|
|
|
// Set general coupon data
|
|
|
|
await clickTab( 'General' );
|
|
|
|
await expect( page ).toSelect( '#discount_type', 'Fixed cart discount' );
|
|
|
|
await expect( page ).toFill( '#coupon_amount', '100' );
|
|
|
|
|
|
|
|
// Publish coupon, verify that it was published. Trash coupon, verify that it was trashed.
|
|
|
|
await verifyPublishAndTrash(
|
|
|
|
'#publish',
|
|
|
|
'#message',
|
|
|
|
'Coupon updated.',
|
|
|
|
'1 coupon moved to the Trash.'
|
|
|
|
);
|
|
|
|
|
|
|
|
} );
|
|
|
|
} );
|