Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions packages/daemon/src/__tests__/support/command-surface-fake.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@ test('the forwarding surface returns and stores the snapshot tree the daemon bac
expect(set).toHaveBeenCalledWith(expect.objectContaining({ name: 'default', snapshot }));
});

test('the forwarding surface falls back to a flat node list from a backend that returns no snapshot', async () => {
const { config, set } = configReturning({ nodes: [node] });
const surface = await forwardingCreateCommandSurface(config);

const result = await surface.capture.snapshot({ session: 'default' });

expect(result.nodes).toEqual([node]);
expect(set).toHaveBeenCalledWith(
expect.objectContaining({ snapshot: expect.objectContaining({ nodes: [node] }) }),
);
});

test('the forwarding surface diff stores the observed tree and reports whether it initialized the baseline', async () => {
const snapshot: SnapshotState = { nodes: [node], createdAt: 1, backend: 'android' };
const first = configReturning({ snapshot });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const forwardingCreateCommandSurface: CreateDaemonCommandSurface = async
},
);
const stored = captured?.snapshot ?? {
nodes: captured?.nodes ?? [],
nodes: [],
createdAt: Date.now(),
backend: 'android' as const,
};
Expand Down
78 changes: 36 additions & 42 deletions src/commands/capture/runtime/snapshot-freshness.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ const ANDROID_ROWS = Array.from({ length: 24 }, (_, index) => ({

test('runtime snapshot warns when Android freshness retries still return the previous route', async () => {
const device = snapshotDevice({
nodes: ANDROID_ROWS,
truncated: false,
backend: 'android',
snapshot: makeSnapshotState(ANDROID_ROWS, { truncated: false, backend: 'android' }),
freshness: {
action: 'press',
retryCount: 3,
Expand All @@ -58,9 +56,7 @@ test('runtime diff snapshot carries the stale-route warning for recent Android p
baseline.createdAt = 1_000;
const device = snapshotDevice(
{
nodes: ANDROID_ROWS,
truncated: false,
backend: 'android',
snapshot: makeSnapshotState(ANDROID_ROWS, { truncated: false, backend: 'android' }),
freshness: {
action: 'press',
retryCount: 3,
Expand All @@ -78,9 +74,7 @@ test('runtime diff snapshot carries the stale-route warning for recent Android p

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

Expand All @@ -106,16 +100,17 @@ test.each([
previous.presentationKey = buildSnapshotPresentationKey({ interactiveOnly: interactive });
const device = snapshotDevice(
{
nodes: Array.from({ length: 8 }, (_, index) => ({
ref: `e${index + 1}`,
index,
depth: 0,
type: 'android.widget.Button',
label: `Action ${index + 1}`,
hittable: true,
})),
truncated: false,
backend: 'android',
snapshot: makeSnapshotState(
Array.from({ length: 8 }, (_, index) => ({
ref: `e${index + 1}`,
index,
depth: 0,
type: 'android.widget.Button',
label: `Action ${index + 1}`,
hittable: true,
})),
{ truncated: false, backend: 'android' },
),
},
{ name: 'default', snapshot: previous },
);
Expand All @@ -130,29 +125,28 @@ test.each([

test('runtime snapshot reports normalized visibility metadata for scroll-hidden content', async () => {
const device = snapshotDevice({
nodes: [
{
ref: 'e1',
index: 0,
depth: 0,
type: 'android.widget.ScrollView',
label: 'Messages',
rect: { x: 0, y: 100, width: 390, height: 500 },
hiddenContentBelow: true,
},
{
ref: 'e2',
index: 1,
depth: 1,
parentIndex: 0,
type: 'android.widget.Button',
label: 'Visible message',
rect: { x: 0, y: 140, width: 390, height: 48 },
hittable: true,
},
],
truncated: false,
backend: 'android',
snapshot: makeSnapshotState(
[
{
index: 0,
depth: 0,
type: 'android.widget.ScrollView',
label: 'Messages',
rect: { x: 0, y: 100, width: 390, height: 500 },
hiddenContentBelow: true,
},
{
index: 1,
depth: 1,
parentIndex: 0,
type: 'android.widget.Button',
label: 'Visible message',
rect: { x: 0, y: 140, width: 390, height: 48 },
hittable: true,
},
],
{ truncated: false, backend: 'android' },
),
analysis: { rawNodeCount: 2, maxDepth: 1 },
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ const BATTERY = makeSnapshotState(
);

function pollingDevice(captureOptions: Array<BackendSnapshotOptions | undefined>) {
const captures = [LOCATION_REQUIRED, BATTERY];
const backend: AgentDeviceBackend = {
platform: 'android',
captureSnapshot: async (_context, options) => {
captureOptions.push(options);
return { snapshot: captures[Math.min(captureOptions.length, captures.length) - 1] };
return { snapshot: captureOptions.length === 1 ? LOCATION_REQUIRED : BATTERY };
},
};
return createAgentDevice({
Expand Down
Loading