mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
fix(runner): warn on malformed screen snapshot (#13)
* fix(runner): warn on malformed screen snapshot screenFromSnapshot swallowed json.Unmarshal errors, so a non-string screen value silently became "" in the step log and trace while the verifier still saw the raw JSON. Return the error and warn at the call site, matching the hierarchy warning pattern. * docs: clarify --avd is optional for uatu test The CLI accepts --avd as an empty-string default (cmd/uatu/main.go:49) and only requires it when no device is connected and multiple AVDs exist (cmd/uatu/android_env.go:63). Docs and examples that showed it as required or always-passed were misleading.
This commit is contained in:
6 files changed
+49
-10
No files matched your search
@@ -235,6 +235,38 @@ func TestRunner_RecordsScreenFieldFromSnapshot(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestScreenFromSnapshot(t *testing.T) {
|
||||
t.Run("string value returns screen", func(t *testing.T) {
|
||||
snapshots := map[string]json.RawMessage{"screen": json.RawMessage(`"home"`)}
|
||||
screen, err := screenFromSnapshot(snapshots)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if screen != "home" {
|
||||
t.Errorf("screen = %q, want %q", screen, "home")
|
||||
}
|
||||
})
|
||||
t.Run("missing key returns empty with no error", func(t *testing.T) {
|
||||
screen, err := screenFromSnapshot(map[string]json.RawMessage{})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if screen != "" {
|
||||
t.Errorf("screen = %q, want empty", screen)
|
||||
}
|
||||
})
|
||||
t.Run("non-string value returns error", func(t *testing.T) {
|
||||
snapshots := map[string]json.RawMessage{"screen": json.RawMessage(`{"nested":1}`)}
|
||||
screen, err := screenFromSnapshot(snapshots)
|
||||
if err == nil {
|
||||
t.Fatalf("expected error for non-string screen, got nil")
|
||||
}
|
||||
if screen != "" {
|
||||
t.Errorf("screen = %q, want empty on error", screen)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestApplyAction_InputTextSurfacesFocusTapError(t *testing.T) {
|
||||
t.Run("selector focus tap fails", func(t *testing.T) {
|
||||
driverMock := mockdriver.New()
|
||||
|
||||
Reference in new issue
Block a user