Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-84778 || Fix realId of undefined #171

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/polyfills.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//! Was added to support NodeJS 10.
if (!Promise.allSettled) {
Promise.allSettled = function (promises) {
return Promise.all(
promises.map((p) =>
Promise.resolve(p).then(
(value) => ({
status: 'fulfilled',
value,
}),
(error) => ({
status: 'rejected',
reason: error,
}),
),
),
);
};
}
41 changes: 24 additions & 17 deletions lib/report-portal-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { getClientConfig } = require('./commons/config');
const Statistics = require('../statistics/statistics');
const { EVENT_NAME } = require('../statistics/constants');
const { RP_STATUSES } = require('./constants/statuses');
require('./polyfills');

const MULTIPART_BOUNDARY = Math.floor(Math.random() * 10000000000).toString();

Expand Down Expand Up @@ -581,32 +582,38 @@ class RPClient {

itemObj.finishSend = true;
this.logDebug(`Finish all children for test item with tempId ${itemTempId}`);
Promise.all(
Promise.allSettled(
itemObj.children.map((itemId) => this.map[itemId] && this.map[itemId].promiseFinish),
).then(
() => {
)
.then((results) => {
if (this.debug) {
results.forEach((result, index) => {
if (result.status === 'fulfilled') {
this.logDebug(
`Successfully finish child with tempId ${itemObj.children[index]}
of test item with tempId ${itemTempId}`,
);
} else {
this.logDebug(
`Failed to finish child with tempId ${itemObj.children[index]}
of test item with tempId ${itemTempId}`,
);
}
});
}

this.cleanMap(itemObj.children);
this.logDebug(
`All children for test item with tempId ${itemTempId} successfully finished.`,
);

this.logDebug(`Finish test item with tempId ${itemTempId}`, finishTestItemRQ);
this.finishTestItemPromiseStart(
itemObj,
itemTempId,
Object.assign(finishTestItemData, { launchUuid: this.launchUuid }),
);
},
() => {
this.cleanMap(itemObj.children);
})
.catch(() => {
this.logDebug(`Error finish children of test item with tempId ${itemTempId}`);
this.logDebug(`Finish test item with tempId ${itemTempId}`, finishTestItemRQ);
this.finishTestItemPromiseStart(
itemObj,
itemTempId,
Object.assign(finishTestItemData, { launchUuid: this.launchUuid }),
);
},
);
});

return {
tempId: itemTempId,
Expand Down