Skip to content

Commit 5a8332b

Browse files
committed
chore: merge base branch
1 parent c8707b5 commit 5a8332b

File tree

5 files changed

+27
-19
lines changed

5 files changed

+27
-19
lines changed

src/commands/lightning/preview/app.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ export default class LightningPreviewApp extends SfCommand<void> {
142142
const { flags } = await this.parse(LightningPreviewApp);
143143
const logger = await Logger.child(this.ctor.name);
144144

145-
await startLWCServer(process.cwd(), logger);
146-
147145
const appName = flags['name'];
148146
const platform = flags['device-type'];
149147
const targetOrg = flags['target-org'];
@@ -202,6 +200,8 @@ export default class LightningPreviewApp extends SfCommand<void> {
202200

203201
const launchArguments = PreviewUtils.generateDesktopPreviewLaunchArguments(ldpServerUrl, appId, targetOrg);
204202

203+
await startLWCServer(process.cwd(), logger ? logger : await Logger.child(this.ctor.name));
204+
205205
await this.config.runCommand('org:open', launchArguments);
206206
}
207207

@@ -279,6 +279,7 @@ export default class LightningPreviewApp extends SfCommand<void> {
279279
}
280280
}
281281

282+
await startLWCServer(process.cwd(), logger ? logger : await Logger.child(this.ctor.name));
282283
// 7. Launch the native app for previewing (launchMobileApp will show its own spinner)
283284
// eslint-disable-next-line camelcase
284285
appConfig.launch_arguments = PreviewUtils.generateMobileAppPreviewLaunchArguments(ldpServerUrl, appName, appId);

test/commands/lightning/preview/app.test.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ describe('lightning preview app', () => {
202202
const expectedCertFilePath = '/path/to/cert.pem';
203203
$$.SANDBOX.stub(PreviewUtils, 'generateSelfSignedCert').returns(expectedCertFilePath);
204204

205-
const waitForUserToInstallCertStub = $$.SANDBOX.stub(LightningPreviewApp, 'waitForUserToInstallCert').resolves();
205+
const waitForUserToInstallCertStub = $$.SANDBOX.stub(
206+
MockedLightningPreviewApp,
207+
'waitForUserToInstallCert'
208+
).resolves();
206209

207210
$$.SANDBOX.stub(PreviewUtils, 'verifyMobileAppInstalled').resolves(true);
208211
$$.SANDBOX.stub(PreviewUtils, 'launchMobileApp').resolves();
@@ -235,10 +238,10 @@ describe('lightning preview app', () => {
235238
const expectedCertFilePath = '/path/to/cert.pem';
236239
$$.SANDBOX.stub(PreviewUtils, 'generateSelfSignedCert').returns(expectedCertFilePath);
237240

238-
$$.SANDBOX.stub(LightningPreviewApp, 'waitForUserToInstallCert').resolves();
241+
$$.SANDBOX.stub(MockedLightningPreviewApp, 'waitForUserToInstallCert').resolves();
239242

240243
const verifyMobileAppInstalledStub = $$.SANDBOX.stub(PreviewUtils, 'verifyMobileAppInstalled').resolves(false);
241-
$$.SANDBOX.stub(LightningPreviewApp.prototype, 'confirm').resolves(false);
244+
$$.SANDBOX.stub(MockedLightningPreviewApp.prototype, 'confirm').resolves(false);
242245

243246
await verifyMobileThrowsWhenUserDeclinesToInstallApp(Platform.ios, verifyMobileAppInstalledStub);
244247
await verifyMobileThrowsWhenUserDeclinesToInstallApp(Platform.android, verifyMobileAppInstalledStub);
@@ -260,10 +263,10 @@ describe('lightning preview app', () => {
260263
const expectedCertFilePath = '/path/to/cert.pem';
261264
$$.SANDBOX.stub(PreviewUtils, 'generateSelfSignedCert').returns(expectedCertFilePath);
262265

263-
$$.SANDBOX.stub(LightningPreviewApp, 'waitForUserToInstallCert').resolves();
266+
$$.SANDBOX.stub(MockedLightningPreviewApp, 'waitForUserToInstallCert').resolves();
264267

265268
$$.SANDBOX.stub(PreviewUtils, 'verifyMobileAppInstalled').resolves(false);
266-
$$.SANDBOX.stub(LightningPreviewApp.prototype, 'confirm').resolves(true);
269+
$$.SANDBOX.stub(MockedLightningPreviewApp.prototype, 'confirm').resolves(true);
267270

268271
const iosBundlePath = '/path/to/bundle.zip';
269272
const androidBundlePath = '/path/to/bundle.apk';
@@ -381,9 +384,13 @@ describe('lightning preview app', () => {
381384
const expectedAppConfig =
382385
platform === Platform.ios ? iOSSalesforceAppPreviewConfig : androidSalesforceAppPreviewConfig;
383386
// eslint-disable-next-line camelcase
384-
expectedAppConfig.launch_arguments = PreviewUtils.generateMobileAppPreviewLaunchArguments(expectedLdpServerUrl);
387+
expectedAppConfig.launch_arguments = PreviewUtils.generateMobileAppPreviewLaunchArguments(
388+
expectedLdpServerUrl,
389+
'Sales',
390+
testAppId
391+
);
385392

386-
await LightningPreviewApp.run(['-n', 'Sales', '-o', testOrgData.username, '-t', platform]);
393+
await MockedLightningPreviewApp.run(['-n', 'Sales', '-o', testOrgData.username, '-t', platform]);
387394
expect(downloadStub.calledOnce).to.be.true;
388395

389396
if (platform === Platform.ios) {

test/lwc-dev-server/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('lwc-dev-server', () => {
4040
});
4141

4242
it('calling startLWCServer returns an LWCServer', async () => {
43-
const s = await lwcDevServer.startLWCServer(path.resolve(__dirname, './__mock__'), logger);
43+
const s = await lwcDevServer.startLWCServer(path.resolve(__dirname, './__mocks__'), logger);
4444
expect(s).to.equal(server);
4545
});
4646
});

yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,16 +1121,16 @@
11211121
resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.6.tgz#08bb6612b11bdec78f3feed3db196da682454a5e"
11221122
integrity sha512-4yA7s865JHaqUdRbnaxarZREuPTHrjpDT+pXoAZ1yhyo6uFnIEpS8VMu16siFOHDpZNKYv5BObhsB//ycbICyw==
11231123

1124+
"@babel/helper-validator-option@^7.23.5", "@babel/helper-validator-option@^7.24.7":
1125+
version "7.24.7"
1126+
resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.24.7.tgz#24c3bb77c7a425d1742eec8fb433b5a1b38e62f6"
1127+
integrity sha512-yy1/KvjhV/ZCL+SM7hBrvnZJ3ZuT9OuZgIJAGpPEToANvc3iM6iDvBnRjtElWibHU6n8/LPR/EjX9EtIEYO3pw==
1128+
11241129
"@babel/helper-validator-option@^7.24.6":
11251130
version "7.24.6"
11261131
resolved "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.24.6.tgz#59d8e81c40b7d9109ab7e74457393442177f460a"
11271132
integrity sha512-Jktc8KkF3zIkePb48QO+IapbXlSapOW9S+ogZZkcO6bABgYAxtZcjZ/O005111YLf+j4M84uEgwYoidDkXbCkQ==
11281133

1129-
"@babel/helper-validator-option@^7.24.7":
1130-
version "7.24.7"
1131-
resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.24.7.tgz#24c3bb77c7a425d1742eec8fb433b5a1b38e62f6"
1132-
integrity sha512-yy1/KvjhV/ZCL+SM7hBrvnZJ3ZuT9OuZgIJAGpPEToANvc3iM6iDvBnRjtElWibHU6n8/LPR/EjX9EtIEYO3pw==
1133-
11341134
"@babel/helper-wrap-function@^7.24.7":
11351135
version "7.24.7"
11361136
resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.24.7.tgz#52d893af7e42edca7c6d2c6764549826336aae1f"
@@ -1338,7 +1338,7 @@
13381338
dependencies:
13391339
"@babel/helper-plugin-utils" "^7.8.0"
13401340

1341-
"@babel/plugin-syntax-jsx@7", "@babel/plugin-syntax-jsx@^7.24.7":
1341+
"@babel/plugin-syntax-jsx@7", "@babel/plugin-syntax-jsx@^7.24.1", "@babel/plugin-syntax-jsx@^7.24.7":
13421342
version "7.24.7"
13431343
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.24.7.tgz#39a1fa4a7e3d3d7f34e2acc6be585b718d30e02d"
13441344
integrity sha512-6ddciUPe/mpMnOKv/U+RSd2vvVy+Yw/JfBB0ZHYjEZt9NLHmCUylNYlsbqCCS1Bffjlb0fCwC9Vqz+sBz6PsiQ==
@@ -1623,7 +1623,7 @@
16231623
"@babel/helper-module-transforms" "^7.24.7"
16241624
"@babel/helper-plugin-utils" "^7.24.7"
16251625

1626-
"@babel/plugin-transform-modules-commonjs@^7.24.7":
1626+
"@babel/plugin-transform-modules-commonjs@^7.24.1", "@babel/plugin-transform-modules-commonjs@^7.24.7":
16271627
version "7.24.7"
16281628
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.24.7.tgz#9fd5f7fdadee9085886b183f1ad13d1ab260f4ab"
16291629
integrity sha512-iFI8GDxtevHJ/Z22J5xQpVqFLlMNstcLXh994xifFwxxGslr2ZXXLWgtBeLctOD63UFDArdvN6Tg8RFw+aEmjQ==
@@ -1861,7 +1861,7 @@
18611861
dependencies:
18621862
"@babel/helper-plugin-utils" "^7.24.7"
18631863

1864-
"@babel/plugin-transform-typescript@^7.24.7":
1864+
"@babel/plugin-transform-typescript@^7.24.1", "@babel/plugin-transform-typescript@^7.24.7":
18651865
version "7.24.7"
18661866
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.24.7.tgz#b006b3e0094bf0813d505e0c5485679eeaf4a881"
18671867
integrity sha512-iLD3UNkgx2n/HrjBesVbYX6j0yqn/sJktvbtKKgcaLIQ4bTTQ8obAypc1VpyHPD2y4Phh9zHOaAt8e/L14wCpw==
@@ -2138,7 +2138,7 @@
21382138
"@babel/helper-validator-identifier" "^7.24.5"
21392139
to-fast-properties "^2.0.0"
21402140

2141-
"@babel/types@^7.0.0", "@babel/types@^7.12.11", "@babel/types@^7.20.7", "@babel/types@^7.21.4", "@babel/types@^7.24.0", "@babel/types@^7.24.5", "@babel/types@^7.24.7", "@babel/types@^7.3.3", "@babel/types@^7.4.4", "@babel/types@~7.24.0":
2141+
"@babel/types@^7.0.0", "@babel/types@^7.12.11", "@babel/types@^7.20.7", "@babel/types@^7.21.4", "@babel/types@^7.22.5", "@babel/types@^7.23.0", "@babel/types@^7.24.0", "@babel/types@^7.24.5", "@babel/types@^7.24.7", "@babel/types@^7.3.3", "@babel/types@^7.4.4", "@babel/types@~7.24.0":
21422142
version "7.24.7"
21432143
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.24.7.tgz#6027fe12bc1aa724cd32ab113fb7f1988f1f66f2"
21442144
integrity sha512-XEFXSlxiG5td2EJRe8vOmRbaXVgfcBlszKujvVmWIK/UpywWljQCfzAv3RQCGujWQ1RD4YYWEAqDXfuJiy8f5Q==

0 commit comments

Comments
 (0)