mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
fix(spec): match a merged label by its leading name on web too
The native desc rule accepts the label or the label at the head of an iOS merged label; both web translators compared the whole string, so the same selector matched natively and missed on web. The live-page parity test caught it.
This commit is contained in:
1 parent
b8bb44cf61
commit
cb880edf44
4 files changed
+20
-3
No files matched your search
@@ -94,7 +94,10 @@ const KNOWN_KEY_TO_CSS: Record<string, (value: string) => string> = {
|
||||
// The native rule also accepts the local name after Android's "<package>:id/".
|
||||
// The DOM has no such prefix, so a plain starts-with is the same rule here.
|
||||
idPrefix: (v) => `[id^="${cssEscape(v)}"]`,
|
||||
desc: (v) => `[aria-label="${cssEscape(v)}"]`,
|
||||
// The native rule accepts the label itself or the label at the head of an
|
||||
// iOS merged label ("account_card:7, Tim, $100"). `:is()` keeps that one
|
||||
// compound piece, since a multi-key selector concatenates the parts.
|
||||
desc: (v) => `:is([aria-label="${cssEscape(v)}"], [aria-label^="${cssEscape(v)}, "])`,
|
||||
descPrefix: (v) => `[aria-label^="${cssEscape(v)}"]`,
|
||||
// The native table aliases testTag onto resource-id, which the host DOM walk
|
||||
// fills from el.id, so the native path already accepts a testTag emitted as
|
||||
|
||||
@@ -342,6 +342,14 @@ test("selectorFromObject routes idPrefix to a starts-with id match", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// The native rule matches an iOS merged label ("account_card:7, Tim, $100") by
|
||||
// its leading name, and the web table has to mean the same thing by desc.
|
||||
test("selectorFromObject matches a merged label by its leading name", () => {
|
||||
assert.deepEqual(selectorFromObject({ desc: "account_card" }), {
|
||||
css: `:is([aria-label="account_card"], [aria-label^="account_card, "])`,
|
||||
});
|
||||
});
|
||||
|
||||
test("selectorFromString and selectorFromObject agree on descPrefix", () => {
|
||||
assert.deepEqual(selectorFromString("descPrefix:account:"), {
|
||||
css: `[aria-label^="account\\:"]`,
|
||||
|
||||
Reference in new issue
Block a user