Skip to content

Commit 872908b

Browse files
thymikeeclaude
andcommitted
fix(test): migrate the daemon stack's tests to complete runtime snapshots
#3642 made BackendSnapshotResult carry a required snapshot and dropped the flat nodes fields; the daemon test relocations (#3652, #3666) landed after it with the old shape, so main fails tsc -b. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 615d245 commit 872908b

4 files changed

Lines changed: 38 additions & 57 deletions

File tree

‎packages/daemon/src/__tests__/support/command-surface-fake.test.ts‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@ test('the forwarding surface returns and stores the snapshot tree the daemon bac
3131
expect(set).toHaveBeenCalledWith(expect.objectContaining({ name: 'default', snapshot }));
3232
});
3333

34-
test('the forwarding surface falls back to a flat node list from a backend that returns no snapshot', async () => {
35-
const { config, set } = configReturning({ nodes: [node] });
36-
const surface = await forwardingCreateCommandSurface(config);
37-
38-
const result = await surface.capture.snapshot({ session: 'default' });
39-
40-
expect(result.nodes).toEqual([node]);
41-
expect(set).toHaveBeenCalledWith(
42-
expect.objectContaining({ snapshot: expect.objectContaining({ nodes: [node] }) }),
43-
);
44-
});
45-
4634
test('the forwarding surface diff stores the observed tree and reports whether it initialized the baseline', async () => {
4735
const snapshot: SnapshotState = { nodes: [node], createdAt: 1, backend: 'android' };
4836
const first = configReturning({ snapshot });

‎packages/daemon/src/__tests__/support/command-surface-fake.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export const forwardingCreateCommandSurface: CreateDaemonCommandSurface = async
8888
},
8989
);
9090
const stored = captured?.snapshot ?? {
91-
nodes: captured?.nodes ?? [],
91+
nodes: [],
9292
createdAt: Date.now(),
9393
backend: 'android' as const,
9494
};

‎src/commands/capture/runtime/snapshot-freshness.test.ts‎

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ const ANDROID_ROWS = Array.from({ length: 24 }, (_, index) => ({
3737

3838
test('runtime snapshot warns when Android freshness retries still return the previous route', async () => {
3939
const device = snapshotDevice({
40-
nodes: ANDROID_ROWS,
41-
truncated: false,
42-
backend: 'android',
40+
snapshot: makeSnapshotState(ANDROID_ROWS, { truncated: false, backend: 'android' }),
4341
freshness: {
4442
action: 'press',
4543
retryCount: 3,
@@ -58,9 +56,7 @@ test('runtime diff snapshot carries the stale-route warning for recent Android p
5856
baseline.createdAt = 1_000;
5957
const device = snapshotDevice(
6058
{
61-
nodes: ANDROID_ROWS,
62-
truncated: false,
63-
backend: 'android',
59+
snapshot: makeSnapshotState(ANDROID_ROWS, { truncated: false, backend: 'android' }),
6460
freshness: {
6561
action: 'press',
6662
retryCount: 3,
@@ -78,9 +74,7 @@ test('runtime diff snapshot carries the stale-route warning for recent Android p
7874

7975
test('runtime snapshot raises no stale-route warning once the freshness retries succeeded', async () => {
8076
const device = snapshotDevice({
81-
nodes: ANDROID_ROWS,
82-
truncated: false,
83-
backend: 'android',
77+
snapshot: makeSnapshotState(ANDROID_ROWS, { truncated: false, backend: 'android' }),
8478
freshness: { action: 'press', retryCount: 1, staleAfterRetries: false },
8579
});
8680

@@ -106,16 +100,17 @@ test.each([
106100
previous.presentationKey = buildSnapshotPresentationKey({ interactiveOnly: interactive });
107101
const device = snapshotDevice(
108102
{
109-
nodes: Array.from({ length: 8 }, (_, index) => ({
110-
ref: `e${index + 1}`,
111-
index,
112-
depth: 0,
113-
type: 'android.widget.Button',
114-
label: `Action ${index + 1}`,
115-
hittable: true,
116-
})),
117-
truncated: false,
118-
backend: 'android',
103+
snapshot: makeSnapshotState(
104+
Array.from({ length: 8 }, (_, index) => ({
105+
ref: `e${index + 1}`,
106+
index,
107+
depth: 0,
108+
type: 'android.widget.Button',
109+
label: `Action ${index + 1}`,
110+
hittable: true,
111+
})),
112+
{ truncated: false, backend: 'android' },
113+
),
119114
},
120115
{ name: 'default', snapshot: previous },
121116
);
@@ -130,29 +125,28 @@ test.each([
130125

131126
test('runtime snapshot reports normalized visibility metadata for scroll-hidden content', async () => {
132127
const device = snapshotDevice({
133-
nodes: [
134-
{
135-
ref: 'e1',
136-
index: 0,
137-
depth: 0,
138-
type: 'android.widget.ScrollView',
139-
label: 'Messages',
140-
rect: { x: 0, y: 100, width: 390, height: 500 },
141-
hiddenContentBelow: true,
142-
},
143-
{
144-
ref: 'e2',
145-
index: 1,
146-
depth: 1,
147-
parentIndex: 0,
148-
type: 'android.widget.Button',
149-
label: 'Visible message',
150-
rect: { x: 0, y: 140, width: 390, height: 48 },
151-
hittable: true,
152-
},
153-
],
154-
truncated: false,
155-
backend: 'android',
128+
snapshot: makeSnapshotState(
129+
[
130+
{
131+
index: 0,
132+
depth: 0,
133+
type: 'android.widget.ScrollView',
134+
label: 'Messages',
135+
rect: { x: 0, y: 100, width: 390, height: 500 },
136+
hiddenContentBelow: true,
137+
},
138+
{
139+
index: 1,
140+
depth: 1,
141+
parentIndex: 0,
142+
type: 'android.widget.Button',
143+
label: 'Visible message',
144+
rect: { x: 0, y: 140, width: 390, height: 48 },
145+
hittable: true,
146+
},
147+
],
148+
{ truncated: false, backend: 'android' },
149+
),
156150
analysis: { rawNodeCount: 2, maxDepth: 1 },
157151
});
158152

‎src/commands/interaction/runtime/wait-capture-options.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ const BATTERY = makeSnapshotState(
2121
);
2222

2323
function pollingDevice(captureOptions: Array<BackendSnapshotOptions | undefined>) {
24-
const captures = [LOCATION_REQUIRED, BATTERY];
2524
const backend: AgentDeviceBackend = {
2625
platform: 'android',
2726
captureSnapshot: async (_context, options) => {
2827
captureOptions.push(options);
29-
return { snapshot: captures[Math.min(captureOptions.length, captures.length) - 1] };
28+
return { snapshot: captureOptions.length === 1 ? LOCATION_REQUIRED : BATTERY };
3029
},
3130
};
3231
return createAgentDevice({

0 commit comments

Comments
 (0)