From a5175c75d6741e74d327a9040b1c9ec2c6f575fc Mon Sep 17 00:00:00 2001 From: Veljko V Date: Thu, 24 Dec 2020 11:57:17 +0100 Subject: [PATCH] Fix problem in headless by adding uiUnblocked --- .../front-end-checkout-coupons.test.js | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/tests/e2e/core-tests/specs/shopper/front-end-checkout-coupons.test.js b/tests/e2e/core-tests/specs/shopper/front-end-checkout-coupons.test.js index fc7373f4479..da89375b9fe 100644 --- a/tests/e2e/core-tests/specs/shopper/front-end-checkout-coupons.test.js +++ b/tests/e2e/core-tests/specs/shopper/front-end-checkout-coupons.test.js @@ -6,7 +6,8 @@ const { shopper, merchant, createCoupon, - createSimpleProduct + createSimpleProduct, + uiUnblocked } = require( '@woocommerce/e2e-utils' ); /** @@ -37,9 +38,11 @@ const runCheckoutApplyCouponsTest = () => { await shopper.goToCheckout(); // Apply Fixed cart discount coupon - await expect(page).toClick('a', {text: 'Click here to enter your code'}); + await expect(page).toClick('a', {text: 'Click here to enter your code'}); + await uiUnblocked(); await expect(page).toFill('#coupon_code', 'Code-Fixed cart discount'); await expect(page).toClick('button', {text: 'Apply coupon'}); + await uiUnblocked(); await page.waitForSelector('.woocommerce-message', {text: 'Coupon code applied successfully.'}); // Wait for page to expand total calculations to avoid flakyness @@ -51,45 +54,57 @@ const runCheckoutApplyCouponsTest = () => { // Remove coupon await expect(page).toClick('.woocommerce-remove-coupon', {text: '[Remove]'}); + await uiUnblocked(); await page.waitForSelector('.woocommerce-message', {text: 'Coupon has been removed.'}); // Apply Percentage discount coupon - await expect(page).toClick('a', {text: 'Click here to enter your code'}); + await expect(page).toClick('a', {text: 'Click here to enter your code'}); + await uiUnblocked(); await expect(page).toFill('#coupon_code', 'Code-Percentage discount'); await expect(page).toClick('button', {text: 'Apply coupon'}); + await uiUnblocked(); await page.waitForSelector('.woocommerce-message', {text: 'Coupon code applied successfully.'}); await page.waitForSelector('.cart-discount .amount', {text: '$4.99'}); await page.waitForSelector('.order-total .amount', {text: '$5.00'}); // Remove coupon await expect(page).toClick('.woocommerce-remove-coupon', {text: '[Remove]'}); + await uiUnblocked(); await page.waitForSelector('.woocommerce-message', {text: 'Coupon has been removed.'}); // Apply Fixed product discount coupon - await expect(page).toClick('a', {text: 'Click here to enter your code'}); + await expect(page).toClick('a', {text: 'Click here to enter your code'}); + await uiUnblocked(); await expect(page).toFill('#coupon_code', 'Code-Fixed product discount'); await expect(page).toClick('button', {text: 'Apply coupon'}); + await uiUnblocked(); await page.waitForSelector('.woocommerce-message', {text: 'Coupon code applied successfully.'}); await page.waitForSelector('.cart-discount .amount', {text: '$5.00'}); await page.waitForSelector('.order-total .amount', {text: '$4.99'}); // Try to apply the same coupon - await expect(page).toClick('a', {text: 'Click here to enter your code'}); + await expect(page).toClick('a', {text: 'Click here to enter your code'}); + await uiUnblocked(); await expect(page).toFill('#coupon_code', 'Code-Fixed product discount'); await expect(page).toClick('button', {text: 'Apply coupon'}); + await uiUnblocked(); await page.waitForSelector('.woocommerce-error', { text: 'Coupon code already applied!' }); // Try to apply multiple coupons - await expect(page).toClick('a', {text: 'Click here to enter your code'}); + await expect(page).toClick('a', {text: 'Click here to enter your code'}); + await uiUnblocked(); await expect(page).toFill('#coupon_code', 'Code-Fixed cart discount'); await expect(page).toClick('button', {text: 'Apply coupon'}); + await uiUnblocked(); await page.waitForSelector('.woocommerce-message', {text: 'Coupon code applied successfully.'}); await page.waitForSelector('.order-total .amount', {text: '$0.00'}); // Remove coupon - await expect(page).toClick('.woocommerce-remove-coupon', {text: '[Remove]'}); + await expect(page).toClick('.woocommerce-remove-coupon', {text: '[Remove]'}); + await uiUnblocked(); await page.waitForSelector('.woocommerce-message', {text: 'Coupon has been removed.'}); - await expect(page).toClick('.woocommerce-remove-coupon', {text: '[Remove]'}); + await expect(page).toClick('.woocommerce-remove-coupon', {text: '[Remove]'}); + await uiUnblocked(); await page.waitForSelector('.woocommerce-message', {text: 'Coupon has been removed.'}); // Verify the total amount after all coupons removal