feat(browser): add snapshot refs=aria mode
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
buildRoleSnapshotFromAiSnapshot,
|
||||
buildRoleSnapshotFromAriaSnapshot,
|
||||
getRoleSnapshotStats,
|
||||
parseRoleRef,
|
||||
@@ -67,4 +68,24 @@ describe("pw-role-snapshot", () => {
|
||||
expect(parseRoleRef("12")).toBeNull();
|
||||
expect(parseRoleRef("")).toBeNull();
|
||||
});
|
||||
|
||||
it("preserves Playwright aria-ref ids in ai snapshots", () => {
|
||||
const ai = [
|
||||
'- navigation [ref=e1]:',
|
||||
' - link "Home" [ref=e5]',
|
||||
' - heading "Title" [ref=e6]',
|
||||
' - button "Save" [ref=e7] [cursor=pointer]:',
|
||||
" - paragraph: hello",
|
||||
].join("\n");
|
||||
|
||||
const res = buildRoleSnapshotFromAiSnapshot(ai, { interactive: true });
|
||||
expect(res.snapshot).toContain('[ref=e5]');
|
||||
expect(res.snapshot).toContain('- link "Home"');
|
||||
expect(res.snapshot).toContain('- button "Save"');
|
||||
expect(res.snapshot).not.toContain("navigation");
|
||||
expect(res.snapshot).not.toContain("heading");
|
||||
expect(Object.keys(res.refs).sort()).toEqual(["e5", "e7"]);
|
||||
expect(res.refs.e5).toMatchObject({ role: "link", name: "Home" });
|
||||
expect(res.refs.e7).toMatchObject({ role: "button", name: "Save" });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user