Update components and test to be more concise

This commit is contained in:
Veljko V 2021-01-06 17:08:29 +01:00
parent d3169dcf43
commit 79904279fa
2 changed files with 10 additions and 6 deletions

View File

@ -21,18 +21,22 @@ const {
const runCheckoutApplyCouponsTest = () => {
describe('Checkout applying coupons', () => {
let couponFixedCart;
let couponPercentage;
let couponFixedProduct;
beforeAll(async () => {
await merchant.login();
await createSimpleProduct();
await createCoupon('Fixed cart discount');
await createCoupon('Percentage discount', '50');
await createCoupon('Fixed product discount');
couponFixedCart = await createCoupon();
couponPercentage = await createCoupon('50', 'Percentage discount');
couponFixedProduct = await createCoupon('5', 'Fixed product discount');
await merchant.logout();
});
it('allows customer to apply coupons in the checkout', async () => {
await shopper.goToShop();
await shopper.addToCartFromShopPage('Simple product');
await uiUnblocked();
await shopper.goToCheckout();
// Apply Fixed cart discount coupon

View File

@ -401,10 +401,10 @@ const addProductToOrder = async ( orderId, productName ) => {
/**
* Creates a basic coupon with the provided coupon amount. Returns the coupon code.
*
* @param discountType Type of a coupon. Defaults to Fixed cart discount.
* @param couponAmount Amount to be applied. Defaults to 5.
* @param discountType Type of a coupon. Defaults to Fixed cart discount.
*/
const createCoupon = async ( discountType = 'Fixed cart discount', couponAmount = '5' ) => {
const createCoupon = async ( couponAmount = '5', discountType = 'Fixed cart discount' ) => {
await merchant.openNewCoupon();
// Fill in coupon code
@ -413,8 +413,8 @@ const createCoupon = async ( discountType = 'Fixed cart discount', couponAmount
// Set general coupon data
await clickTab( 'General' );
await expect(page).toSelect( '#discount_type', discountType );
await expect(page).toFill( '#coupon_amount', couponAmount );
await expect(page).toSelect( '#discount_type', discountType );
// Publish coupon
await expect( page ).toClick( '#publish' );