Merge pull request #29548 from woocommerce/e2e/e2e-fix-flaky-shipping-zones
Fix flakiness in Merchant's Add Shipping Zones test
This commit is contained in:
commit
a4ef0b0b1d
|
@ -17,7 +17,7 @@ const {
|
|||
const config = require( 'config' );
|
||||
const simpleProductPrice = config.has( 'products.simple.price' ) ? config.get( 'products.simple.price' ) : '9.99';
|
||||
const simpleProductName = config.get( 'products.simple.name' );
|
||||
const california = 'California, United States (US)';
|
||||
const california = 'state:US:CA';
|
||||
const sanFranciscoZIP = '94107';
|
||||
const shippingZoneNameUS = 'US with Flat rate';
|
||||
const shippingZoneNameFL = 'CA with Free shipping';
|
||||
|
@ -90,10 +90,6 @@ const runAddNewShippingZoneTest = () => {
|
|||
await selectOptionInSelect2('New York');
|
||||
await expect(page).toClick('button[name="calc_shipping"]');
|
||||
|
||||
// Set shipping postcode to 10010
|
||||
await clearAndFillInput('#calc_shipping_postcode', '10010');
|
||||
await expect(page).toClick('button[name="calc_shipping"]');
|
||||
|
||||
// Verify shipping costs
|
||||
await page.waitForSelector('.order-total');
|
||||
await expect(page).toMatchElement('.shipping .amount', {text: '$10.00'});
|
||||
|
@ -102,6 +98,7 @@ const runAddNewShippingZoneTest = () => {
|
|||
|
||||
it('allows customer to benefit from a Free shipping if in CA', async () => {
|
||||
await page.reload();
|
||||
|
||||
// Set shipping state to California
|
||||
await expect(page).toClick('a.shipping-calculator-button');
|
||||
await expect(page).toClick('#select2-calc_shipping_state-container');
|
||||
|
@ -119,6 +116,7 @@ const runAddNewShippingZoneTest = () => {
|
|||
|
||||
it('allows customer to benefit from a free Local pickup if in SF', async () => {
|
||||
await page.reload();
|
||||
|
||||
// Set shipping postcode to 94107
|
||||
await expect(page).toClick('a.shipping-calculator-button');
|
||||
await clearAndFillInput('#calc_shipping_postcode', '94107');
|
||||
|
|
|
@ -472,11 +472,11 @@ const createCoupon = async ( couponAmount = '5', discountType = 'Fixed cart disc
|
|||
* Adds a shipping zone along with a shipping method.
|
||||
*
|
||||
* @param zoneName Shipping zone name.
|
||||
* @param zoneLocation Shiping zone location. Defaults to United States (US).
|
||||
* @param zoneLocation Shiping zone location. Defaults to country:US. For states use: state:US:CA
|
||||
* @param zipCode Shipping zone zip code. Defaults to empty one space.
|
||||
* @param zoneMethod Shipping method type. Defaults to flat_rate (use also: free_shipping or local_pickup)
|
||||
*/
|
||||
const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'United States (US)', zipCode = ' ', zoneMethod = 'flat_rate' ) => {
|
||||
const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'country:US', zipCode = ' ', zoneMethod = 'flat_rate' ) => {
|
||||
await merchant.openNewShipping();
|
||||
|
||||
// Fill shipping zone name
|
||||
|
@ -484,12 +484,7 @@ const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'United States
|
|||
await expect(page).toFill('input#zone_name', zoneName);
|
||||
|
||||
// Select shipping zone location
|
||||
// (.toSelect is not best option here because a lot of   are present in country/state names)
|
||||
await expect(page).toFill('#zone_locations', zoneLocation);
|
||||
await uiUnblocked();
|
||||
await page.keyboard.press('Tab');
|
||||
await uiUnblocked();
|
||||
await page.keyboard.press('Enter');
|
||||
await expect(page).toSelect('select[name="zone_locations"]', zoneLocation);
|
||||
|
||||
// Fill shipping zone postcode if needed otherwise just put empty space
|
||||
await page.waitForSelector('a.wc-shipping-zone-postcodes-toggle');
|
||||
|
@ -499,14 +494,12 @@ const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'United States
|
|||
await expect(page).toClick('button#submit');
|
||||
|
||||
// Add shipping zone method
|
||||
await uiUnblocked();
|
||||
await page.waitFor(1000);
|
||||
await expect(page).toClick('button.wc-shipping-zone-add-method', {text:'Add shipping method'});
|
||||
await page.waitForSelector('.wc-shipping-zone-method-selector');
|
||||
await expect(page).toSelect('select[name="add_method_id"]', zoneMethod);
|
||||
await uiUnblocked();
|
||||
await expect(page).toClick('button#btn-ok');
|
||||
await page.waitForSelector('#zone_locations');
|
||||
await uiUnblocked();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue