Skip to content

Commit

Permalink
chore: include child nodes when parsing snapshot (#34318)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Jan 14, 2025
1 parent fe96104 commit ad365c3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ export function parseAriaSnapshot(yaml: YamlLibrary, text: string, options: yaml

// - role "name":
// - child
const valueIsSequence = value instanceof yaml.YAMLSeq ;
const valueIsSequence = value instanceof yaml.YAMLSeq;
if (valueIsSequence) {
container.children.push(childNode);
convertSeq(childNode, value as yamlTypes.YAMLSeq);
continue;
}
Expand Down
1 change: 1 addition & 0 deletions packages/trace-viewer/src/ui/inspectorTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const InspectorTab: React.FunctionComponent<{
<div style={{ margin: '0 10px 10px', flex: 'auto' }}>
<CodeMirrorWrapper
text={highlightedElement.ariaSnapshot || ''}
language='yaml'
wrapLines={false}
highlight={ariaSnapshotErrors}
onChange={onAriaEditorChange} />
Expand Down
12 changes: 12 additions & 0 deletions tests/page/to-match-aria-snapshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,3 +670,15 @@ test('should not unshift actual template text', async ({ page }) => {
- heading "title" [level=1]
- heading "title 2" [level=1]`);
});

test('should not match what is not matched', async ({ page }) => {
await page.setContent(`<p>Text</p>`);
const error = await expect(page.locator('body')).toMatchAriaSnapshot(`
- paragraph:
- button "bogus"
`).catch(e => e);
expect(stripAnsi(error.message)).toContain(`
- - paragraph:
- - button "bogus"
+ - paragraph: Text`);
});

0 comments on commit ad365c3

Please sign in to comment.