From fd5bc2a420f409f46caee2cae92482de71f0f7a7 Mon Sep 17 00:00:00 2001 From: rodelgc Date: Wed, 17 May 2023 15:19:18 +0800 Subject: [PATCH] Replace deprecated page methods. Blur and wait for autosave. Add a few explicit waits. --- .../e2e-pw/tests/merchant/create-coupon.spec.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-coupon.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-coupon.spec.js index eb98753bdac..80e94ef6ed0 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-coupon.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/create-coupon.spec.js @@ -29,14 +29,20 @@ test.describe( 'Add New Coupon Page', () => { waitUntil: 'networkidle', } ); - await page.fill( '#title', couponCode ); + await page.locator( '#title' ).fill( couponCode ); - await page.fill( '#woocommerce-coupon-description', 'test coupon' ); + // Blur then wait for the auto-save to finish + await page.locator( '#title' ).blur(); + await page.waitForLoadState( 'networkidle' ); - await page.fill( '#coupon_amount', '100' ); + await page + .locator( '#woocommerce-coupon-description' ) + .fill( 'test coupon' ); - await expect( page.locator( '#publish:not(.disabled)' ) ).toBeVisible(); - await page.click( '#publish' ); + await page.locator( '#coupon_amount' ).fill( '100' ); + + await page.locator( '#publish:not(.disabled)' ).click(); + await page.waitForLoadState( 'networkidle' ); await expect( page