Skip to content

Commit 5a6517b

Browse files
test(mobile): reproduce #27412 live activity toggle failing on link proof
Enabling Live Activities fails and rolls back the device preference when a saved host refuses the environment link proof ("Invalid managed endpoint origin."), which every LAN or tunnel host does for a phone. This test reproduces #27412 and fails on main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent fa4e467 commit 5a6517b

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

‎apps/mobile/src/features/agent-awareness/liveActivityPreferences.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { beforeEach, vi } from "vite-plus/test";
22
import { describe, expect, it } from "@effect/vitest";
33
import * as Effect from "effect/Effect";
4+
import * as Exit from "effect/Exit";
45
import type { EnvironmentId } from "@t3tools/contracts";
56
import { ManagedRelay } from "@t3tools/client-runtime/relay";
67
import * as Layer from "effect/Layer";
@@ -158,4 +159,31 @@ describe("liveActivityPreferences", () => {
158159
expect(updateAgentAwarenessRegistrationPreferences).toHaveBeenCalledTimes(1);
159160
}).pipe(Effect.provide(layerTest));
160161
});
162+
163+
it.effect("enables updates when a host refuses an environment link proof", () => {
164+
vi.mocked(linkEnvironmentToCloudWithPreference).mockImplementationOnce(() =>
165+
Effect.fail(
166+
new CloudEnvironmentLinkError({
167+
message: "Could not obtain environment link proof: Invalid managed endpoint origin.",
168+
}),
169+
),
170+
);
171+
172+
return Effect.gen(function* () {
173+
const exit = yield* Effect.exit(
174+
setLiveActivityUpdatesEnabled({
175+
enabled: true,
176+
previousEnabled: false,
177+
clerkToken: "clerk-token",
178+
connections: [connection],
179+
canConfigureEnvironment: () => true,
180+
}),
181+
);
182+
183+
expect(exit).toStrictEqual(Exit.void);
184+
expect(vi.mocked(updateAgentAwarenessRegistrationPreferences).mock.lastCall).toEqual([
185+
{ liveActivitiesEnabled: true },
186+
]);
187+
}).pipe(Effect.provide(layerTest));
188+
});
161189
});

0 commit comments

Comments
 (0)