Open History to see the last commit
1import type { LiveActivityLayout } from "expo-widgets";
2import { describe, expect, it, vi } from "vite-plus/test";
3
4vi.mock("@expo/ui/swift-ui", () => ({
5 HStack: "HStack",
6 Image: "Image",
7 Spacer: "Spacer",
8 Text: "Text",
9 VStack: "VStack",
10 ZStack: "ZStack",
11}));
12
13vi.mock("@expo/ui/swift-ui/modifiers", () => {
14 const modifier = (value: unknown) => value;
15 return {
16 accessibilityElement: modifier,
17 accessibilityLabel: modifier,
18 activityBackgroundTint: modifier,
19 font: modifier,
20 foregroundStyle: modifier,
21 frame: modifier,
22 layoutPriority: modifier,
23 lineLimit: modifier,
24 minimumScaleFactor: modifier,
25 padding: modifier,
26 resizable: modifier,
27 widgetURL: modifier,
28 };
29});
30
31// Hand back the layout function so the test can render it with a chosen environment.
32vi.mock("expo-widgets", () => ({
33 createLiveActivity: (_name: string, layout: unknown) => layout,
34}));
35
36import AgentActivity, {
37 type AgentActivityProps,
38 type AgentActivityRowProps,
39} from "./AgentActivity";
40
41const render = AgentActivity as unknown as (
42 props: AgentActivityProps,
43 environment: unknown,
44) => LiveActivityLayout;
45
46function row(overrides: Partial<AgentActivityRowProps>): AgentActivityRowProps {
47 return {
48 environmentId: "env-1",
49 threadId: "thread-1",
50 projectTitle: "Project",
51 threadTitle: "Thread",
52 modelTitle: "Model",
53 phase: "running",
54 status: "Working",
55 updatedAt: "2026-01-01T00:00:00.000Z",
56 deepLink: "/threads/env-1/thread-1",
57 ...overrides,
58 };
59}
60
61describe("AgentActivity", () => {
62 it("drops the agent count from the expanded Dynamic Island once the activity is stale", () => {
63 const layout = render(
64 {
65 title: "Agents",
66 subtitle: "",
67 activeCount: 2,
68 updatedAt: "2026-01-01T00:00:00.000Z",
69 activities: [row({}), row({ threadId: "thread-2", phase: "starting" })],
70 },
71 {
72 colorScheme: "dark",
73 isLuminanceReduced: false,
74 isLiquidGlassAvailable: false,
75 isStale: true,
76 widgetRenderingMode: "fullColor",
77 },
78 );
79 const expandedLeading = JSON.stringify(layout.expandedLeading);
80 expect(expandedLeading).not.toContain('"children":"2"');
81 expect(expandedLeading).toContain('"children":"Out of date"');
82 });
83});