@reportportal/client-javascript 5.0.6 → 5.0.8
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/CHANGELOG.md +13 -1
- package/README.md +11 -9
- package/VERSION +1 -1
- package/analytics/events.js +2 -1
- package/lib/helpers.js +28 -21
- package/lib/publicReportingAPI.js +49 -49
- package/lib/report-portal-client.js +321 -202
- package/lib/rest.js +33 -15
- package/package.json +21 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
|
|
2
|
+
## [5.0.8] - 2023-01-24
|
|
3
|
+
### Added
|
|
4
|
+
- `mergeOptions` parameter to `mergeLaunches` method.
|
|
5
|
+
- Dynamic page size for launch merge based on launches count, resolves [#86](https://github.com/reportportal/client-javascript/issues/86).
|
|
6
|
+
### Security
|
|
7
|
+
- Updated versions of vulnerable packages (json5, minimist).
|
|
8
|
+
|
|
9
|
+
## [5.0.7] - 2022-12-26
|
|
10
|
+
### Added
|
|
11
|
+
- The ability to see verbose logs in debug mode. To enable the debug mode, the `debug: true` flag should be specified in `params`.
|
|
12
|
+
### Security
|
|
13
|
+
- Updated versions of vulnerable packages (ajv, qs, follow-redirects, minimatch).
|
|
14
|
+
|
|
2
15
|
## [5.0.6] - 2022-01-13
|
|
3
16
|
### Fixed
|
|
4
17
|
- Security vulnerabilities (axios, path-parse, minimist)
|
|
@@ -39,6 +52,5 @@
|
|
|
39
52
|
## [5.0.0] - 2020-06-09
|
|
40
53
|
### Added
|
|
41
54
|
- Full compatibility with ReportPortal version 5.* (see [reportportal releases](https://github.com/reportportal/reportportal/releases))
|
|
42
|
-
|
|
43
55
|
### Deprecated
|
|
44
56
|
- Previous package version (`reportportal-client`) will no longer supported by reportportal.io
|
package/README.md
CHANGED
|
@@ -48,14 +48,16 @@ rpClient.checkConnect().then((response) => {
|
|
|
48
48
|
## Settings
|
|
49
49
|
When creating a client instance, you need to specify the following parameters:
|
|
50
50
|
|
|
51
|
-
Parameter
|
|
52
|
-
|
|
53
|
-
token
|
|
54
|
-
endpoint
|
|
55
|
-
launch
|
|
56
|
-
project
|
|
57
|
-
headers
|
|
58
|
-
|
|
51
|
+
| Parameter | Description |
|
|
52
|
+
|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
53
|
+
| token | User's token Report Portal from which you want to send requests. It can be found on the profile page of this user. |
|
|
54
|
+
| endpoint | URL of your server. For example, if you visit the page at 'https://server:8080/ui', then endpoint will be equal to 'https://server:8080/api/v1'. |
|
|
55
|
+
| launch | Name of launch at creation. |
|
|
56
|
+
| project | The name of the project in which the launches will be created. |
|
|
57
|
+
| headers | (optional) The object with custom headers for internal http client. |
|
|
58
|
+
| debug | (optional) *Default: false.* This flag allows seeing the logs of the client. Useful for debugging. |
|
|
59
|
+
| isLaunchMergeRequired | (optional) *Default: false.* Allows client to merge launches into one at the end of the run via saving their UUIDs to the file system. At the end of the run launches can be merged using `mergeLaunches` method. |
|
|
60
|
+
| restClientConfig | (optional) The object with `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, may contain other client options eg. `timeout`. |
|
|
59
61
|
|
|
60
62
|
## Asynchronous reporting
|
|
61
63
|
The client supports an asynchronous reporting.
|
|
@@ -74,7 +76,7 @@ The client works synchronously, so it is not necessary to wait for the end of th
|
|
|
74
76
|
### Timeout (30000ms) on axios requests
|
|
75
77
|
There is a timeout on axios requests. If for instance the server your making a request to is taking too long to load, then axios timeout will work and you will see the error "Error: timeout of 30000ms exceeded".
|
|
76
78
|
|
|
77
|
-
You can simply change this timeout by adding a `timeout` property to `restClientConfig` with your desired numeric value.
|
|
79
|
+
You can simply change this timeout by adding a `timeout` property to `restClientConfig` with your desired numeric value (in _ms_) or *0* to disable it.
|
|
78
80
|
|
|
79
81
|
### checkConnect
|
|
80
82
|
checkConnect - asynchronous method for verifying the correctness of the client connection
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
5.0.
|
|
1
|
+
5.0.8
|
package/analytics/events.js
CHANGED
|
@@ -8,7 +8,8 @@ const CLIENT_JAVASCRIPT_EVENTS = {
|
|
|
8
8
|
},
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const getAgentEventLabel = (agentParams) =>
|
|
11
|
+
const getAgentEventLabel = (agentParams) =>
|
|
12
|
+
`Agent name "${agentParams.name}", version "${agentParams.version}"`;
|
|
12
13
|
|
|
13
14
|
module.exports = {
|
|
14
15
|
CLIENT_JAVASCRIPT_EVENTS,
|
package/lib/helpers.js
CHANGED
|
@@ -15,7 +15,7 @@ module.exports = {
|
|
|
15
15
|
formatName(name) {
|
|
16
16
|
const len = name.length;
|
|
17
17
|
// eslint-disable-next-line no-mixed-operators
|
|
18
|
-
return (
|
|
18
|
+
return (len < MIN ? name + new Array(MIN - len + 1).join('.') : name).slice(-MAX);
|
|
19
19
|
},
|
|
20
20
|
|
|
21
21
|
now() {
|
|
@@ -23,8 +23,7 @@ module.exports = {
|
|
|
23
23
|
},
|
|
24
24
|
|
|
25
25
|
getServerResult(url, request, options, method) {
|
|
26
|
-
return RestClient
|
|
27
|
-
.request(method, url, request, options);
|
|
26
|
+
return RestClient.request(method, url, request, options);
|
|
28
27
|
},
|
|
29
28
|
|
|
30
29
|
readLaunchesFromFile() {
|
|
@@ -48,23 +47,28 @@ module.exports = {
|
|
|
48
47
|
const osArchitecture = os.arch();
|
|
49
48
|
const RAMSize = os.totalmem();
|
|
50
49
|
const nodeVersion = process.version;
|
|
51
|
-
const systemAttr = [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
50
|
+
const systemAttr = [
|
|
51
|
+
{
|
|
52
|
+
key: 'client',
|
|
53
|
+
value: `${PJSON_NAME}|${PJSON_VERSION}`,
|
|
54
|
+
system: true,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
key: 'os',
|
|
58
|
+
value: `${osType}|${osArchitecture}`,
|
|
59
|
+
system: true,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
key: 'RAMSize',
|
|
63
|
+
value: RAMSize,
|
|
64
|
+
system: true,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
key: 'nodeJS',
|
|
68
|
+
value: nodeVersion,
|
|
69
|
+
system: true,
|
|
70
|
+
},
|
|
71
|
+
];
|
|
68
72
|
|
|
69
73
|
return systemAttr;
|
|
70
74
|
},
|
|
@@ -78,7 +82,10 @@ module.exports = {
|
|
|
78
82
|
return codeRef;
|
|
79
83
|
}
|
|
80
84
|
|
|
81
|
-
const parameters = params.reduce(
|
|
85
|
+
const parameters = params.reduce(
|
|
86
|
+
(result, item) => (item.value ? result.concat(item.value) : result),
|
|
87
|
+
[],
|
|
88
|
+
);
|
|
82
89
|
|
|
83
90
|
return `${codeRef}[${parameters}]`;
|
|
84
91
|
},
|
|
@@ -5,85 +5,85 @@ const { EVENTS } = require('./constants/events');
|
|
|
5
5
|
*/
|
|
6
6
|
class PublicReportingAPI {
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
* Emit set description event.
|
|
9
|
+
* @param {String} text - description of current test/suite.
|
|
10
|
+
* @param {String} suite - suite description, optional.
|
|
11
|
+
*/
|
|
12
12
|
static setDescription(text, suite) {
|
|
13
13
|
process.emit(EVENTS.SET_DESCRIPTION, { text, suite });
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
* Emit add attributes event.
|
|
18
|
+
* @param {Array} attributes - array of attributes, should looks like this:
|
|
19
|
+
* [{
|
|
20
|
+
* key: "attrKey",
|
|
21
|
+
* value: "attrValue",
|
|
22
|
+
* }]
|
|
23
|
+
*
|
|
24
|
+
* @param {String} suite - suite description, optional.
|
|
25
|
+
*/
|
|
26
26
|
static addAttributes(attributes, suite) {
|
|
27
27
|
process.emit(EVENTS.ADD_ATTRIBUTES, { attributes, suite });
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
* Emit send log to test item event.
|
|
32
|
+
* @param {Object} log - log object should looks like this:
|
|
33
|
+
* {
|
|
34
|
+
* level: "INFO",
|
|
35
|
+
* message: "log message",
|
|
36
|
+
* file: {
|
|
37
|
+
* name: "filename",
|
|
38
|
+
* type: "image/png", // media type
|
|
39
|
+
* content: data, // file content represented as 64base string
|
|
40
|
+
* },
|
|
41
|
+
* }
|
|
42
|
+
* @param {String} suite - suite description, optional.
|
|
43
|
+
*/
|
|
44
44
|
static addLog(log, suite) {
|
|
45
45
|
process.emit(EVENTS.ADD_LOG, { log, suite });
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
* Emit send log to current launch event.
|
|
50
|
+
* @param {Object} log - log object should looks like this:
|
|
51
|
+
* {
|
|
52
|
+
* level: "INFO",
|
|
53
|
+
* message: "log message",
|
|
54
|
+
* file: {
|
|
55
|
+
* name: "filename",
|
|
56
|
+
* type: "image/png", // media type
|
|
57
|
+
* content: data, // file content represented as 64base string
|
|
58
|
+
* },
|
|
59
|
+
* }
|
|
60
|
+
*/
|
|
61
61
|
static addLaunchLog(log) {
|
|
62
62
|
process.emit(EVENTS.ADD_LAUNCH_LOG, log);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
* Emit set testCaseId event.
|
|
67
|
+
* @param {String} testCaseId - testCaseId of current test/suite.
|
|
68
|
+
* @param {String} suite - suite description, optional.
|
|
69
|
+
*/
|
|
70
70
|
static setTestCaseId(testCaseId, suite) {
|
|
71
71
|
process.emit(EVENTS.SET_TEST_CASE_ID, { testCaseId, suite });
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
* Emit set status to current launch event.
|
|
76
|
+
* @param {String} status - status of current launch.
|
|
77
|
+
*/
|
|
78
78
|
static setLaunchStatus(status) {
|
|
79
79
|
process.emit(EVENTS.SET_LAUNCH_STATUS, status);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
* Emit set status event.
|
|
84
|
+
* @param {String} status - status of current test/suite.
|
|
85
|
+
* @param {String} suite - suite description, optional.
|
|
86
|
+
*/
|
|
87
87
|
static setStatus(status, suite) {
|
|
88
88
|
process.emit(EVENTS.SET_STATUS, { status, suite });
|
|
89
89
|
}
|
|
@@ -11,26 +11,27 @@ const MULTIPART_BOUNDARY = Math.floor(Math.random() * 10000000000).toString();
|
|
|
11
11
|
|
|
12
12
|
class RPClient {
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
14
|
+
* Create a client for RP.
|
|
15
|
+
* @param {Object} params - config object.
|
|
16
|
+
* params should look like this
|
|
17
|
+
* {
|
|
18
|
+
* token: "00000000-0000-0000-0000-000000000000",
|
|
19
|
+
* endpoint: "http://localhost:8080/api/v1",
|
|
20
|
+
* launch: "YOUR LAUNCH NAME",
|
|
21
|
+
* project: "PROJECT NAME",
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} agentParams - agent's info object.
|
|
25
|
+
* agentParams should look like this
|
|
26
|
+
* {
|
|
27
|
+
* name: "AGENT NAME",
|
|
28
|
+
* version: "AGENT VERSION",
|
|
29
|
+
* }
|
|
30
|
+
*/
|
|
31
31
|
constructor(params, agentParams) {
|
|
32
32
|
this.debug = params.debug;
|
|
33
|
-
this.isLaunchMergeRequired =
|
|
33
|
+
this.isLaunchMergeRequired =
|
|
34
|
+
params.isLaunchMergeRequired === undefined ? false : params.isLaunchMergeRequired;
|
|
34
35
|
this.map = {};
|
|
35
36
|
this.baseURL = [params.endpoint, params.project].join('/');
|
|
36
37
|
const headers = {
|
|
@@ -57,9 +58,9 @@ class RPClient {
|
|
|
57
58
|
*
|
|
58
59
|
* @Private
|
|
59
60
|
*/
|
|
60
|
-
logDebug(msg) {
|
|
61
|
+
logDebug(msg, dataMsg = '') {
|
|
61
62
|
if (this.debug) {
|
|
62
|
-
console.log(msg);
|
|
63
|
+
console.log(msg, dataMsg);
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -82,14 +83,14 @@ class RPClient {
|
|
|
82
83
|
let resolveFinish;
|
|
83
84
|
let rejectFinish;
|
|
84
85
|
const obj = {
|
|
85
|
-
promiseStart:
|
|
86
|
+
promiseStart: new Promise(startPromiseFunc),
|
|
86
87
|
realId: '',
|
|
87
88
|
children: [],
|
|
88
89
|
finishSend: false,
|
|
89
|
-
promiseFinish:
|
|
90
|
+
promiseFinish: new Promise((resolve, reject) => {
|
|
90
91
|
resolveFinish = resolve;
|
|
91
92
|
rejectFinish = reject;
|
|
92
|
-
})
|
|
93
|
+
}),
|
|
93
94
|
};
|
|
94
95
|
obj.resolveFinish = resolveFinish;
|
|
95
96
|
obj.rejectFinish = rejectFinish;
|
|
@@ -185,9 +186,9 @@ class RPClient {
|
|
|
185
186
|
|
|
186
187
|
this.map[tempId] = this.getNewItemObj((resolve, reject) => {
|
|
187
188
|
const url = 'launch';
|
|
188
|
-
this.logDebug(`Start launch ${tempId}
|
|
189
|
-
this.restClient.create(url, launchData, { headers: this.headers })
|
|
190
|
-
|
|
189
|
+
this.logDebug(`Start launch with tempId ${tempId}`, launchDataRQ);
|
|
190
|
+
this.restClient.create(url, launchData, { headers: this.headers }).then(
|
|
191
|
+
(response) => {
|
|
191
192
|
this.map[tempId].realId = response.id;
|
|
192
193
|
this.launchUuid = response.id;
|
|
193
194
|
|
|
@@ -195,11 +196,15 @@ class RPClient {
|
|
|
195
196
|
helpers.saveLaunchIdToFile(response.id);
|
|
196
197
|
}
|
|
197
198
|
|
|
199
|
+
this.logDebug(`Success start launch with tempId ${tempId}`, response);
|
|
198
200
|
resolve(response);
|
|
199
|
-
},
|
|
201
|
+
},
|
|
202
|
+
(error) => {
|
|
203
|
+
this.logDebug(`Error start launch with tempId ${tempId}`, error);
|
|
200
204
|
console.dir(error);
|
|
201
205
|
reject(error);
|
|
202
|
-
}
|
|
206
|
+
},
|
|
207
|
+
);
|
|
203
208
|
});
|
|
204
209
|
}
|
|
205
210
|
this.triggerAnalyticsEvent();
|
|
@@ -210,46 +215,57 @@ class RPClient {
|
|
|
210
215
|
}
|
|
211
216
|
|
|
212
217
|
/**
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
218
|
+
* Finish launch.
|
|
219
|
+
* @param {string} launchTempId - temp launch id (returned in the query "startLaunch").
|
|
220
|
+
* @param {Object} finishExecutionRQ - finish launch info should include time and status.
|
|
221
|
+
* finishExecutionRQ should look like this
|
|
222
|
+
* {
|
|
223
|
+
* "endTime": this.helper.now(),
|
|
224
|
+
* "status": "passed" or one of ‘passed’, ‘failed’, ‘stopped’, ‘skipped’, ‘interrupted’, ‘cancelled’
|
|
225
|
+
* }
|
|
226
|
+
* @Returns {Object} - an object which contains a tempID and a promise
|
|
227
|
+
*/
|
|
223
228
|
finishLaunch(launchTempId, finishExecutionRQ) {
|
|
224
229
|
const launchObj = this.map[launchTempId];
|
|
225
230
|
if (!launchObj) {
|
|
226
|
-
return this.getRejectAnswer(
|
|
231
|
+
return this.getRejectAnswer(
|
|
232
|
+
launchTempId,
|
|
233
|
+
new Error(`Launch with tempId "${launchTempId}" not found`),
|
|
234
|
+
);
|
|
227
235
|
}
|
|
228
236
|
|
|
229
237
|
const finishExecutionData = { endTime: this.helpers.now(), ...finishExecutionRQ };
|
|
230
238
|
|
|
231
239
|
launchObj.finishSend = true;
|
|
232
|
-
Promise.all(launchObj.children.map((itemId) => this.map[itemId].promiseFinish))
|
|
233
|
-
|
|
234
|
-
launchObj.promiseStart
|
|
235
|
-
|
|
236
|
-
this.logDebug(`Finish launch ${launchTempId}
|
|
240
|
+
Promise.all(launchObj.children.map((itemId) => this.map[itemId].promiseFinish)).then(
|
|
241
|
+
() => {
|
|
242
|
+
launchObj.promiseStart.then(
|
|
243
|
+
() => {
|
|
244
|
+
this.logDebug(`Finish launch with tempId ${launchTempId}`, finishExecutionData);
|
|
237
245
|
const url = ['launch', launchObj.realId, 'finish'].join('/');
|
|
238
|
-
this.restClient.update(url, finishExecutionData, { headers: this.headers })
|
|
239
|
-
|
|
240
|
-
this.logDebug(`Success finish launch ${launchTempId}
|
|
246
|
+
this.restClient.update(url, finishExecutionData, { headers: this.headers }).then(
|
|
247
|
+
(response) => {
|
|
248
|
+
this.logDebug(`Success finish launch with tempId ${launchTempId}`, response);
|
|
241
249
|
launchObj.resolveFinish(response);
|
|
242
|
-
},
|
|
243
|
-
|
|
250
|
+
},
|
|
251
|
+
(error) => {
|
|
252
|
+
this.logDebug(`Error finish launch with tempId ${launchTempId}`, error);
|
|
244
253
|
console.dir(error);
|
|
245
254
|
launchObj.rejectFinish(error);
|
|
246
|
-
}
|
|
247
|
-
|
|
255
|
+
},
|
|
256
|
+
);
|
|
257
|
+
},
|
|
258
|
+
(error) => {
|
|
259
|
+
console.dir(error);
|
|
248
260
|
launchObj.rejectFinish(error);
|
|
249
|
-
}
|
|
250
|
-
|
|
261
|
+
},
|
|
262
|
+
);
|
|
263
|
+
},
|
|
264
|
+
(error) => {
|
|
265
|
+
console.dir(error);
|
|
251
266
|
launchObj.rejectFinish(error);
|
|
252
|
-
}
|
|
267
|
+
},
|
|
268
|
+
);
|
|
253
269
|
|
|
254
270
|
return {
|
|
255
271
|
tempId: launchTempId,
|
|
@@ -258,67 +274,87 @@ class RPClient {
|
|
|
258
274
|
}
|
|
259
275
|
|
|
260
276
|
/*
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
getMergeLaunchesRequest(launchIds) {
|
|
277
|
+
* This method is used to create data object for merge request to ReportPortal.
|
|
278
|
+
*
|
|
279
|
+
* @Returns {Object} - an object which contains a data for merge launches in ReportPortal.
|
|
280
|
+
*/
|
|
281
|
+
getMergeLaunchesRequest(launchIds, mergeOptions = {}) {
|
|
266
282
|
return {
|
|
267
|
-
description: "Merged launch",
|
|
268
|
-
endTime: this.helpers.now(),
|
|
269
|
-
extendSuitesDescription: true,
|
|
270
283
|
launches: launchIds,
|
|
271
|
-
mergeType:
|
|
272
|
-
|
|
284
|
+
mergeType: 'BASIC',
|
|
285
|
+
description: this.config.description || 'Merged launch',
|
|
286
|
+
mode: this.config.mode || 'DEFAULT',
|
|
273
287
|
name: this.config.launch || 'Test launch name',
|
|
274
288
|
attributes: this.config.attributes,
|
|
289
|
+
endTime: this.helpers.now(),
|
|
290
|
+
extendSuitesDescription: true,
|
|
291
|
+
...mergeOptions,
|
|
275
292
|
};
|
|
276
293
|
}
|
|
277
294
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
295
|
+
/**
|
|
296
|
+
* This method is used for merge launches in ReportPortal.
|
|
297
|
+
* @param {Object} mergeOptions - options for merge request, can override default options.
|
|
298
|
+
* mergeOptions should look like this
|
|
299
|
+
* {
|
|
300
|
+
* "extendSuitesDescription": boolean,
|
|
301
|
+
* "description": string,
|
|
302
|
+
* "mergeType": 'BASIC' | 'DEEP',
|
|
303
|
+
* "name": string
|
|
304
|
+
* }
|
|
305
|
+
* Please, keep in mind that this method is work only in case
|
|
306
|
+
* the option isLaunchMergeRequired is true.
|
|
307
|
+
*
|
|
308
|
+
* @Returns {Promise}
|
|
309
|
+
*/
|
|
310
|
+
mergeLaunches(mergeOptions= {}) {
|
|
285
311
|
if (this.isLaunchMergeRequired) {
|
|
286
312
|
const launchUUIds = helpers.readLaunchesFromFile();
|
|
287
313
|
const params = new URLSearchParams({
|
|
288
314
|
'filter.in.uuid': launchUUIds,
|
|
315
|
+
'page.size': launchUUIds.length,
|
|
289
316
|
});
|
|
290
317
|
const launchSearchUrl = `launch?${params.toString()}`;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
318
|
+
this.logDebug(`Find launches with UUIDs to merge: ${launchUUIds}`);
|
|
319
|
+
return this.restClient
|
|
320
|
+
.retrieveSyncAPI(launchSearchUrl, { headers: this.headers })
|
|
321
|
+
.then(
|
|
322
|
+
(response) => {
|
|
323
|
+
const launchIds = response.content.map((launch) => launch.id);
|
|
324
|
+
this.logDebug(`Found launches: ${launchIds}`, response.content);
|
|
325
|
+
return launchIds;
|
|
326
|
+
},
|
|
327
|
+
(error) => {
|
|
328
|
+
this.logDebug(`Error during launches search with UUIDs: ${launchUUIds}`, error);
|
|
329
|
+
console.dir(error);
|
|
330
|
+
},
|
|
331
|
+
)
|
|
299
332
|
.then((launchIds) => {
|
|
300
|
-
const request = this.getMergeLaunchesRequest(launchIds);
|
|
333
|
+
const request = this.getMergeLaunchesRequest(launchIds, mergeOptions);
|
|
334
|
+
this.logDebug(`Merge launches with ids: ${launchIds}`, request);
|
|
301
335
|
const mergeURL = 'launch/merge';
|
|
302
336
|
return this.restClient.create(mergeURL, request, { headers: this.headers });
|
|
303
337
|
})
|
|
304
338
|
.then(() => {
|
|
305
|
-
this.logDebug(`Launches successfully merged!`);
|
|
339
|
+
this.logDebug(`Launches with UUIDs: ${launchUUIds} were successfully merged!`);
|
|
306
340
|
})
|
|
307
341
|
.catch((error) => {
|
|
308
|
-
this.logDebug(
|
|
309
|
-
|
|
342
|
+
this.logDebug(`Error merging launches with UUIDs: ${launchUUIds}`, error);
|
|
343
|
+
console.dir(error);
|
|
310
344
|
});
|
|
311
345
|
}
|
|
312
|
-
this.logDebug(
|
|
346
|
+
this.logDebug(
|
|
347
|
+
'Option isLaunchMergeRequired is false, merge process cannot be done as no launch UUIDs where saved.',
|
|
348
|
+
);
|
|
313
349
|
}
|
|
314
350
|
|
|
315
351
|
/*
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
352
|
+
* This method is used for frameworks as Jasmine. There is problem when
|
|
353
|
+
* it doesn't wait for promise resolve and stop the process. So it better to call
|
|
354
|
+
* this method at the spec's function as @afterAll() and manually resolve this promise.
|
|
355
|
+
*
|
|
356
|
+
* @return Promise
|
|
357
|
+
*/
|
|
322
358
|
getPromiseFinishAllItems(launchTempId) {
|
|
323
359
|
const launchObj = this.map[launchTempId];
|
|
324
360
|
return Promise.all(launchObj.children.map((itemId) => this.map[itemId].promiseFinish));
|
|
@@ -347,7 +383,10 @@ class RPClient {
|
|
|
347
383
|
updateLaunch(launchTempId, launchData) {
|
|
348
384
|
const launchObj = this.map[launchTempId];
|
|
349
385
|
if (!launchObj) {
|
|
350
|
-
return this.getRejectAnswer(
|
|
386
|
+
return this.getRejectAnswer(
|
|
387
|
+
launchTempId,
|
|
388
|
+
new Error(`Launch with tempId "${launchTempId}" not found`),
|
|
389
|
+
);
|
|
351
390
|
}
|
|
352
391
|
let resolvePromise;
|
|
353
392
|
let rejectPromise;
|
|
@@ -356,17 +395,26 @@ class RPClient {
|
|
|
356
395
|
rejectPromise = reject;
|
|
357
396
|
});
|
|
358
397
|
|
|
359
|
-
launchObj.promiseFinish.then(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
.
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
398
|
+
launchObj.promiseFinish.then(
|
|
399
|
+
() => {
|
|
400
|
+
const url = ['launch', launchObj.realId, 'update'].join('/');
|
|
401
|
+
this.logDebug(`Update launch with tempId ${launchTempId}`, launchData);
|
|
402
|
+
this.restClient.update(url, launchData, { headers: this.headers }).then(
|
|
403
|
+
(response) => {
|
|
404
|
+
this.logDebug(`Launch with tempId ${launchTempId} were successfully updated`, response);
|
|
405
|
+
resolvePromise(response);
|
|
406
|
+
},
|
|
407
|
+
(error) => {
|
|
408
|
+
this.logDebug(`Error when updating launch with tempId ${launchTempId}`, error);
|
|
409
|
+
console.dir(error);
|
|
410
|
+
rejectPromise(error);
|
|
411
|
+
},
|
|
412
|
+
);
|
|
413
|
+
},
|
|
414
|
+
(error) => {
|
|
415
|
+
rejectPromise(error);
|
|
416
|
+
},
|
|
417
|
+
);
|
|
370
418
|
return {
|
|
371
419
|
tempId: launchTempId,
|
|
372
420
|
promise,
|
|
@@ -404,23 +452,37 @@ class RPClient {
|
|
|
404
452
|
let parentMapId = launchTempId;
|
|
405
453
|
const launchObj = this.map[launchTempId];
|
|
406
454
|
if (!launchObj) {
|
|
407
|
-
return this.getRejectAnswer(
|
|
455
|
+
return this.getRejectAnswer(
|
|
456
|
+
launchTempId,
|
|
457
|
+
new Error(`Launch with tempId "${launchTempId}" not found`),
|
|
458
|
+
);
|
|
408
459
|
}
|
|
460
|
+
// TODO: Allow items reporting to finished launch
|
|
409
461
|
if (launchObj.finishSend) {
|
|
410
|
-
const err = new Error(
|
|
462
|
+
const err = new Error(
|
|
463
|
+
`Launch with tempId "${launchTempId}" is already finished, you can not add an item to it`,
|
|
464
|
+
);
|
|
411
465
|
return this.getRejectAnswer(launchTempId, err);
|
|
412
466
|
}
|
|
413
467
|
|
|
414
|
-
const testCaseId =
|
|
415
|
-
|
|
416
|
-
|
|
468
|
+
const testCaseId =
|
|
469
|
+
testItemDataRQ.testCaseId ||
|
|
470
|
+
helpers.generateTestCaseId(testItemDataRQ.codeRef, testItemDataRQ.parameters);
|
|
471
|
+
const testItemData = {
|
|
472
|
+
startTime: this.helpers.now(),
|
|
473
|
+
...testItemDataRQ,
|
|
474
|
+
...(testCaseId && { testCaseId }),
|
|
475
|
+
};
|
|
417
476
|
|
|
418
477
|
let parentPromise = launchObj.promiseStart;
|
|
419
478
|
if (parentTempId) {
|
|
420
479
|
parentMapId = parentTempId;
|
|
421
480
|
const parentObj = this.map[parentTempId];
|
|
422
481
|
if (!parentObj) {
|
|
423
|
-
return this.getRejectAnswer(
|
|
482
|
+
return this.getRejectAnswer(
|
|
483
|
+
launchTempId,
|
|
484
|
+
new Error(`Item with tempId "${parentTempId}" not found`),
|
|
485
|
+
);
|
|
424
486
|
}
|
|
425
487
|
parentPromise = parentObj.promiseStart;
|
|
426
488
|
}
|
|
@@ -438,29 +500,34 @@ class RPClient {
|
|
|
438
500
|
|
|
439
501
|
const tempId = this.getUniqId();
|
|
440
502
|
this.map[tempId] = this.getNewItemObj((resolve, reject) => {
|
|
441
|
-
parentPromise.then(
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
.
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
503
|
+
parentPromise.then(
|
|
504
|
+
() => {
|
|
505
|
+
const realLaunchId = this.map[launchTempId].realId;
|
|
506
|
+
let url = 'item/';
|
|
507
|
+
if (parentTempId) {
|
|
508
|
+
const realParentId = this.map[parentTempId].realId;
|
|
509
|
+
url += `${realParentId}`;
|
|
510
|
+
}
|
|
511
|
+
testItemData.launchUuid = realLaunchId;
|
|
512
|
+
this.logDebug(`Start test item with tempId ${tempId}`, testItemData);
|
|
513
|
+
this.restClient.create(url, testItemData, { headers: this.headers }).then(
|
|
514
|
+
(response) => {
|
|
515
|
+
this.logDebug(`Success start item with tempId ${tempId}`, response);
|
|
516
|
+
this.map[tempId].realId = response.id;
|
|
517
|
+
this.nonRetriedItemMap.delete(itemKey);
|
|
518
|
+
resolve(response);
|
|
519
|
+
},
|
|
520
|
+
(error) => {
|
|
521
|
+
this.logDebug(`Error start item with tempId ${tempId}`, error);
|
|
522
|
+
console.dir(error);
|
|
523
|
+
reject(error);
|
|
524
|
+
},
|
|
525
|
+
);
|
|
526
|
+
},
|
|
527
|
+
(error) => {
|
|
528
|
+
reject(error);
|
|
529
|
+
},
|
|
530
|
+
);
|
|
464
531
|
});
|
|
465
532
|
this.map[parentMapId].children.push(tempId);
|
|
466
533
|
|
|
@@ -501,7 +568,10 @@ class RPClient {
|
|
|
501
568
|
finishTestItem(itemTempId, finishTestItemRQ) {
|
|
502
569
|
const itemObj = this.map[itemTempId];
|
|
503
570
|
if (!itemObj) {
|
|
504
|
-
return this.getRejectAnswer(
|
|
571
|
+
return this.getRejectAnswer(
|
|
572
|
+
itemTempId,
|
|
573
|
+
new Error(`Item with tempId "${itemTempId}" not found`),
|
|
574
|
+
);
|
|
505
575
|
}
|
|
506
576
|
|
|
507
577
|
const finishTestItemData = {
|
|
@@ -511,24 +581,33 @@ class RPClient {
|
|
|
511
581
|
};
|
|
512
582
|
|
|
513
583
|
itemObj.finishSend = true;
|
|
514
|
-
|
|
515
|
-
|
|
584
|
+
this.logDebug(`Finish all children for test item with tempId ${itemTempId}`);
|
|
585
|
+
Promise.all(
|
|
586
|
+
itemObj.children.map((itemId) => this.map[itemId] && this.map[itemId].promiseFinish),
|
|
587
|
+
).then(
|
|
588
|
+
() => {
|
|
516
589
|
this.cleanMap(itemObj.children);
|
|
590
|
+
this.logDebug(
|
|
591
|
+
`All children for test item with tempId ${itemTempId} successfully finished.`,
|
|
592
|
+
);
|
|
593
|
+
this.logDebug(`Finish test item with tempId ${itemTempId}`, finishTestItemRQ);
|
|
517
594
|
this.finishTestItemPromiseStart(
|
|
518
595
|
itemObj,
|
|
519
596
|
itemTempId,
|
|
520
597
|
Object.assign(finishTestItemData, { launchUuid: this.launchUuid }),
|
|
521
598
|
);
|
|
522
|
-
},
|
|
599
|
+
},
|
|
600
|
+
() => {
|
|
523
601
|
this.cleanMap(itemObj.children);
|
|
524
|
-
this.logDebug(`Error finish children of test item ${itemTempId}`);
|
|
525
|
-
this.logDebug(`Finish test item ${itemTempId}
|
|
602
|
+
this.logDebug(`Error finish children of test item with tempId ${itemTempId}`);
|
|
603
|
+
this.logDebug(`Finish test item with tempId ${itemTempId}`, finishTestItemRQ);
|
|
526
604
|
this.finishTestItemPromiseStart(
|
|
527
605
|
itemObj,
|
|
528
606
|
itemTempId,
|
|
529
607
|
Object.assign(finishTestItemData, { launchUuid: this.launchUuid }),
|
|
530
608
|
);
|
|
531
|
-
}
|
|
609
|
+
},
|
|
610
|
+
);
|
|
532
611
|
|
|
533
612
|
return {
|
|
534
613
|
tempId: itemTempId,
|
|
@@ -539,24 +618,34 @@ class RPClient {
|
|
|
539
618
|
saveLog(itemObj, requestPromiseFunc) {
|
|
540
619
|
const tempId = this.getUniqId();
|
|
541
620
|
this.map[tempId] = this.getNewItemObj((resolve, reject) => {
|
|
542
|
-
itemObj.promiseStart.then(
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
this.
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
621
|
+
itemObj.promiseStart.then(
|
|
622
|
+
() => {
|
|
623
|
+
this.logDebug(`Save log with tempId ${tempId}`, itemObj);
|
|
624
|
+
requestPromiseFunc(itemObj.realId, this.launchUuid).then(
|
|
625
|
+
(response) => {
|
|
626
|
+
this.logDebug(`Successfully save log with tempId ${tempId}`, response);
|
|
627
|
+
resolve(response);
|
|
628
|
+
},
|
|
629
|
+
(error) => {
|
|
630
|
+
this.logDebug(`Error save log with tempId ${tempId}`, error);
|
|
631
|
+
console.dir(error);
|
|
632
|
+
reject(error);
|
|
633
|
+
},
|
|
634
|
+
);
|
|
635
|
+
},
|
|
636
|
+
(error) => {
|
|
549
637
|
reject(error);
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
reject(error);
|
|
553
|
-
});
|
|
638
|
+
},
|
|
639
|
+
);
|
|
554
640
|
});
|
|
555
641
|
itemObj.children.push(tempId);
|
|
556
642
|
|
|
557
643
|
const logObj = this.map[tempId];
|
|
558
644
|
logObj.finishSend = true;
|
|
559
|
-
logObj.promiseStart.then(
|
|
645
|
+
logObj.promiseStart.then(
|
|
646
|
+
(response) => logObj.resolveFinish(response),
|
|
647
|
+
(error) => logObj.rejectFinish(error),
|
|
648
|
+
);
|
|
560
649
|
|
|
561
650
|
return {
|
|
562
651
|
tempId,
|
|
@@ -579,21 +668,24 @@ class RPClient {
|
|
|
579
668
|
}
|
|
580
669
|
|
|
581
670
|
/**
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
671
|
+
* Send log of test results.
|
|
672
|
+
* @param {string} itemTempId - temp item id (returned in the query "startTestItem").
|
|
673
|
+
* @param {Object} saveLogRQ - object with data of test result.
|
|
674
|
+
* saveLogRQ should look like this
|
|
675
|
+
* {
|
|
676
|
+
* level: 'error' or one of 'trace', 'debug', 'info', 'warn', 'error', '',
|
|
677
|
+
* message: 'string' (support markdown),
|
|
678
|
+
* time: this.helpers.now()
|
|
679
|
+
* }
|
|
680
|
+
* @Returns {Object} - an object which contains a tempId and a promise
|
|
681
|
+
*/
|
|
593
682
|
sendLogWithoutFile(itemTempId, saveLogRQ) {
|
|
594
683
|
const itemObj = this.map[itemTempId];
|
|
595
684
|
if (!itemObj) {
|
|
596
|
-
return this.getRejectAnswer(
|
|
685
|
+
return this.getRejectAnswer(
|
|
686
|
+
itemTempId,
|
|
687
|
+
new Error(`Item with tempId "${itemTempId}" not found`),
|
|
688
|
+
);
|
|
597
689
|
}
|
|
598
690
|
|
|
599
691
|
const requestPromise = (itemUuid, launchUuid) => {
|
|
@@ -601,11 +693,7 @@ class RPClient {
|
|
|
601
693
|
const isItemUuid = itemUuid !== launchUuid;
|
|
602
694
|
return this.restClient.create(
|
|
603
695
|
url,
|
|
604
|
-
Object.assign(
|
|
605
|
-
saveLogRQ,
|
|
606
|
-
{ launchUuid },
|
|
607
|
-
isItemUuid && { itemUuid },
|
|
608
|
-
),
|
|
696
|
+
Object.assign(saveLogRQ, { launchUuid }, isItemUuid && { itemUuid }),
|
|
609
697
|
{ headers: this.headers },
|
|
610
698
|
);
|
|
611
699
|
};
|
|
@@ -636,14 +724,19 @@ class RPClient {
|
|
|
636
724
|
sendLogWithFile(itemTempId, saveLogRQ, fileObj) {
|
|
637
725
|
const itemObj = this.map[itemTempId];
|
|
638
726
|
if (!itemObj) {
|
|
639
|
-
return this.getRejectAnswer(
|
|
727
|
+
return this.getRejectAnswer(
|
|
728
|
+
itemTempId,
|
|
729
|
+
new Error(`Item with tempId "${itemTempId}" not found`),
|
|
730
|
+
);
|
|
640
731
|
}
|
|
641
|
-
|
|
732
|
+
|
|
642
733
|
const requestPromise = (itemUuid, launchUuid) => {
|
|
643
734
|
const isItemUuid = itemUuid !== launchUuid;
|
|
644
735
|
|
|
645
|
-
|
|
646
|
-
|
|
736
|
+
return this.getRequestLogWithFile(
|
|
737
|
+
Object.assign(saveLogRQ, { launchUuid }, isItemUuid && { itemUuid }),
|
|
738
|
+
fileObj,
|
|
739
|
+
);
|
|
647
740
|
};
|
|
648
741
|
|
|
649
742
|
return this.saveLog(itemObj, requestPromise);
|
|
@@ -653,17 +746,21 @@ class RPClient {
|
|
|
653
746
|
const url = 'log';
|
|
654
747
|
// eslint-disable-next-line no-param-reassign
|
|
655
748
|
saveLogRQ.file = { name: fileObj.name };
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
this.buildMultiPartStream([saveLogRQ], fileObj, MULTIPART_BOUNDARY),
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
749
|
+
this.logDebug(`Save log with file: ${fileObj.name}`, saveLogRQ);
|
|
750
|
+
return this.restClient
|
|
751
|
+
.create(url, this.buildMultiPartStream([saveLogRQ], fileObj, MULTIPART_BOUNDARY), {
|
|
752
|
+
headers: {
|
|
753
|
+
...this.headers,
|
|
754
|
+
'Content-Type': `multipart/form-data; boundary=${MULTIPART_BOUNDARY}`,
|
|
755
|
+
},
|
|
756
|
+
})
|
|
757
|
+
.then((response) => {
|
|
758
|
+
this.logDebug(`Success save log with file: ${fileObj.name}`, response);
|
|
759
|
+
return response;
|
|
760
|
+
})
|
|
664
761
|
.catch((error) => {
|
|
665
|
-
this.logDebug(
|
|
666
|
-
|
|
762
|
+
this.logDebug(`Error save log with file: ${fileObj.name}`, error);
|
|
763
|
+
console.dir(error);
|
|
667
764
|
});
|
|
668
765
|
}
|
|
669
766
|
|
|
@@ -673,21 +770,36 @@ class RPClient {
|
|
|
673
770
|
* @Private
|
|
674
771
|
*/
|
|
675
772
|
buildMultiPartStream(jsonPart, filePart, boundary) {
|
|
676
|
-
const eol =
|
|
773
|
+
const eol = '\r\n';
|
|
677
774
|
const bx = `--${boundary}`;
|
|
678
775
|
const buffers = [
|
|
679
776
|
// eslint-disable-next-line function-paren-newline
|
|
680
777
|
Buffer.from(
|
|
681
778
|
// eslint-disable-next-line prefer-template
|
|
682
|
-
bx +
|
|
683
|
-
|
|
684
|
-
|
|
779
|
+
bx +
|
|
780
|
+
eol +
|
|
781
|
+
'Content-Disposition: form-data; name="json_request_part"' +
|
|
782
|
+
eol +
|
|
783
|
+
'Content-Type: application/json' +
|
|
784
|
+
eol +
|
|
785
|
+
eol +
|
|
786
|
+
eol +
|
|
787
|
+
JSON.stringify(jsonPart) +
|
|
788
|
+
eol,
|
|
685
789
|
),
|
|
686
790
|
// eslint-disable-next-line function-paren-newline
|
|
687
791
|
Buffer.from(
|
|
688
792
|
// eslint-disable-next-line prefer-template
|
|
689
|
-
bx +
|
|
690
|
-
|
|
793
|
+
bx +
|
|
794
|
+
eol +
|
|
795
|
+
'Content-Disposition: form-data; name="file"; filename="' +
|
|
796
|
+
filePart.name +
|
|
797
|
+
'"' +
|
|
798
|
+
eol +
|
|
799
|
+
'Content-Type: ' +
|
|
800
|
+
filePart.type +
|
|
801
|
+
eol +
|
|
802
|
+
eol,
|
|
691
803
|
),
|
|
692
804
|
Buffer.from(filePart.content, 'base64'),
|
|
693
805
|
Buffer.from(`${eol + bx}--${eol}`),
|
|
@@ -696,23 +808,30 @@ class RPClient {
|
|
|
696
808
|
}
|
|
697
809
|
|
|
698
810
|
finishTestItemPromiseStart(itemObj, itemTempId, finishTestItemData) {
|
|
699
|
-
itemObj.promiseStart
|
|
700
|
-
|
|
811
|
+
itemObj.promiseStart.then(
|
|
812
|
+
() => {
|
|
701
813
|
const url = ['item', itemObj.realId].join('/');
|
|
702
|
-
this.logDebug(`Finish test item ${itemTempId}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
814
|
+
this.logDebug(`Finish test item with tempId ${itemTempId}`, itemObj);
|
|
815
|
+
this.restClient
|
|
816
|
+
.update(url, Object.assign(finishTestItemData, { launchUuid: this.launchUuid }), {
|
|
817
|
+
headers: this.headers,
|
|
818
|
+
})
|
|
819
|
+
.then(
|
|
820
|
+
(response) => {
|
|
821
|
+
this.logDebug(`Success finish item with tempId ${itemTempId}`, response);
|
|
822
|
+
itemObj.resolveFinish(response);
|
|
823
|
+
},
|
|
824
|
+
(error) => {
|
|
825
|
+
this.logDebug(`Error finish test item with tempId ${itemTempId}`, error);
|
|
826
|
+
console.dir(error);
|
|
827
|
+
itemObj.rejectFinish(error);
|
|
828
|
+
},
|
|
829
|
+
);
|
|
830
|
+
},
|
|
831
|
+
(error) => {
|
|
714
832
|
itemObj.rejectFinish(error);
|
|
715
|
-
}
|
|
833
|
+
},
|
|
834
|
+
);
|
|
716
835
|
}
|
|
717
836
|
}
|
|
718
837
|
|
package/lib/rest.js
CHANGED
|
@@ -5,7 +5,11 @@ const https = require('https');
|
|
|
5
5
|
|
|
6
6
|
const DEFAULT_MAX_CONNECTION_TIME_MS = 30000;
|
|
7
7
|
|
|
8
|
-
axiosRetry(axios, {
|
|
8
|
+
axiosRetry(axios, {
|
|
9
|
+
retryDelay: () => 100,
|
|
10
|
+
retries: 10,
|
|
11
|
+
retryCondition: axiosRetry.isRetryableError,
|
|
12
|
+
});
|
|
9
13
|
|
|
10
14
|
class RestClient {
|
|
11
15
|
constructor(options) {
|
|
@@ -34,11 +38,16 @@ class RestClient {
|
|
|
34
38
|
.catch((error) => {
|
|
35
39
|
const errorMessage = error.message;
|
|
36
40
|
const responseData = error.response && error.response.data;
|
|
37
|
-
throw new Error(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
throw new Error(
|
|
42
|
+
`${errorMessage}${
|
|
43
|
+
responseData && typeof responseData === 'object'
|
|
44
|
+
? `: ${JSON.stringify(responseData)}`
|
|
45
|
+
: ''
|
|
46
|
+
}
|
|
47
|
+
URL: ${url}
|
|
48
|
+
method: ${method}
|
|
49
|
+
Request data: ${JSON.stringify(data)}`,
|
|
50
|
+
);
|
|
42
51
|
});
|
|
43
52
|
}
|
|
44
53
|
|
|
@@ -65,24 +74,33 @@ class RestClient {
|
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
create(path, data, options = { headers: this.headers }) {
|
|
68
|
-
return RestClient.request('POST', this.buildPath(path), data, {
|
|
77
|
+
return RestClient.request('POST', this.buildPath(path), data, {
|
|
78
|
+
...options,
|
|
79
|
+
...this.getRestConfig(),
|
|
80
|
+
});
|
|
69
81
|
}
|
|
70
82
|
|
|
71
83
|
retrieve(path, options = { headers: this.headers }) {
|
|
72
|
-
return RestClient.request(
|
|
84
|
+
return RestClient.request(
|
|
85
|
+
'GET',
|
|
86
|
+
this.buildPath(path),
|
|
87
|
+
{},
|
|
88
|
+
{ ...options, ...this.getRestConfig() },
|
|
89
|
+
);
|
|
73
90
|
}
|
|
74
91
|
|
|
75
92
|
update(path, data, options = { headers: this.headers }) {
|
|
76
|
-
return RestClient.request('PUT', this.buildPath(path), data, {
|
|
93
|
+
return RestClient.request('PUT', this.buildPath(path), data, {
|
|
94
|
+
...options,
|
|
95
|
+
...this.getRestConfig(),
|
|
96
|
+
});
|
|
77
97
|
}
|
|
78
98
|
|
|
79
99
|
delete(path, data, options = { headers: this.headers }) {
|
|
80
|
-
return RestClient.request(
|
|
81
|
-
|
|
82
|
-
this.
|
|
83
|
-
|
|
84
|
-
{ ...options, ...this.getRestConfig() },
|
|
85
|
-
);
|
|
100
|
+
return RestClient.request('DELETE', this.buildPath(path), data, {
|
|
101
|
+
...options,
|
|
102
|
+
...this.getRestConfig(),
|
|
103
|
+
});
|
|
86
104
|
}
|
|
87
105
|
|
|
88
106
|
retrieveSyncAPI(path, options = { headers: this.headers }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reportportal/client-javascript",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.8",
|
|
4
4
|
"description": "ReportPortal client for node.js",
|
|
5
5
|
"author": "ReportPortal.io",
|
|
6
6
|
"contributors": [
|
|
@@ -31,15 +31,17 @@
|
|
|
31
31
|
"node": ">= 10.0.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"axios": "^0.
|
|
34
|
+
"axios": "^0.27.2",
|
|
35
35
|
"axios-retry": "^3.2.4",
|
|
36
36
|
"glob": "^7.2.0",
|
|
37
37
|
"uniqid": "^5.4.0",
|
|
38
|
-
"universal-analytics": "^0.
|
|
38
|
+
"universal-analytics": "^0.5.3"
|
|
39
39
|
},
|
|
40
40
|
"license": "Apache-2.0",
|
|
41
41
|
"scripts": {
|
|
42
|
-
"
|
|
42
|
+
"build": "npm run clean && tsc",
|
|
43
|
+
"clean": "rimraf ./build",
|
|
44
|
+
"lint": "eslint ./analytics/**/* ./lib/**/* ./spec/**/*",
|
|
43
45
|
"format": "npm run lint -- --fix",
|
|
44
46
|
"test": "nyc ./node_modules/jasmine/bin/jasmine.js",
|
|
45
47
|
"test:coverage": "nyc report --reporter=lcov --reporter=text-summary"
|
|
@@ -47,12 +49,24 @@
|
|
|
47
49
|
"devDependencies": {
|
|
48
50
|
"eslint": "^7.32.0",
|
|
49
51
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
50
|
-
"eslint-plugin-import": "^2.
|
|
52
|
+
"eslint-plugin-import": "^2.26.0",
|
|
51
53
|
"eslint-plugin-node": "^11.1.0",
|
|
54
|
+
"typescript": "^4.7.4",
|
|
52
55
|
"jasmine": "^3.5.0",
|
|
53
56
|
"lodash": "^4.17.11",
|
|
54
|
-
"nock": "^
|
|
55
|
-
"nyc": "^15.1.0"
|
|
57
|
+
"nock": "^13.2.9",
|
|
58
|
+
"nyc": "^15.1.0",
|
|
59
|
+
"prettier": "^2.7.1",
|
|
60
|
+
"rimraf": "^3.0.2",
|
|
61
|
+
"@types/jasmine": "^4.0.3",
|
|
62
|
+
"@types/node": "^18.7.6",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^5.33.1",
|
|
64
|
+
"@typescript-eslint/parser": "^5.33.1",
|
|
65
|
+
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
66
|
+
"eslint-config-prettier": "^8.5.0",
|
|
67
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
68
|
+
"jasmine-ts": "^0.4.0",
|
|
69
|
+
"ts-node": "^10.9.1"
|
|
56
70
|
},
|
|
57
71
|
"bugs": {
|
|
58
72
|
"url": "https://github.com/reportportal/client-javascript/issues"
|