zephyr-enterprise-tools 1.0.2 → 1.0.4
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/package.json +1 -1
- package/zephyr-enterprise-tools.js +44 -19
package/package.json
CHANGED
|
@@ -919,42 +919,66 @@ export class QualityGates {
|
|
|
919
919
|
async getTestCaseTrends(projectId, releaseId, options = {}) {
|
|
920
920
|
const { days = 30 } = options;
|
|
921
921
|
|
|
922
|
-
//
|
|
923
|
-
const
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
922
|
+
// Calculate start date for ZQL query
|
|
923
|
+
const now = new Date();
|
|
924
|
+
const startDate = new Date(now.getTime() - days * 24 * 60 * 60 * 1000);
|
|
925
|
+
const startDateStr = startDate.toISOString().split('T')[0]; // YYYY-MM-DD format
|
|
926
|
+
|
|
927
|
+
// Use v3 ZQL advanced search API to get executions within date range
|
|
928
|
+
const v3BaseUrl = this.baseUrl.replace('/latest', '/v3');
|
|
929
|
+
const url = new URL(`${v3BaseUrl}/advancesearch/zql`);
|
|
930
|
+
|
|
931
|
+
const requestBody = {
|
|
932
|
+
firstresult: 0,
|
|
933
|
+
maxresults: 10000,
|
|
934
|
+
entitytype: "execution",
|
|
935
|
+
order: "testcaseId",
|
|
936
|
+
isascorder: true,
|
|
937
|
+
is_cfield: false,
|
|
938
|
+
releaseid: String(releaseId),
|
|
939
|
+
projectid: String(projectId),
|
|
940
|
+
word: `executedOn > "${startDateStr}"`,
|
|
941
|
+
zql: true,
|
|
942
|
+
isOld: false
|
|
943
|
+
};
|
|
944
|
+
|
|
945
|
+
const res = await fetch(url.toString(), {
|
|
946
|
+
method: 'POST',
|
|
947
|
+
headers: { Accept: 'application/json', 'Content-Type': 'application/json', ...this.authHeader() },
|
|
948
|
+
body: JSON.stringify(requestBody),
|
|
928
949
|
});
|
|
929
950
|
|
|
930
|
-
|
|
951
|
+
if (!res.ok) {
|
|
952
|
+
throw new Error(`ZQL API ${res.status}: ${await res.text()}`);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
const responseData = await res.json();
|
|
956
|
+
const executions = responseData[0]?.results || [];
|
|
957
|
+
const totalCount = responseData[0]?.resultSize || executions.length;
|
|
931
958
|
|
|
932
959
|
// Group executions by date
|
|
933
960
|
const trendsByDate = {};
|
|
934
|
-
const now = new Date();
|
|
935
|
-
const startDate = new Date(now.getTime() - days * 24 * 60 * 60 * 1000);
|
|
936
961
|
|
|
937
962
|
for (const exec of executions) {
|
|
938
|
-
|
|
963
|
+
// Use lastModifiedOn or createDatetime as execution date
|
|
964
|
+
const executedOn = exec.lastModifiedOn || exec.createDatetime;
|
|
939
965
|
if (!executedOn) continue;
|
|
940
966
|
|
|
941
967
|
const execDate = new Date(executedOn);
|
|
942
|
-
if (execDate < startDate) continue;
|
|
943
|
-
|
|
944
968
|
const dateKey = execDate.toISOString().split('T')[0];
|
|
945
969
|
|
|
946
970
|
if (!trendsByDate[dateKey]) {
|
|
947
971
|
trendsByDate[dateKey] = { passed: 0, failed: 0, blocked: 0, wip: 0, total: 0 };
|
|
948
972
|
}
|
|
949
973
|
|
|
950
|
-
const status = exec.
|
|
974
|
+
const status = exec.status || '0';
|
|
951
975
|
trendsByDate[dateKey].total++;
|
|
952
976
|
|
|
953
|
-
switch (
|
|
954
|
-
case 1: trendsByDate[dateKey].passed++; break;
|
|
955
|
-
case 2: trendsByDate[dateKey].failed++; break;
|
|
956
|
-
case 3: trendsByDate[dateKey].wip++; break;
|
|
957
|
-
case 4: trendsByDate[dateKey].blocked++; break;
|
|
977
|
+
switch (String(status)) {
|
|
978
|
+
case '1': trendsByDate[dateKey].passed++; break;
|
|
979
|
+
case '2': trendsByDate[dateKey].failed++; break;
|
|
980
|
+
case '3': trendsByDate[dateKey].wip++; break;
|
|
981
|
+
case '4': trendsByDate[dateKey].blocked++; break;
|
|
958
982
|
}
|
|
959
983
|
}
|
|
960
984
|
|
|
@@ -979,11 +1003,12 @@ export class QualityGates {
|
|
|
979
1003
|
timestamp: new Date().toISOString(),
|
|
980
1004
|
period: {
|
|
981
1005
|
days,
|
|
982
|
-
from:
|
|
1006
|
+
from: startDateStr,
|
|
983
1007
|
to: now.toISOString().split('T')[0],
|
|
984
1008
|
},
|
|
985
1009
|
summary: {
|
|
986
1010
|
totalExecutionsInPeriod: totals.total,
|
|
1011
|
+
totalFromAPI: totalCount,
|
|
987
1012
|
passed: totals.passed,
|
|
988
1013
|
failed: totals.failed,
|
|
989
1014
|
blocked: totals.blocked,
|