reportportal-js-client
Advanced tools
Comparing version 1.2.3 to 2.0.0
@@ -13,3 +13,3 @@ /* eslint-disable no-console */ | ||
console.log('You have successfully connected to the server.'); | ||
console.log(`You are using an account: ${response.full_name}`); | ||
console.log(`You are using an account: ${response.fullName}`); | ||
}, (error) => { | ||
@@ -16,0 +16,0 @@ console.log('Error connection to server'); |
@@ -21,3 +21,2 @@ const RestClient = require('./rest'); | ||
}, | ||
}; |
@@ -41,2 +41,4 @@ /* eslint-disable quotes,no-console,class-methods-use-this */ | ||
}); | ||
this.launchUuid = ''; | ||
this.nonRetriedItemMap = new Map(); | ||
} | ||
@@ -55,2 +57,6 @@ | ||
calculateNonRetriedItemMapKey(launchId, parentId, name, itemId = '') { | ||
return `${launchId}__${parentId}__${name}__${itemId}`; | ||
} | ||
getUniqId() { | ||
@@ -96,13 +102,9 @@ return UniqId(); | ||
checkConnect() { | ||
const url = [this.config.endpoint, 'user'].join('/'); | ||
return RestClient.request('GET', url, {}, { headers: this.headers }); | ||
getLaunchByUid(uuid) { | ||
const url = ['launch/uuid', uuid].join('/'); | ||
return this.restClient.retrieve(url, { headers: this.headers }); | ||
} | ||
/** | ||
* Warning report v5 api used | ||
* @return {Object} - plugins object. | ||
*/ | ||
getPlugins() { | ||
const url = [this.config.endpoint, 'plugin'].join('/'); | ||
checkConnect() { | ||
const url = [this.config.endpoint.replace('/v2', '/v1'), 'user'].join('/'); | ||
return RestClient.request('GET', url, {}, { headers: this.headers }); | ||
@@ -112,12 +114,2 @@ } | ||
/** | ||
* Warning report v5 api used | ||
* @param {Object} uuid - launch uuid. | ||
* @return {Object} - launch object | ||
*/ | ||
getLaunchByUid(uuid) { | ||
const url = ['launch/uuid', uuid].join('/'); | ||
return this.restClient.retrieve(url, { headers: this.headers }); | ||
} | ||
/** | ||
* Start launch and report it. | ||
@@ -131,4 +123,10 @@ * @param {Object} launchDataRQ - request object. | ||
"startTime": this.helper.now(), | ||
"tags": [ | ||
"string" | ||
"attributes": [ | ||
{ | ||
"key": "string", | ||
"value": "string" | ||
}, | ||
{ | ||
"value": "string" | ||
} | ||
] | ||
@@ -154,17 +152,9 @@ * } | ||
this.map[tempId].realId = launchDataRQ.id; | ||
this.launchUuid = launchDataRQ.id; | ||
} else { | ||
const launchData = Object.assign( | ||
{ | ||
name: this.config.launch || 'Test launch name', | ||
startTime: this.helpers.now(), | ||
start_time: this.helpers.now(), | ||
}, | ||
{ name: this.config.launch || 'Test launch name', startTime: this.helpers.now() }, | ||
launchDataRQ, | ||
); | ||
if (launchDataRQ.tags) { | ||
launchData.attributes = launchDataRQ.tags | ||
.map((value) => (typeof value === 'string' ? { value } : { ...value })); | ||
} | ||
this.map[tempId] = this.getNewItemObj((resolve, reject) => { | ||
@@ -175,4 +165,4 @@ const url = 'launch'; | ||
.then((response) => { | ||
const realId = response.uuid || response.id; | ||
this.map[tempId].realId = realId; | ||
this.map[tempId].realId = response.id; | ||
this.launchUuid = response.id; | ||
resolve(response); | ||
@@ -198,3 +188,3 @@ }, (error) => { | ||
* "endTime": this.helper.now(), | ||
* "status": "PASSED" or one of ‘PASSED’, ‘FAILED’, ‘STOPPED’, ‘SKIPPED’, ‘RESTED’, ‘CANCELLED’ | ||
* "status": "passed" or one of ‘passed’, ‘failed’, ‘stopped’, ‘skipped’, ‘interrupted’, ‘cancelled’ | ||
* } | ||
@@ -209,8 +199,3 @@ * @Returns {Object} - an object which contains a tempID and a promise | ||
const finishExecutionData = Object.assign( | ||
{ | ||
end_time: this.helpers.now(), | ||
endTime: this.helpers.now(), | ||
}, finishExecutionRQ, | ||
); | ||
const finishExecutionData = Object.assign({ endTime: this.helpers.now() }, finishExecutionRQ); | ||
@@ -267,4 +252,10 @@ launchObj.finishSend = true; | ||
"mode": "DEFAULT" or "DEBUG", | ||
"tags": [ | ||
"string" | ||
"attributes": [ | ||
{ | ||
"key": "string", | ||
"value": "string" | ||
}, | ||
{ | ||
"value": "string" | ||
} | ||
] | ||
@@ -312,4 +303,10 @@ } | ||
"startTime": this.helper.now(), | ||
"tags": [ | ||
"string" | ||
"attributes": [ | ||
{ | ||
"key": "string", | ||
"value": "string" | ||
}, | ||
{ | ||
"value": "string" | ||
} | ||
], | ||
@@ -337,4 +334,3 @@ "type": 'SUITE' or one of 'SUITE', 'STORY', 'TEST', | ||
const testItemData = { startTime: this.helpers.now(), start_time: this.helpers.now() }; | ||
Object.assign(testItemData, testItemDataRQ); | ||
const testItemData = Object.assign({ startTime: this.helpers.now() }, testItemDataRQ); | ||
@@ -351,2 +347,13 @@ let parentPromise = launchObj.promiseStart; | ||
const itemKey = this.calculateNonRetriedItemMapKey( | ||
launchTempId, | ||
parentTempId, | ||
testItemDataRQ.name, | ||
testItemDataRQ.uniqueId, | ||
); | ||
const firstNonRetriedItemPromise = testItemDataRQ.retry && this.nonRetriedItemMap.get(itemKey); | ||
if (firstNonRetriedItemPromise) { | ||
parentPromise = Promise.all([parentPromise, firstNonRetriedItemPromise]); | ||
} | ||
const tempId = this.getUniqId(); | ||
@@ -356,9 +363,8 @@ this.map[tempId] = this.getNewItemObj((resolve, reject) => { | ||
const realLaunchId = this.map[launchTempId].realId; | ||
let url = 'item'; | ||
let url = 'item/'; | ||
if (parentTempId) { | ||
const realParentId = this.map[parentTempId].realId; | ||
url += `/${realParentId}`; | ||
url += `${realParentId}`; | ||
} | ||
testItemData.launch_id = realLaunchId; | ||
testItemData.launchId = realLaunchId; | ||
testItemData.launchUuid = realLaunchId; | ||
this.logDebug(`Start test item ${tempId}`); | ||
@@ -368,3 +374,4 @@ this.restClient.create(url, testItemData, { headers: this.headers }) | ||
this.logDebug(`Success start item ${tempId}`); | ||
this.map[tempId].realId = response.uuid || response.id; | ||
this.map[tempId].realId = response.id; | ||
this.nonRetriedItemMap.delete(itemKey); | ||
resolve(response); | ||
@@ -382,2 +389,6 @@ }, (error) => { | ||
if (!testItemDataRQ.retry) { | ||
this.nonRetriedItemMap.set(itemKey, this.map[tempId].promiseStart); | ||
} | ||
return { | ||
@@ -407,5 +418,5 @@ tempId, | ||
], | ||
"issue_type": "string" | ||
"issueType": "string" | ||
}, | ||
"status": "PASSED" or one of 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'RESETED', 'CANCELLED' | ||
"status": "passed" or one of 'passed', 'failed', 'stopped', 'skipped', 'interrupted', 'cancelled' | ||
} | ||
@@ -421,5 +432,4 @@ * @Returns {Object} - an object which contains a tempId and a promise | ||
const finishTestItemData = Object.assign({ | ||
end_time: this.helpers.now(), | ||
endTime: this.helpers.now(), | ||
status: 'PASSED', | ||
status: 'passed', | ||
}, finishTestItemRQ); | ||
@@ -431,3 +441,5 @@ | ||
this.cleanMap(itemObj.childrens); | ||
this.finishTestItemPromiseStart(itemObj, itemTempId, finishTestItemData); | ||
this.finishTestItemPromiseStart(itemObj, | ||
itemTempId, | ||
Object.assign(finishTestItemData, { launchUuid: this.launchUuid })); | ||
}, () => { | ||
@@ -437,3 +449,5 @@ this.cleanMap(itemObj.childrens); | ||
this.logDebug(`Finish test item ${itemTempId}`); | ||
this.finishTestItemPromiseStart(itemObj, itemTempId, finishTestItemData); | ||
this.finishTestItemPromiseStart(itemObj, | ||
itemTempId, | ||
Object.assign(finishTestItemData, { launchUuid: this.launchUuid })); | ||
}); | ||
@@ -452,3 +466,3 @@ | ||
this.logDebug(`Save log ${tempId}`); | ||
requestPromiseFunc(itemObj.realId).then((response) => { | ||
requestPromiseFunc(itemObj.realId, this.launchUuid).then((response) => { | ||
this.logDebug(`Successfully save log ${tempId}`); | ||
@@ -507,9 +521,6 @@ resolve(response); | ||
const requestPromise = (id) => { | ||
const requestPromise = (itemUuid, launchUuid) => { | ||
const url = 'log'; | ||
// eslint-disable-next-line no-param-reassign | ||
saveLogRQ.itemId = id; | ||
// eslint-disable-next-line no-param-reassign | ||
saveLogRQ.item_id = id; | ||
return this.restClient.create(url, saveLogRQ, { headers: this.headers }); | ||
// eslint-disable-next-line max-len | ||
return this.restClient.create(url, Object.assign(saveLogRQ, { itemUuid, launchUuid }), { headers: this.headers }); | ||
}; | ||
@@ -545,10 +556,5 @@ return this.saveLog(itemObj, requestPromise); | ||
} | ||
// eslint-disable-next-line max-len | ||
const requestPromise = (itemUuid, launchUuid) => this.getRequestLogWithFile(Object.assign(saveLogRQ, { itemUuid, launchUuid }), fileObj); | ||
const requestPromise = (id) => { | ||
// eslint-disable-next-line no-param-reassign | ||
saveLogRQ.itemId = id; | ||
// eslint-disable-next-line no-param-reassign | ||
saveLogRQ.item_id = id; | ||
return this.getRequestLogWithFile(saveLogRQ, fileObj); | ||
}; | ||
return this.saveLog(itemObj, requestPromise); | ||
@@ -611,3 +617,4 @@ } | ||
this.logDebug(`Finish test item ${itemTempId}`); | ||
this.restClient.update(url, finishTestItemData, { headers: this.headers }) | ||
// eslint-disable-next-line max-len | ||
this.restClient.update(url, Object.assign(finishTestItemData, { launchUuid: this.launchUuid }), { headers: this.headers }) | ||
.then((response) => { | ||
@@ -614,0 +621,0 @@ this.logDebug(`Success finish item ${itemTempId}`); |
{ | ||
"name": "reportportal-js-client", | ||
"version": "1.2.3", | ||
"version": "2.0.0", | ||
"description": "ReportPortal client for NodeJS", | ||
@@ -36,3 +36,3 @@ "contributors": [ | ||
}, | ||
"license": "GPL-3.0", | ||
"license": "Apache-2.0", | ||
"scripts": { | ||
@@ -39,0 +39,0 @@ "lint": "eslint . --quiet", |
@@ -28,3 +28,3 @@ [![Build Status](https://travis-ci.org/BorisOsipov/reportportal-js-client.svg?branch=master)](https://travis-ci.org/BorisOsipov/reportportal-js-client) | ||
console.log('You have successfully connected to the server.'); | ||
console.log(`You are using an account: ${response.full_name}`); | ||
console.log(`You are using an account: ${response.fullName}`); | ||
}, (error) => { | ||
@@ -57,2 +57,6 @@ console.log('Error connection to server'); | ||
## Asynchronous reporting | ||
The client supports an asynchronous reporting. | ||
If you want the client to work asynchronously change v1 to v2 in addresses in endpoint | ||
### checkConnect | ||
@@ -63,3 +67,3 @@ checkConnect - asynchronous method for verifying the correctness of the client connection | ||
console.log('You have successfully connected to the server.'); | ||
console.log(`You are using an account: ${response.full_name}`); | ||
console.log(`You are using an account: ${response.fullName}`); | ||
}, (error) => { | ||
@@ -76,5 +80,13 @@ console.log('Error connection to server'); | ||
name: "Client test", | ||
start_time: rpClient.helpers.now(), | ||
startTime: rpClient.helpers.now(), | ||
description: "description of the launch", | ||
tags: ["tag1", "tag2"], | ||
attributes: [ | ||
{ | ||
"key": "yourKey", | ||
"value": "yourValue" | ||
}, | ||
{ | ||
"value": "yourValue" | ||
} | ||
], | ||
//this param used only when you need client to send data into the existing launch | ||
@@ -90,10 +102,10 @@ id: 'id' | ||
--------- | ----------- | ||
start_time | (optional) start time launch(unix time). Default: rpClient.helpers.now() | ||
startTime | (optional) start time launch(unix time). Default: rpClient.helpers.now() | ||
name | (optional) launch name. Default: parameter 'launch' specified when creating the client instance | ||
mode | (optional) "DEFAULT" or "DEBUG". Default: "DEFAULT" | ||
description | (optional) description of the launch (supports markdown syntax) | ||
tags | (optional) array of launch tags | ||
attributes | (optional) array of launch tags | ||
id | id of the existing launch in which tests data would be sent, without this param new launch instance would be created | ||
To know the real launch id wait for the method to finish (the real id is not used by the client) | ||
To know the real launch id wait for the method to finish. The real id is used by the client in asynchronous reporting. | ||
```javascript | ||
@@ -114,3 +126,3 @@ let launchObj = rpClient.startLaunch(); | ||
let launchFinishObj = rpClient.finishLaunch(launchObj.tempId, { | ||
end_time: rpClient.helpers.now() | ||
endTime: rpClient.helpers.now() | ||
}); | ||
@@ -124,4 +136,4 @@ ``` | ||
--------- | ----------- | ||
end_time | (optional) end time of launch. Default: rpClient.helpers.now() | ||
status | (optional) status of launch, one of "", "PASSED", "FAILED", "STOPPED", "SKIPPED", "RESTED", "CANCELLED". Default: "". | ||
endTime | (optional) end time of launch. Default: rpClient.helpers.now() | ||
status | (optional) status of launch, one of "", "PASSED", "FAILED", "STOPPED", "SKIPPED", "INTERRUPTED", "CANCELLED". | ||
@@ -147,3 +159,11 @@ ### getPromiseFinishAllItems | ||
description: 'new launch description', | ||
tags: ['new_tag1', 'new_tag2'], | ||
attributes: [ | ||
{ | ||
"key": "yourKey", | ||
"value": "yourValue" | ||
}, | ||
{ | ||
"value": "yourValue" | ||
} | ||
], | ||
mode: 'DEBUG' | ||
@@ -164,3 +184,3 @@ } | ||
name: makeid(), | ||
start_time: rpClient.helpers.now(), | ||
startTime: rpClient.helpers.now(), | ||
type: "SUITE" | ||
@@ -171,4 +191,13 @@ }, launchObj.tempId); | ||
name: makeid(), | ||
start_time: rpClient.helpers.now(), | ||
tags: ['step_tag', 'step_tag2', 'step_tag3'], | ||
startTime: rpClient.helpers.now(), | ||
attributes: [ | ||
{ | ||
"key": "yourKey", | ||
"value": "yourValue" | ||
}, | ||
{ | ||
"value": "yourValue" | ||
} | ||
], | ||
type: "STEP" | ||
@@ -186,4 +215,4 @@ }, launchObj.tempId, suiteObj.tempId); | ||
description | (optional) description of the launch (supports markdown syntax) | ||
start_time | (optional) start time item(unix time). Default: rpClient.helpers.now() | ||
tags | (optional) array of item tags | ||
startTime | (optional) start time item(unix time). Default: rpClient.helpers.now() | ||
attributes | (optional) array of item attributes | ||
@@ -209,5 +238,5 @@ * id launch (returned by method 'startLaunch') | ||
--------- | ----------- | ||
end_time | (optional) end time of launch. Default: rpClient.helpers.now() | ||
status | (optional) item status, one of "", "PASSED", "FAILED", "STOPPED", "SKIPPED", "RESTED", "CANCELLED". Default: "PASSED". | ||
issue | (optional) object issue | ||
endTime | (optional) end time of launch. Default: rpClient.helpers.now() | ||
status | (optional) item status, one of "", "PASSED", "FAILED", "STOPPED", "SKIPPED", "INTERRUPTED", "CANCELLED". Default: "PASSED". | ||
issue | (optional) object issue. IssueType is required, allowable values: "pb***", "ab***", "si***", "ti***", "nd001". Where *** is locator id | ||
@@ -217,2 +246,3 @@ Example issue object: | ||
{ | ||
issueType: "string", | ||
comment: "string", | ||
@@ -260,3 +290,3 @@ externalSystemIssues: [ | ||
# Copyright Notice | ||
Licensed under the [GPLv3](https://www.gnu.org/licenses/quick-guide-gplv3.html) | ||
Licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.html) | ||
license (see the LICENSE.txt file). |
@@ -26,3 +26,2 @@ /* eslint-disable global-require,no-underscore-dangle */ | ||
client.startLaunch({ | ||
start_time: time, | ||
startTime: time, | ||
@@ -33,5 +32,18 @@ }); | ||
startTime: time, | ||
start_time: time, | ||
}, { headers: client.headers }); | ||
}); | ||
it('dont start new launch if launchDataRQ.id is not empty', () => { | ||
client = new RPClient({ token: 'startLaunchTest', endpoint: 'https://rp.us/api/v1', project: 'tst' }); | ||
const myPromise = Promise.resolve({ id: 'testidlaunch' }); | ||
spyOn(client.restClient, 'create').and.returnValue(myPromise); | ||
const startTime = 12345734; | ||
const id = 12345734; | ||
client.startLaunch({ | ||
startTime, | ||
id, | ||
}); | ||
expect(client.restClient.create).not.toHaveBeenCalled(); | ||
expect(client.launchUuid).toEqual(id); | ||
}); | ||
}); | ||
@@ -38,0 +50,0 @@ xdescribe('updateLaunch', () => { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
136729
19
0
100
1396
279