11import test from 'node:test' ;
2- import assert from 'node:assert/strict' ;
32import { existsSync } from 'node:fs' ;
43import path from 'node:path' ;
5- import { formatResultDebug , runCliJson } from './test-helpers.ts' ;
4+ import { createIntegrationTestContext , runCliJson } from './test-helpers.ts' ;
65
76const session = [ '--session' , 'ios-test' ] ;
87
@@ -11,53 +10,60 @@ test.after(() => {
1110} ) ;
1211
1312test ( 'ios settings commands' , { skip : shouldSkipIos ( ) } , async ( ) => {
13+ const integration = createIntegrationTestContext ( {
14+ platform : 'ios' ,
15+ testName : 'ios settings commands' ,
16+ } ) ;
1417 const openArgs = [ 'open' , 'com.apple.Preferences' , '--platform' , 'ios' , '--json' , ...session ] ;
15- const open = runCliJson ( openArgs ) ;
16- assert . equal ( open . status , 0 , formatResultDebug ( 'open settings' , openArgs , open ) ) ;
18+ integration . runStep ( 'open settings' , openArgs ) ;
1719
1820 const outPath = path . resolve ( 'test/screenshots/ios-settings.png' ) ;
1921 const shotArgs = [ 'screenshot' , outPath , '--platform' , 'ios' , '--json' , ...session ] ;
20- const shot = runCliJson ( shotArgs ) ;
21- assert . equal ( shot . status , 0 , formatResultDebug ( 'screenshot settings' , shotArgs , shot ) ) ;
22- assert . ok ( existsSync ( outPath ) , formatResultDebug ( 'screenshot file missing' , shotArgs , shot ) ) ;
22+ const shot = integration . runStep ( 'screenshot settings' , shotArgs ) ;
23+ integration . assertResult ( existsSync ( outPath ) , 'screenshot file missing' , shotArgs , shot , {
24+ detail : `expected screenshot file at ${ outPath } ` ,
25+ } ) ;
2326
2427 const snapshotArgs = [ 'snapshot' , '-i' , '--json' , ...session ] ;
25- const snapshot = runCliJson ( snapshotArgs ) ;
26- assert . equal ( snapshot . status , 0 , formatResultDebug ( 'snapshot' , snapshotArgs , snapshot ) ) ;
27- assert . ok (
28- Array . isArray ( snapshot . json ?. data ?. nodes ) ,
29- formatResultDebug ( 'snapshot nodes' , snapshotArgs , snapshot ) ,
30- ) ;
28+ const snapshot = integration . runStep ( 'snapshot' , snapshotArgs ) ;
29+ integration . assertResult ( Array . isArray ( snapshot . json ?. data ?. nodes ) , 'snapshot nodes' , snapshotArgs , snapshot , {
30+ detail : 'expected snapshot to include a nodes array' ,
31+ } ) ;
3132
3233 const clickArgs = [ 'click' , '@e21' , '--json' , ...session ] ;
33- const click = runCliJson ( clickArgs ) ;
34- assert . equal ( click . status , 0 , formatResultDebug ( 'click @e13' , clickArgs , click ) ) ;
34+ integration . runStep ( 'click @e21' , clickArgs ) ;
3535
36- const snapshotGeneral = runCliJson ( [ 'snapshot' , '--json' , ...session ] ) ;
36+ const snapshotGeneralArgs = [ 'snapshot' , '--json' , ...session ] ;
37+ const snapshotGeneral = integration . runStep ( 'snapshot general' , snapshotGeneralArgs ) ;
3738 const generalDescription = 'Manage your overall setup and preferences' ;
3839 const generalNodes = Array . isArray ( snapshotGeneral . json ?. data ?. nodes )
3940 ? snapshotGeneral . json . data . nodes
4041 : [ ] ;
41- assert . ok (
42+ integration . assertResult (
4243 generalNodes . some (
4344 ( node : { label ?: string } ) =>
4445 typeof node ?. label === 'string' && node . label . includes ( generalDescription ) ,
4546 ) ,
46- formatResultDebug ( 'snapshot shows general page description' , snapshotArgs , snapshotGeneral ) ,
47+ 'snapshot shows general page description' ,
48+ snapshotGeneralArgs ,
49+ snapshotGeneral ,
50+ {
51+ detail : `expected a node label containing ${ JSON . stringify ( generalDescription ) } ` ,
52+ } ,
4753 ) ;
4854
4955 const findTextArgs = [ 'find' , 'text' , generalDescription , 'exists' , '--json' , ...session ] ;
50- const findText = runCliJson ( findTextArgs ) ;
51- assert . equal ( findText . status , 0 , formatResultDebug ( 'find text' , findTextArgs , findText ) ) ;
52- assert . equal (
56+ const findText = integration . runStep ( 'find text' , findTextArgs ) ;
57+ integration . assertResult (
5358 findText . json ?. success ,
54- true ,
55- formatResultDebug ( 'find text success' , findTextArgs , findText ) ,
59+ 'find text success' ,
60+ findTextArgs ,
61+ findText ,
62+ { detail : 'expected find command to return success=true' } ,
5663 ) ;
5764
58- const backArgs = [ 'back' , ...session ] ;
59- const back = runCliJson ( backArgs ) ;
60- assert . equal ( back . status , 0 , formatResultDebug ( 'back' , backArgs , back ) ) ;
65+ const backArgs = [ 'back' , '--json' , ...session ] ;
66+ integration . runStep ( 'back' , backArgs ) ;
6167} ) ;
6268
6369function shouldSkipIos ( ) : boolean {
0 commit comments