@@ -144,22 +144,50 @@ describe('lightning dev app', () => {
144
144
}
145
145
} ) ;
146
146
147
- describe ( 'interactive ' , ( ) => {
147
+ describe ( 'desktop dev ' , ( ) => {
148
148
it ( 'prompts user to select platform when not provided' , async ( ) => {
149
149
const promptStub = $$ . SANDBOX . stub ( PromptUtils , 'promptUserToSelectPlatform' ) . resolves ( Platform . desktop ) ;
150
150
await verifyOrgOpen ( 'lightning' ) ;
151
151
expect ( promptStub . calledOnce ) ;
152
152
} ) ;
153
- } ) ;
154
153
155
- describe ( 'desktop dev' , ( ) => {
156
154
it ( 'runs org:open with proper flags when app name provided' , async ( ) => {
157
155
await verifyOrgOpen ( `lightning/app/${ testAppId } ` , Platform . desktop , 'Sales' ) ;
158
156
} ) ;
159
157
160
158
it ( 'runs org:open with proper flags when no app name provided' , async ( ) => {
161
159
await verifyOrgOpen ( 'lightning' , Platform . desktop ) ;
162
160
} ) ;
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
+ }
163
191
} ) ;
164
192
165
193
describe ( 'mobile dev' , ( ) => {
@@ -240,6 +268,22 @@ describe('lightning dev app', () => {
240
268
await verifyMobileThrowsWhenUserDeclinesToInstallApp ( Platform . android ) ;
241
269
} ) ;
242
270
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
+
243
287
it ( 'installs and launches app on mobile device' , async ( ) => {
244
288
$$ . SANDBOX . stub ( OrgUtils , 'getAppId' ) . resolves ( testAppId ) ;
245
289
$$ . SANDBOX . stub ( PreviewUtils , 'generateWebSocketUrlForLocalDevServer' ) . returns ( testServerUrl ) ;
@@ -396,34 +440,4 @@ describe('lightning dev app', () => {
396
440
launchStub . restore ( ) ;
397
441
}
398
442
} ) ;
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
- }
429
443
} ) ;
0 commit comments