mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +00:00
feat(hierarchy): name the route a native tree shows
The screen name was web-only: the Chrome driver stamps sanderling-screen on the root and nothing else does, so every Android and iOS step recorded and logged an empty screen. The route marker the tree already carries (the resource id ending in Screen, the same one Transitional counts) names it.
This commit is contained in:
1 parent
9b4ff5f247
commit
be8a7e0194
2 files changed
+79
No files matched your search
@@ -1821,3 +1821,57 @@ func TestTagMatchesTheElementItNames(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestScreenNameNamesTheRouteTheTreeShows(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
tree string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
"driver-set screen",
|
||||
`{"attributes": {"bounds": "[0,0,10,10]", "sanderling-screen": "/ledger"}, "children": []}`,
|
||||
"/ledger",
|
||||
},
|
||||
{
|
||||
"route marker",
|
||||
`{"attributes": {"bounds": "[0,0,10,10]"}, "children": [
|
||||
{"attributes": {"resource-id": "HomeScreen", "bounds": "[0,0,10,10]"}, "children": []}
|
||||
]}`,
|
||||
"HomeScreen",
|
||||
},
|
||||
{
|
||||
"route marker repeated by a nested node",
|
||||
`{"attributes": {"bounds": "[0,0,10,10]"}, "children": [
|
||||
{"attributes": {"resource-id": "HomeScreen", "bounds": "[0,0,10,10]"}, "children": [
|
||||
{"attributes": {"resource-id": "HomeScreen", "bounds": "[0,0,10,5]"}, "children": []}
|
||||
]}
|
||||
]}`,
|
||||
"HomeScreen",
|
||||
},
|
||||
{
|
||||
"cross-fade names no screen",
|
||||
`{"attributes": {"bounds": "[0,0,10,10]"}, "children": [
|
||||
{"attributes": {"resource-id": "HomeScreen", "bounds": "[0,0,10,10]"}, "children": []},
|
||||
{"attributes": {"resource-id": "LedgerScreen", "bounds": "[0,0,10,10]"}, "children": []}
|
||||
]}`,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"no marker at all",
|
||||
`{"attributes": {"bounds": "[0,0,10,10]"}, "children": []}`,
|
||||
"",
|
||||
},
|
||||
}
|
||||
for _, testCase := range cases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
tree, err := Parse(testCase.tree)
|
||||
if err != nil {
|
||||
t.Fatalf("Parse: %v", err)
|
||||
}
|
||||
if got := tree.ScreenName(); got != testCase.want {
|
||||
t.Errorf("ScreenName = %q, want %q", got, testCase.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user