Commit 4df458c4c15 for woocommerce

commit 4df458c4c152d9e3facd2a673be8573b45990d24
Author: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com>
Date:   Tue Sep 29 18:22:29 2026 +0300

    e2e tests: fix flaky analytics overview performance indicators E2E test (#69214)

diff --git a/plugins/woocommerce/changelog/fix-e2e-analytics-performance-indicators b/plugins/woocommerce/changelog/fix-e2e-analytics-performance-indicators
new file mode 100644
index 00000000000..7e143070f96
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-e2e-analytics-performance-indicators
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+Comment: Isolate the analytics overview E2E spec's dashboard layout to fix a flaky test; no production change.
+
diff --git a/plugins/woocommerce/tests/e2e/tests/analytics/analytics-overview.spec.ts b/plugins/woocommerce/tests/e2e/tests/analytics/analytics-overview.spec.ts
index e78092c31a5..9c75a6fbb86 100644
--- a/plugins/woocommerce/tests/e2e/tests/analytics/analytics-overview.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/analytics/analytics-overview.spec.ts
@@ -13,7 +13,7 @@ import type {
  */
 import { admin } from '../../test-data/data';
 import { tags } from '../../fixtures/fixtures';
-import { ADMIN_STATE_PATH } from '../../playwright.config';
+import { random } from '../../utils/helpers';

 const EXPECTED_SECTION_HEADERS = [ 'Performance', 'Charts', 'Leaderboards' ];

@@ -25,14 +25,28 @@ let menuitem_moveUp: Locator;
 let menuitem_moveDown: Locator;
 let page: Page;

-const base64String = Buffer.from(
-	`${ admin.username }:${ admin.password }`
-).toString( 'base64' );
+// The section layout is stored per user, so this spec uses its own
+// administrator to leave the shared admin's Overview untouched for the specs
+// running alongside it.
+const sectionsUser = {
+	username: `analytics-overview-${ random() }`,
+	password: `password-${ random() }`,
+};

-const headers = {
-	Authorization: `Basic ${ base64String }`,
+const basicAuthHeaders = ( {
+	username,
+	password,
+}: {
+	username: string;
+	password: string;
+} ) => ( {
+	Authorization: `Basic ${ Buffer.from(
+		`${ username }:${ password }`
+	).toString( 'base64' ) }`,
 	cookie: '',
-};
+} );
+
+const headers = basicAuthHeaders( sectionsUser );

 // Call this before the click that triggers the save, and await the returned
 // promise after it — registering the listener after the click can miss a
@@ -124,26 +138,38 @@ test.describe(
 	'Analytics pages',
 	{ tag: [ tags.PAYMENTS, tags.SERVICES ] },
 	() => {
-		test.use( { storageState: ADMIN_STATE_PATH } );
-
 		test.beforeAll( async ( { browser } ) => {
-			page = await browser.newPage();
-
-			await test.step( `Send GET request to get the current user id`, async () => {
-				const pageRequest = page.request;
-				const data = {
-					_fields: 'id',
-				};
-				const response = await pageRequest.get(
-					'./wp-json/wp/v2/users/me',
+			page = await browser.newPage( {
+				storageState: { cookies: [], origins: [] },
+			} );
+
+			await test.step( `Create an administrator for this spec`, async () => {
+				const response = await page.request.post(
+					'./wp-json/wp/v2/users',
 					{
-						data,
-						headers,
+						data: {
+							...sectionsUser,
+							email: `${ sectionsUser.username }@example.com`,
+							roles: [ 'administrator' ],
+						},
+						headers: basicAuthHeaders( admin ),
 					}
 				);
-				const { id } = await response.json();
+				expect(
+					response.ok(),
+					`${ response.status() } ${ await response.text() }`
+				).toBeTruthy();

-				userId = id;
+				userId = ( await response.json() ).id;
+			} );
+
+			await test.step( `Log in as that administrator`, async () => {
+				await page.request.post( './wp-login.php', {
+					form: {
+						log: sectionsUser.username,
+						pwd: sectionsUser.password,
+					},
+				} );
 			} );

 			await resetSections();
@@ -188,6 +214,10 @@ test.describe(
 		} );

 		test.afterAll( async () => {
+			await page.request.delete( `./wp-json/wp/v2/users/${ userId }`, {
+				params: { force: true, reassign: false },
+				headers: basicAuthHeaders( admin ),
+			} );
 			await page.close();
 		} );