Added new component and updated tests

This commit is contained in:
Veljko 2021-04-08 12:41:02 +02:00
parent b195e354a2
commit 7a1ba36fc9
5 changed files with 35 additions and 50 deletions

View File

@ -10,8 +10,7 @@ const {
addShippingZoneAndMethod,
clearAndFillInput,
selectOptionInSelect2,
evalAndClick,
uiUnblocked,
deleteAllShippingZones,
} = require( '@woocommerce/e2e-utils' );
const config = require( 'config' );
@ -28,27 +27,7 @@ const runAddNewShippingZoneTest = () => {
beforeAll(async () => {
await merchant.login();
await createSimpleProduct();
await merchant.openSettings('shipping');
// Delete existing shipping zones.
try {
let zone = await page.$( '.wc-shipping-zone-delete' );
if ( zone ) {
// WP action links aren't clickable because they are hidden with a left=-9999 style.
await page.evaluate(() => {
document.querySelector('.wc-shipping-zone-name .row-actions')
.style
.left = '0';
});
while ( zone ) {
await evalAndClick( '.wc-shipping-zone-delete' );
await uiUnblocked();
zone = await page.$( '.wc-shipping-zone-delete' );
}
}
} catch (error) {
// Prevent an error here causing the test to fail.
}
await deleteAllShippingZones();
});
it('add shipping zone for San Francisco with free Local pickup', async () => {

View File

@ -8,7 +8,7 @@ const {
createSimpleProduct,
addShippingZoneAndMethod,
clearAndFillInput,
evalAndClick,
deleteAllShippingZones,
uiUnblocked,
selectOptionInSelect2,
} = require( '@woocommerce/e2e-utils' );
@ -33,33 +33,9 @@ const runCartCalculateShippingTest = () => {
beforeAll(async () => {
await merchant.login();
await createSimpleProduct(firstProductName);
await merchant.openSettings('general');
await createSimpleProduct(secondProductName, secondProductPrice);
await merchant.openSettings('shipping');
await deleteAllShippingZones();
});
it('can remove the existing shippings if they are present', async () => {
// Delete existing shipping zones.
try {
let zone = await page.$( '.wc-shipping-zone-delete' );
if ( zone ) {
// WP action links aren't clickable because they are hidden with a left=-9999 style.
await page.evaluate(() => {
document.querySelector('.wc-shipping-zone-name .row-actions')
.style
.left = '0';
});
while ( zone ) {
await evalAndClick( '.wc-shipping-zone-delete' );
await uiUnblocked();
zone = await page.$( '.wc-shipping-zone-delete' );
}
}
} catch (error) {
// Prevent an error here causing the test to fail.
}
});
it('can prepare the shipping zones for the test', async () => {
// Add a new shipping zone Germany with Free shipping
await addShippingZoneAndMethod(shippingZoneNameDE, shippingCountryDE, ' ', 'free_shipping');

View File

@ -1,6 +1,7 @@
# Unreleased
- `emptyCart()` Shopper flow helper that empties the cart
- `deleteAllShippingZones` Delete all the existing shipping zones
# 0.1.4

View File

@ -124,6 +124,7 @@ describe( 'Cart page', () => {
| `removeCoupon` | | helper method that removes a single coupon within cart or checkout |
| `selectOrderAction` | `action` | Helper method to select an order action in the `Order Actions` postbox |
| `clickUpdateOrder` | `noticeText`, `waitForSave` | Helper method to click the Update button on the order details page |
| `deleteAllShippingZones` | | Delete all the existing shipping zones |
### Test Utilities

View File

@ -12,7 +12,8 @@ import {
verifyCheckboxIsUnset,
selectOptionInSelect2,
setCheckbox,
unsetCheckbox
unsetCheckbox,
evalAndClick,
} from './page-utils';
import factories from './factories';
@ -538,6 +539,32 @@ const deleteAllEmailLogs = async () => {
}
};
/**
* Delete all the existing shipping zones.
*/
const deleteAllShippingZones = async () => {
await merchant.openSettings('shipping');
// Delete existing shipping zones.
try {
let zone = await page.$( '.wc-shipping-zone-delete' );
if ( zone ) {
// WP action links aren't clickable because they are hidden with a left=-9999 style.
await page.evaluate(() => {
document.querySelector('.wc-shipping-zone-name .row-actions')
.style
.left = '0';
});
while ( zone ) {
await evalAndClick( '.wc-shipping-zone-delete' );
await uiUnblocked();
zone = await page.$( '.wc-shipping-zone-delete' );
};
};
} catch (error) {
// Prevent an error here causing the test to fail.
};
};
export {
completeOnboardingWizard,
createSimpleProduct,
@ -551,4 +578,5 @@ export {
createSimpleProductWithCategory,
clickUpdateOrder,
deleteAllEmailLogs,
deleteAllShippingZones,
};