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
45 changes: 45 additions & 0 deletions src/__tests__/cli-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,51 @@ test('command-specific config defaults are ignored for commands that do not supp
fs.rmSync(root, { recursive: true, force: true });
});

test('interaction commands preserve remote config defaults', async () => {
const { root, home, project } = makeTempWorkspace();
fs.mkdirSync(path.join(home, '.agent-device'), { recursive: true });
fs.writeFileSync(
path.join(project, 'agent-device.json'),
JSON.stringify({
daemonBaseUrl: 'https://daemon.example.test',
daemonAuthToken: 'token-123',
daemonTransport: 'http',
tenant: 'tenant-123',
runId: 'run-123',
leaseId: 'lease-123',
platform: 'ios',
}),
'utf8',
);

const commands = [
['press', '10', '20'],
['click', '10', '20'],
['fill', '10', '20', 'hello'],
['longpress', '10', '20'],
['get', 'text', '@e1'],
];

for (const command of commands) {
const result = await runCliCapture([...command, '--json'], {
cwd: project,
env: { HOME: home },
});

assert.equal(result.code, null, command.join(' '));
assert.equal(result.calls.length, 1, command.join(' '));
assert.equal(result.calls[0]?.flags?.daemonBaseUrl, 'https://daemon.example.test');
assert.equal(result.calls[0]?.flags?.daemonAuthToken, 'token-123');
assert.equal(result.calls[0]?.flags?.daemonTransport, 'http');
assert.equal(result.calls[0]?.flags?.tenant, 'tenant-123');
assert.equal(result.calls[0]?.flags?.runId, 'run-123');
assert.equal(result.calls[0]?.flags?.leaseId, 'lease-123');
assert.equal(result.calls[0]?.flags?.platform, 'ios');
}

fs.rmSync(root, { recursive: true, force: true });
});

test('explicit --config path overrides default config discovery', async () => {
const { root, home, project } = makeTempWorkspace();
fs.mkdirSync(path.join(home, '.agent-device'), { recursive: true });
Expand Down
4 changes: 2 additions & 2 deletions src/commands/command-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ export function optionalEnum<const T extends readonly string[]>(
export function commonToClientOptions(
input: CommonCommandInput,
): AgentDeviceRequestOverrides & AgentDeviceSelectionOptions {
return {
return compactRecord({
session: input.session,
platform: input.platform,
target: input.deviceTarget,
Expand All @@ -453,7 +453,7 @@ export function commonToClientOptions(
leaseId: input.leaseId,
cwd: input.cwd,
debug: input.debug,
};
}) as AgentDeviceRequestOverrides & AgentDeviceSelectionOptions;
}

export function toClientInteractionTarget(target: InteractionTargetInput): InteractionTarget {
Expand Down
Loading