@@ -37,6 +37,7 @@ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
37
37
38
38
describe ( 'lightning dev app' , ( ) => {
39
39
const messages = Messages . loadMessages ( '@salesforce/plugin-lightning-dev' , 'lightning.dev.app' ) ;
40
+ const sharedMessages = Messages . loadMessages ( '@salesforce/plugin-lightning-dev' , 'shared.utils' ) ;
40
41
const $$ = new TestContext ( ) ;
41
42
const testOrgData = new MockTestOrgData ( ) ;
42
43
const testAppId = '06m8b000002vpFSAAY' ;
@@ -83,6 +84,7 @@ describe('lightning dev app', () => {
83
84
$$ . SANDBOX . stub ( SfConfig . prototype , 'set' ) ;
84
85
$$ . SANDBOX . stub ( SfConfig . prototype , 'write' ) . resolves ( ) ;
85
86
$$ . SANDBOX . stub ( ConfigUtils , 'getOrCreateIdentityToken' ) . resolves ( fakeIdentityToken ) ;
87
+ $$ . SANDBOX . stub ( OrgUtils , 'isLocalDevEnabled' ) . resolves ( true ) ;
86
88
87
89
MockedLightningPreviewApp = await esmock < typeof LightningDevApp > ( '../../../../src/commands/lightning/dev/app.js' , {
88
90
'../../../../src/lwc-dev-server/index.js' : {
@@ -95,6 +97,16 @@ describe('lightning dev app', () => {
95
97
$$ . restore ( ) ;
96
98
} ) ;
97
99
100
+ it ( 'throws when local dev not enabled' , async ( ) => {
101
+ try {
102
+ $$ . SANDBOX . restore ( ) ;
103
+ $$ . SANDBOX . stub ( OrgUtils , 'isLocalDevEnabled' ) . resolves ( false ) ;
104
+ await MockedLightningPreviewApp . run ( [ '--name' , 'blah' , '-o' , testOrgData . username ] ) ;
105
+ } catch ( err ) {
106
+ expect ( err ) . to . be . an ( 'error' ) . with . property ( 'message' , sharedMessages . getMessage ( 'error.localdev.not.enabled' ) ) ;
107
+ }
108
+ } ) ;
109
+
98
110
it ( 'throws when app not found' , async ( ) => {
99
111
try {
100
112
$$ . SANDBOX . stub ( OrgUtils , 'getAppId' ) . resolves ( undefined ) ;
@@ -226,24 +238,6 @@ describe('lightning dev app', () => {
226
238
await verifyMobileThrowsWhenFailedToGenerateCert ( Platform . android ) ;
227
239
} ) ;
228
240
229
- /* it('waits for user to manually install the certificate', async () => {
230
- $$.SANDBOX.stub(OrgUtils, 'getAppId').resolves(testAppId);
231
- $$.SANDBOX.stub(PreviewUtils, 'generateWebSocketUrlForLocalDevServer').returns(testServerUrl);
232
- $$.SANDBOX.stub(ConfigUtils, 'getIdentityData').resolves(fakeIdentityData);
233
-
234
- $$.SANDBOX.stub(LwcDevMobileCoreSetup.prototype, 'init').resolves();
235
- $$.SANDBOX.stub(LwcDevMobileCoreSetup.prototype, 'run').resolves();
236
-
237
- $$.SANDBOX.stub(PreviewUtils, 'getMobileDevice').callsFake((platform) =>
238
- Promise.resolve(platform === Platform.ios ? testIOSDevice : testAndroidDevice)
239
- );
240
-
241
- $$.SANDBOX.stub(PreviewUtils, 'generateSelfSignedCert').resolves(certData);
242
-
243
- await verifyMobileWaitsForManualCertInstallation(Platform.ios);
244
- await verifyMobileWaitsForManualCertInstallation(Platform.android);
245
- });*/
246
-
247
241
it ( 'throws if user chooses not to install app on mobile device' , async ( ) => {
248
242
$$ . SANDBOX . stub ( OrgUtils , 'getAppId' ) . resolves ( testAppId ) ;
249
243
$$ . SANDBOX . stub ( PreviewUtils , 'generateWebSocketUrlForLocalDevServer' ) . returns ( testServerUrl ) ;
@@ -332,27 +326,6 @@ describe('lightning dev app', () => {
332
326
}
333
327
}
334
328
335
- /* async function verifyMobileWaitsForManualCertInstallation(platform: Platform.ios | Platform.android) {
336
- const installCertStub =
337
- platform === Platform.ios
338
- ? $$.SANDBOX.stub(AppleDevice.prototype, 'installCert').resolves()
339
- : $$.SANDBOX.stub(AndroidDevice.prototype, 'installCert').resolves();
340
-
341
- if (platform === Platform.ios) {
342
- $$.SANDBOX.stub(AppleDevice.prototype, 'boot').resolves();
343
- $$.SANDBOX.stub(AppleDevice.prototype, 'isAppInstalled').resolves(true);
344
- $$.SANDBOX.stub(AppleDevice.prototype, 'launchApp').resolves();
345
- } else {
346
- $$.SANDBOX.stub(AndroidDevice.prototype, 'boot').resolves();
347
- $$.SANDBOX.stub(AndroidDevice.prototype, 'isAppInstalled').resolves(true);
348
- $$.SANDBOX.stub(AndroidDevice.prototype, 'launchApp').resolves();
349
- $$.SANDBOX.stub(AndroidDevice.prototype, 'isCertInstalled').resolves(false);
350
- }
351
-
352
- await MockedLightningPreviewApp.run(['-n', 'Sales', '-o', testOrgData.username, '-t', platform]);
353
- expect(installCertStub.called).to.be.true;
354
- }*/
355
-
356
329
async function verifyMobileThrowsWhenUserDeclinesToInstallApp ( platform : Platform . ios | Platform . android ) {
357
330
if ( platform === Platform . ios ) {
358
331
$$ . SANDBOX . stub ( AppleDevice . prototype , 'boot' ) . resolves ( ) ;
0 commit comments