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
19 changes: 19 additions & 0 deletions src/platforms/ios/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import { ensureBootedSimulator, openIosSimulatorApp } from '../simulator.ts';
import { prepareSimulatorStatusBarForScreenshot as prepareStatusBarForScreenshot } from '../screenshot-status-bar.ts';
import { runIosRunnerCommand } from '../runner-client.ts';
import { iosRunnerOverrides } from '../interactions.ts';
import { IOS_SIMULATOR_TERMINATE_TIMEOUT_MS } from '../config.ts';
import type { DeviceInfo } from '../../../utils/device.ts';
import { withDiagnosticsScope } from '../../../utils/diagnostics.ts';
import { AppError } from '../../../utils/errors.ts';
Expand Down Expand Up @@ -1136,6 +1137,24 @@ test('closeIosApp on macOS uses helper quit for bundle identifiers', async () =>
);
});

test('closeIosApp on iOS simulator bounds simctl terminate', async () => {
mockEnsureBootedSimulator.mockResolvedValue(undefined);
mockRunCmd.mockResolvedValue({ stdout: '', stderr: '', exitCode: 0 });

await closeIosApp(IOS_TEST_SIMULATOR, 'com.example.foobar');

assert.equal(mockRunCmd.mock.calls.length, 1);
assert.equal(mockRunCmd.mock.calls[0]?.[0], 'xcrun');
assert.deepEqual(mockRunCmd.mock.calls[0]?.[1], [
'simctl',
'terminate',
'sim-1',
'com.example.foobar',
]);
assert.equal(mockRunCmd.mock.calls[0]?.[2]?.allowFailure, true);
assert.equal(mockRunCmd.mock.calls[0]?.[2]?.timeoutMs, IOS_SIMULATOR_TERMINATE_TIMEOUT_MS);
});

test('quitMacOsApp rejects invalid bundle identifiers before invoking helper', async () => {
await assert.rejects(() => quitMacOsApp('not a bundle id'), /reverse-DNS form/i);
});
Expand Down
7 changes: 6 additions & 1 deletion src/platforms/ios/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ import {
type CommandAttemptFailure,
} from '../command-attempts.ts';

import { IOS_APP_LAUNCH_TIMEOUT_MS, IOS_DEVICECTL_TIMEOUT_MS } from './config.ts';
import {
IOS_APP_LAUNCH_TIMEOUT_MS,
IOS_DEVICECTL_TIMEOUT_MS,
IOS_SIMULATOR_TERMINATE_TIMEOUT_MS,
} from './config.ts';
import {
IOS_DEVICECTL_DEFAULT_HINT,
listIosDeviceApps,
Expand Down Expand Up @@ -277,6 +281,7 @@ export async function closeIosApp(device: DeviceInfo, app: string): Promise<void
const terminateArgs = simctlArgs(device, ['terminate', device.id, bundleId]);
const result = await runXcrun(terminateArgs, {
allowFailure: true,
timeoutMs: IOS_SIMULATOR_TERMINATE_TIMEOUT_MS,
});
if (result.exitCode !== 0) {
const stderr = result.stderr.toLowerCase();
Expand Down
2 changes: 2 additions & 0 deletions src/platforms/ios/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const IOS_DEVICECTL_TIMEOUT_MS = 20_000;

export const IOS_SIMULATOR_FOCUS_TIMEOUT_MS = 10_000;

export const IOS_SIMULATOR_TERMINATE_TIMEOUT_MS = 15_000;

export const IOS_SIMULATOR_SCREENSHOT_TIMEOUT_MS = 20_000;

export const IOS_RUNNER_SCREENSHOT_COPY_TIMEOUT_MS = 20_000;
Expand Down
Loading