Skip to content

Commit 8868fb5

Browse files
committed
test(interaction): pin data.readiness on the client and MCP success paths
1 parent 9794df6 commit 8868fb5

4 files changed

Lines changed: 37 additions & 2 deletions

File tree

‎src/__tests__/client-interactions-readiness.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,17 @@ test('readinessTimeoutMs on press/click/longpress reaches the request flags', as
1717
assert.equal(setup.calls[1]?.flags?.readinessTimeoutMs, 1_500);
1818
assert.equal(setup.calls[2]?.flags?.readinessTimeoutMs, 900);
1919
});
20+
21+
test('a press that waited returns the daemon data.readiness untouched', async () => {
22+
const readiness = { polls: 2, waitedMs: 180 };
23+
const setup = createTransport(async () => ({ ok: true, data: { ref: '@e1', readiness } }));
24+
const client = createAgentDeviceClient(setup.config, { transport: setup.transport });
25+
26+
const pressed = await client.interactions.press({ selector: 'label=Foo' });
27+
const clicked = await client.interactions.click({ selector: 'label=Foo' });
28+
const longPressed = await client.interactions.longPress({ selector: 'label=Foo' });
29+
30+
for (const result of [pressed, clicked, longPressed]) {
31+
assert.deepEqual((result as { readiness?: unknown }).readiness, readiness);
32+
}
33+
});

‎src/commands/interaction/runtime/selector-readiness.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ test('runtime press with readinessTimeoutMs polls until the target appears', asy
6060

6161
assert.equal(result.kind, 'selector');
6262
assert.equal(result.node?.label, 'Continue');
63-
assert.ok(result.kind === 'selector' && result.readiness && result.readiness.polls > 1);
63+
assert.equal(result.kind === 'selector' ? result.readiness?.polls : undefined, 2);
6464
assert.ok(
6565
captures >= 4,
6666
`expected at least 4 captures before the target appeared, got ${captures}`,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import assert from 'node:assert/strict';
2+
import { test } from 'vitest';
3+
import { createAgentDeviceClient } from '../../agent-device-client.ts';
4+
import { createTransport } from '../../__tests__/client-transport-fixture.ts';
5+
import { createCommandToolExecutor } from '../command-tools.ts';
6+
7+
test('MCP press returns the daemon data.readiness in structuredContent', async () => {
8+
const readiness = { polls: 2, waitedMs: 180 };
9+
const setup = createTransport(async () => ({ ok: true, data: { ref: '@e1', readiness } }));
10+
const executor = createCommandToolExecutor({
11+
createClient: () => createAgentDeviceClient(setup.config, { transport: setup.transport }),
12+
});
13+
14+
const result = await executor.execute('press', {
15+
target: { kind: 'selector', selector: 'label=Continue' },
16+
});
17+
18+
assert.equal(result.isError, false);
19+
assert.deepEqual(result.structuredContent?.readiness, readiness);
20+
});

‎website/docs/docs/replay-e2e.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ agent-device replay ~/.agent-device/sessions/e2e-2026-02-09T12-00-00-000Z.ad --s
6262
they fail. A step recorded against a screen that was still loading passes on replay once the
6363
target shows up. The wait covers only a target that is not on screen yet: a target that is
6464
covered, off-screen, or matched by more than one element fails at once, as it does live.
65-
Under `--debug`, each wait shows up as an `interaction_target_readiness` diagnostic.
65+
A step that waited and then passed shows no trace of the wait in the replay output; run with
66+
`--debug` to see it in the diagnostics.
6667
- When the target never appears, replay stops with `REPLAY_DIVERGENCE`, and
6768
`error.details.readiness` says how long the step waited and how many times it looked (`waitedMs`,
6869
`polls`, `end`). For a step recorded with a target annotation (the `# agent-device:target-v1`

0 commit comments

Comments
 (0)