@@ -2,6 +2,7 @@ import assert from 'node:assert/strict';
22import fs from 'node:fs' ;
33import path from 'node:path' ;
44import { test } from 'vitest' ;
5+ import { runCmd } from '@agent-device/host-kit/command' ;
56import { assertFlatToolCall , assertRpcOk } from './assertions.ts' ;
67import {
78 createIosBottomTabsSnapshotWorld ,
@@ -404,23 +405,22 @@ test('Provider-backed integration iOS physical reinstall uses scripted devicectl
404405 appPath ,
405406 ] ) ;
406407
407- const callsBeforeCorrupt = appleTool . calls . length ;
408- const corruptIpa = path . join ( path . dirname ( appPath ) , 'corrupt.ipa' ) ;
409- fs . writeFileSync ( corruptIpa , 'not a zip archive' ) ;
410- const corrupt = await daemon . callCommand ( 'reinstall' , [ 'com.example.demo' , corruptIpa ] , {
408+ const callsBeforeInvalidArchive = appleTool . calls . length ;
409+ const archiveDirectory = path . dirname ( appPath ) ;
410+ fs . writeFileSync ( path . join ( archiveDirectory , 'README.txt' ) , 'no app bundle' ) ;
411+ const invalidIpa = path . join ( archiveDirectory , 'no-app.ipa' ) ;
412+ await runCmd ( 'zip' , [ '-q' , invalidIpa , 'README.txt' ] , { cwd : archiveDirectory } ) ;
413+ const invalid = await daemon . callCommand ( 'reinstall' , [ 'com.example.demo' , invalidIpa ] , {
411414 platform : 'ios' ,
412415 udid : PROVIDER_SCENARIO_IOS_REINSTALL_DEVICE . id ,
413416 } ) ;
414- assert . notEqual ( corrupt . statusCode , 200 , JSON . stringify ( corrupt . json ) ) ;
415- assert . match (
416- corrupt . json ?. error ?. message ?? '' ,
417- / E n d o f c e n t r a l d i r e c t o r y r e c o r d s i g n a t u r e n o t f o u n d / ,
418- ) ;
419- const laterCalls = appleTool . calls . slice ( callsBeforeCorrupt ) ;
417+ assert . equal ( invalid . statusCode , 400 , JSON . stringify ( invalid . json ) ) ;
418+ assert . equal ( invalid . json ?. error ?. data ?. code , 'INVALID_ARGS' , JSON . stringify ( invalid . json ) ) ;
419+ const laterCalls = appleTool . calls . slice ( callsBeforeInvalidArchive ) ;
420420 assert . equal (
421421 laterCalls . some ( ( call ) => call . includes ( 'uninstall' ) || call . includes ( 'install' ) ) ,
422422 false ,
423- `Corrupt replacement must not reach uninstall or install: ${ JSON . stringify ( laterCalls ) } ` ,
423+ `Archive without an app must not reach uninstall or install: ${ JSON . stringify ( laterCalls ) } ` ,
424424 ) ;
425425 } ,
426426 ) ;
0 commit comments