mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
fix(hierarchy): populate ResourceID from accessibilityIdentifier
iOS Compose surfaces testTag as accessibilityIdentifier. Previously only resource-id and identifier seeded element.ResourceID, leaving element.id empty for iOS Compose nodes and forcing specs to walk attrs to recover stable identifiers.
This commit is contained in:
1 parent
569e0c818e
commit
139ca958f6
2 files changed
+17
No files matched your search
@@ -193,6 +193,9 @@ func elementFromNode(node *treeNodeJSON) *Element {
|
||||
if element.ResourceID == "" {
|
||||
element.ResourceID = attrs["identifier"]
|
||||
}
|
||||
if element.ResourceID == "" {
|
||||
element.ResourceID = attrs["accessibilityIdentifier"]
|
||||
}
|
||||
element.Text = attrs["text"]
|
||||
element.Description = attrs["content-desc"]
|
||||
if element.Description == "" {
|
||||
|
||||
@@ -514,6 +514,20 @@ func TestResourceIDFallsBackToAccessibilityIdentifier(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestElementResourceIDPopulatesFromAccessibilityIdentifier(t *testing.T) {
|
||||
input := `{
|
||||
"attributes": {"accessibilityIdentifier": "LoginEmail", "bounds": "[0,0,100,100]"},
|
||||
"children": []
|
||||
}`
|
||||
tree, _ := Parse(input)
|
||||
if len(tree.Elements) == 0 {
|
||||
t.Fatal("no elements parsed")
|
||||
}
|
||||
if got := tree.Elements[0].ResourceID; got != "LoginEmail" {
|
||||
t.Fatalf("ResourceID = %q, want LoginEmail (iOS Compose accessibilityIdentifier path)", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNodeFindDoesNotReturnSiblings(t *testing.T) {
|
||||
tree, _ := Parse(pathDump)
|
||||
a2Node := tree.FindNode("id:A2")
|
||||
|
||||
Reference in new issue
Block a user