Skip to content

Commit 999d824

Browse files
maria-hambardzumianmaria-hambardzumian
andauthored
EPMRPP-84449 || Added 'skippedIssue' (#246)
* EPMRPP-84449 || Added 'skippedIssue' * EPMRPP-84449 || format fix * EPMRPP-84449 || Exclude tests from lint * EPMRPP-84449 || crf * EPMRPP-84449 || removed redundant test * EPMRPP-84449 || coderabbitai comment fix --------- Co-authored-by: maria-hambardzumian <[email protected]>
1 parent 893d4fc commit 999d824

File tree

6 files changed

+121
-1
lines changed

6 files changed

+121
-1
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"es6": true,
2020
"jest": true
2121
},
22+
"ignorePatterns": ["__tests__/**/*"],
2223
"rules": {
2324
"valid-jsdoc": ["error", { "requireReturn": false }],
2425
"consistent-return": 0,

__tests__/report-portal-client.spec.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,108 @@ describe('ReportPortal javascript client', () => {
876876
});
877877
});
878878

879+
it('should automatically add NOT_ISSUE when status is SKIPPED and skippedIsNotIssue is true', function (done) {
880+
const mockClient = new RPClient(
881+
{
882+
apiKey: 'test',
883+
endpoint: 'https://reportportal-stub-url',
884+
launch: 'test launch',
885+
project: 'test project',
886+
skippedIsNotIssue: true,
887+
},
888+
{ name: 'test', version: '1.0.0' },
889+
);
890+
891+
const spyFinishTestItemPromiseStart = jest
892+
.spyOn(mockClient, 'finishTestItemPromiseStart')
893+
.mockImplementation(() => {});
894+
895+
mockClient.map = {
896+
testItemId: {
897+
children: [],
898+
finishSend: false,
899+
promiseFinish: Promise.resolve(),
900+
resolveFinish: () => {},
901+
},
902+
};
903+
904+
const finishTestItemRQ = {
905+
status: 'skipped',
906+
};
907+
908+
mockClient.finishTestItem('testItemId', finishTestItemRQ);
909+
910+
setTimeout(() => {
911+
try {
912+
expect(spyFinishTestItemPromiseStart).toHaveBeenCalledWith(
913+
expect.any(Object),
914+
'testItemId',
915+
expect.objectContaining({
916+
status: 'skipped',
917+
issue: { issueType: 'NOT_ISSUE' },
918+
}),
919+
);
920+
done();
921+
} catch (error) {
922+
done(error);
923+
}
924+
}, 50);
925+
});
926+
927+
it('should not add NOT_ISSUE when status is SKIPPED and skippedIsNotIssue is false', function (done) {
928+
const mockClient = new RPClient(
929+
{
930+
apiKey: 'test',
931+
endpoint: 'https://reportportal-stub-url',
932+
launch: 'test launch',
933+
project: 'test project',
934+
skippedIsNotIssue: false,
935+
},
936+
{ name: 'test', version: '1.0.0' },
937+
);
938+
939+
const spyFinishTestItemPromiseStart = jest
940+
.spyOn(mockClient, 'finishTestItemPromiseStart')
941+
.mockImplementation(() => {});
942+
943+
mockClient.map = {
944+
testItemId: {
945+
children: [],
946+
finishSend: false,
947+
promiseFinish: Promise.resolve(),
948+
resolveFinish: () => {},
949+
},
950+
};
951+
952+
const finishTestItemRQ = {
953+
status: 'skipped',
954+
};
955+
956+
mockClient.finishTestItem('testItemId', finishTestItemRQ);
957+
958+
setTimeout(() => {
959+
try {
960+
expect(spyFinishTestItemPromiseStart).toHaveBeenCalledWith(
961+
expect.any(Object),
962+
'testItemId',
963+
expect.objectContaining({
964+
status: 'skipped',
965+
}),
966+
);
967+
expect(spyFinishTestItemPromiseStart).not.toHaveBeenCalledWith(
968+
expect.any(Object),
969+
'testItemId',
970+
expect.objectContaining({
971+
issue: expect.anything(),
972+
}),
973+
);
974+
done();
975+
} catch (error) {
976+
done(error);
977+
}
978+
}, 100);
979+
});
980+
879981
describe('saveLog', () => {
880982
it('should return object with tempId and promise', () => {
881983
const client = new RPClient({ apiKey: 'any', endpoint: 'https://rp.api', project: 'prj' });

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ declare module '@reportportal/client-javascript' {
155155
launchUuidPrintOutput?: string;
156156
restClientConfig?: RestClientConfig;
157157
token?: string;
158+
skippedIsNotIssue?: boolean;
158159
/**
159160
* OAuth 2.0 configuration object. When provided, OAuth authentication will be used instead of API key.
160161
*/

lib/commons/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ const getClientConfig = (options) => {
115115
description: options.description,
116116
launchUuidPrint: options.launchUuidPrint,
117117
launchUuidPrintOutput,
118+
skippedIsNotIssue: !!options.skippedIsNotIssue,
118119
};
119120
} catch (error) {
120121
// don't throw the error up to not break the entire process

lib/report-portal-client.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ class RPClient {
202202
this.launchUuid = launchDataRQ.id;
203203
} else {
204204
const systemAttr = helpers.getSystemAttribute();
205+
if (this.config.skippedIsNotIssue === true) {
206+
const skippedIsNotIssueAttribute = {
207+
key: 'skippedIssue',
208+
value: 'false',
209+
system: true,
210+
};
211+
systemAttr.push(skippedIsNotIssueAttribute);
212+
}
205213
const attributes = Array.isArray(launchDataRQ.attributes)
206214
? launchDataRQ.attributes.concat(systemAttr)
207215
: systemAttr;
@@ -612,6 +620,13 @@ class RPClient {
612620
...finishTestItemRQ,
613621
};
614622

623+
if (
624+
finishTestItemData.status === RP_STATUSES.SKIPPED &&
625+
this.config.skippedIsNotIssue === true
626+
) {
627+
finishTestItemData.issue = { issueType: 'NOT_ISSUE' };
628+
}
629+
615630
itemObj.finishSend = true;
616631
this.logDebug(`Finish all children for test item with tempId ${itemTempId}`);
617632
Promise.allSettled(

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"build": "npm run clean && tsc",
88
"clean": "rimraf ./build",
9-
"lint": "eslint ./statistics/**/* ./lib/**/* ./__tests__/**/*",
9+
"lint": "eslint ./statistics/**/* ./lib/**/*",
1010
"format": "npm run lint -- --fix",
1111
"test": "jest",
1212
"test:coverage": "jest --coverage"

0 commit comments

Comments
 (0)