@salesforce/apex-node 2.1.4 → 2.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/lib/src/common/cancellation.js +6 -17
  2. package/lib/src/common/cancellation.js.map +1 -1
  3. package/lib/src/execute/executeService.js +52 -69
  4. package/lib/src/execute/executeService.js.map +1 -1
  5. package/lib/src/i18n/index.js.map +1 -1
  6. package/lib/src/i18n/localization.js.map +1 -1
  7. package/lib/src/logs/logService.js +73 -101
  8. package/lib/src/logs/logService.js.map +1 -1
  9. package/lib/src/reporters/coverageReporter.js +4 -6
  10. package/lib/src/reporters/coverageReporter.js.map +1 -1
  11. package/lib/src/reporters/humanReporter.js.map +1 -1
  12. package/lib/src/reporters/junitReporter.js.map +1 -1
  13. package/lib/src/reporters/tapReporter.js +1 -1
  14. package/lib/src/reporters/tapReporter.js.map +1 -1
  15. package/lib/src/streaming/streamingClient.js +98 -119
  16. package/lib/src/streaming/streamingClient.js.map +1 -1
  17. package/lib/src/tests/asyncTests.js +234 -247
  18. package/lib/src/tests/asyncTests.js.map +1 -1
  19. package/lib/src/tests/codeCoverage.js +85 -99
  20. package/lib/src/tests/codeCoverage.js.map +1 -1
  21. package/lib/src/tests/diagnosticUtil.js +1 -2
  22. package/lib/src/tests/diagnosticUtil.js.map +1 -1
  23. package/lib/src/tests/syncTests.js +83 -85
  24. package/lib/src/tests/syncTests.js.map +1 -1
  25. package/lib/src/tests/testService.js +235 -273
  26. package/lib/src/tests/testService.js.map +1 -1
  27. package/lib/src/tests/utils.d.ts +2 -0
  28. package/lib/src/tests/utils.js +29 -24
  29. package/lib/src/tests/utils.js.map +1 -1
  30. package/lib/src/utils/authUtil.js +3 -14
  31. package/lib/src/utils/authUtil.js.map +1 -1
  32. package/lib/src/utils/dateUtil.js.map +1 -1
  33. package/lib/src/utils/fileSystemHandler.js +7 -18
  34. package/lib/src/utils/fileSystemHandler.js.map +1 -1
  35. package/lib/src/utils/table.js.map +1 -1
  36. package/lib/src/utils/traceFlags.js +95 -122
  37. package/lib/src/utils/traceFlags.js.map +1 -1
  38. package/package.json +3 -3
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.TestService = void 0;
13
4
  const types_1 = require("./types");
@@ -29,40 +20,34 @@ class TestService {
29
20
  * Retrieve all suites in org
30
21
  * @returns list of Suites in org
31
22
  */
32
- retrieveAllSuites() {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const testSuiteRecords = (yield this.connection.tooling.query(`SELECT id, TestSuiteName FROM ApexTestSuite`));
35
- return testSuiteRecords.records;
36
- });
23
+ async retrieveAllSuites() {
24
+ const testSuiteRecords = (await this.connection.tooling.query(`SELECT id, TestSuiteName FROM ApexTestSuite`));
25
+ return testSuiteRecords.records;
37
26
  }
38
- retrieveSuiteId(suitename) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const suiteResult = (yield this.connection.tooling.query(`SELECT id FROM ApexTestSuite WHERE TestSuiteName = '${suitename}'`));
41
- if (suiteResult.records.length === 0) {
42
- return undefined;
43
- }
44
- return suiteResult.records[0].Id;
45
- });
27
+ async retrieveSuiteId(suitename) {
28
+ const suiteResult = (await this.connection.tooling.query(`SELECT id FROM ApexTestSuite WHERE TestSuiteName = '${suitename}'`));
29
+ if (suiteResult.records.length === 0) {
30
+ return undefined;
31
+ }
32
+ return suiteResult.records[0].Id;
46
33
  }
47
34
  /**
48
35
  * Retrive the ids for the given suites
49
36
  * @param suitenames names of suites
50
37
  * @returns Ids associated with each suite
51
38
  */
52
- getOrCreateSuiteIds(suitenames) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- const suiteIds = suitenames.map((suite) => __awaiter(this, void 0, void 0, function* () {
55
- const suiteId = yield this.retrieveSuiteId(suite);
56
- if (suiteId === undefined) {
57
- const result = (yield this.connection.tooling.create('ApexTestSuite', {
58
- TestSuiteName: suite
59
- }));
60
- return result.id;
61
- }
62
- return suiteId;
63
- }));
64
- return yield Promise.all(suiteIds);
39
+ async getOrCreateSuiteIds(suitenames) {
40
+ const suiteIds = suitenames.map(async (suite) => {
41
+ const suiteId = await this.retrieveSuiteId(suite);
42
+ if (suiteId === undefined) {
43
+ const result = (await this.connection.tooling.create('ApexTestSuite', {
44
+ TestSuiteName: suite
45
+ }));
46
+ return result.id;
47
+ }
48
+ return suiteId;
65
49
  });
50
+ return await Promise.all(suiteIds);
66
51
  }
67
52
  /**
68
53
  * Retrieves the test classes in a given suite
@@ -70,63 +55,57 @@ class TestService {
70
55
  * @param suiteId id of suite
71
56
  * @returns list of test classes in the suite
72
57
  */
73
- getTestsInSuite(suitename, suiteId) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- if (suitename === undefined && suiteId === undefined) {
76
- throw new Error(i18n_1.nls.localize('suitenameErr'));
58
+ async getTestsInSuite(suitename, suiteId) {
59
+ if (suitename === undefined && suiteId === undefined) {
60
+ throw new Error(i18n_1.nls.localize('suitenameErr'));
61
+ }
62
+ if (suitename) {
63
+ suiteId = await this.retrieveSuiteId(suitename);
64
+ if (suiteId === undefined) {
65
+ throw new Error(i18n_1.nls.localize('missingSuiteErr'));
77
66
  }
78
- if (suitename) {
79
- suiteId = yield this.retrieveSuiteId(suitename);
80
- if (suiteId === undefined) {
81
- throw new Error(i18n_1.nls.localize('missingSuiteErr'));
82
- }
83
- }
84
- const classRecords = (yield this.connection.tooling.query(`SELECT ApexClassId FROM TestSuiteMembership WHERE ApexTestSuiteId = '${suiteId}'`));
85
- return classRecords.records;
86
- });
67
+ }
68
+ const classRecords = (await this.connection.tooling.query(`SELECT ApexClassId FROM TestSuiteMembership WHERE ApexTestSuiteId = '${suiteId}'`));
69
+ return classRecords.records;
87
70
  }
88
71
  /**
89
72
  * Returns the associated Ids for each given Apex class
90
73
  * @param testClasses list of Apex class names
91
74
  * @returns the associated ids for each Apex class
92
75
  */
93
- getApexClassIds(testClasses) {
94
- return __awaiter(this, void 0, void 0, function* () {
95
- const classIds = testClasses.map((testClass) => __awaiter(this, void 0, void 0, function* () {
96
- const apexClass = (yield this.connection.tooling.query(`SELECT id, name FROM ApexClass WHERE Name = '${testClass}'`));
97
- if (apexClass.records.length === 0) {
98
- throw new Error(i18n_1.nls.localize('missingTestClassErr', testClass));
99
- }
100
- return apexClass.records[0].Id;
101
- }));
102
- return yield Promise.all(classIds);
76
+ async getApexClassIds(testClasses) {
77
+ const classIds = testClasses.map(async (testClass) => {
78
+ const apexClass = (await this.connection.tooling.query(`SELECT id, name FROM ApexClass WHERE Name = '${testClass}'`));
79
+ if (apexClass.records.length === 0) {
80
+ throw new Error(i18n_1.nls.localize('missingTestClassErr', testClass));
81
+ }
82
+ return apexClass.records[0].Id;
103
83
  });
84
+ return await Promise.all(classIds);
104
85
  }
105
86
  /**
106
87
  * Builds a test suite with the given test classes. Creates the test suite if it doesn't exist already
107
88
  * @param suitename name of suite
108
89
  * @param tests tests to be added to suite
109
90
  */
110
- buildSuite(suitename, testClasses) {
111
- return __awaiter(this, void 0, void 0, function* () {
112
- const testSuiteId = (yield this.getOrCreateSuiteIds([suitename]))[0];
113
- const classesInSuite = yield this.getTestsInSuite(undefined, testSuiteId);
114
- const testClassIds = yield this.getApexClassIds(testClasses);
115
- yield Promise.all(testClassIds.map((classId) => __awaiter(this, void 0, void 0, function* () {
116
- const existingClass = classesInSuite.filter((rec) => rec.ApexClassId === classId);
117
- const testClass = testClasses[testClassIds.indexOf(classId)];
118
- if (existingClass.length > 0) {
119
- console.log(i18n_1.nls.localize('testSuiteMsg', [testClass, suitename]));
120
- }
121
- else {
122
- yield this.connection.tooling.create('TestSuiteMembership', {
123
- ApexClassId: classId,
124
- ApexTestSuiteId: testSuiteId
125
- });
126
- console.log(i18n_1.nls.localize('classSuiteMsg', [testClass, suitename]));
127
- }
128
- })));
129
- });
91
+ async buildSuite(suitename, testClasses) {
92
+ const testSuiteId = (await this.getOrCreateSuiteIds([suitename]))[0];
93
+ const classesInSuite = await this.getTestsInSuite(undefined, testSuiteId);
94
+ const testClassIds = await this.getApexClassIds(testClasses);
95
+ await Promise.all(testClassIds.map(async (classId) => {
96
+ const existingClass = classesInSuite.filter((rec) => rec.ApexClassId === classId);
97
+ const testClass = testClasses[testClassIds.indexOf(classId)];
98
+ if (existingClass.length > 0) {
99
+ console.log(i18n_1.nls.localize('testSuiteMsg', [testClass, suitename]));
100
+ }
101
+ else {
102
+ await this.connection.tooling.create('TestSuiteMembership', {
103
+ ApexClassId: classId,
104
+ ApexTestSuiteId: testSuiteId
105
+ });
106
+ console.log(i18n_1.nls.localize('classSuiteMsg', [testClass, suitename]));
107
+ }
108
+ }));
130
109
  }
131
110
  /**
132
111
  * Synchronous Test Runs
@@ -134,10 +113,8 @@ class TestService {
134
113
  * @param codeCoverage should report code coverage
135
114
  * @param token cancellation token
136
115
  */
137
- runTestSynchronous(options, codeCoverage = false, token) {
138
- return __awaiter(this, void 0, void 0, function* () {
139
- return yield this.syncService.runTests(options, codeCoverage, token);
140
- });
116
+ async runTestSynchronous(options, codeCoverage = false, token) {
117
+ return await this.syncService.runTests(options, codeCoverage, token);
141
118
  }
142
119
  /**
143
120
  * Asynchronous Test Runs
@@ -147,10 +124,8 @@ class TestService {
147
124
  * @param progress progress reporter
148
125
  * @param token cancellation token
149
126
  */
150
- runTestAsynchronous(options, codeCoverage = false, immediatelyReturn = false, progress, token) {
151
- return __awaiter(this, void 0, void 0, function* () {
152
- return yield this.asyncService.runTests(options, codeCoverage, immediatelyReturn, progress, token);
153
- });
127
+ async runTestAsynchronous(options, codeCoverage = false, immediatelyReturn = false, progress, token) {
128
+ return await this.asyncService.runTests(options, codeCoverage, immediatelyReturn, progress, token);
154
129
  }
155
130
  /**
156
131
  * Report Asynchronous Test Run Results
@@ -158,10 +133,8 @@ class TestService {
158
133
  * @param codeCoverage should report code coverages
159
134
  * @param token cancellation token
160
135
  */
161
- reportAsyncResults(testRunId, codeCoverage = false, token) {
162
- return __awaiter(this, void 0, void 0, function* () {
163
- return yield this.asyncService.reportAsyncResults(testRunId, codeCoverage, token);
164
- });
136
+ async reportAsyncResults(testRunId, codeCoverage = false, token) {
137
+ return await this.asyncService.reportAsyncResults(testRunId, codeCoverage, token);
165
138
  }
166
139
  /**
167
140
  *
@@ -170,222 +143,211 @@ class TestService {
170
143
  * @param codeCoverage should report code coverage
171
144
  * @returns list of result files created
172
145
  */
173
- writeResultFiles(result, outputDirConfig, codeCoverage = false) {
174
- return __awaiter(this, void 0, void 0, function* () {
175
- const { dirPath, resultFormats, fileInfos } = outputDirConfig;
176
- const fileMap = [];
177
- const testRunId = result.hasOwnProperty('summary')
178
- ? result.summary.testRunId
179
- : result.testRunId;
180
- fileMap.push({
181
- path: (0, path_1.join)(dirPath, 'test-run-id.txt'),
182
- content: testRunId
183
- });
184
- if (resultFormats) {
185
- if (!result.hasOwnProperty('summary')) {
186
- throw new Error(i18n_1.nls.localize('runIdFormatErr'));
146
+ async writeResultFiles(result, outputDirConfig, codeCoverage = false) {
147
+ const { dirPath, resultFormats, fileInfos } = outputDirConfig;
148
+ const fileMap = [];
149
+ const testRunId = result.hasOwnProperty('summary')
150
+ ? result.summary.testRunId
151
+ : result.testRunId;
152
+ fileMap.push({
153
+ path: (0, path_1.join)(dirPath, 'test-run-id.txt'),
154
+ content: testRunId
155
+ });
156
+ if (resultFormats) {
157
+ if (!result.hasOwnProperty('summary')) {
158
+ throw new Error(i18n_1.nls.localize('runIdFormatErr'));
159
+ }
160
+ result = result;
161
+ for (const format of resultFormats) {
162
+ if (!(format in types_1.ResultFormat)) {
163
+ throw new Error(i18n_1.nls.localize('resultFormatErr'));
187
164
  }
188
- result = result;
189
- for (const format of resultFormats) {
190
- if (!(format in types_1.ResultFormat)) {
191
- throw new Error(i18n_1.nls.localize('resultFormatErr'));
192
- }
193
- switch (format) {
194
- case types_1.ResultFormat.json:
195
- fileMap.push({
196
- path: (0, path_1.join)(dirPath, testRunId ? `test-result-${testRunId}.json` : `test-result.json`),
197
- content: (0, utils_1.stringify)(result)
198
- });
199
- break;
200
- case types_1.ResultFormat.tap:
201
- const tapResult = new reporters_1.TapReporter().format(result);
202
- fileMap.push({
203
- path: (0, path_1.join)(dirPath, `test-result-${testRunId}-tap.txt`),
204
- content: tapResult
205
- });
206
- break;
207
- case types_1.ResultFormat.junit:
208
- const junitResult = new reporters_1.JUnitReporter().format(result);
209
- fileMap.push({
210
- path: (0, path_1.join)(dirPath, testRunId
211
- ? `test-result-${testRunId}-junit.xml`
212
- : `test-result-junit.xml`),
213
- content: junitResult
214
- });
215
- break;
216
- }
165
+ switch (format) {
166
+ case types_1.ResultFormat.json:
167
+ fileMap.push({
168
+ path: (0, path_1.join)(dirPath, testRunId ? `test-result-${testRunId}.json` : `test-result.json`),
169
+ content: (0, utils_1.stringify)(result)
170
+ });
171
+ break;
172
+ case types_1.ResultFormat.tap:
173
+ const tapResult = new reporters_1.TapReporter().format(result);
174
+ fileMap.push({
175
+ path: (0, path_1.join)(dirPath, `test-result-${testRunId}-tap.txt`),
176
+ content: tapResult
177
+ });
178
+ break;
179
+ case types_1.ResultFormat.junit:
180
+ const junitResult = new reporters_1.JUnitReporter().format(result);
181
+ fileMap.push({
182
+ path: (0, path_1.join)(dirPath, testRunId
183
+ ? `test-result-${testRunId}-junit.xml`
184
+ : `test-result-junit.xml`),
185
+ content: junitResult
186
+ });
187
+ break;
217
188
  }
218
189
  }
219
- if (codeCoverage) {
220
- if (!result.hasOwnProperty('summary')) {
221
- throw new Error(i18n_1.nls.localize('covIdFormatErr'));
222
- }
223
- result = result;
224
- const coverageRecords = result.tests.map((record) => {
225
- return record.perClassCoverage;
226
- });
227
- fileMap.push({
228
- path: (0, path_1.join)(dirPath, `test-result-${testRunId}-codecoverage.json`),
229
- content: (0, utils_1.stringify)(coverageRecords)
230
- });
190
+ }
191
+ if (codeCoverage) {
192
+ if (!result.hasOwnProperty('summary')) {
193
+ throw new Error(i18n_1.nls.localize('covIdFormatErr'));
231
194
  }
232
- fileInfos === null || fileInfos === void 0 ? void 0 : fileInfos.forEach((fileInfo) => {
233
- fileMap.push({
234
- path: (0, path_1.join)(dirPath, fileInfo.filename),
235
- content: typeof fileInfo.content !== 'string'
236
- ? (0, utils_1.stringify)(fileInfo.content)
237
- : fileInfo.content
238
- });
195
+ result = result;
196
+ const coverageRecords = result.tests.map((record) => {
197
+ return record.perClassCoverage;
239
198
  });
240
- (0, fileSystemHandler_1.createFiles)(fileMap);
241
- return fileMap.map((file) => {
242
- return file.path;
199
+ fileMap.push({
200
+ path: (0, path_1.join)(dirPath, `test-result-${testRunId}-codecoverage.json`),
201
+ content: (0, utils_1.stringify)(coverageRecords)
202
+ });
203
+ }
204
+ fileInfos?.forEach((fileInfo) => {
205
+ fileMap.push({
206
+ path: (0, path_1.join)(dirPath, fileInfo.filename),
207
+ content: typeof fileInfo.content !== 'string'
208
+ ? (0, utils_1.stringify)(fileInfo.content)
209
+ : fileInfo.content
243
210
  });
244
211
  });
212
+ (0, fileSystemHandler_1.createFiles)(fileMap);
213
+ return fileMap.map((file) => {
214
+ return file.path;
215
+ });
245
216
  }
246
217
  // utils to build test run payloads that may contain namespaces
247
- buildSyncPayload(testLevel, tests, classnames) {
248
- var _a;
249
- return __awaiter(this, void 0, void 0, function* () {
250
- try {
251
- if (tests) {
252
- const payload = yield this.buildTestPayload(tests);
253
- const classes = (_a = payload.tests) === null || _a === void 0 ? void 0 : _a.map((testItem) => {
254
- if (testItem.className) {
255
- return testItem.className;
256
- }
257
- });
258
- if (new Set(classes).size !== 1) {
259
- throw new Error(i18n_1.nls.localize('syncClassErr'));
218
+ async buildSyncPayload(testLevel, tests, classnames) {
219
+ try {
220
+ if (tests) {
221
+ const payload = await this.buildTestPayload(tests);
222
+ const classes = payload.tests?.map((testItem) => {
223
+ if (testItem.className) {
224
+ return testItem.className;
260
225
  }
261
- return payload;
262
- }
263
- else if (classnames) {
264
- const prop = (0, utils_1.isValidApexClassID)(classnames) ? 'classId' : 'className';
265
- return {
266
- tests: [{ [prop]: classnames }],
267
- testLevel
268
- };
226
+ });
227
+ if (new Set(classes).size !== 1) {
228
+ throw new Error(i18n_1.nls.localize('syncClassErr'));
269
229
  }
270
- throw new Error(i18n_1.nls.localize('payloadErr'));
230
+ return payload;
271
231
  }
272
- catch (e) {
273
- throw (0, diagnosticUtil_1.formatTestErrors)(e);
232
+ else if (classnames) {
233
+ const prop = (0, utils_1.isValidApexClassID)(classnames) ? 'classId' : 'className';
234
+ return {
235
+ tests: [{ [prop]: classnames }],
236
+ testLevel
237
+ };
274
238
  }
275
- });
239
+ throw new Error(i18n_1.nls.localize('payloadErr'));
240
+ }
241
+ catch (e) {
242
+ throw (0, diagnosticUtil_1.formatTestErrors)(e);
243
+ }
276
244
  }
277
- buildAsyncPayload(testLevel, tests, classNames, suiteNames) {
278
- return __awaiter(this, void 0, void 0, function* () {
279
- try {
280
- if (tests) {
281
- return (yield this.buildTestPayload(tests));
282
- }
283
- else if (classNames) {
284
- return yield this.buildAsyncClassPayload(classNames);
285
- }
286
- else {
287
- return {
288
- suiteNames,
289
- testLevel
290
- };
291
- }
245
+ async buildAsyncPayload(testLevel, tests, classNames, suiteNames) {
246
+ try {
247
+ if (tests) {
248
+ return (await this.buildTestPayload(tests));
292
249
  }
293
- catch (e) {
294
- throw (0, diagnosticUtil_1.formatTestErrors)(e);
250
+ else if (classNames) {
251
+ return await this.buildAsyncClassPayload(classNames);
295
252
  }
296
- });
253
+ else {
254
+ return {
255
+ suiteNames,
256
+ testLevel
257
+ };
258
+ }
259
+ }
260
+ catch (e) {
261
+ throw (0, diagnosticUtil_1.formatTestErrors)(e);
262
+ }
297
263
  }
298
- buildAsyncClassPayload(classNames) {
299
- return __awaiter(this, void 0, void 0, function* () {
300
- const classNameArray = classNames.split(',');
301
- const classItems = classNameArray.map((item) => {
302
- const classParts = item.split('.');
303
- if (classParts.length > 1) {
304
- return {
305
- className: `${classParts[0]}.${classParts[1]}`
306
- };
307
- }
308
- const prop = (0, utils_1.isValidApexClassID)(item) ? 'classId' : 'className';
309
- return { [prop]: item };
310
- });
311
- return { tests: classItems, testLevel: "RunSpecifiedTests" /* TestLevel.RunSpecifiedTests */ };
264
+ async buildAsyncClassPayload(classNames) {
265
+ const classNameArray = classNames.split(',');
266
+ const classItems = classNameArray.map((item) => {
267
+ const classParts = item.split('.');
268
+ if (classParts.length > 1) {
269
+ return {
270
+ className: `${classParts[0]}.${classParts[1]}`
271
+ };
272
+ }
273
+ const prop = (0, utils_1.isValidApexClassID)(item) ? 'classId' : 'className';
274
+ return { [prop]: item };
312
275
  });
276
+ return { tests: classItems, testLevel: "RunSpecifiedTests" /* TestLevel.RunSpecifiedTests */ };
313
277
  }
314
- buildTestPayload(testNames) {
315
- return __awaiter(this, void 0, void 0, function* () {
316
- const testNameArray = testNames.split(',');
317
- const testItems = [];
318
- const classes = [];
319
- let namespaceInfos;
320
- for (const test of testNameArray) {
321
- if (test.indexOf('.') > 0) {
322
- const testParts = test.split('.');
323
- if (testParts.length === 3) {
324
- if (!classes.includes(testParts[1])) {
278
+ async buildTestPayload(testNames) {
279
+ const testNameArray = testNames.split(',');
280
+ const testItems = [];
281
+ const classes = [];
282
+ let namespaceInfos;
283
+ for (const test of testNameArray) {
284
+ if (test.indexOf('.') > 0) {
285
+ const testParts = test.split('.');
286
+ if (testParts.length === 3) {
287
+ if (!classes.includes(testParts[1])) {
288
+ testItems.push({
289
+ namespace: `${testParts[0]}`,
290
+ className: `${testParts[1]}`,
291
+ testMethods: [testParts[2]]
292
+ });
293
+ classes.push(testParts[1]);
294
+ }
295
+ else {
296
+ testItems.forEach((element) => {
297
+ if (element.className === `${testParts[1]}`) {
298
+ element.namespace = `${testParts[0]}`;
299
+ element.testMethods.push(`${testParts[2]}`);
300
+ }
301
+ });
302
+ }
303
+ }
304
+ else {
305
+ if (typeof namespaceInfos === 'undefined') {
306
+ namespaceInfos = await (0, utils_1.queryNamespaces)(this.connection);
307
+ }
308
+ const currentNamespace = namespaceInfos.find((namespaceInfo) => namespaceInfo.namespace === testParts[0]);
309
+ // NOTE: Installed packages require the namespace to be specified as part of the className field
310
+ // The namespace field should not be used with subscriber orgs
311
+ if (currentNamespace) {
312
+ if (currentNamespace.installedNs) {
325
313
  testItems.push({
326
- namespace: `${testParts[0]}`,
327
- className: `${testParts[1]}`,
328
- testMethods: [testParts[2]]
314
+ className: `${testParts[0]}.${testParts[1]}`
329
315
  });
330
- classes.push(testParts[1]);
331
316
  }
332
317
  else {
333
- testItems.forEach((element) => {
334
- if (element.className === `${testParts[1]}`) {
335
- element.namespace = `${testParts[0]}`;
336
- element.testMethods.push(`${testParts[2]}`);
337
- }
318
+ testItems.push({
319
+ namespace: `${testParts[0]}`,
320
+ className: `${testParts[1]}`
338
321
  });
339
322
  }
340
323
  }
341
324
  else {
342
- if (typeof namespaceInfos === 'undefined') {
343
- namespaceInfos = yield (0, utils_1.queryNamespaces)(this.connection);
344
- }
345
- const currentNamespace = namespaceInfos.find((namespaceInfo) => namespaceInfo.namespace === testParts[0]);
346
- // NOTE: Installed packages require the namespace to be specified as part of the className field
347
- // The namespace field should not be used with subscriber orgs
348
- if (currentNamespace) {
349
- if (currentNamespace.installedNs) {
350
- testItems.push({
351
- className: `${testParts[0]}.${testParts[1]}`
352
- });
353
- }
354
- else {
355
- testItems.push({
356
- namespace: `${testParts[0]}`,
357
- className: `${testParts[1]}`
358
- });
359
- }
325
+ if (!classes.includes(testParts[0])) {
326
+ testItems.push({
327
+ className: testParts[0],
328
+ testMethods: [testParts[1]]
329
+ });
330
+ classes.push(testParts[0]);
360
331
  }
361
332
  else {
362
- if (!classes.includes(testParts[0])) {
363
- testItems.push({
364
- className: testParts[0],
365
- testMethods: [testParts[1]]
366
- });
367
- classes.push(testParts[0]);
368
- }
369
- else {
370
- testItems.forEach((element) => {
371
- if (element.className === testParts[0]) {
372
- element.testMethods.push(testParts[1]);
373
- }
374
- });
375
- }
333
+ testItems.forEach((element) => {
334
+ if (element.className === testParts[0]) {
335
+ element.testMethods.push(testParts[1]);
336
+ }
337
+ });
376
338
  }
377
339
  }
378
340
  }
379
- else {
380
- const prop = (0, utils_1.isValidApexClassID)(test) ? 'classId' : 'className';
381
- testItems.push({ [prop]: test });
382
- }
383
341
  }
384
- return {
385
- tests: testItems,
386
- testLevel: "RunSpecifiedTests" /* TestLevel.RunSpecifiedTests */
387
- };
388
- });
342
+ else {
343
+ const prop = (0, utils_1.isValidApexClassID)(test) ? 'classId' : 'className';
344
+ testItems.push({ [prop]: test });
345
+ }
346
+ }
347
+ return {
348
+ tests: testItems,
349
+ testLevel: "RunSpecifiedTests" /* TestLevel.RunSpecifiedTests */
350
+ };
389
351
  }
390
352
  }
391
353
  exports.TestService = TestService;