Uh oh!
There was an error while loading. Please reload this page.
fix(aria): annotate aria-hidden elements in AI snapshots - #42268
Conversation
| const childAriaNode = visible ? toAriaNode(element, options, nameSourceElements) : null; | ||
| if (childAriaNode && !isElementVisibleForAria) | ||
| childAriaNode.props['aria-hidden'] = 'true'; |
There was a problem hiding this comment.
It annotates every node in a hidden subtree, not just the boundary. This will bloat snapshots in the scenario like the one in the issue.
There was a problem hiding this comment.
+1. Let's also add a test that covers this, to make sure we only annotate the top element in the hidden subtree.
There was a problem hiding this comment.
Fixed, checks the element's own attribute now.
There was a problem hiding this comment.
Let's also add a test that covers this, to make sure we only annotate the top element in the hidden subtree.
added
| // AI snapshot includes aria-hidden elements but annotates them. | ||
| const aiSnapshot = await snapshotForAI(page); | ||
| expect(aiSnapshot).toContain('[aria-hidden]'); |
There was a problem hiding this comment.
Please assert the exact snapshot with toContainYaml like other tests here.
There was a problem hiding this comment.
Done.
| const childAriaNode = visible ? toAriaNode(element, options, nameSourceElements) : null; | ||
| if (childAriaNode && !isElementVisibleForAria) | ||
| childAriaNode.props['aria-hidden'] = 'true'; |
There was a problem hiding this comment.
+1. Let's also add a test that covers this, to make sure we only annotate the top element in the hidden subtree.
368b5c1 to
3d0036bCompare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
3d0036b to
e29f979CompareTest results for "tests 1"21 flaky51215 passed, 1233 skipped Merge workflow run. |
Test results for "MCP"3 failed 8120 passed, 1341 skipped Merge workflow run. |
Dmitry Gozman (dgozman)
left a comment
There was a problem hiding this comment.
Looks good to me, thank you.
4126cf5
into
microsoft:mainUh oh!
There was an error while loading. Please reload this page.
Rationale
The AI-mode snapshot (
mode: "ai") intentionally includesaria-hiddenelements because they are visually visible, but nothing distinguishes them from ARIA-visible content. When a test fails anderror-context.mdis generated, agents (and humans) see content thatgetByRoleandariaSnapshot()will never find, with no indication why.This adds an
[aria-hidden]annotation following the same bracket pattern as[checked],[disabled],[expanded]etc. Elements included only through visual visibility (not ARIA visibility) now render with[aria-hidden]in the key. Default-mode snapshots are completely unaffected since they exclude these elements entirely.Fixes#42223