diff --git a/plugins/woocommerce/changelog/fix-some_e2e_tests_for_linked_product b/plugins/woocommerce/changelog/fix-some_e2e_tests_for_linked_product new file mode 100644 index 00000000000..43e077ef6d2 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-some_e2e_tests_for_linked_product @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +Fix some e2e tests for linked product #46506 diff --git a/plugins/woocommerce/tests/e2e-pw/tests/merchant/products/block-editor/linked-product-tab-product-block-editor.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/merchant/products/block-editor/linked-product-tab-product-block-editor.spec.js index b9ddd75bf89..d5d4a21ca28 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/merchant/products/block-editor/linked-product-tab-product-block-editor.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/merchant/products/block-editor/linked-product-tab-product-block-editor.spec.js @@ -63,11 +63,11 @@ test.describe( 'General tab', () => { await clickOnTab( 'Linked products', page ); - await page - .getByRole( 'heading', { + await expect( + page.getByRole( 'heading', { name: 'Cross-sells', } ) - .isVisible(); + ).toBeVisible(); await page .locator( @@ -79,9 +79,7 @@ test.describe( 'General tab', () => { await page.getByText( linkedProductsData[ 0 ].name ).click(); - await page.getByText( 'Choose products for me' ).first().click(); - - await page.waitForResponse( + const chooseProductsResponsePromise = page.waitForResponse( ( response ) => response .url() @@ -90,6 +88,9 @@ test.describe( 'General tab', () => { ) && response.status() === 200 ); + await page.getByText( 'Choose products for me' ).first().click(); + await chooseProductsResponsePromise; + await expect( page.getByRole( 'row', { name: 'Product name' } ) ).toHaveCount( 4 ); @@ -98,9 +99,7 @@ test.describe( 'General tab', () => { 'div.woocommerce-product-list div[role="table"] div[role="rowgroup"] div[role="row"]' ); - const upsellsRowsCount = await upsellsRows.count(); - - await expect( upsellsRowsCount ).toBe( 4 ); + await expect( upsellsRows ).toHaveCount( 4 ); await page .locator( @@ -154,9 +153,7 @@ test.describe( 'General tab', () => { 'section.upsells.products ul > li' ); - const productsCount = await productsList.count(); - - await expect( productsCount ).toBe( 4 ); + await expect( productsList ).toHaveCount( 4 ); } ); } ); } );