2021-02-11 16:47:58 +00:00
|
|
|
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
const {
|
|
|
|
merchant,
|
|
|
|
addShippingZoneAndMethod,
|
2021-02-11 18:05:50 +00:00
|
|
|
clearAndFillInput,
|
2021-02-11 16:47:58 +00:00
|
|
|
} = require( '@woocommerce/e2e-utils' );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
const {
|
|
|
|
it,
|
|
|
|
describe,
|
|
|
|
beforeAll,
|
|
|
|
} = require( '@jest/globals' );
|
|
|
|
|
|
|
|
// Shipping Zone Names
|
2021-02-11 18:05:50 +00:00
|
|
|
const shippingZoneNameUS = 'US with Flat rate';
|
|
|
|
const shippingZoneNameCA = 'CA with Free shipping';
|
|
|
|
const shippingZoneNameSF = 'SF with Local pickup';
|
2021-02-11 16:47:58 +00:00
|
|
|
// Shipping Zone Locations
|
2021-02-11 18:05:50 +00:00
|
|
|
const california = 'California, United States (US)';
|
|
|
|
const sanFranciscoZIP = '94110';
|
2021-02-11 16:47:58 +00:00
|
|
|
|
|
|
|
const runAddNewShippingZoneTest = () => {
|
|
|
|
describe('WooCommerce Shipping Settings - Add new shipping zone', () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
await merchant.login();
|
|
|
|
});
|
|
|
|
|
2021-02-11 18:05:50 +00:00
|
|
|
it('add shipping zone for the US with Flat rate', async () => {
|
2021-02-11 16:47:58 +00:00
|
|
|
// Add a new shipping zone for the US with Flat rate
|
2021-02-11 18:05:50 +00:00
|
|
|
await addShippingZoneAndMethod(shippingZoneNameUS);
|
|
|
|
|
|
|
|
// Set Flat rate cost
|
|
|
|
await expect(page).toClick('a.wc-shipping-zone-method-settings', {text: 'Edit'});
|
|
|
|
await clearAndFillInput('#woocommerce_flat_rate_cost', '10');
|
|
|
|
await expect(page).toClick('button#btn-ok');
|
2021-02-11 16:47:58 +00:00
|
|
|
});
|
|
|
|
|
2021-02-11 18:05:50 +00:00
|
|
|
it('add shipping zone for California with Free shipping', async () => {
|
2021-02-11 16:47:58 +00:00
|
|
|
// Add a new shipping zone for California with Free shipping
|
2021-02-11 18:05:50 +00:00
|
|
|
await addShippingZoneAndMethod(shippingZoneNameCA, california, 'free_shipping');
|
2021-02-11 16:47:58 +00:00
|
|
|
});
|
|
|
|
|
2021-02-11 18:05:50 +00:00
|
|
|
it('add shipping zone for San Francisco with free Local pickup', async () => {
|
2021-02-11 16:47:58 +00:00
|
|
|
// Add a new shipping zone for the US with Flat Rate
|
2021-02-11 18:05:50 +00:00
|
|
|
await addShippingZoneAndMethod(shippingZoneNameSF, california, 'local_pickup');
|
|
|
|
|
|
|
|
// Set San Francisco as a local pickup city
|
|
|
|
await expect(page).toClick('a.wc-shipping-zone-postcodes-toggle');
|
|
|
|
await expect(page).toFill('#zone_postcodes', sanFranciscoZIP);
|
2021-02-11 16:47:58 +00:00
|
|
|
|
2021-02-11 18:05:50 +00:00
|
|
|
// Save the shipping zone
|
|
|
|
await expect(page).toClick('button#submit');
|
2021-02-11 16:47:58 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = runAddNewShippingZoneTest;
|