From 2762dc3011710677ceea4d660322d6308f0e5556 Mon Sep 17 00:00:00 2001 From: PJ Date: Sat, 15 Aug 2026 21:30:15 +0530 Subject: [PATCH] test(runner): answer Snapshot and Hierarchy off one tree in the fakes --- internal/runner/foreground_guard_last_action_test.go | 10 ++++++++++ internal/runner/uncertain_last_action_test.go | 4 ++++ internal/runner/web_carrier_test.go | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/internal/runner/foreground_guard_last_action_test.go b/internal/runner/foreground_guard_last_action_test.go index 3ec733c..8932f1b 100644 --- a/internal/runner/foreground_guard_last_action_test.go +++ b/internal/runner/foreground_guard_last_action_test.go @@ -74,6 +74,12 @@ func (d *leavesForegroundAfterSubmitDriver) Snapshot(context.Context) (string, d return fmt.Sprintf(homeWithTxnCount, d.committed.Load()), driver.Image{}, nil } +// No device answers Snapshot and Hierarchy off different trees, and the runner +// reads both per step, so this one answers them off the same commit count. +func (d *leavesForegroundAfterSubmitDriver) Hierarchy(context.Context) (string, error) { + return fmt.Sprintf(homeWithTxnCount, d.committed.Load()), nil +} + // obscuredAfterSubmitDriver is the other half of the same guard: the app stays // the resumed activity, but a system window (the notification shade) owns the // focused window when the next step looks, and the guard presses back to @@ -123,6 +129,10 @@ func (d *obscuredAfterSubmitDriver) Snapshot(context.Context) (string, driver.Im return fmt.Sprintf(homeWithTxnCount, d.committed.Load()), driver.Image{}, nil } +func (d *obscuredAfterSubmitDriver) Hierarchy(context.Context) (string, error) { + return fmt.Sprintf(homeWithTxnCount, d.committed.Load()), nil +} + // runTwoSubmitSteps drives two steps of the shipped folio counting property // against a device that commits on every tap, and hands back what the property // decided. Both steps have to run: the first arms the comparison, the second is diff --git a/internal/runner/uncertain_last_action_test.go b/internal/runner/uncertain_last_action_test.go index a02ffd4..cd122f5 100644 --- a/internal/runner/uncertain_last_action_test.go +++ b/internal/runner/uncertain_last_action_test.go @@ -90,6 +90,10 @@ func (d *dispatchThenFailDriver) Snapshot(context.Context) (string, driver.Image return fmt.Sprintf(homeWithTxnCount, d.committed.Load()), driver.Image{}, nil } +func (d *dispatchThenFailDriver) Hierarchy(context.Context) (string, error) { + return fmt.Sprintf(homeWithTxnCount, d.committed.Load()), nil +} + func TestRunner_ApplyErrorAfterDispatchDoesNotConvictTheSubmitCountingProperty(t *testing.T) { predicates, err := filepath.Abs("../../examples/folio/sanderling/predicates.ts") if err != nil { diff --git a/internal/runner/web_carrier_test.go b/internal/runner/web_carrier_test.go index d4776a5..c5cb169 100644 --- a/internal/runner/web_carrier_test.go +++ b/internal/runner/web_carrier_test.go @@ -55,6 +55,12 @@ func (d *carrierWebDriver) Snapshot(ctx context.Context) (string, driver.Image, func (d *carrierWebDriver) InstallBundle(context.Context, []byte) error { return nil } +// A web target says so. The runner's per-step hierarchy reread is android-only, +// and a fake claiming android would take a path no chrome run takes. +func (d *carrierWebDriver) Health(context.Context) (driver.Health, error) { + return driver.Health{Ready: true, Version: "fake", Platform: "web"}, nil +} + func (d *carrierWebDriver) EvaluateExtractors(context.Context) (map[int]json.RawMessage, error) { d.reads++ return map[int]json.RawMessage{0: json.RawMessage(strconv.Itoa(d.reads))}, nil