@reportportal/client-javascript 5.5.12 → 5.6.1
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/README.md +22 -0
- package/VERSION +1 -1
- package/build/commons/config.d.ts +5 -0
- package/build/commons/config.js +125 -0
- package/build/commons/config.js.map +1 -0
- package/build/commons/errors.d.ts +9 -0
- package/build/commons/errors.js +28 -0
- package/build/commons/errors.js.map +1 -0
- package/build/constants/events.d.ts +9 -0
- package/build/constants/events.js +14 -0
- package/build/constants/events.js.map +1 -0
- package/build/constants/index.d.ts +7 -0
- package/build/constants/index.js +19 -0
- package/build/constants/index.js.map +1 -0
- package/build/constants/launchModes.d.ts +4 -0
- package/build/constants/launchModes.js +9 -0
- package/build/constants/launchModes.js.map +1 -0
- package/build/constants/logLevels.d.ts +9 -0
- package/build/constants/logLevels.js +13 -0
- package/build/constants/logLevels.js.map +1 -0
- package/build/constants/mergeTypes.d.ts +4 -0
- package/build/constants/mergeTypes.js +9 -0
- package/build/constants/mergeTypes.js.map +1 -0
- package/build/constants/outputs.d.ts +2 -0
- package/build/constants/outputs.js +35 -0
- package/build/constants/outputs.js.map +1 -0
- package/build/constants/statuses.d.ts +14 -0
- package/build/constants/statuses.js +19 -0
- package/build/constants/statuses.js.map +1 -0
- package/build/constants/testItemTypes.d.ts +17 -0
- package/build/constants/testItemTypes.js +22 -0
- package/build/constants/testItemTypes.js.map +1 -0
- package/build/helpers.d.ts +22 -0
- package/build/helpers.js +110 -0
- package/build/helpers.js.map +1 -0
- package/build/logger.d.ts +2 -0
- package/build/logger.js +28 -0
- package/build/logger.js.map +1 -0
- package/build/models/common.d.ts +37 -0
- package/build/models/common.js +3 -0
- package/build/models/common.js.map +1 -0
- package/build/models/config.d.ts +97 -0
- package/build/models/config.js +3 -0
- package/build/models/config.js.map +1 -0
- package/build/models/index.d.ts +5 -0
- package/build/models/index.js +22 -0
- package/build/models/index.js.map +1 -0
- package/build/models/reporting.d.ts +11 -0
- package/build/models/reporting.js +3 -0
- package/build/models/reporting.js.map +1 -0
- package/build/models/requests.d.ts +84 -0
- package/build/models/requests.js +3 -0
- package/build/models/requests.js.map +1 -0
- package/build/models/responses.d.ts +87 -0
- package/build/models/responses.js +3 -0
- package/build/models/responses.js.map +1 -0
- package/build/oauth.d.ts +42 -0
- package/build/oauth.js +182 -0
- package/build/oauth.js.map +1 -0
- package/build/pjson.d.ts +2 -0
- package/build/pjson.js +28 -0
- package/build/pjson.js.map +1 -0
- package/build/proxyHelper.d.ts +28 -0
- package/build/proxyHelper.js +173 -0
- package/build/proxyHelper.js.map +1 -0
- package/build/publicReportingAPI.d.ts +37 -0
- package/build/publicReportingAPI.js +56 -0
- package/build/publicReportingAPI.js.map +1 -0
- package/build/report-portal-client.d.ts +99 -0
- package/build/report-portal-client.js +607 -0
- package/build/report-portal-client.js.map +1 -0
- package/build/rest.d.ts +23 -0
- package/build/rest.js +205 -0
- package/build/rest.js.map +1 -0
- package/build/statistics/client-id.d.ts +1 -0
- package/build/statistics/client-id.js +73 -0
- package/build/statistics/client-id.js.map +1 -0
- package/build/statistics/constants.d.ts +11 -0
- package/build/statistics/constants.js +52 -0
- package/build/statistics/constants.js.map +1 -0
- package/build/statistics/statistics.d.ts +19 -0
- package/build/statistics/statistics.js +57 -0
- package/build/statistics/statistics.js.map +1 -0
- package/constants.d.ts +1 -0
- package/constants.js +1 -0
- package/helpers.d.ts +2 -0
- package/helpers.js +1 -0
- package/models.d.ts +1 -0
- package/package.json +82 -16
- package/publicReportingAPI.d.ts +2 -0
- package/publicReportingAPI.js +1 -0
- package/index.d.ts +0 -443
- package/lib/commons/config.js +0 -133
- package/lib/commons/errors.js +0 -29
- package/lib/constants/events.js +0 -11
- package/lib/constants/outputs.js +0 -13
- package/lib/constants/statuses.js +0 -12
- package/lib/helpers.js +0 -111
- package/lib/logger.js +0 -41
- package/lib/oauth.js +0 -226
- package/lib/proxyHelper.js +0 -232
- package/lib/publicReportingAPI.js +0 -92
- package/lib/report-portal-client.js +0 -905
- package/lib/rest.js +0 -218
- package/statistics/client-id.js +0 -46
- package/statistics/constants.js +0 -49
- package/statistics/statistics.js +0 -63
|
@@ -1,905 +0,0 @@
|
|
|
1
|
-
/* eslint-disable quotes,no-console,class-methods-use-this */
|
|
2
|
-
const { randomUUID } = require('crypto');
|
|
3
|
-
const { URLSearchParams } = require('url');
|
|
4
|
-
const helpers = require('./helpers');
|
|
5
|
-
const RestClient = require('./rest');
|
|
6
|
-
const { getClientConfig } = require('./commons/config');
|
|
7
|
-
const Statistics = require('../statistics/statistics');
|
|
8
|
-
const { EVENT_NAME } = require('../statistics/constants');
|
|
9
|
-
const { RP_STATUSES } = require('./constants/statuses');
|
|
10
|
-
|
|
11
|
-
const MULTIPART_BOUNDARY = Math.floor(Math.random() * 10000000000).toString();
|
|
12
|
-
|
|
13
|
-
class RPClient {
|
|
14
|
-
/**
|
|
15
|
-
* Create a client for RP.
|
|
16
|
-
* @param {Object} options - config object.
|
|
17
|
-
* options should look like this
|
|
18
|
-
* {
|
|
19
|
-
* apiKey: "reportportalApiKey",
|
|
20
|
-
* endpoint: "http://localhost:8080/api/v1",
|
|
21
|
-
* launch: "YOUR LAUNCH NAME",
|
|
22
|
-
* project: "PROJECT NAME",
|
|
23
|
-
* }
|
|
24
|
-
*
|
|
25
|
-
* @param {Object} agentParams - agent's info object.
|
|
26
|
-
* agentParams should look like this
|
|
27
|
-
* {
|
|
28
|
-
* name: "AGENT NAME",
|
|
29
|
-
* version: "AGENT VERSION",
|
|
30
|
-
* }
|
|
31
|
-
*/
|
|
32
|
-
constructor(options, agentParams) {
|
|
33
|
-
this.config = getClientConfig(options);
|
|
34
|
-
this.debug = this.config.debug;
|
|
35
|
-
this.isLaunchMergeRequired = this.config.isLaunchMergeRequired;
|
|
36
|
-
this.apiKey = this.config.apiKey;
|
|
37
|
-
// deprecated
|
|
38
|
-
this.token = this.apiKey;
|
|
39
|
-
|
|
40
|
-
this.map = {};
|
|
41
|
-
this.baseURL = [this.config.endpoint, this.config.project].join('/');
|
|
42
|
-
|
|
43
|
-
const headers = {
|
|
44
|
-
'User-Agent': 'NodeJS',
|
|
45
|
-
'Content-Type': 'application/json; charset=UTF-8',
|
|
46
|
-
...(this.config.headers || {}),
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// Only set API key header if OAuth is not configured
|
|
50
|
-
// OAuth interceptor will handle Authorization header when configured
|
|
51
|
-
if (!this.config.oauth && this.apiKey) {
|
|
52
|
-
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
this.headers = headers;
|
|
56
|
-
this.helpers = helpers;
|
|
57
|
-
this.restClient = new RestClient({
|
|
58
|
-
baseURL: this.baseURL,
|
|
59
|
-
headers: this.headers,
|
|
60
|
-
restClientConfig: this.config.restClientConfig,
|
|
61
|
-
oauthConfig: this.config.oauth,
|
|
62
|
-
debug: this.debug,
|
|
63
|
-
});
|
|
64
|
-
this.statistics = new Statistics(EVENT_NAME, agentParams);
|
|
65
|
-
this.launchUuid = '';
|
|
66
|
-
this.itemRetriesChainMap = new Map();
|
|
67
|
-
this.itemRetriesChainKeyMapByTempId = new Map();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// eslint-disable-next-line valid-jsdoc
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
* @Private
|
|
74
|
-
*/
|
|
75
|
-
logDebug(msg, dataMsg = '') {
|
|
76
|
-
if (this.debug) {
|
|
77
|
-
console.log(msg, dataMsg);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
calculateItemRetriesChainMapKey(launchId, parentId, name, itemId = '') {
|
|
82
|
-
return `${launchId}__${parentId}__${name}__${itemId}`;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// eslint-disable-next-line valid-jsdoc
|
|
86
|
-
/**
|
|
87
|
-
*
|
|
88
|
-
* @Private
|
|
89
|
-
*/
|
|
90
|
-
cleanItemRetriesChain(tempIds) {
|
|
91
|
-
tempIds.forEach((id) => {
|
|
92
|
-
const key = this.itemRetriesChainKeyMapByTempId.get(id);
|
|
93
|
-
|
|
94
|
-
if (key) {
|
|
95
|
-
this.itemRetriesChainMap.delete(key);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
this.itemRetriesChainKeyMapByTempId.delete(id);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
getUniqId() {
|
|
103
|
-
return randomUUID();
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
getRejectAnswer(tempId, error) {
|
|
107
|
-
return {
|
|
108
|
-
tempId,
|
|
109
|
-
promise: Promise.reject(error),
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
getNewItemObj(startPromiseFunc) {
|
|
114
|
-
let resolveFinish;
|
|
115
|
-
let rejectFinish;
|
|
116
|
-
const obj = {
|
|
117
|
-
promiseStart: new Promise(startPromiseFunc),
|
|
118
|
-
realId: '',
|
|
119
|
-
children: [],
|
|
120
|
-
finishSend: false,
|
|
121
|
-
promiseFinish: new Promise((resolve, reject) => {
|
|
122
|
-
resolveFinish = resolve;
|
|
123
|
-
rejectFinish = reject;
|
|
124
|
-
}),
|
|
125
|
-
};
|
|
126
|
-
obj.resolveFinish = resolveFinish;
|
|
127
|
-
obj.rejectFinish = rejectFinish;
|
|
128
|
-
return obj;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// eslint-disable-next-line valid-jsdoc
|
|
132
|
-
/**
|
|
133
|
-
*
|
|
134
|
-
* @Private
|
|
135
|
-
*/
|
|
136
|
-
cleanMap(ids) {
|
|
137
|
-
ids.forEach((id) => {
|
|
138
|
-
delete this.map[id];
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
checkConnect() {
|
|
143
|
-
const url = [this.config.endpoint.replace('/v2', '/v1'), this.config.project, 'launch']
|
|
144
|
-
.join('/')
|
|
145
|
-
.concat('?page.page=1&page.size=1');
|
|
146
|
-
return this.restClient.request('GET', url, {});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
getServerInfoUrl() {
|
|
150
|
-
return this.config.endpoint.replace('/v1', '/info').replace('/v2', '/info');
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
async fetchServerInfo() {
|
|
154
|
-
const url = this.getServerInfoUrl();
|
|
155
|
-
return this.restClient.request('GET', url, {});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async triggerStatisticsEvent() {
|
|
159
|
-
if (process.env.REPORTPORTAL_CLIENT_JS_NO_ANALYTICS) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
try {
|
|
163
|
-
const serverInfo = await this.fetchServerInfo();
|
|
164
|
-
const instanceID = serverInfo?.extensions?.result?.['server.details.instance'];
|
|
165
|
-
if (instanceID) {
|
|
166
|
-
this.statistics.setInstanceID(instanceID);
|
|
167
|
-
}
|
|
168
|
-
} catch (e) {
|
|
169
|
-
this.statistics.setInstanceID('not_set');
|
|
170
|
-
}
|
|
171
|
-
await this.statistics.trackEvent();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Start launch and report it.
|
|
176
|
-
* @param {Object} launchDataRQ - request object.
|
|
177
|
-
* launchDataRQ should look like this
|
|
178
|
-
* {
|
|
179
|
-
"description": "string" (support markdown),
|
|
180
|
-
"mode": "DEFAULT" or "DEBUG",
|
|
181
|
-
"name": "string",
|
|
182
|
-
"startTime": this.helper.now(),
|
|
183
|
-
"attributes": [
|
|
184
|
-
{
|
|
185
|
-
"key": "string",
|
|
186
|
-
"value": "string"
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
"value": "string"
|
|
190
|
-
}
|
|
191
|
-
]
|
|
192
|
-
* }
|
|
193
|
-
* @Returns an object which contains a tempID and a promise
|
|
194
|
-
*
|
|
195
|
-
* As system attributes, this method sends the following data (these data are not for public use):
|
|
196
|
-
* client name, version;
|
|
197
|
-
* agent name, version (if given);
|
|
198
|
-
* browser name, version (if given);
|
|
199
|
-
* OS type, architecture;
|
|
200
|
-
* RAMSize;
|
|
201
|
-
* nodeJS version;
|
|
202
|
-
*
|
|
203
|
-
* This method works in two ways:
|
|
204
|
-
* First - If launchDataRQ object doesn't contain ID field,
|
|
205
|
-
* it would create a new Launch instance at the Report Portal with it ID.
|
|
206
|
-
* Second - If launchDataRQ would contain ID field,
|
|
207
|
-
* client would connect to the existing Launch which ID
|
|
208
|
-
* has been sent , and would send all data to it.
|
|
209
|
-
* Notice that Launch which ID has been sent must be 'IN PROGRESS' state at the Report Portal
|
|
210
|
-
* or it would throw an error.
|
|
211
|
-
* @Returns {Object} - an object which contains a tempID and a promise
|
|
212
|
-
*/
|
|
213
|
-
startLaunch(launchDataRQ) {
|
|
214
|
-
const tempId = this.getUniqId();
|
|
215
|
-
|
|
216
|
-
if (launchDataRQ.id) {
|
|
217
|
-
this.logDebug(`Use existing launch with tempId ${tempId}`, launchDataRQ);
|
|
218
|
-
this.map[tempId] = this.getNewItemObj((resolve) => resolve(launchDataRQ));
|
|
219
|
-
this.map[tempId].realId = launchDataRQ.id;
|
|
220
|
-
this.launchUuid = launchDataRQ.id;
|
|
221
|
-
} else {
|
|
222
|
-
const systemAttr = helpers.getSystemAttribute();
|
|
223
|
-
if (this.config.skippedIsNotIssue === true) {
|
|
224
|
-
const skippedIsNotIssueAttribute = {
|
|
225
|
-
key: 'skippedIssue',
|
|
226
|
-
value: 'false',
|
|
227
|
-
system: true,
|
|
228
|
-
};
|
|
229
|
-
systemAttr.push(skippedIsNotIssueAttribute);
|
|
230
|
-
}
|
|
231
|
-
const attributes = Array.isArray(launchDataRQ.attributes)
|
|
232
|
-
? launchDataRQ.attributes.concat(systemAttr)
|
|
233
|
-
: systemAttr;
|
|
234
|
-
const launchData = {
|
|
235
|
-
name: this.config.launch || 'Test launch name',
|
|
236
|
-
startTime: this.helpers.now(),
|
|
237
|
-
...launchDataRQ,
|
|
238
|
-
attributes,
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
this.map[tempId] = this.getNewItemObj((resolve, reject) => {
|
|
242
|
-
const url = 'launch';
|
|
243
|
-
this.logDebug(`Start launch with tempId ${tempId}`, launchData);
|
|
244
|
-
this.restClient.create(url, launchData).then(
|
|
245
|
-
(response) => {
|
|
246
|
-
this.map[tempId].realId = response.id;
|
|
247
|
-
this.launchUuid = response.id;
|
|
248
|
-
if (this.config.launchUuidPrint) {
|
|
249
|
-
this.config.launchUuidPrintOutput(this.launchUuid);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (this.isLaunchMergeRequired) {
|
|
253
|
-
helpers.saveLaunchIdToFile(response.id);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
this.logDebug(`Success start launch with tempId ${tempId}`, response);
|
|
257
|
-
resolve(response);
|
|
258
|
-
},
|
|
259
|
-
(error) => {
|
|
260
|
-
this.logDebug(`Error start launch with tempId ${tempId}`, error);
|
|
261
|
-
console.dir(error);
|
|
262
|
-
reject(error);
|
|
263
|
-
},
|
|
264
|
-
);
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
this.triggerStatisticsEvent().catch(console.error);
|
|
268
|
-
return {
|
|
269
|
-
tempId,
|
|
270
|
-
promise: this.map[tempId].promiseStart,
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Finish launch.
|
|
276
|
-
* @param {string} launchTempId - temp launch id (returned in the query "startLaunch").
|
|
277
|
-
* @param {Object} finishExecutionRQ - finish launch info should include time and status.
|
|
278
|
-
* finishExecutionRQ should look like this
|
|
279
|
-
* {
|
|
280
|
-
* "endTime": this.helper.now(),
|
|
281
|
-
* "status": "passed" or one of ‘passed’, ‘failed’, ‘stopped’, ‘skipped’, ‘interrupted’, ‘cancelled’
|
|
282
|
-
* }
|
|
283
|
-
* @Returns {Object} - an object which contains a tempID and a promise
|
|
284
|
-
*/
|
|
285
|
-
finishLaunch(launchTempId, finishExecutionRQ) {
|
|
286
|
-
const launchObj = this.map[launchTempId];
|
|
287
|
-
if (!launchObj) {
|
|
288
|
-
return this.getRejectAnswer(
|
|
289
|
-
launchTempId,
|
|
290
|
-
new Error(`Launch with tempId "${launchTempId}" not found`),
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const finishExecutionData = { endTime: this.helpers.now(), ...finishExecutionRQ };
|
|
295
|
-
|
|
296
|
-
launchObj.finishSend = true;
|
|
297
|
-
Promise.all(launchObj.children.map((itemId) => this.map[itemId].promiseFinish)).then(
|
|
298
|
-
() => {
|
|
299
|
-
launchObj.promiseStart.then(
|
|
300
|
-
() => {
|
|
301
|
-
this.logDebug(`Finish launch with tempId ${launchTempId}`, finishExecutionData);
|
|
302
|
-
const url = ['launch', launchObj.realId, 'finish'].join('/');
|
|
303
|
-
this.restClient.update(url, finishExecutionData).then(
|
|
304
|
-
(response) => {
|
|
305
|
-
this.logDebug(`Success finish launch with tempId ${launchTempId}`, response);
|
|
306
|
-
console.log(`\nReportPortal Launch Link: ${response.link}`);
|
|
307
|
-
launchObj.resolveFinish(response);
|
|
308
|
-
},
|
|
309
|
-
(error) => {
|
|
310
|
-
this.logDebug(`Error finish launch with tempId ${launchTempId}`, error);
|
|
311
|
-
console.dir(error);
|
|
312
|
-
launchObj.rejectFinish(error);
|
|
313
|
-
},
|
|
314
|
-
);
|
|
315
|
-
},
|
|
316
|
-
(error) => {
|
|
317
|
-
console.dir(error);
|
|
318
|
-
launchObj.rejectFinish(error);
|
|
319
|
-
},
|
|
320
|
-
);
|
|
321
|
-
},
|
|
322
|
-
(error) => {
|
|
323
|
-
console.dir(error);
|
|
324
|
-
launchObj.rejectFinish(error);
|
|
325
|
-
},
|
|
326
|
-
);
|
|
327
|
-
|
|
328
|
-
return {
|
|
329
|
-
tempId: launchTempId,
|
|
330
|
-
promise: launchObj.promiseFinish,
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/*
|
|
335
|
-
* This method is used to create data object for merge request to ReportPortal.
|
|
336
|
-
*
|
|
337
|
-
* @Returns {Object} - an object which contains a data for merge launches in ReportPortal.
|
|
338
|
-
*/
|
|
339
|
-
getMergeLaunchesRequest(launchIds, mergeOptions = {}) {
|
|
340
|
-
return {
|
|
341
|
-
launches: launchIds,
|
|
342
|
-
mergeType: 'BASIC',
|
|
343
|
-
description: this.config.description || 'Merged launch',
|
|
344
|
-
mode: this.config.mode || 'DEFAULT',
|
|
345
|
-
name: this.config.launch || 'Test launch name',
|
|
346
|
-
attributes: this.config.attributes,
|
|
347
|
-
endTime: this.helpers.now(),
|
|
348
|
-
extendSuitesDescription: true,
|
|
349
|
-
...mergeOptions,
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* This method is used for merge launches in ReportPortal.
|
|
355
|
-
* @param {Object} mergeOptions - options for merge request, can override default options.
|
|
356
|
-
* mergeOptions should look like this
|
|
357
|
-
* {
|
|
358
|
-
* "extendSuitesDescription": boolean,
|
|
359
|
-
* "description": string,
|
|
360
|
-
* "mergeType": 'BASIC' | 'DEEP',
|
|
361
|
-
* "name": string
|
|
362
|
-
* }
|
|
363
|
-
* Please, keep in mind that this method is work only in case
|
|
364
|
-
* the option isLaunchMergeRequired is true.
|
|
365
|
-
*
|
|
366
|
-
* @returns {Promise} - action promise
|
|
367
|
-
*/
|
|
368
|
-
mergeLaunches(mergeOptions = {}) {
|
|
369
|
-
if (this.isLaunchMergeRequired) {
|
|
370
|
-
const launchUUIds = helpers.readLaunchesFromFile();
|
|
371
|
-
const params = new URLSearchParams({
|
|
372
|
-
'filter.in.uuid': launchUUIds,
|
|
373
|
-
'page.size': launchUUIds.length,
|
|
374
|
-
});
|
|
375
|
-
const launchSearchUrl =
|
|
376
|
-
this.config.mode === 'DEBUG'
|
|
377
|
-
? `launch/mode?${params.toString()}`
|
|
378
|
-
: `launch?${params.toString()}`;
|
|
379
|
-
this.logDebug(`Find launches with UUIDs to merge: ${launchUUIds}`);
|
|
380
|
-
return this.restClient
|
|
381
|
-
.retrieveSyncAPI(launchSearchUrl)
|
|
382
|
-
.then(
|
|
383
|
-
(response) => {
|
|
384
|
-
const launchIds = response.content.map((launch) => launch.id);
|
|
385
|
-
this.logDebug(`Found launches: ${launchIds}`, response.content);
|
|
386
|
-
return launchIds;
|
|
387
|
-
},
|
|
388
|
-
(error) => {
|
|
389
|
-
this.logDebug(`Error during launches search with UUIDs: ${launchUUIds}`, error);
|
|
390
|
-
console.dir(error);
|
|
391
|
-
},
|
|
392
|
-
)
|
|
393
|
-
.then((launchIds) => {
|
|
394
|
-
const request = this.getMergeLaunchesRequest(launchIds, mergeOptions);
|
|
395
|
-
this.logDebug(`Merge launches with ids: ${launchIds}`, request);
|
|
396
|
-
const mergeURL = 'launch/merge';
|
|
397
|
-
return this.restClient.create(mergeURL, request);
|
|
398
|
-
})
|
|
399
|
-
.then((response) => {
|
|
400
|
-
this.logDebug(`Launches with UUIDs: ${launchUUIds} were successfully merged!`);
|
|
401
|
-
if (this.config.launchUuidPrint) {
|
|
402
|
-
this.config.launchUuidPrintOutput(response.uuid);
|
|
403
|
-
}
|
|
404
|
-
})
|
|
405
|
-
.catch((error) => {
|
|
406
|
-
this.logDebug(`Error merging launches with UUIDs: ${launchUUIds}`, error);
|
|
407
|
-
console.dir(error);
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
this.logDebug(
|
|
411
|
-
'Option isLaunchMergeRequired is false, merge process cannot be done as no launch UUIDs where saved.',
|
|
412
|
-
);
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/*
|
|
416
|
-
* This method is used for frameworks as Jasmine. There is problem when
|
|
417
|
-
* it doesn't wait for promise resolve and stop the process. So it better to call
|
|
418
|
-
* this method at the spec's function as @afterAll() and manually resolve this promise.
|
|
419
|
-
*
|
|
420
|
-
* @return Promise
|
|
421
|
-
*/
|
|
422
|
-
getPromiseFinishAllItems(launchTempId) {
|
|
423
|
-
const launchObj = this.map[launchTempId];
|
|
424
|
-
return Promise.all(launchObj.children.map((itemId) => this.map[itemId].promiseFinish));
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Update launch.
|
|
429
|
-
* @param {string} launchTempId - temp launch id (returned in the query "startLaunch").
|
|
430
|
-
* @param {Object} launchData - new launch data
|
|
431
|
-
* launchData should look like this
|
|
432
|
-
* {
|
|
433
|
-
"description": "string" (support markdown),
|
|
434
|
-
"mode": "DEFAULT" or "DEBUG",
|
|
435
|
-
"attributes": [
|
|
436
|
-
{
|
|
437
|
-
"key": "string",
|
|
438
|
-
"value": "string"
|
|
439
|
-
},
|
|
440
|
-
{
|
|
441
|
-
"value": "string"
|
|
442
|
-
}
|
|
443
|
-
]
|
|
444
|
-
}
|
|
445
|
-
* @Returns {Object} - an object which contains a tempId and a promise
|
|
446
|
-
*/
|
|
447
|
-
updateLaunch(launchTempId, launchData) {
|
|
448
|
-
const launchObj = this.map[launchTempId];
|
|
449
|
-
if (!launchObj) {
|
|
450
|
-
return this.getRejectAnswer(
|
|
451
|
-
launchTempId,
|
|
452
|
-
new Error(`Launch with tempId "${launchTempId}" not found`),
|
|
453
|
-
);
|
|
454
|
-
}
|
|
455
|
-
let resolvePromise;
|
|
456
|
-
let rejectPromise;
|
|
457
|
-
const promise = new Promise((resolve, reject) => {
|
|
458
|
-
resolvePromise = resolve;
|
|
459
|
-
rejectPromise = reject;
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
launchObj.promiseFinish.then(
|
|
463
|
-
() => {
|
|
464
|
-
const url = ['launch', launchObj.realId, 'update'].join('/');
|
|
465
|
-
this.logDebug(`Update launch with tempId ${launchTempId}`, launchData);
|
|
466
|
-
this.restClient.update(url, launchData).then(
|
|
467
|
-
(response) => {
|
|
468
|
-
this.logDebug(`Launch with tempId ${launchTempId} were successfully updated`, response);
|
|
469
|
-
resolvePromise(response);
|
|
470
|
-
},
|
|
471
|
-
(error) => {
|
|
472
|
-
this.logDebug(`Error when updating launch with tempId ${launchTempId}`, error);
|
|
473
|
-
console.dir(error);
|
|
474
|
-
rejectPromise(error);
|
|
475
|
-
},
|
|
476
|
-
);
|
|
477
|
-
},
|
|
478
|
-
(error) => {
|
|
479
|
-
rejectPromise(error);
|
|
480
|
-
},
|
|
481
|
-
);
|
|
482
|
-
return {
|
|
483
|
-
tempId: launchTempId,
|
|
484
|
-
promise,
|
|
485
|
-
};
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* If there is no parentItemId starts Suite, else starts test or item.
|
|
490
|
-
* @param {Object} testItemDataRQ - object with item parameters
|
|
491
|
-
* testItemDataRQ should look like this
|
|
492
|
-
* {
|
|
493
|
-
"description": "string" (support markdown),
|
|
494
|
-
"name": "string",
|
|
495
|
-
"startTime": this.helper.now(),
|
|
496
|
-
"attributes": [
|
|
497
|
-
{
|
|
498
|
-
"key": "string",
|
|
499
|
-
"value": "string"
|
|
500
|
-
},
|
|
501
|
-
{
|
|
502
|
-
"value": "string"
|
|
503
|
-
}
|
|
504
|
-
],
|
|
505
|
-
"type": 'SUITE' or one of 'SUITE', 'STORY', 'TEST',
|
|
506
|
-
'SCENARIO', 'STEP', 'BEFORE_CLASS', 'BEFORE_GROUPS',
|
|
507
|
-
'BEFORE_METHOD', 'BEFORE_SUITE', 'BEFORE_TEST',
|
|
508
|
-
'AFTER_CLASS', 'AFTER_GROUPS', 'AFTER_METHOD',
|
|
509
|
-
'AFTER_SUITE', 'AFTER_TEST'
|
|
510
|
-
}
|
|
511
|
-
* @param {string} launchTempId - temp launch id (returned in the query "startLaunch").
|
|
512
|
-
* @param {string} parentTempId (optional) - temp item id (returned in the query "startTestItem").
|
|
513
|
-
* @Returns {Object} - an object which contains a tempId and a promise
|
|
514
|
-
*/
|
|
515
|
-
startTestItem(testItemDataRQ, launchTempId, parentTempId) {
|
|
516
|
-
let parentMapId = launchTempId;
|
|
517
|
-
const launchObj = this.map[launchTempId];
|
|
518
|
-
if (!launchObj) {
|
|
519
|
-
return this.getRejectAnswer(
|
|
520
|
-
launchTempId,
|
|
521
|
-
new Error(`Launch with tempId "${launchTempId}" not found`),
|
|
522
|
-
);
|
|
523
|
-
}
|
|
524
|
-
// TODO: Allow items reporting to finished launch
|
|
525
|
-
if (launchObj.finishSend) {
|
|
526
|
-
const err = new Error(
|
|
527
|
-
`Launch with tempId "${launchTempId}" is already finished, you can not add an item to it`,
|
|
528
|
-
);
|
|
529
|
-
return this.getRejectAnswer(launchTempId, err);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
const testCaseId =
|
|
533
|
-
testItemDataRQ.testCaseId ||
|
|
534
|
-
helpers.generateTestCaseId(testItemDataRQ.codeRef, testItemDataRQ.parameters);
|
|
535
|
-
const testItemData = {
|
|
536
|
-
startTime: this.helpers.now(),
|
|
537
|
-
...testItemDataRQ,
|
|
538
|
-
...(testCaseId && { testCaseId }),
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
let parentPromise = launchObj.promiseStart;
|
|
542
|
-
if (parentTempId) {
|
|
543
|
-
parentMapId = parentTempId;
|
|
544
|
-
const parentObj = this.map[parentTempId];
|
|
545
|
-
if (!parentObj) {
|
|
546
|
-
return this.getRejectAnswer(
|
|
547
|
-
launchTempId,
|
|
548
|
-
new Error(`Item with tempId "${parentTempId}" not found`),
|
|
549
|
-
);
|
|
550
|
-
}
|
|
551
|
-
parentPromise = parentObj.promiseStart;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
const itemKey = this.calculateItemRetriesChainMapKey(
|
|
555
|
-
launchTempId,
|
|
556
|
-
parentTempId,
|
|
557
|
-
testItemDataRQ.name,
|
|
558
|
-
testItemDataRQ.uniqueId,
|
|
559
|
-
);
|
|
560
|
-
const executionItemPromise = testItemDataRQ.retry && this.itemRetriesChainMap.get(itemKey);
|
|
561
|
-
|
|
562
|
-
const tempId = this.getUniqId();
|
|
563
|
-
this.map[tempId] = this.getNewItemObj((resolve, reject) => {
|
|
564
|
-
(executionItemPromise || parentPromise).then(
|
|
565
|
-
() => {
|
|
566
|
-
const realLaunchId = this.map[launchTempId].realId;
|
|
567
|
-
let url = 'item/';
|
|
568
|
-
if (parentTempId) {
|
|
569
|
-
const realParentId = this.map[parentTempId].realId;
|
|
570
|
-
url += `${realParentId}`;
|
|
571
|
-
}
|
|
572
|
-
testItemData.launchUuid = realLaunchId;
|
|
573
|
-
this.logDebug(`Start test item with tempId ${tempId}`, testItemData);
|
|
574
|
-
this.restClient.create(url, testItemData).then(
|
|
575
|
-
(response) => {
|
|
576
|
-
this.logDebug(`Success start item with tempId ${tempId}`, response);
|
|
577
|
-
this.map[tempId].realId = response.id;
|
|
578
|
-
resolve(response);
|
|
579
|
-
},
|
|
580
|
-
(error) => {
|
|
581
|
-
this.logDebug(`Error start item with tempId ${tempId}`, error);
|
|
582
|
-
console.dir(error);
|
|
583
|
-
reject(error);
|
|
584
|
-
},
|
|
585
|
-
);
|
|
586
|
-
},
|
|
587
|
-
(error) => {
|
|
588
|
-
reject(error);
|
|
589
|
-
},
|
|
590
|
-
);
|
|
591
|
-
});
|
|
592
|
-
this.map[parentMapId].children.push(tempId);
|
|
593
|
-
this.itemRetriesChainKeyMapByTempId.set(tempId, itemKey);
|
|
594
|
-
this.itemRetriesChainMap.set(itemKey, this.map[tempId].promiseStart);
|
|
595
|
-
|
|
596
|
-
return {
|
|
597
|
-
tempId,
|
|
598
|
-
promise: this.map[tempId].promiseStart,
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
* Finish Suite or Step level.
|
|
604
|
-
* @param {string} itemTempId - temp item id (returned in the query "startTestItem").
|
|
605
|
-
* @param {Object} finishTestItemRQ - object with item parameters.
|
|
606
|
-
* finishTestItemRQ should look like this
|
|
607
|
-
{
|
|
608
|
-
"endTime": this.helper.now(),
|
|
609
|
-
"issue": {
|
|
610
|
-
"comment": "string",
|
|
611
|
-
"externalSystemIssues": [
|
|
612
|
-
{
|
|
613
|
-
"submitDate": 0,
|
|
614
|
-
"submitter": "string",
|
|
615
|
-
"systemId": "string",
|
|
616
|
-
"ticketId": "string",
|
|
617
|
-
"url": "string"
|
|
618
|
-
}
|
|
619
|
-
],
|
|
620
|
-
"issueType": "string"
|
|
621
|
-
},
|
|
622
|
-
"status": "passed" or one of 'passed', 'failed', 'stopped', 'skipped', 'interrupted', 'cancelled'
|
|
623
|
-
}
|
|
624
|
-
* @Returns {Object} - an object which contains a tempId and a promise
|
|
625
|
-
*/
|
|
626
|
-
finishTestItem(itemTempId, finishTestItemRQ) {
|
|
627
|
-
const itemObj = this.map[itemTempId];
|
|
628
|
-
if (!itemObj) {
|
|
629
|
-
return this.getRejectAnswer(
|
|
630
|
-
itemTempId,
|
|
631
|
-
new Error(`Item with tempId "${itemTempId}" not found`),
|
|
632
|
-
);
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
const finishTestItemData = {
|
|
636
|
-
endTime: this.helpers.now(),
|
|
637
|
-
...(itemObj.children.length ? {} : { status: RP_STATUSES.PASSED }),
|
|
638
|
-
...finishTestItemRQ,
|
|
639
|
-
};
|
|
640
|
-
|
|
641
|
-
if (
|
|
642
|
-
finishTestItemData.status === RP_STATUSES.SKIPPED &&
|
|
643
|
-
this.config.skippedIsNotIssue === true
|
|
644
|
-
) {
|
|
645
|
-
finishTestItemData.issue = { issueType: 'NOT_ISSUE' };
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
itemObj.finishSend = true;
|
|
649
|
-
this.logDebug(`Finish all children for test item with tempId ${itemTempId}`);
|
|
650
|
-
Promise.allSettled(
|
|
651
|
-
itemObj.children.map((itemId) => this.map[itemId] && this.map[itemId].promiseFinish),
|
|
652
|
-
)
|
|
653
|
-
.then((results) => {
|
|
654
|
-
if (this.debug) {
|
|
655
|
-
results.forEach((result, index) => {
|
|
656
|
-
if (result.status === 'fulfilled') {
|
|
657
|
-
this.logDebug(
|
|
658
|
-
`Successfully finish child with tempId ${itemObj.children[index]}
|
|
659
|
-
of test item with tempId ${itemTempId}`,
|
|
660
|
-
);
|
|
661
|
-
} else {
|
|
662
|
-
this.logDebug(
|
|
663
|
-
`Failed to finish child with tempId ${itemObj.children[index]}
|
|
664
|
-
of test item with tempId ${itemTempId}`,
|
|
665
|
-
);
|
|
666
|
-
}
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
this.cleanItemRetriesChain(itemObj.children);
|
|
670
|
-
this.cleanMap(itemObj.children);
|
|
671
|
-
|
|
672
|
-
this.logDebug(`Finish test item with tempId ${itemTempId}`, finishTestItemRQ);
|
|
673
|
-
this.finishTestItemPromiseStart(
|
|
674
|
-
itemObj,
|
|
675
|
-
itemTempId,
|
|
676
|
-
Object.assign(finishTestItemData, { launchUuid: this.launchUuid }),
|
|
677
|
-
);
|
|
678
|
-
})
|
|
679
|
-
.catch(() => {
|
|
680
|
-
this.logDebug(`Error finish children of test item with tempId ${itemTempId}`);
|
|
681
|
-
});
|
|
682
|
-
|
|
683
|
-
return {
|
|
684
|
-
tempId: itemTempId,
|
|
685
|
-
promise: itemObj.promiseFinish,
|
|
686
|
-
};
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
saveLog(itemObj, requestPromiseFunc) {
|
|
690
|
-
const tempId = this.getUniqId();
|
|
691
|
-
this.map[tempId] = this.getNewItemObj((resolve, reject) => {
|
|
692
|
-
itemObj.promiseStart.then(
|
|
693
|
-
() => {
|
|
694
|
-
this.logDebug(`Save log with tempId ${tempId}`, itemObj);
|
|
695
|
-
requestPromiseFunc(itemObj.realId, this.launchUuid).then(
|
|
696
|
-
(response) => {
|
|
697
|
-
this.logDebug(`Successfully save log with tempId ${tempId}`, response);
|
|
698
|
-
resolve(response);
|
|
699
|
-
},
|
|
700
|
-
(error) => {
|
|
701
|
-
this.logDebug(`Error save log with tempId ${tempId}`, error);
|
|
702
|
-
console.dir(error);
|
|
703
|
-
reject(error);
|
|
704
|
-
},
|
|
705
|
-
);
|
|
706
|
-
},
|
|
707
|
-
(error) => {
|
|
708
|
-
reject(error);
|
|
709
|
-
},
|
|
710
|
-
);
|
|
711
|
-
});
|
|
712
|
-
itemObj.children.push(tempId);
|
|
713
|
-
|
|
714
|
-
const logObj = this.map[tempId];
|
|
715
|
-
logObj.finishSend = true;
|
|
716
|
-
logObj.promiseStart.then(
|
|
717
|
-
(response) => logObj.resolveFinish(response),
|
|
718
|
-
(error) => logObj.rejectFinish(error),
|
|
719
|
-
);
|
|
720
|
-
|
|
721
|
-
return {
|
|
722
|
-
tempId,
|
|
723
|
-
promise: this.map[tempId].promiseFinish,
|
|
724
|
-
};
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
sendLog(itemTempId, saveLogRQ, fileObj) {
|
|
728
|
-
const saveLogData = {
|
|
729
|
-
time: this.helpers.now(),
|
|
730
|
-
message: '',
|
|
731
|
-
level: '',
|
|
732
|
-
...saveLogRQ,
|
|
733
|
-
};
|
|
734
|
-
|
|
735
|
-
if (fileObj) {
|
|
736
|
-
return this.sendLogWithFile(itemTempId, saveLogData, fileObj);
|
|
737
|
-
}
|
|
738
|
-
return this.sendLogWithoutFile(itemTempId, saveLogData);
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
/**
|
|
742
|
-
* Send log of test results.
|
|
743
|
-
* @param {string} itemTempId - temp item id (returned in the query "startTestItem").
|
|
744
|
-
* @param {Object} saveLogRQ - object with data of test result.
|
|
745
|
-
* saveLogRQ should look like this
|
|
746
|
-
* {
|
|
747
|
-
* level: 'error' or one of 'trace', 'debug', 'info', 'warn', 'error', '',
|
|
748
|
-
* message: 'string' (support markdown),
|
|
749
|
-
* time: this.helpers.now()
|
|
750
|
-
* }
|
|
751
|
-
* @Returns {Object} - an object which contains a tempId and a promise
|
|
752
|
-
*/
|
|
753
|
-
sendLogWithoutFile(itemTempId, saveLogRQ) {
|
|
754
|
-
const itemObj = this.map[itemTempId];
|
|
755
|
-
if (!itemObj) {
|
|
756
|
-
return this.getRejectAnswer(
|
|
757
|
-
itemTempId,
|
|
758
|
-
new Error(`Item with tempId "${itemTempId}" not found`),
|
|
759
|
-
);
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
const requestPromise = (itemUuid, launchUuid) => {
|
|
763
|
-
const url = 'log';
|
|
764
|
-
const isItemUuid = itemUuid !== launchUuid;
|
|
765
|
-
return this.restClient.create(
|
|
766
|
-
url,
|
|
767
|
-
Object.assign(saveLogRQ, { launchUuid }, isItemUuid && { itemUuid }),
|
|
768
|
-
);
|
|
769
|
-
};
|
|
770
|
-
return this.saveLog(itemObj, requestPromise);
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
/**
|
|
774
|
-
* Send log of test results with file.
|
|
775
|
-
* @param {string} itemTempId - temp item id (returned in the query "startTestItem").
|
|
776
|
-
* @param {Object} saveLogRQ - object with data of test result.
|
|
777
|
-
* saveLogRQ should look like this
|
|
778
|
-
* {
|
|
779
|
-
* level: 'error' or one of 'trace', 'debug', 'info', 'warn', 'error', '',
|
|
780
|
-
* message: 'string' (support markdown),
|
|
781
|
-
* time: this.helpers.now()
|
|
782
|
-
* }
|
|
783
|
-
* @param {Object} fileObj - object with file data.
|
|
784
|
-
* fileObj should look like this
|
|
785
|
-
* {
|
|
786
|
-
name: 'string',
|
|
787
|
-
type: "image/png" or your file mimeType
|
|
788
|
-
(supported types: 'image/*', application/ ['xml', 'javascript', 'json', 'css', 'php'],
|
|
789
|
-
another format will be opened in a new browser tab ),
|
|
790
|
-
content: file
|
|
791
|
-
* }
|
|
792
|
-
* @Returns {Object} - an object which contains a tempId and a promise
|
|
793
|
-
*/
|
|
794
|
-
sendLogWithFile(itemTempId, saveLogRQ, fileObj) {
|
|
795
|
-
const itemObj = this.map[itemTempId];
|
|
796
|
-
if (!itemObj) {
|
|
797
|
-
return this.getRejectAnswer(
|
|
798
|
-
itemTempId,
|
|
799
|
-
new Error(`Item with tempId "${itemTempId}" not found`),
|
|
800
|
-
);
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
const requestPromise = (itemUuid, launchUuid) => {
|
|
804
|
-
const isItemUuid = itemUuid !== launchUuid;
|
|
805
|
-
|
|
806
|
-
return this.getRequestLogWithFile(
|
|
807
|
-
Object.assign(saveLogRQ, { launchUuid }, isItemUuid && { itemUuid }),
|
|
808
|
-
fileObj,
|
|
809
|
-
);
|
|
810
|
-
};
|
|
811
|
-
|
|
812
|
-
return this.saveLog(itemObj, requestPromise);
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
getRequestLogWithFile(saveLogRQ, fileObj) {
|
|
816
|
-
const url = 'log';
|
|
817
|
-
// eslint-disable-next-line no-param-reassign
|
|
818
|
-
saveLogRQ.file = { name: fileObj.name };
|
|
819
|
-
this.logDebug(`Save log with file: ${fileObj.name}`, saveLogRQ);
|
|
820
|
-
return this.restClient
|
|
821
|
-
.create(url, this.buildMultiPartStream([saveLogRQ], fileObj, MULTIPART_BOUNDARY), {
|
|
822
|
-
headers: {
|
|
823
|
-
'Content-Type': `multipart/form-data; boundary=${MULTIPART_BOUNDARY}`,
|
|
824
|
-
},
|
|
825
|
-
})
|
|
826
|
-
.then((response) => {
|
|
827
|
-
this.logDebug(`Success save log with file: ${fileObj.name}`, response);
|
|
828
|
-
return response;
|
|
829
|
-
})
|
|
830
|
-
.catch((error) => {
|
|
831
|
-
this.logDebug(`Error save log with file: ${fileObj.name}`, error);
|
|
832
|
-
console.dir(error);
|
|
833
|
-
});
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
// eslint-disable-next-line valid-jsdoc
|
|
837
|
-
/**
|
|
838
|
-
*
|
|
839
|
-
* @Private
|
|
840
|
-
*/
|
|
841
|
-
buildMultiPartStream(jsonPart, filePart, boundary) {
|
|
842
|
-
const eol = '\r\n';
|
|
843
|
-
const bx = `--${boundary}`;
|
|
844
|
-
const buffers = [
|
|
845
|
-
// eslint-disable-next-line function-paren-newline
|
|
846
|
-
Buffer.from(
|
|
847
|
-
// eslint-disable-next-line prefer-template
|
|
848
|
-
bx +
|
|
849
|
-
eol +
|
|
850
|
-
'Content-Disposition: form-data; name="json_request_part"' +
|
|
851
|
-
eol +
|
|
852
|
-
'Content-Type: application/json' +
|
|
853
|
-
eol +
|
|
854
|
-
eol +
|
|
855
|
-
eol +
|
|
856
|
-
JSON.stringify(jsonPart) +
|
|
857
|
-
eol,
|
|
858
|
-
),
|
|
859
|
-
// eslint-disable-next-line function-paren-newline
|
|
860
|
-
Buffer.from(
|
|
861
|
-
// eslint-disable-next-line prefer-template
|
|
862
|
-
bx +
|
|
863
|
-
eol +
|
|
864
|
-
'Content-Disposition: form-data; name="file"; filename="' +
|
|
865
|
-
filePart.name +
|
|
866
|
-
'"' +
|
|
867
|
-
eol +
|
|
868
|
-
'Content-Type: ' +
|
|
869
|
-
filePart.type +
|
|
870
|
-
eol +
|
|
871
|
-
eol,
|
|
872
|
-
),
|
|
873
|
-
Buffer.from(filePart.content, 'base64'),
|
|
874
|
-
Buffer.from(`${eol + bx}--${eol}`),
|
|
875
|
-
];
|
|
876
|
-
return Buffer.concat(buffers);
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
finishTestItemPromiseStart(itemObj, itemTempId, finishTestItemData) {
|
|
880
|
-
itemObj.promiseStart.then(
|
|
881
|
-
() => {
|
|
882
|
-
const url = ['item', itemObj.realId].join('/');
|
|
883
|
-
this.logDebug(`Finish test item with tempId ${itemTempId}`, itemObj);
|
|
884
|
-
this.restClient
|
|
885
|
-
.update(url, Object.assign(finishTestItemData, { launchUuid: this.launchUuid }))
|
|
886
|
-
.then(
|
|
887
|
-
(response) => {
|
|
888
|
-
this.logDebug(`Success finish item with tempId ${itemTempId}`, response);
|
|
889
|
-
itemObj.resolveFinish(response);
|
|
890
|
-
},
|
|
891
|
-
(error) => {
|
|
892
|
-
this.logDebug(`Error finish test item with tempId ${itemTempId}`, error);
|
|
893
|
-
console.dir(error);
|
|
894
|
-
itemObj.rejectFinish(error);
|
|
895
|
-
},
|
|
896
|
-
);
|
|
897
|
-
},
|
|
898
|
-
(error) => {
|
|
899
|
-
itemObj.rejectFinish(error);
|
|
900
|
-
},
|
|
901
|
-
);
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
module.exports = RPClient;
|