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
8 changes: 4 additions & 4 deletions packages/platform-apple/src/core/__tests__/apps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ test('openIosApp web URL on iOS device without app falls back to Safari', async
'launch',
'--device',
'ios-device-1',
'com.apple.mobilesafari',
'--payload-url',
'https://example.com/path',
'com.apple.mobilesafari',
],
]);
},
Expand Down Expand Up @@ -290,9 +290,9 @@ test('openIosApp custom scheme on iOS device uses active app context', async ()
'launch',
'--device',
'ios-device-1',
'com.example.app',
'--payload-url',
'myapp://item/42',
'com.example.app',
],
]);
},
Expand Down Expand Up @@ -382,9 +382,9 @@ test('openIosApp appends launchArgs alongside --payload-url for iOS device deep
'launch',
'--device',
'ios-device-1',
'com.example.app',
'--payload-url',
'myapp://item/42',
'com.example.app',
'--',
'-Tracking',
'NO',
Expand Down Expand Up @@ -562,9 +562,9 @@ test('openIosApp with app and URL on iOS device launches app bundle with payload
'launch',
'--device',
'ios-device-1',
'com.example.app',
'--payload-url',
'myapp://screen/to',
'com.example.app',
],
]);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import path from 'node:path';
import { test } from 'vitest';
import type { DeviceInfo } from '@agent-device/kernel/device';
import {
launchCoreDeviceApp,
parseIosDeviceDetailsPayload,
readIosDeviceReadiness,
resolveIosReadyHint,
Expand All @@ -15,6 +16,7 @@ import {
} from '../devicectl.ts';
import { resolveIosPhysicalDeviceControl } from '../physical-device-control.ts';
import { createLocalAppleToolProvider, withAppleToolProvider } from '../tool-provider.ts';
import { withFakeAppleTool } from '../../__tests__/fake-apple-tool.ts';

/**
* `xcrun devicectl device info details` is the one tool that answers what a device thinks of itself,
Expand All @@ -29,6 +31,59 @@ const DEVICE_INFO_DETAILS_CAPTURE = JSON.parse(
),
) as unknown;

test('launchCoreDeviceApp puts --payload-url before the bundle ID', async () => {
await withFakeAppleTool(
() => '',
async ({ calls }) => {
await launchCoreDeviceApp(IOS_DEVICE, 'com.example.app', {
payloadUrl: 'myapp://item/42',
});
assert.deepEqual(calls, [
[
'devicectl',
'device',
'process',
'launch',
'--device',
IOS_DEVICE.id,
'--payload-url',
'myapp://item/42',
'com.example.app',
],
]);
},
{ device: IOS_DEVICE },
);
});

test('launchCoreDeviceApp keeps launch args after the bundle ID, separated by --', async () => {
await withFakeAppleTool(
() => '',
async ({ calls }) => {
await launchCoreDeviceApp(IOS_DEVICE, 'com.example.app', {
payloadUrl: 'myapp://item/42',
launchArgs: ['--debug'],
});
assert.deepEqual(calls, [
[
'devicectl',
'device',
'process',
'launch',
'--device',
IOS_DEVICE.id,
'--payload-url',
'myapp://item/42',
'com.example.app',
'--',
'--debug',
],
]);
},
{ device: IOS_DEVICE },
);
});

test('parseIosDeviceDetailsPayload reads direct and nested tunnel state', () => {
assert.equal(
parseIosDeviceDetailsPayload({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ export async function launchCoreDeviceApp(
bundleId: string,
options: { payloadUrl?: string; launchArgs?: string[] } = {},
): Promise<void> {
const args = ['device', 'process', 'launch', '--device', device.id, bundleId];
const args = ['device', 'process', 'launch', '--device', device.id];
if (options.payloadUrl) {
// `devicectl` treats everything after the bundle ID as app argv, so
// `--payload-url` must precede it to be honored as a launch option.
args.push('--payload-url', options.payloadUrl);
}
args.push(bundleId);
if (options.launchArgs && options.launchArgs.length > 0) {
// `devicectl` uses Swift ArgumentParser; preserve app-owned leading dashes.
args.push('--', ...options.launchArgs);
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/app-event-delivery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ test('trigger-app-event supports iOS device path and prefers iOS template', asyn
'launch',
'--device',
'ios-device-1',
'com.example.app',
'--payload-url',
expectedUrl,
'com.example.app',
]);
} finally {
process.env.PATH = previousPath;
Expand Down
Loading