woocommerce/tests/e2e/core-tests/specs/merchant/wp-admin-settings-shipping-...

64 lines
1.9 KiB
JavaScript
Raw Normal View History

/* eslint-disable jest/no-export, jest/no-disabled-tests */
/**
* Internal dependencies
*/
const {
merchant,
addShippingZoneAndMethod,
2021-02-11 18:05:50 +00:00
clearAndFillInput,
} = 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';
// Shipping Zone Locations
2021-02-11 18:05:50 +00:00
const california = 'California, United States (US)';
const sanFranciscoZIP = '94110';
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 () => {
// 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 18:05:50 +00:00
it('add shipping zone for California with Free shipping', async () => {
// 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 18:05:50 +00:00
it('add shipping zone for San Francisco with free Local pickup', async () => {
// 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 18:05:50 +00:00
// Save the shipping zone
await expect(page).toClick('button#submit');
});
});
};
module.exports = runAddNewShippingZoneTest;