Skip to content

Commit da33323

Browse files
authored
fix(mcp): snapshot for ai fixes (#37527)
1 parent 796cf89 commit da33323

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/injected/src/ariaSnapshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ function normalizeGenericRoles(node: AriaNode) {
302302
}
303303

304304
// Only remove generic that encloses one element, logical grouping still makes sense, even if it is not ref-able.
305-
const removeSelf = node.role === 'generic' && result.length <= 1 && result.every(c => typeof c !== 'string' && !!c.ref);
305+
const removeSelf = node.role === 'generic' && !node.name && result.length <= 1 && result.every(c => typeof c !== 'string' && !!c.ref);
306306
if (removeSelf)
307307
return result;
308308
node.children = result;

tests/page/page-aria-snapshot-ai.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,3 +439,12 @@ it('should collapse inline generic nodes', async ({ page }) => {
439439
- generic [ref=e12]: 1,200
440440
`);
441441
});
442+
443+
it('should not remove generic nodes with title', async ({ page }) => {
444+
await page.setContent(`<div title="Element title">Element content</div>`);
445+
446+
const snapshot = await snapshotForAI(page);
447+
expect(snapshot).toContainYaml(`
448+
- generic "Element title" [ref=e2]
449+
`);
450+
});

0 commit comments

Comments
 (0)