Add waits to fix flakyness

This commit is contained in:
Veljko 2021-03-05 08:50:11 +01:00
parent 9e1d785086
commit eaf8039223
3 changed files with 4 additions and 12 deletions

View File

@ -10,7 +10,6 @@ const {
addShippingZoneAndMethod,
clearAndFillInput,
selectOptionInSelect2,
uiUnblocked,
} = require( '@woocommerce/e2e-utils' );
const config = require( 'config' );
@ -60,15 +59,11 @@ const runAddNewShippingZoneTest = () => {
// Set shipping country to United States (US)
await expect(page).toClick('a.shipping-calculator-button');
await expect(page).toClick('#select2-calc_shipping_country-container');
await uiUnblocked();
await selectOptionInSelect2('United States (US)');
// Set shipping state to New York
await uiUnblocked();
await expect(page).toClick('#select2-calc_shipping_state-container');
await uiUnblocked();
await selectOptionInSelect2('New York');
await uiUnblocked();
await expect(page).toClick('button[name="calc_shipping"]');
// Verify shipping costs
@ -87,11 +82,9 @@ const runAddNewShippingZoneTest = () => {
// Set shipping state to California
await expect(page).toClick('a.shipping-calculator-button');
await expect(page).toClick('#select2-calc_shipping_state-container');
await uiUnblocked();
await selectOptionInSelect2('California');
// Set shipping postcode to 94000
await uiUnblocked();
await clearAndFillInput('#calc_shipping_postcode', '94000');
await expect(page).toClick('button[name="calc_shipping"]');
@ -99,7 +92,6 @@ const runAddNewShippingZoneTest = () => {
await page.waitForSelector('.order-total');
await expect(page).toMatchElement('.shipping ul#shipping_method > li', {text: 'Free shipping'});
await expect(page).toMatchElement('.order-total .amount', {text: '$9.99'});
await shopper.removeFromCart(simpleProductName);
})
@ -110,9 +102,7 @@ const runAddNewShippingZoneTest = () => {
// Set shipping postcode to 94107
await expect(page).toClick('a.shipping-calculator-button');
await uiUnblocked();
await clearAndFillInput('#calc_shipping_postcode', '94107');
await uiUnblocked();
await expect(page).toClick('button[name="calc_shipping"]');
// Verify shipping method and cost

View File

@ -463,9 +463,9 @@ const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'United States
await expect(page).toClick('button#submit');
// Add shipping zone method
await page.waitFor(1000); // avoiding flakiness
await page.waitFor(2000); // avoiding flakiness
await expect(page).toClick('button.wc-shipping-zone-add-method', {text:'Add shipping method'});
await page.waitFor(1000); // avoiding flakiness
await page.waitFor(2000); // avoiding flakiness
await expect(page).toSelect('select[name="add_method_id"]', zoneMethod);
await expect(page).toClick('button#btn-ok');
await page.waitForSelector('#zone_locations');

View File

@ -11,7 +11,9 @@ import { pressKeyWithModifier } from '@wordpress/e2e-test-utils';
*/
const clearAndFillInput = async ( selector, value ) => {
await page.focus( selector );
await page.waitFor(2000); // avoiding flakiness
await pressKeyWithModifier( 'primary', 'a' );
await page.waitFor(2000); // avoiding flakiness
await page.type( selector, value );
};