Skip to content

Commit 8eff3d9

Browse files
thymikeeclaude
andcommitted
test(host): bind host-taking commands once in a shared helper
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent eef3345 commit 8eff3d9

4 files changed

Lines changed: 30 additions & 81 deletions

File tree

‎src/__tests__/cli-client-commands.test.ts‎

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from 'node:path';
33
import { test } from 'vitest';
44
import assert from 'node:assert/strict';
55
import { PNG } from '@agent-device/capture-kit/png';
6-
import { tryRunClientBackedCommand } from '../cli/commands/router.ts';
6+
import { tryRunClientBackedCommand } from './test-utils/host-bound-commands.ts';
77
import { runCliCapture } from './cli-capture.ts';
88
import type {
99
AgentDeviceClient,
@@ -15,7 +15,7 @@ import type {
1515
import type { SettingsUpdateOptions } from '@agent-device/contracts/client';
1616
import { AppError } from '@agent-device/kernel/errors';
1717
import { resolveCliOptions } from '../cli/resolve-cli-options.ts';
18-
import { mkdtempForTestSync, createTestHostEnvironment } from '@agent-device/test-kit';
18+
import { mkdtempForTestSync } from '@agent-device/test-kit';
1919
import { createStubClientLeases } from './test-utils/client-lease-fixtures.ts';
2020
import { withCapturedOutput, withCapturedStdoutAsync } from './test-utils/stream-capture.ts';
2121

@@ -42,7 +42,6 @@ test('install-from-source forwards URL and repeated headers to client.apps.insta
4242
});
4343

4444
const handled = await tryRunClientBackedCommand({
45-
host: createTestHostEnvironment(),
4645
command: 'install-from-source',
4746
positionals: ['https://example.com/app.apk'],
4847
flags: {
@@ -85,7 +84,6 @@ test('install-from-source forwards GitHub Actions artifact flag to client.apps.i
8584
});
8685

8786
const handled = await tryRunClientBackedCommand({
88-
host: createTestHostEnvironment(),
8987
command: 'install-from-source',
9088
positionals: [],
9189
flags: {
@@ -122,7 +120,6 @@ test('install-from-source preserves colons in GitHub Actions artifact names', as
122120
});
123121

124122
await tryRunClientBackedCommand({
125-
host: createTestHostEnvironment(),
126123
command: 'install-from-source',
127124
positionals: [],
128125
flags: {
@@ -156,7 +153,6 @@ test('install-from-source forwards configured GitHub Actions artifact name to cl
156153
});
157154

158155
const handled = await tryRunClientBackedCommand({
159-
host: createTestHostEnvironment(),
160156
command: 'install-from-source',
161157
positionals: [],
162158
flags: {
@@ -193,7 +189,6 @@ test('install-from-source rejects malformed header syntax', async () => {
193189
await assert.rejects(
194190
() =>
195191
tryRunClientBackedCommand({
196-
host: createTestHostEnvironment(),
197192
command: 'install-from-source',
198193
positionals: ['https://example.com/app.apk'],
199194
flags: {
@@ -221,7 +216,6 @@ test('install-from-source rejects headers with GitHub Actions artifact sources',
221216
await assert.rejects(
222217
() =>
223218
tryRunClientBackedCommand({
224-
host: createTestHostEnvironment(),
225219
command: 'install-from-source',
226220
positionals: [],
227221
flags: {
@@ -274,7 +268,6 @@ test('metro prepare forwards normalized options to client.metro.prepare', async
274268

275269
const stdout = await withCapturedStdoutAsync(async () => {
276270
const handled = await tryRunClientBackedCommand({
277-
host: createTestHostEnvironment(),
278271
command: 'metro',
279272
positionals: ['prepare'],
280273
flags: {
@@ -337,7 +330,6 @@ test('metro prepare rejects when no public or proxy base URL is provided', async
337330
await assert.rejects(
338331
() =>
339332
tryRunClientBackedCommand({
340-
host: createTestHostEnvironment(),
341333
command: 'metro',
342334
positionals: ['prepare'],
343335
flags: {
@@ -374,7 +366,6 @@ test('metro reload forwards host, port, bundle URL, and timeout to client.metro.
374366

375367
const stdout = await withCapturedStdoutAsync(async () => {
376368
const handled = await tryRunClientBackedCommand({
377-
host: createTestHostEnvironment(),
378369
command: 'metro',
379370
positionals: ['reload'],
380371
flags: {
@@ -429,7 +420,6 @@ test('events prints a parsed session timeline from the generic CLI route', async
429420

430421
const output = await withCapturedOutput(async () => {
431422
const handled = await tryRunClientBackedCommand({
432-
host: createTestHostEnvironment(),
433423
command: 'events',
434424
positionals: [],
435425
flags: {
@@ -471,7 +461,6 @@ test('screenshot forwards --overlay-refs to the client capture API', async () =>
471461
});
472462

473463
const handled = await tryRunClientBackedCommand({
474-
host: createTestHostEnvironment(),
475464
command: 'screenshot',
476465
positionals: ['/tmp/screenshot.png'],
477466
flags: {
@@ -521,7 +510,6 @@ test('diff screenshot forwards --surface to live client screenshot capture', asy
521510

522511
await withCapturedStdoutAsync(async () => {
523512
const handled = await tryRunClientBackedCommand({
524-
host: createTestHostEnvironment(),
525513
command: 'diff',
526514
positionals: ['screenshot'],
527515
flags: {
@@ -566,7 +554,6 @@ test('open forwards macOS surface to the client apps API', async () => {
566554
});
567555

568556
const handled = await tryRunClientBackedCommand({
569-
host: createTestHostEnvironment(),
570557
command: 'open',
571558
positionals: ['MenuBarApp'],
572559
flags: {
@@ -602,7 +589,6 @@ test('open forwards launch console option to the client apps API', async () => {
602589
});
603590

604591
const handled = await tryRunClientBackedCommand({
605-
host: createTestHostEnvironment(),
606592
command: 'open',
607593
positionals: ['Agent Device Tester'],
608594
flags: {
@@ -636,7 +622,6 @@ test('apps command defaults to user-installed and prints discovery hint', async
636622

637623
const output = await withCapturedOutput(async () => {
638624
const handled = await tryRunClientBackedCommand({
639-
host: createTestHostEnvironment(),
640625
command: 'apps',
641626
positionals: [],
642627
flags: {
@@ -684,7 +669,6 @@ test('screenshot reports annotated ref count in non-json mode', async () => {
684669

685670
const stdout = await withCapturedStdoutAsync(async () => {
686671
const handled = await tryRunClientBackedCommand({
687-
host: createTestHostEnvironment(),
688672
command: 'screenshot',
689673
positionals: ['/tmp/screenshot.png'],
690674
flags: {
@@ -719,7 +703,6 @@ click text="Continue"
719703

720704
const stdout = await withCapturedStdoutAsync(async () => {
721705
const handled = await tryRunClientBackedCommand({
722-
host: createTestHostEnvironment(),
723706
command: 'replay',
724707
positionals: ['export', sourcePath],
725708
flags: {
@@ -801,7 +784,6 @@ test('replay rejects extra plain replay paths before daemon dispatch', async ()
801784
await assert.rejects(
802785
async () =>
803786
await tryRunClientBackedCommand({
804-
host: createTestHostEnvironment(),
805787
command: 'replay',
806788
positionals: ['one.ad', 'two.ad'],
807789
flags: {
@@ -832,7 +814,6 @@ test('wait keeps CLI bare text behavior through the typed client command API', a
832814
};
833815

834816
const handled = await tryRunClientBackedCommand({
835-
host: createTestHostEnvironment(),
836817
command: 'wait',
837818
positionals: ['Continue', '1500'],
838819
flags: {
@@ -867,7 +848,6 @@ test('keyboard status prints Android input ownership in human output', async ()
867848

868849
const stdout = await withCapturedStdoutAsync(async () => {
869850
const handled = await tryRunClientBackedCommand({
870-
host: createTestHostEnvironment(),
871851
command: 'keyboard',
872852
positionals: ['status'],
873853
flags: {
@@ -900,7 +880,6 @@ test('metro prepare wraps output in the standard success envelope for --json', a
900880

901881
const stdout = await withCapturedStdoutAsync(async () => {
902882
const handled = await tryRunClientBackedCommand({
903-
host: createTestHostEnvironment(),
904883
command: 'metro',
905884
positionals: ['prepare'],
906885
flags: {
@@ -974,7 +953,6 @@ test('metro prepare with --remote-config loads profile defaults', async () => {
974953

975954
const stdout = await withCapturedStdoutAsync(async () => {
976955
const handled = await tryRunClientBackedCommand({
977-
host: createTestHostEnvironment(),
978956
command: 'metro',
979957
positionals: ['prepare'],
980958
flags: parsed.flags,
@@ -1015,7 +993,6 @@ test('install prints command-owned success output in human mode', async () => {
1015993

1016994
const stdout = await withCapturedStdoutAsync(async () => {
1017995
const handled = await tryRunClientBackedCommand({
1018-
host: createTestHostEnvironment(),
1019996
command: 'install',
1020997
positionals: ['Demo', '/tmp/Demo.app'],
1021998
flags: {
@@ -1046,7 +1023,6 @@ test('settings location set forwards coordinates to client settings update', asy
10461023
});
10471024

10481025
const handled = await tryRunClientBackedCommand({
1049-
host: createTestHostEnvironment(),
10501026
command: 'settings',
10511027
positionals: ['location', 'set', '37.3349', '-122.009'],
10521028
flags: {
@@ -1088,7 +1064,6 @@ test('settings location set rejects invalid coordinates before client call', asy
10881064
await assert.rejects(
10891065
() =>
10901066
tryRunClientBackedCommand({
1091-
host: createTestHostEnvironment(),
10921067
command: 'settings',
10931068
positionals,
10941069
flags: {

0 commit comments

Comments
 (0)