feat: add topology graph v0.2.2 contract

This commit is contained in:
赵义仑
2026-06-24 09:47:23 +08:00
parent a7458265c0
commit 2f12fe8cda
16 changed files with 1041 additions and 42 deletions

View File

@@ -91,6 +91,45 @@ test("locator candidates carry context-scope evidence for duplicated actions", (
assert.equal(candidates[0].scopes.some((scope) => scope.kind === "row"), true);
});
test("scoped row locator resolves duplicated row actions to one target", async () => {
await withPage(
`
<table>
<tr><td>Acme Co</td><td><button>Edit</button></td></tr>
<tr><td>Beta LLC</td><td><button>Edit</button></td></tr>
</table>
`,
async (page) => {
const rawElement = raw({
uid: "button_1_Edit",
candidateIndex: 1,
tag: "button",
role: "button",
accessibleName: "Edit",
identityText: "Edit",
text: "Edit",
attributes: {},
context: {
dialog: null,
form: null,
section: null,
row: { kind: "row", name: null, text: "Acme Co Edit" },
landmark: null,
listitem: null,
},
});
const scoped = generateLocators("el_scoped_edit", rawElement).find((candidate) => candidate.strategy === "scoped");
assert.ok(scoped);
const [verified] = await verifyLocators(page, rawElement, [scoped]);
assert.equal(verified.verified, true);
assert.equal(verified.matchCount, 1);
assert.equal(verified.identity?.sameAccessibleName, true);
},
);
});
test("placeholder-only input locator verifies identity from raw placeholder evidence", async () => {
await withPage(`<input placeholder="Search customers" />`, async (page) => {
const rawElement = raw({