Commit 91fa08f9a35 for woocommerce

commit 91fa08f9a35ddb4ee329fac1d2dd0f94be51d1d6
Author: Darren Ethier <darren@roughsmootheng.in>
Date:   Sun Nov 29 16:26:01 2026 +0100

    Fix add-product-task e2e locators matching marketplace suggestions (#71590)

    The add-product task page lists woocommerce.com extension suggestions
    below the product types. A new "Smart Variations & Attributes Display"
    suggestion mentions "variable products", so the substring locator
    `{ name: 'Variable product' }` matched two menu items and failed strict
    mode. Anchor the product-type locators to the start of the name.

    The "task list is hidden" test also restored the setup task list only at
    the end of the test body, so a failed assertion left it hidden and broke
    the onboarding-wizard tests that run after it. Restore it in a finally
    block.

diff --git a/plugins/woocommerce/changelog/fix-WOOPLUG-8367-core-serial-e2e-add-product-task-variable b/plugins/woocommerce/changelog/fix-WOOPLUG-8367-core-serial-e2e-add-product-task-variable
new file mode 100644
index 00000000000..5a7fef8c794
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-WOOPLUG-8367-core-serial-e2e-add-product-task-variable
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Fix add-product-task e2e locators and task list cleanup that broke onboarding e2e tests; no production change.
diff --git a/plugins/woocommerce/tests/e2e/tests/onboarding/add-product-task.spec.ts b/plugins/woocommerce/tests/e2e/tests/onboarding/add-product-task.spec.ts
index 5bf49547d42..bc96932eb6c 100644
--- a/plugins/woocommerce/tests/e2e/tests/onboarding/add-product-task.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/onboarding/add-product-task.spec.ts
@@ -94,13 +94,13 @@ test.describe( 'Add Product Task', () => {

 		// Verify product type options are displayed
 		await expect(
-			page.getByRole( 'menuitem', { name: 'Physical product' } )
+			page.getByRole( 'menuitem', { name: /^Physical product/ } )
 		).toBeVisible();
 		await expect(
-			page.getByRole( 'menuitem', { name: 'Variable product' } )
+			page.getByRole( 'menuitem', { name: /^Variable product/ } )
 		).toBeVisible();
 		await expect(
-			page.getByRole( 'menuitem', { name: 'Grouped product' } )
+			page.getByRole( 'menuitem', { name: /^Grouped product/ } )
 		).toBeVisible();
 		await expect(
 			page.locator( '#toplevel_page_woocommerce' )
@@ -110,7 +110,7 @@ test.describe( 'Add Product Task', () => {
 		);

 		await page
-			.getByRole( 'menuitem', { name: 'Physical product' } )
+			.getByRole( 'menuitem', { name: /^Physical product/ } )
 			.click();
 		await expect(
 			page.locator(
@@ -130,13 +130,13 @@ test.describe( 'Add Product Task', () => {
 			/.+path=%2Fadd-product.+task=products/
 		);
 		await expect(
-			page.getByRole( 'menuitem', { name: 'Physical product' } )
+			page.getByRole( 'menuitem', { name: /^Physical product/ } )
 		).toBeVisible();
 		await expect(
-			page.getByRole( 'menuitem', { name: 'Variable product' } )
+			page.getByRole( 'menuitem', { name: /^Variable product/ } )
 		).toBeVisible();
 		await expect(
-			page.getByRole( 'menuitem', { name: 'Grouped product' } )
+			page.getByRole( 'menuitem', { name: /^Grouped product/ } )
 		).toBeVisible();
 		await expect( page.locator( '#menu-posts-product' ) ).toHaveClass(
 			/wp-has-current-submenu/
@@ -199,24 +199,26 @@ test.describe( 'Add Product Task', () => {
 		// Hide the task list
 		expect( await hide_task_list( restApi, 'setup' ) ).toBe( true );

-		// Navigate to All Products page
-		await page.goto( 'wp-admin/edit.php?post_type=product' );
-
-		// Verify redirect to add product task
-		await expect( page ).toHaveURL(
-			/.+path=%2Fadd-product.+task=products/
-		);
-		await expect(
-			page.getByRole( 'menuitem', { name: 'Physical product' } )
-		).toBeVisible();
-		await expect(
-			page.getByRole( 'menuitem', { name: 'Variable product' } )
-		).toBeVisible();
-		await expect(
-			page.getByRole( 'menuitem', { name: 'Grouped product' } )
-		).toBeVisible();
-
-		// Reset task list to visible
-		expect( await show_task_list( restApi, 'setup' ) ).toBe( true );
+		// Later serial specs (e.g. onboarding-wizard) need the setup task list visible, so restore it even if this test fails.
+		try {
+			// Navigate to All Products page
+			await page.goto( 'wp-admin/edit.php?post_type=product' );
+
+			// Verify redirect to add product task
+			await expect( page ).toHaveURL(
+				/.+path=%2Fadd-product.+task=products/
+			);
+			await expect(
+				page.getByRole( 'menuitem', { name: /^Physical product/ } )
+			).toBeVisible();
+			await expect(
+				page.getByRole( 'menuitem', { name: /^Variable product/ } )
+			).toBeVisible();
+			await expect(
+				page.getByRole( 'menuitem', { name: /^Grouped product/ } )
+			).toBeVisible();
+		} finally {
+			expect( await show_task_list( restApi, 'setup' ) ).toBe( true );
+		}
 	} );
 } );