Skip to content

fix(mcp): handle non-deterministic contextmenu/mouseup order in right…#39416

Merged
yury-s merged 1 commit intomicrosoft:mainfrom
yury-s:fix/mcp-mouse-right-click-event-order
Feb 25, 2026
Merged

fix(mcp): handle non-deterministic contextmenu/mouseup order in right…#39416
yury-s merged 1 commit intomicrosoft:mainfrom
yury-s:fix/mcp-mouse-right-click-event-order

Conversation

@yury-s
Copy link
Copy Markdown
Member

@yury-s yury-s commented Feb 25, 2026

…-click test

Use lookaheads instead of sequential matching so both events are asserted regardless of which fires first.

Fixes the following sporadic error on the bots:

Error: expect(received).toEqual(expected) // deep equality

- Expected  -  3
+ Received  + 10

- ObjectContaining {
-   "code": StringContaining "await page.mouse.click(100, 100, {
+ Object {
+   "code": "// Click mouse at coordinates (100, 100)
+ await page.mouse.click(100, 100, {
    button: 'right'
  });",
-   "snapshot": StringMatching /mousemove 100 100.*mousedown button:2.*contextmenu button:2.*mouseup button:2/s,
+   "snapshot": "\`\`\`yaml
+ - <changed> generic [ref=e2]:
+   - generic [ref=e3]: mousemove 100 100
+   - generic [ref=e4]: mousedown button:2
+   - generic [ref=e5]: mouseup button:2
+   - generic [ref=e6]: contextmenu button:2
+ \`\`\`",
  }

…-click test

Use lookaheads instead of sequential matching so both events are asserted
regardless of which fires first.

Fixes the following sporadic error on the bots:

Error: expect(received).toEqual(expected) // deep equality

- Expected  -  3
+ Received  + 10

- ObjectContaining {
-   "code": StringContaining "await page.mouse.click(100, 100, {
+ Object {
+   "code": "// Click mouse at coordinates (100, 100)
+ await page.mouse.click(100, 100, {
    button: 'right'
  });",
-   "snapshot": StringMatching /mousemove 100 100.*mousedown button:2.*contextmenu button:2.*mouseup button:2/s,
+   "snapshot": "```yaml
+ - <changed> generic [ref=e2]:
+   - generic [ref=e3]: mousemove 100 100
+   - generic [ref=e4]: mousedown button:2
+   - generic [ref=e5]: mouseup button:2
+   - generic [ref=e6]: contextmenu button:2
+ ```",
  }
@yury-s yury-s merged commit 522c2be into microsoft:main Feb 25, 2026
3 of 6 checks passed
@yury-s yury-s deleted the fix/mcp-mouse-right-click-event-order branch February 25, 2026 23:18
@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

9 failed
❌ [chrome] › mcp/cli-storage.spec.ts:21 › state-save saves storage state to file @mcp-ubuntu-latest
❌ [chromium] › mcp/cli-storage.spec.ts:21 › state-save saves storage state to file @mcp-ubuntu-latest
❌ [firefox] › mcp/cli-storage.spec.ts:21 › state-save saves storage state to file @mcp-ubuntu-latest
❌ [webkit] › mcp/cli-storage.spec.ts:21 › state-save saves storage state to file @mcp-ubuntu-latest
❌ [firefox] › mcp/cli-storage.spec.ts:21 › state-save saves storage state to file @mcp-windows-latest
❌ [msedge] › mcp/cli-storage.spec.ts:21 › state-save saves storage state to file @mcp-windows-latest
❌ [chrome] › mcp/cli-storage.spec.ts:21 › state-save saves storage state to file @mcp-macos-15
❌ [chromium] › mcp/cli-storage.spec.ts:21 › state-save saves storage state to file @mcp-macos-15
❌ [webkit] › mcp/cli-storage.spec.ts:21 › state-save saves storage state to file @mcp-macos-15

5227 passed, 185 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants