diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f8dbb4..eb26a17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### Fixed +- Use correct launch search URL based on config mode while merging launches. Resolves [#200](https://github.com/reportportal/client-javascript/issues/200). Thanks to [hoangthanhtri](https://github.com/hoangthanhtri). +- Print launch UUID after merging launches. Resolves [#202](https://github.com/reportportal/client-javascript/issues/202). Thanks to [hoangthanhtri](https://github.com/hoangthanhtri). ## [5.1.3] - 2024-04-11 ### Added diff --git a/VERSION b/VERSION index cdb98d2..e118921 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.1.3 +5.1.4-SNAPSHOT diff --git a/lib/report-portal-client.js b/lib/report-portal-client.js index be95cee..05402e1 100644 --- a/lib/report-portal-client.js +++ b/lib/report-portal-client.js @@ -332,7 +332,8 @@ class RPClient { 'filter.in.uuid': launchUUIds, 'page.size': launchUUIds.length, }); - const launchSearchUrl = `launch?${params.toString()}`; + const launchSearchUrl = this.config.mode === 'DEBUG' ? + `launch/mode?${params.toString()}` : `launch?${params.toString()}`; this.logDebug(`Find launches with UUIDs to merge: ${launchUUIds}`); return this.restClient .retrieveSyncAPI(launchSearchUrl, { headers: this.headers }) @@ -353,8 +354,11 @@ class RPClient { const mergeURL = 'launch/merge'; return this.restClient.create(mergeURL, request, { headers: this.headers }); }) - .then(() => { + .then((response) => { this.logDebug(`Launches with UUIDs: ${launchUUIds} were successfully merged!`); + if (this.config.launchUuidPrint) { + this.config.launchUuidPrintOutput(response.uuid); + } }) .catch((error) => { this.logDebug(`Error merging launches with UUIDs: ${launchUUIds}`, error); diff --git a/spec/report-portal-client.spec.js b/spec/report-portal-client.spec.js index 9a864a5..cc3ef88 100644 --- a/spec/report-portal-client.spec.js +++ b/spec/report-portal-client.spec.js @@ -543,7 +543,7 @@ describe('ReportPortal javascript client', () => { name: 'Test launch name', }; - it('should calls client', (done) => { + it('should call rest client with required parameters', async () => { const client = new RPClient({ apiKey: 'startLaunchTest', endpoint: 'https://rp.us/api/v1', @@ -564,16 +564,13 @@ describe('ReportPortal javascript client', () => { const promise = client.mergeLaunches(); expect(promise.then).toBeDefined(); - promise.then(() => { - expect(client.restClient.create).toHaveBeenCalledWith('launch/merge', fakeMergeDataRQ, { - headers: client.headers, - }); - - done(); + await promise; + expect(client.restClient.create).toHaveBeenCalledWith('launch/merge', fakeMergeDataRQ, { + headers: client.headers, }); }); - it('should not call client if something went wrong', (done) => { + it('should not call rest client if something went wrong', async () => { const client = new RPClient({ apiKey: 'startLaunchTest', endpoint: 'https://rp.us/api/v1', @@ -585,13 +582,9 @@ describe('ReportPortal javascript client', () => { spyOn(client.restClient, 'retrieveSyncAPI').and.resolveTo(); spyOn(client.restClient, 'create').and.rejectWith(); - const promise = client.mergeLaunches(); - - promise.then(() => { - expect(client.restClient.create).not.toHaveBeenCalled(); + await client.mergeLaunches(); - done(); - }); + expect(client.restClient.create).not.toHaveBeenCalled(); }); it('should return undefined if isLaunchMergeRequired is false', () => {