@@ -144,22 +144,50 @@ describe('lightning dev app', () => {
144144 }
145145 } ) ;
146146
147- describe ( 'interactive ' , ( ) => {
147+ describe ( 'desktop dev ' , ( ) => {
148148 it ( 'prompts user to select platform when not provided' , async ( ) => {
149149 const promptStub = $$ . SANDBOX . stub ( PromptUtils , 'promptUserToSelectPlatform' ) . resolves ( Platform . desktop ) ;
150150 await verifyOrgOpen ( 'lightning' ) ;
151151 expect ( promptStub . calledOnce ) ;
152152 } ) ;
153- } ) ;
154153
155- describe ( 'desktop dev' , ( ) => {
156154 it ( 'runs org:open with proper flags when app name provided' , async ( ) => {
157155 await verifyOrgOpen ( `lightning/app/${ testAppId } ` , Platform . desktop , 'Sales' ) ;
158156 } ) ;
159157
160158 it ( 'runs org:open with proper flags when no app name provided' , async ( ) => {
161159 await verifyOrgOpen ( 'lightning' , Platform . desktop ) ;
162160 } ) ;
161+
162+ async function verifyOrgOpen ( expectedAppPath : string , deviceType ?: Platform , appName ?: string ) : Promise < void > {
163+ $$ . SANDBOX . stub ( OrgUtils , 'getAppId' ) . resolves ( testAppId ) ;
164+ $$ . SANDBOX . stub ( PreviewUtils , 'generateWebSocketUrlForLocalDevServer' ) . returns ( testServerUrl ) ;
165+ $$ . SANDBOX . stub ( ConfigUtils , 'getIdentityData' ) . resolves ( testIdentityData ) ;
166+
167+ const runCmdStub = $$ . SANDBOX . stub ( OclifConfig . prototype , 'runCommand' ) . resolves ( ) ;
168+ const flags = [ '--target-org' , testOrgData . username ] ;
169+
170+ if ( deviceType ) {
171+ flags . push ( '--device-type' , deviceType ) ;
172+ }
173+
174+ if ( appName ) {
175+ flags . push ( '--name' , appName ) ;
176+ }
177+
178+ await MockedLightningPreviewApp . run ( flags ) ;
179+
180+ expect ( runCmdStub . calledOnce ) ;
181+ expect ( runCmdStub . getCall ( 0 ) . args ) . to . deep . equal ( [
182+ 'org:open' ,
183+ [
184+ '--path' ,
185+ `${ expectedAppPath } ?0.aura.ldpServerUrl=${ testServerUrl } &0.aura.ldpServerId=${ testLdpServerId } &0.aura.mode=DEVPREVIEW` ,
186+ '--target-org' ,
187+ testOrgData . username ,
188+ ] ,
189+ ] ) ;
190+ }
163191 } ) ;
164192
165193 describe ( 'mobile dev' , ( ) => {
@@ -240,6 +268,22 @@ describe('lightning dev app', () => {
240268 await verifyMobileThrowsWhenUserDeclinesToInstallApp ( Platform . android ) ;
241269 } ) ;
242270
271+ it ( 'prompts user to select mobile device when not provided' , async ( ) => {
272+ $$ . SANDBOX . stub ( OrgUtils , 'getAppId' ) . resolves ( testAppId ) ;
273+ $$ . SANDBOX . stub ( PreviewUtils , 'generateWebSocketUrlForLocalDevServer' ) . returns ( testServerUrl ) ;
274+ $$ . SANDBOX . stub ( ConfigUtils , 'getIdentityData' ) . resolves ( testIdentityData ) ;
275+
276+ $$ . SANDBOX . stub ( LwcDevMobileCoreSetup . prototype , 'init' ) . resolves ( ) ;
277+ $$ . SANDBOX . stub ( LwcDevMobileCoreSetup . prototype , 'run' ) . resolves ( ) ;
278+
279+ $$ . SANDBOX . stub ( PreviewUtils , 'generateSelfSignedCert' ) . resolves ( certData ) ;
280+ $$ . SANDBOX . stub ( MockedLightningPreviewApp . prototype , 'confirm' ) . resolves ( true ) ;
281+
282+ const promptStub = $$ . SANDBOX . stub ( PromptUtils , 'promptUserToSelectMobileDevice' ) . resolves ( testIOSDevice ) ;
283+ await verifyAppInstallAndLaunch ( Platform . ios ) ;
284+ expect ( promptStub . calledOnce ) ;
285+ } ) ;
286+
243287 it ( 'installs and launches app on mobile device' , async ( ) => {
244288 $$ . SANDBOX . stub ( OrgUtils , 'getAppId' ) . resolves ( testAppId ) ;
245289 $$ . SANDBOX . stub ( PreviewUtils , 'generateWebSocketUrlForLocalDevServer' ) . returns ( testServerUrl ) ;
@@ -396,34 +440,4 @@ describe('lightning dev app', () => {
396440 launchStub . restore ( ) ;
397441 }
398442 } ) ;
399-
400- async function verifyOrgOpen ( expectedAppPath : string , deviceType ?: Platform , appName ?: string ) : Promise < void > {
401- $$ . SANDBOX . stub ( OrgUtils , 'getAppId' ) . resolves ( testAppId ) ;
402- $$ . SANDBOX . stub ( PreviewUtils , 'generateWebSocketUrlForLocalDevServer' ) . returns ( testServerUrl ) ;
403- $$ . SANDBOX . stub ( ConfigUtils , 'getIdentityData' ) . resolves ( testIdentityData ) ;
404-
405- const runCmdStub = $$ . SANDBOX . stub ( OclifConfig . prototype , 'runCommand' ) . resolves ( ) ;
406- const flags = [ '--target-org' , testOrgData . username ] ;
407-
408- if ( deviceType ) {
409- flags . push ( '--device-type' , deviceType ) ;
410- }
411-
412- if ( appName ) {
413- flags . push ( '--name' , appName ) ;
414- }
415-
416- await MockedLightningPreviewApp . run ( flags ) ;
417-
418- expect ( runCmdStub . calledOnce ) ;
419- expect ( runCmdStub . getCall ( 0 ) . args ) . to . deep . equal ( [
420- 'org:open' ,
421- [
422- '--path' ,
423- `${ expectedAppPath } ?0.aura.ldpServerUrl=${ testServerUrl } &0.aura.ldpServerId=${ testLdpServerId } &0.aura.mode=DEVPREVIEW` ,
424- '--target-org' ,
425- testOrgData . username ,
426- ] ,
427- ] ) ;
428- }
429443} ) ;
0 commit comments