Fix problem in headless by adding uiUnblocked

This commit is contained in:
Veljko V 2020-12-24 11:53:45 +01:00
parent f4be2afa2a
commit 121099afe7
1 changed files with 13 additions and 3 deletions

View File

@ -6,7 +6,8 @@ const {
shopper,
merchant,
createCoupon,
createSimpleProduct
createSimpleProduct,
uiUnblocked
} = require( '@woocommerce/e2e-utils' );
/**
@ -38,6 +39,7 @@ const runCartApplyCouponsTest = () => {
// Apply Fixed cart discount coupon
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
@ -49,22 +51,26 @@ const runCartApplyCouponsTest = () => {
// 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).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).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'});
@ -72,18 +78,22 @@ const runCartApplyCouponsTest = () => {
// Try to apply the same coupon
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).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