@@ -37,6 +37,7 @@ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
3737
3838describe ( 'lightning dev app' , ( ) => {
3939 const messages = Messages . loadMessages ( '@salesforce/plugin-lightning-dev' , 'lightning.dev.app' ) ;
40+ const sharedMessages = Messages . loadMessages ( '@salesforce/plugin-lightning-dev' , 'shared.utils' ) ;
4041 const $$ = new TestContext ( ) ;
4142 const testOrgData = new MockTestOrgData ( ) ;
4243 const testAppId = '06m8b000002vpFSAAY' ;
@@ -83,6 +84,7 @@ describe('lightning dev app', () => {
8384 $$ . SANDBOX . stub ( SfConfig . prototype , 'set' ) ;
8485 $$ . SANDBOX . stub ( SfConfig . prototype , 'write' ) . resolves ( ) ;
8586 $$ . SANDBOX . stub ( ConfigUtils , 'getOrCreateIdentityToken' ) . resolves ( fakeIdentityToken ) ;
87+ $$ . SANDBOX . stub ( OrgUtils , 'isLocalDevEnabled' ) . resolves ( true ) ;
8688
8789 MockedLightningPreviewApp = await esmock < typeof LightningDevApp > ( '../../../../src/commands/lightning/dev/app.js' , {
8890 '../../../../src/lwc-dev-server/index.js' : {
@@ -95,6 +97,16 @@ describe('lightning dev app', () => {
9597 $$ . restore ( ) ;
9698 } ) ;
9799
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+
98110 it ( 'throws when app not found' , async ( ) => {
99111 try {
100112 $$ . SANDBOX . stub ( OrgUtils , 'getAppId' ) . resolves ( undefined ) ;
@@ -226,24 +238,6 @@ describe('lightning dev app', () => {
226238 await verifyMobileThrowsWhenFailedToGenerateCert ( Platform . android ) ;
227239 } ) ;
228240
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-
247241 it ( 'throws if user chooses not to install app on mobile device' , async ( ) => {
248242 $$ . SANDBOX . stub ( OrgUtils , 'getAppId' ) . resolves ( testAppId ) ;
249243 $$ . SANDBOX . stub ( PreviewUtils , 'generateWebSocketUrlForLocalDevServer' ) . returns ( testServerUrl ) ;
@@ -332,27 +326,6 @@ describe('lightning dev app', () => {
332326 }
333327 }
334328
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-
356329 async function verifyMobileThrowsWhenUserDeclinesToInstallApp ( platform : Platform . ios | Platform . android ) {
357330 if ( platform === Platform . ios ) {
358331 $$ . SANDBOX . stub ( AppleDevice . prototype , 'boot' ) . resolves ( ) ;
0 commit comments