@@ -71,6 +71,7 @@ import { ensureBootedSimulator, openIosSimulatorApp } from '../simulator.ts';
7171import { prepareSimulatorStatusBarForScreenshot as prepareStatusBarForScreenshot } from '../screenshot-status-bar.ts' ;
7272import { runIosRunnerCommand } from '../runner-client.ts' ;
7373import { iosRunnerOverrides } from '../interactions.ts' ;
74+ import { IOS_SIMULATOR_TERMINATE_TIMEOUT_MS } from '../config.ts' ;
7475import type { DeviceInfo } from '../../../utils/device.ts' ;
7576import { withDiagnosticsScope } from '../../../utils/diagnostics.ts' ;
7677import { AppError } from '../../../utils/errors.ts' ;
@@ -1136,6 +1137,24 @@ test('closeIosApp on macOS uses helper quit for bundle identifiers', async () =>
11361137 ) ;
11371138} ) ;
11381139
1140+ test ( 'closeIosApp on iOS simulator bounds simctl terminate' , async ( ) => {
1141+ mockEnsureBootedSimulator . mockResolvedValue ( undefined ) ;
1142+ mockRunCmd . mockResolvedValue ( { stdout : '' , stderr : '' , exitCode : 0 } ) ;
1143+
1144+ await closeIosApp ( IOS_TEST_SIMULATOR , 'com.example.foobar' ) ;
1145+
1146+ assert . equal ( mockRunCmd . mock . calls . length , 1 ) ;
1147+ assert . equal ( mockRunCmd . mock . calls [ 0 ] ?. [ 0 ] , 'xcrun' ) ;
1148+ assert . deepEqual ( mockRunCmd . mock . calls [ 0 ] ?. [ 1 ] , [
1149+ 'simctl' ,
1150+ 'terminate' ,
1151+ 'sim-1' ,
1152+ 'com.example.foobar' ,
1153+ ] ) ;
1154+ assert . equal ( mockRunCmd . mock . calls [ 0 ] ?. [ 2 ] ?. allowFailure , true ) ;
1155+ assert . equal ( mockRunCmd . mock . calls [ 0 ] ?. [ 2 ] ?. timeoutMs , IOS_SIMULATOR_TERMINATE_TIMEOUT_MS ) ;
1156+ } ) ;
1157+
11391158test ( 'quitMacOsApp rejects invalid bundle identifiers before invoking helper' , async ( ) => {
11401159 await assert . rejects ( ( ) => quitMacOsApp ( 'not a bundle id' ) , / r e v e r s e - D N S f o r m / i) ;
11411160} ) ;
0 commit comments