Commit b8142c7a14b for woocommerce

commit b8142c7a14b3550d617adc195ec3ae65ad334c6e
Author: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com>
Date:   Tue Jul 7 15:59:40 2026 +0300

    e2e test: Fix command palette test modifier detection (#66364)

diff --git a/plugins/woocommerce/changelog/66364-fix-command-palette-e2e-modifier-detection b/plugins/woocommerce/changelog/66364-fix-command-palette-e2e-modifier-detection
new file mode 100644
index 00000000000..62ccf520c03
--- /dev/null
+++ b/plugins/woocommerce/changelog/66364-fix-command-palette-e2e-modifier-detection
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Fix command palette E2E test modifier-key detection under Playwright 1.61 (test-only; no merchant-facing change).
diff --git a/plugins/woocommerce/tests/e2e/tests/editor/command-palette.spec.ts b/plugins/woocommerce/tests/e2e/tests/editor/command-palette.spec.ts
index 6f9d43cd18d..a61ac4ad46f 100644
--- a/plugins/woocommerce/tests/e2e/tests/editor/command-palette.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/editor/command-palette.spec.ts
@@ -23,19 +23,29 @@ const clickOnCommandPaletteOption = async ( {
 		/Search (?:commands(?: and settings)?|for commands)/
 	);

-	// Playwright's browser reports a non-Apple platform even on macOS, so picking the combo from
-	// reports a non-Apple platform even on macOS, so picking the combo from
-	// `process.platform` would send Meta+K while WordPress listens for Ctrl+K and
-	// the palette would never open. Derive the modifier from the page instead.
-	const isApplePlatform = await page.evaluate( () =>
-		/Mac|iPhone|iPod|iPad/i.test(
-			(
-				navigator as Navigator & {
-					userAgentData?: { platform?: string };
-				}
-			 ).userAgentData?.platform || navigator.platform
-		)
-	);
+	// WordPress registers the command-palette shortcut via @wordpress/keycodes'
+	// `isAppleOS()`, which inspects `navigator.platform` only. In Playwright's
+	// Chromium on macOS these two disagree: `navigator.platform` is "MacIntel"
+	// (Apple → Cmd+K) while `navigator.userAgentData.platform` is "Windows".
+	// Deriving the modifier from `userAgentData` therefore sends Ctrl+K and the
+	// palette never opens. Reuse `isAppleOS()` so the test always matches whatever
+	// modifier WordPress actually registered (falling back to its logic if the
+	// keycodes package is unavailable).
+	const isApplePlatform = await page.evaluate( () => {
+		const isAppleOS = (
+			window as Window & {
+				wp?: { keycodes?: { isAppleOS?: () => boolean } };
+			}
+		 ).wp?.keycodes?.isAppleOS;
+		if ( typeof isAppleOS === 'function' ) {
+			return isAppleOS();
+		}
+		const { platform } = navigator;
+		return (
+			platform.indexOf( 'Mac' ) !== -1 ||
+			[ 'iPad', 'iPhone' ].includes( platform )
+		);
+	} );
 	const cmdKeyCombo = isApplePlatform ? 'Meta+k' : 'Control+k';

 	// Press `Ctrl`/`Cmd` + `K` to open the command palette.