Skip to content

Commit d411742

Browse files
committed
test: preserve snapshot and daemon cleanup evidence
1 parent 86bfbc5 commit d411742

4 files changed

Lines changed: 44 additions & 23 deletions

File tree

‎packages/daemon/src/sessions/handlers/snapshot-runtime-disclosure.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ test('a snapshot after a scroll that moved nothing warns and stamps the no-effec
138138
await vi.advanceTimersByTimeAsync(100);
139139
await new Promise((resolve) => realSetTimeout(resolve, 1));
140140
}
141-
await pending;
141+
const response = await pending;
142142

143+
expect(response.ok).toBe(true);
143144
expect(input.sessionStore.get(input.sessionName)?.snapshot?.postGestureOutcome).toEqual(outcome);
144145
});
145146

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,25 @@ test('runtime snapshot warns when its tree was read on a surface still moving af
841841
assert.deepEqual(result.warnings, [formatPostGestureOutcomeWarning(outcome)]);
842842
});
843843

844+
test('runtime snapshot warns when a gesture produced no visible change', async () => {
845+
const outcome: PostGestureOutcome = {
846+
kind: 'no-effect',
847+
gesture: { action: 'scroll', positionals: ['up'] },
848+
};
849+
const device = createSnapshotOnlyDevice({
850+
snapshot: {
851+
...makeSnapshotState([{ index: 0, depth: 0, type: 'Window', label: 'Home' }], {
852+
backend: 'xctest',
853+
}),
854+
postGestureOutcome: outcome,
855+
},
856+
});
857+
858+
const result = await device.capture.snapshot({ session: 'default' });
859+
860+
assert.deepEqual(result.warnings, [formatPostGestureOutcomeWarning(outcome)]);
861+
});
862+
844863
// The box a capture's rects are measured in is public output (#3182) for the same reason the
845864
// keyboard band is: `snapshot --json` is how a caller learns the surface to scale against, and a
846865
// producer that measured no box has to leave the key off rather than claim a screen it never read.

‎src/daemon-runtime-limrun-public-http.test.ts‎

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,33 +77,35 @@ test('public HTTP rejects Limrun uploaded-app listing and allocation before prov
7777
limrunTestDependencies,
7878
);
7979
rootPorts.providerComposition.mockResolvedValue({ runtimes: [limrun], platformModules: [] });
80-
const runtime = await startDaemonRuntime({
81-
composeDeps: createDaemonRuntimeDeps,
82-
env: {
83-
...process.env,
84-
AGENT_DEVICE_STATE_DIR: stateDir,
85-
AGENT_DEVICE_DAEMON_IDLE_TIMEOUT_MS: '0',
86-
AGENT_DEVICE_DAEMON_SERVER_MODE: 'http',
87-
LIM_ANDROID_INSTANCE_URL: 'https://region.limrun.example/v1/android_test/api',
88-
LIM_ANDROID_INSTANCE_TOKEN: 'lim-test-token',
89-
LIM_ANDROID_INSTANCE_ADB_URL: 'https://region.limrun.example/v1/android_test/adb',
90-
},
91-
exit: () => {},
92-
registerProcessHandlers: false,
93-
stderr: { write: () => {} },
94-
stdout: { write: () => {} },
95-
});
80+
let runtime: Awaited<ReturnType<typeof startDaemonRuntime>> | undefined;
9681

9782
try {
98-
if (!runtime?.httpPort) throw new Error('HTTP daemon runtime did not start');
83+
runtime = await startDaemonRuntime({
84+
composeDeps: createDaemonRuntimeDeps,
85+
env: {
86+
...process.env,
87+
AGENT_DEVICE_STATE_DIR: stateDir,
88+
AGENT_DEVICE_DAEMON_IDLE_TIMEOUT_MS: '0',
89+
AGENT_DEVICE_DAEMON_SERVER_MODE: 'http',
90+
LIM_ANDROID_INSTANCE_URL: 'https://region.limrun.example/v1/android_test/api',
91+
LIM_ANDROID_INSTANCE_TOKEN: 'lim-test-token',
92+
LIM_ANDROID_INSTANCE_ADB_URL: 'https://region.limrun.example/v1/android_test/adb',
93+
},
94+
exit: () => {},
95+
registerProcessHandlers: false,
96+
stderr: { write: () => {} },
97+
stdout: { write: () => {} },
98+
});
99+
const activeRuntime = runtime;
100+
if (!activeRuntime?.httpPort) throw new Error('HTTP daemon runtime did not start');
99101
limrunIo.listAssets.mockClear();
100102
limrunIo.createAndroidInstance.mockClear();
101103

102104
const callRpc = async (payload: Record<string, unknown>) => {
103-
const response = await fetch(`http://127.0.0.1:${runtime.httpPort}/rpc`, {
105+
const response = await fetch(`http://127.0.0.1:${activeRuntime.httpPort}/rpc`, {
104106
method: 'POST',
105107
headers: {
106-
authorization: `Bearer ${runtime.token}`,
108+
authorization: `Bearer ${activeRuntime.token}`,
107109
'content-type': 'application/json',
108110
[DAEMON_HTTP_NETWORK_ACCESS_HEADER]: DAEMON_HTTP_PUBLIC_NETWORK_ACCESS,
109111
},
@@ -147,7 +149,8 @@ test('public HTTP rejects Limrun uploaded-app listing and allocation before prov
147149
} finally {
148150
await runtime?.shutdown();
149151
await limrun.shutdown();
150-
assert.equal(rootPorts.applicationLifecycle.finalizeDaemonShutdown.mock.calls.length, 1);
151152
fs.rmSync(paths.baseDir, { recursive: true, force: true });
153+
if (runtime)
154+
assert.equal(rootPorts.applicationLifecycle.finalizeDaemonShutdown.mock.calls.length, 1);
152155
}
153156
});

‎src/platform-runtime-gateway-gesture-admission.test.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ test('Android phones and emulators admit single- and multi-touch gesture plans',
2929
test('target-authored drag is admitted only where adapters preserve every authored phase', async () => {
3030
const supported = [
3131
device({ kind: 'device', target: 'mobile' }),
32-
device({ platform: 'apple', appleOs: 'ios', kind: 'device', target: 'mobile' }),
3332
device({ platform: 'apple', appleOs: 'ios', kind: 'simulator', target: 'mobile' }),
34-
device({ platform: 'apple', appleOs: 'ipados', kind: 'device', target: 'mobile' }),
3533
device({ platform: 'apple', appleOs: 'ipados', kind: 'simulator', target: 'mobile' }),
3634
device({ platform: 'apple', kind: 'simulator', target: 'mobile' }),
3735
];

0 commit comments

Comments
 (0)