Fix flaky scenarios and improve code
This commit is contained in:
parent
1e26d880c1
commit
2b0127f9e3
|
@ -29,19 +29,12 @@ const runAddNewShippingZoneTest = () => {
|
|||
|
||||
it('add shipping zone for San Francisco with free Local pickup', async () => {
|
||||
// Add a new shipping zone for the US with Flat Rate
|
||||
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);
|
||||
|
||||
// Save the shipping zone
|
||||
await expect(page).toClick('button#submit');
|
||||
await addShippingZoneAndMethod(shippingZoneNameSF, california, sanFranciscoZIP, 'local_pickup');
|
||||
});
|
||||
|
||||
it('add shipping zone for California with Free shipping', async () => {
|
||||
// Add a new shipping zone for California with Free shipping
|
||||
await addShippingZoneAndMethod(shippingZoneNameFL, california, 'free_shipping');
|
||||
await addShippingZoneAndMethod(shippingZoneNameFL, california, ' ', 'free_shipping');
|
||||
});
|
||||
|
||||
it('add shipping zone for the US with Flat rate', async () => {
|
||||
|
|
|
@ -431,12 +431,14 @@ const createCoupon = async ( couponAmount = '5', discountType = 'Fixed cart disc
|
|||
*
|
||||
* @param zoneName Shipping zone name.
|
||||
* @param zoneLocation Shiping zone location. Defaults to United States (US).
|
||||
* @param zipCode TBD
|
||||
* @param zoneMethod Shipping method type. Defaults to flat_rate (use also: free_shipping or local_pickup)
|
||||
*/
|
||||
const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'United States (US)', zoneMethod = 'flat_rate' ) => {
|
||||
const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'United States (US)', zipCode = ' ', zoneMethod = 'flat_rate' ) => {
|
||||
await merchant.openNewShipping();
|
||||
|
||||
// Fill shipping zone name
|
||||
await page.waitForSelector('input#zone_name');
|
||||
await expect(page).toFill('input#zone_name', zoneName);
|
||||
|
||||
// Select shipping zone location
|
||||
|
@ -445,9 +447,15 @@ const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'United States
|
|||
await page.keyboard.press('Tab');
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
// Fill shipping zone postcode if needed otherwise just put empty space
|
||||
await expect(page).toClick('a.wc-shipping-zone-postcodes-toggle');
|
||||
await expect(page).toFill('#zone_postcodes', zipCode);
|
||||
await expect(page).toClick('button#submit');
|
||||
|
||||
// Add shipping zone method
|
||||
await expect(page).toClick('button.button.wc-shipping-zone-add-method', {text:'Add shipping method'});
|
||||
await page.waitForSelector('woocommerce_flat_rate_cost');
|
||||
await page.waitFor(1000); // avoiding flakiness
|
||||
await expect(page).toClick('button.wc-shipping-zone-add-method', {text:'Add shipping method'});
|
||||
await page.waitFor(1000); // avoiding flakiness
|
||||
await expect(page).toSelect('select[name="add_method_id"]', zoneMethod);
|
||||
await expect(page).toClick('button#btn-ok');
|
||||
await page.waitForSelector('#zone_locations');
|
||||
|
|
Loading…
Reference in New Issue