Skip to content

Commit e95941d

Browse files
committed
test: drive hover through the apple output guard; cover direct hover dispatch
The provider-integration apple-leak guard partitions every public command into driven/skipped; hover was neither, which failed Integration Tests and took Coverage down with it. Drive it (it reaches the Apple capability refusal, which is scanned like any other error response). Also cover the direct-dispatch handleHoverCommand seam.
1 parent fdebd81 commit e95941d

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { test } from 'vitest';
2+
import assert from 'node:assert/strict';
3+
import { AppError } from '@agent-device/kernel/errors';
4+
import type { Interactor } from '@agent-device/contracts/interaction';
5+
import { handleHoverCommand } from '../dispatch-interactions.ts';
6+
7+
// #1783: the direct-dispatch hover handler (the core seam the daemon's web
8+
// backend calls, and what `agent-device hover x y` reaches without a session).
9+
10+
test('dispatch hover moves the pointer through the interactor and reports the point', async () => {
11+
const calls: Array<[number, number]> = [];
12+
const interactor = {
13+
hover: async (x: number, y: number) => {
14+
calls.push([x, y]);
15+
},
16+
} as unknown as Interactor;
17+
18+
const result = await handleHoverCommand(interactor, ['155', '172']);
19+
20+
assert.deepEqual(calls, [[155, 172]]);
21+
assert.equal(result.x, 155);
22+
assert.equal(result.y, 172);
23+
assert.match(String(result.message), /Hovered \(155, 172\)/);
24+
});
25+
26+
test('dispatch hover refuses platforms whose interactor has no pointer', async () => {
27+
const interactor = {} as unknown as Interactor;
28+
29+
await assert.rejects(
30+
() => handleHoverCommand(interactor, ['10', '10']),
31+
(error: unknown) =>
32+
error instanceof AppError &&
33+
error.code === 'UNSUPPORTED_OPERATION' &&
34+
/hover is not supported on this platform/i.test(error.message) &&
35+
/web targets only/i.test(String(error.details?.hint)),
36+
);
37+
});
38+
39+
test('dispatch hover explains the direct platform coordinate requirement', async () => {
40+
const interactor = { hover: async () => {} } as unknown as Interactor;
41+
42+
await assert.rejects(
43+
() => handleHoverCommand(interactor, ['@e40']),
44+
(error: unknown) =>
45+
error instanceof AppError &&
46+
error.code === 'INVALID_ARGS' &&
47+
/hover requires x y/i.test(error.message) &&
48+
/open daemon session/i.test(String(error.details?.hint)),
49+
);
50+
});

‎test/integration/provider-scenarios/apple-platform-output-guard.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ const DRIVEN_COMMANDS: Record<string, DriveSpec> = {
113113
[PUBLIC_COMMANDS.click]: () => one(['10', '10']),
114114
[PUBLIC_COMMANDS.fill]: () => one(['label=General', 'hello']),
115115
[PUBLIC_COMMANDS.longPress]: () => one(['10', '10']),
116+
// Web-only: reaches the capability refusal on Apple; the error must not leak either.
117+
[PUBLIC_COMMANDS.hover]: () => one(['10', '10']),
116118
[PUBLIC_COMMANDS.press]: () => one(['10', '10']),
117119
[PUBLIC_COMMANDS.type]: () => one(['hello']),
118120
[PUBLIC_COMMANDS.back]: () => one(),

0 commit comments

Comments
 (0)