mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 12:07:09 +00:00
feat(hierarchy): testTag alias resolves to resource-id and accessibilityIdentifier
Compose's testTag surfaces as resource-id on Android and as
accessibilityIdentifier on iOS. Selectors written as
{ testTag: "Foo" } now match either, so Sanderling specs can use the
same tag on both platforms.
Also rounds out the iOS identifier aliases so resource-id /
identifier / accessibilityIdentifier all resolve to one another.
This commit is contained in:
1 parent
28909d954b
commit
d115cdfd97
2 files changed
+58
-4
No files matched your search
@@ -464,6 +464,56 @@ func TestNodeFindScopedSearch(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTestTagAliasMatchesResourceIDAndroid(t *testing.T) {
|
||||
input := `{
|
||||
"attributes": {"resource-id": "AccountCard", "bounds": "[0,0,100,100]"},
|
||||
"children": []
|
||||
}`
|
||||
tree, _ := Parse(input)
|
||||
sel := Selector{Filters: []AttrFilter{{Attr: "testTag", Value: "AccountCard"}}}
|
||||
if len(searchSubtreeBySelector(tree.Root, sel)) == 0 {
|
||||
t.Fatal("expected testTag selector to match resource-id on Android")
|
||||
}
|
||||
}
|
||||
|
||||
func TestTestTagAliasMatchesAccessibilityIdentifierIOS(t *testing.T) {
|
||||
input := `{
|
||||
"attributes": {"accessibilityIdentifier": "AccountCard", "bounds": "[0,0,100,100]"},
|
||||
"children": []
|
||||
}`
|
||||
tree, _ := Parse(input)
|
||||
sel := Selector{Filters: []AttrFilter{{Attr: "testTag", Value: "AccountCard"}}}
|
||||
matches := searchSubtreeBySelector(tree.Root, sel)
|
||||
if len(matches) == 0 {
|
||||
t.Fatal("expected testTag selector to match accessibilityIdentifier on iOS")
|
||||
}
|
||||
}
|
||||
|
||||
func TestTestTagAliasMatchesIdentifierIOSRaw(t *testing.T) {
|
||||
input := `{
|
||||
"attributes": {"identifier": "AccountCard", "bounds": "[0,0,100,100]"},
|
||||
"children": []
|
||||
}`
|
||||
tree, _ := Parse(input)
|
||||
sel := Selector{Filters: []AttrFilter{{Attr: "testTag", Value: "AccountCard"}}}
|
||||
matches := searchSubtreeBySelector(tree.Root, sel)
|
||||
if len(matches) == 0 {
|
||||
t.Fatal("expected testTag selector to match identifier on iOS raw AXElement")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResourceIDFallsBackToAccessibilityIdentifier(t *testing.T) {
|
||||
input := `{
|
||||
"attributes": {"accessibilityIdentifier": "MyButton", "bounds": "[0,0,100,100]"},
|
||||
"children": []
|
||||
}`
|
||||
tree, _ := Parse(input)
|
||||
sel := Selector{Filters: []AttrFilter{{Attr: "resource-id", Value: "MyButton"}}}
|
||||
if len(searchSubtreeBySelector(tree.Root, sel)) == 0 {
|
||||
t.Fatal("expected resource-id selector to fall back to accessibilityIdentifier")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNodeFindDoesNotReturnSiblings(t *testing.T) {
|
||||
tree, _ := Parse(pathDump)
|
||||
a2Node := tree.FindNode("id:A2")
|
||||
|
||||
Reference in new issue
Block a user