@salesforce/apex-node 2.1.4 → 2.1.5
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.
- package/lib/src/common/cancellation.js +6 -17
- package/lib/src/common/cancellation.js.map +1 -1
- package/lib/src/execute/executeService.js +52 -69
- package/lib/src/execute/executeService.js.map +1 -1
- package/lib/src/i18n/index.js.map +1 -1
- package/lib/src/i18n/localization.js.map +1 -1
- package/lib/src/logs/logService.js +73 -101
- package/lib/src/logs/logService.js.map +1 -1
- package/lib/src/reporters/coverageReporter.js +4 -6
- package/lib/src/reporters/coverageReporter.js.map +1 -1
- package/lib/src/reporters/humanReporter.js.map +1 -1
- package/lib/src/reporters/junitReporter.js.map +1 -1
- package/lib/src/reporters/tapReporter.js +1 -1
- package/lib/src/reporters/tapReporter.js.map +1 -1
- package/lib/src/streaming/streamingClient.js +98 -119
- package/lib/src/streaming/streamingClient.js.map +1 -1
- package/lib/src/tests/asyncTests.js +234 -247
- package/lib/src/tests/asyncTests.js.map +1 -1
- package/lib/src/tests/codeCoverage.js +85 -99
- package/lib/src/tests/codeCoverage.js.map +1 -1
- package/lib/src/tests/diagnosticUtil.js +1 -2
- package/lib/src/tests/diagnosticUtil.js.map +1 -1
- package/lib/src/tests/syncTests.js +83 -85
- package/lib/src/tests/syncTests.js.map +1 -1
- package/lib/src/tests/testService.js +235 -273
- package/lib/src/tests/testService.js.map +1 -1
- package/lib/src/tests/utils.d.ts +2 -0
- package/lib/src/tests/utils.js +29 -24
- package/lib/src/tests/utils.js.map +1 -1
- package/lib/src/utils/authUtil.js +3 -14
- package/lib/src/utils/authUtil.js.map +1 -1
- package/lib/src/utils/dateUtil.js.map +1 -1
- package/lib/src/utils/fileSystemHandler.js +7 -18
- package/lib/src/utils/fileSystemHandler.js.map +1 -1
- package/lib/src/utils/table.js.map +1 -1
- package/lib/src/utils/traceFlags.js +95 -122
- package/lib/src/utils/traceFlags.js.map +1 -1
- 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
|
-
|
|
34
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
if (
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
230
|
+
return payload;
|
|
271
231
|
}
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
294
|
-
|
|
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
|
-
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if (testParts
|
|
324
|
-
|
|
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
|
-
|
|
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.
|
|
334
|
-
|
|
335
|
-
|
|
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 (
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
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
|
-
|
|
385
|
-
|
|
386
|
-
|
|
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;
|