A few updates for flaky e2e tests (#45856)
Co-authored-by: Jon Lane <jon.lane@automattic.com>
This commit is contained in:
parent
9000fd764e
commit
ca7e3b99ed
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Fix some flaky e2e tests
|
|
@ -78,36 +78,11 @@ baseTest.describe( 'Merchant > Customer List', () => {
|
||||||
},
|
},
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test.beforeAll( async ( { api } ) => {
|
|
||||||
let oldCustomers = {};
|
|
||||||
await api.get( 'customers' ).then( ( response ) => {
|
|
||||||
oldCustomers = response.data;
|
|
||||||
} );
|
|
||||||
await api.post( `customers/batch`, {
|
|
||||||
delete: oldCustomers.map( ( customer ) => customer.id ),
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
|
|
||||||
test.beforeEach( async ( { context } ) => {
|
test.beforeEach( async ( { context } ) => {
|
||||||
// prevents the column picker from saving state between tests
|
// prevents the column picker from saving state between tests
|
||||||
await context.route( '**/users/**', ( route ) => route.abort() );
|
await context.route( '**/users/**', ( route ) => route.abort() );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// skipping this test because guest orders show in this list as undeletable customers.
|
|
||||||
test.skip( 'Merchant can view an empty customer list', async ( {
|
|
||||||
page,
|
|
||||||
} ) => {
|
|
||||||
await page.goto(
|
|
||||||
'/wp-admin/admin.php?page=wc-admin&path=%2Fcustomers'
|
|
||||||
);
|
|
||||||
await expect(
|
|
||||||
page.getByRole( 'cell', { name: 'No data to display' } )
|
|
||||||
).toBeVisible();
|
|
||||||
await expect(
|
|
||||||
page.getByText( '0customers0Average orders$0.' )
|
|
||||||
).toBeVisible();
|
|
||||||
} );
|
|
||||||
|
|
||||||
test( 'Merchant can view a list of all customers, filter and download', async ( {
|
test( 'Merchant can view a list of all customers, filter and download', async ( {
|
||||||
page,
|
page,
|
||||||
customers,
|
customers,
|
||||||
|
|
|
@ -80,7 +80,7 @@ test.describe( 'WooCommerce Merchant Flow: Orders > Customer Payment Page', () =
|
||||||
|
|
||||||
// verify we landed on the customer payment page
|
// verify we landed on the customer payment page
|
||||||
await expect(
|
await expect(
|
||||||
page.getByText( 'You are paying for a guest order.' )
|
page.getByRole( 'button', { name: 'Pay for order' } )
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
await expect( page.locator( 'td.product-name' ) ).toContainText(
|
await expect( page.locator( 'td.product-name' ) ).toContainText(
|
||||||
productName
|
productName
|
||||||
|
|
|
@ -81,10 +81,9 @@ test.describe( 'General tab', () => {
|
||||||
} )
|
} )
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
const element = page.locator( 'div.components-snackbar__content' );
|
await expect(
|
||||||
const textContent = await element.innerText();
|
page.getByLabel( 'Dismiss this notice' )
|
||||||
|
).toContainText( 'Product published' );
|
||||||
await expect( textContent ).toMatch( /Product published/ );
|
|
||||||
|
|
||||||
const title = page.locator( '.woocommerce-product-header__title' );
|
const title = page.locator( '.woocommerce-product-header__title' );
|
||||||
|
|
||||||
|
@ -133,10 +132,9 @@ test.describe( 'General tab', () => {
|
||||||
} )
|
} )
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
const element = page.locator( 'div.components-snackbar__content' );
|
await expect(
|
||||||
const textContent = await element.innerText();
|
page.getByLabel( 'Dismiss this notice' )
|
||||||
|
).toContainText( 'Invalid or duplicated SKU.' );
|
||||||
await expect( textContent ).toMatch( /Invalid or duplicated SKU./ );
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test( 'can a shopper add the simple product to the cart', async ( {
|
test( 'can a shopper add the simple product to the cart', async ( {
|
||||||
|
|
|
@ -147,12 +147,12 @@ test.describe( 'Variations tab', () => {
|
||||||
} )
|
} )
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
await page
|
// await page
|
||||||
.locator( '.woocommerce-product-publish-panel__header' )
|
// .locator( '.woocommerce-product-publish-panel__header' )
|
||||||
.getByRole( 'button', {
|
// .getByRole( 'button', {
|
||||||
name: 'Publish',
|
// name: 'Publish',
|
||||||
} )
|
// } )
|
||||||
.click();
|
// .click();
|
||||||
|
|
||||||
const element = page.locator( 'div.components-snackbar__content' );
|
const element = page.locator( 'div.components-snackbar__content' );
|
||||||
if ( Array.isArray( element ) ) {
|
if ( Array.isArray( element ) ) {
|
||||||
|
|
|
@ -121,10 +121,9 @@ test.describe( 'General tab', () => {
|
||||||
} )
|
} )
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
const element = page.locator( 'div.components-snackbar__content' );
|
await expect(
|
||||||
const textContent = await element.innerText();
|
page.getByLabel( 'Dismiss this notice' )
|
||||||
|
).toContainText( 'Product published' );
|
||||||
await expect( textContent ).toMatch( /Product published/ );
|
|
||||||
|
|
||||||
const title = page.locator( '.woocommerce-product-header__title' );
|
const title = page.locator( '.woocommerce-product-header__title' );
|
||||||
|
|
||||||
|
|
|
@ -393,7 +393,7 @@ test.describe( 'Cart & Checkout Restricted Coupons', () => {
|
||||||
billing: {
|
billing: {
|
||||||
first_name: 'Marge',
|
first_name: 'Marge',
|
||||||
last_name: 'Simpson',
|
last_name: 'Simpson',
|
||||||
email: 'marge@example.com',
|
email: 'marge.simpson@example.org',
|
||||||
},
|
},
|
||||||
line_items: [
|
line_items: [
|
||||||
{
|
{
|
||||||
|
@ -625,8 +625,8 @@ test.describe( 'Cart & Checkout Restricted Coupons', () => {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test( 'coupon cannot be used by any customer on cart (email restricted)', async ( {
|
test( 'coupon cannot be used by any customer on cart (email restricted)', async ( {
|
||||||
page,
|
page,
|
||||||
} ) => {
|
} ) => {
|
||||||
await page.goto( `/shop/?add-to-cart=${ firstProductId }` );
|
await page.goto( `/shop/?add-to-cart=${ firstProductId }` );
|
||||||
await page.waitForLoadState( 'networkidle' );
|
await page.waitForLoadState( 'networkidle' );
|
||||||
|
|
||||||
|
@ -661,7 +661,7 @@ test.describe( 'Cart & Checkout Restricted Coupons', () => {
|
||||||
await page
|
await page
|
||||||
.getByLabel( 'Email address' )
|
.getByLabel( 'Email address' )
|
||||||
.first()
|
.first()
|
||||||
.fill( 'marge@example.com' );
|
.fill( 'marge.simpson@example.org' );
|
||||||
|
|
||||||
await page
|
await page
|
||||||
.getByRole( 'link', { name: 'Click here to enter your code' } )
|
.getByRole( 'link', { name: 'Click here to enter your code' } )
|
||||||
|
@ -669,6 +669,8 @@ test.describe( 'Cart & Checkout Restricted Coupons', () => {
|
||||||
await page.getByPlaceholder( 'Coupon code' ).fill( 'email-restricted' );
|
await page.getByPlaceholder( 'Coupon code' ).fill( 'email-restricted' );
|
||||||
await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
|
await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
|
||||||
|
|
||||||
|
await page.waitForLoadState( 'networkidle' );
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
page.getByText(
|
page.getByText(
|
||||||
'Please enter a valid email to use coupon code "email-restricted".'
|
'Please enter a valid email to use coupon code "email-restricted".'
|
||||||
|
|
|
@ -10,8 +10,8 @@ const closeWelcomeModal = async ( { page } ) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const disableWelcomeModal = async ( { page } ) => {
|
const disableWelcomeModal = async ( { page } ) => {
|
||||||
await page.waitForLoadState();
|
// Further info: https://github.com/woocommerce/woocommerce/pull/45856/
|
||||||
await page.waitForFunction( () => window?.wp?.data );
|
await page.waitForLoadState( 'domcontentloaded' );
|
||||||
|
|
||||||
const isWelcomeGuideActive = await page.evaluate( () =>
|
const isWelcomeGuideActive = await page.evaluate( () =>
|
||||||
wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' )
|
wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' )
|
||||||
|
|
Loading…
Reference in New Issue