Fix flaky Attributes and Variations E2E tests (#47471)

* Wait for attributes until request is complete

* Wait for response

* Add changelog
This commit is contained in:
Fernando Marichal 2024-05-14 14:59:34 -03:00 committed by GitHub
parent 32d10eacf8
commit 2575d455f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Fix flaky Attributes and Variations E2E tests #47471

View File

@ -209,8 +209,19 @@ test.describe( 'Variations tab', () => {
} )
.click();
const getVariationsResponsePromise = page.waitForResponse(
( response ) =>
response
.url()
.includes(
`/wp-json/wc/v3/products/${ productId_editVariations }/variations`
) && response.status() === 200
);
await clickOnTab( 'Variations', page );
await getVariationsResponsePromise;
await page
.locator( '.woocommerce-product-variations__table-body > div' )
.first()
@ -267,8 +278,19 @@ test.describe( 'Variations tab', () => {
`/wp-admin/admin.php?page=wc-admin&path=/product/${ productId_deleteVariations }`
);
const getVariationsResponsePromise = page.waitForResponse(
( response ) =>
response
.url()
.includes(
`/wp-json/wc/v3/products/${ productId_deleteVariations }/variations`
) && response.status() === 200
);
await clickOnTab( 'Variations', page );
await getVariationsResponsePromise;
await page
.locator(
'.woocommerce-variations-table-error-or-empty-state__actions'

View File

@ -210,7 +210,13 @@ test.skip( 'can add existing attributes', async ( {
} ) => {
await test.step( 'go to product editor, Organization tab', async () => {
await page.goto( `wp-admin/post.php?post=${ product.id }&action=edit` );
const getAttributesResponsePromise = page.waitForResponse(
( response ) =>
response.url().includes( '/terms?attribute_id=' ) &&
response.status() === 200
);
await page.getByRole( 'button', { name: 'Organization' } ).click();
await getAttributesResponsePromise;
} );
await test.step( 'add an existing attribute', async () => {
@ -382,7 +388,13 @@ test( 'can remove product attributes', async ( {
await page.goto(
`wp-admin/post.php?post=${ productWithAttributes.id }&action=edit`
);
const getAttributesResponsePromise = page.waitForResponse(
( response ) =>
response.url().includes( '/terms?attribute_id=' ) &&
response.status() === 200
);
await page.getByRole( 'button', { name: 'Organization' } ).click();
await getAttributesResponsePromise;
} );
const attributeItemLocator = page.getByRole( 'listitem' ).filter( {