From d1243543798eaaab7db7bf4e44592df465ab8c4b Mon Sep 17 00:00:00 2001 From: PJ Date: Sun, 16 Aug 2026 01:04:58 +0530 Subject: [PATCH] test(ios): a clear-state launch for an uncleared bundle is refused --- internal/driver/ioscompanion/driver_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/internal/driver/ioscompanion/driver_test.go b/internal/driver/ioscompanion/driver_test.go index b4f66ad..21e85a8 100644 --- a/internal/driver/ioscompanion/driver_test.go +++ b/internal/driver/ioscompanion/driver_test.go @@ -319,6 +319,25 @@ func TestLaunchRefusesClearStateTheDriverWasNotBuiltFor(t *testing.T) { } } +// TestLaunchRefusesClearStateForABundleItDidNotClear holds the guard to the +// fact it is guarding. A driver built to clear one bundle has cleared nothing +// for another, so reporting that launch as a clear-state launch is a reset the +// caller was told happened and did not. +func TestLaunchRefusesClearStateForABundleItDidNotClear(t *testing.T) { + companion := &fakeCompanion{accessibilityJSON: "[]"} + d := newTestDriver(companion) + d.clearedBundleID = "com.example.app" + + err := d.Launch(context.Background(), "com.other.app", true, nil) + + if err == nil || !strings.Contains(err.Error(), "clear-state") { + t.Fatalf("Launch err = %v, want a refusal naming clear-state: com.other.app was never cleared", err) + } + if indexOf(companion.recorded(), "launch") >= 0 { + t.Fatalf("a launch reporting a clear that never happened must not reach the companion; got %v", companion.recorded()) + } +} + func TestNewRejectsClearStateWithoutBundleID(t *testing.T) { probe := &clearStateProbe{} options := clearStateOptions(t, probe, "NO-BUNDLE-UDID", true)