@smartbear/mcp 0.10.0 → 0.12.0

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.
Files changed (63) hide show
  1. package/README.md +10 -8
  2. package/dist/bugsnag/client/api/Error.js +1 -1
  3. package/dist/bugsnag/client/api/Project.js +152 -0
  4. package/dist/bugsnag/client/api/api.js +130 -3
  5. package/dist/bugsnag/client/api/base.js +19 -0
  6. package/dist/bugsnag/client/api/index.js +2 -0
  7. package/dist/bugsnag/client/filters.js +0 -6
  8. package/dist/bugsnag/client.js +739 -378
  9. package/dist/bugsnag/input-schemas.js +59 -0
  10. package/dist/collaborator/client.js +18 -5
  11. package/dist/common/cache.js +63 -0
  12. package/dist/common/client-registry.js +128 -0
  13. package/dist/common/register-clients.js +31 -0
  14. package/dist/common/server.js +30 -9
  15. package/dist/common/transport-http.js +377 -0
  16. package/dist/common/transport-stdio.js +48 -0
  17. package/dist/index.js +20 -70
  18. package/dist/pactflow/client.js +39 -19
  19. package/dist/qmetry/client/auto-resolve.js +10 -0
  20. package/dist/qmetry/client/automation.js +171 -0
  21. package/dist/qmetry/client/handlers.js +9 -2
  22. package/dist/qmetry/client/project.js +87 -1
  23. package/dist/qmetry/client/testsuite.js +37 -1
  24. package/dist/qmetry/client/tools/automation-tools.js +290 -0
  25. package/dist/qmetry/client/tools/index.js +3 -0
  26. package/dist/qmetry/client/tools/issue-tools.js +1 -1
  27. package/dist/qmetry/client/tools/project-tools.js +311 -1
  28. package/dist/qmetry/client/tools/requirement-tools.js +1 -1
  29. package/dist/qmetry/client/tools/testcase-tools.js +311 -39
  30. package/dist/qmetry/client/tools/testsuite-tools.js +337 -23
  31. package/dist/qmetry/client.js +24 -9
  32. package/dist/qmetry/config/constants.js +6 -0
  33. package/dist/qmetry/config/rest-endpoints.js +8 -0
  34. package/dist/qmetry/types/automation.js +8 -0
  35. package/dist/qmetry/types/common.js +299 -4
  36. package/dist/qmetry/types/issues.js +5 -0
  37. package/dist/qmetry/types/project.js +13 -0
  38. package/dist/qmetry/types/requirements.js +5 -0
  39. package/dist/qmetry/types/testcase.js +5 -0
  40. package/dist/qmetry/types/testsuite.js +9 -0
  41. package/dist/reflect/client.js +10 -4
  42. package/dist/{api-hub → swagger}/client/api.js +94 -37
  43. package/dist/{api-hub → swagger}/client/configuration.js +4 -2
  44. package/dist/{api-hub → swagger}/client/index.js +2 -2
  45. package/dist/{api-hub → swagger}/client/portal-types.js +7 -6
  46. package/dist/{api-hub → swagger}/client/registry-types.js +26 -0
  47. package/dist/{api-hub → swagger}/client/tools.js +19 -20
  48. package/dist/{api-hub → swagger}/client.js +51 -39
  49. package/dist/swagger/config-utils.js +18 -0
  50. package/dist/tests/unit/bugsnag/utils/factories.js +86 -0
  51. package/dist/zephyr/client.js +44 -8
  52. package/dist/zephyr/common/rest-api-schemas.js +79 -78
  53. package/dist/zephyr/tool/environment/get-environments.js +68 -0
  54. package/dist/zephyr/tool/priority/get-priorities.js +43 -0
  55. package/dist/zephyr/tool/status/get-statuses.js +49 -0
  56. package/dist/zephyr/tool/test-case/get-test-case.js +39 -0
  57. package/dist/zephyr/tool/test-case/get-test-cases.js +64 -0
  58. package/dist/zephyr/tool/test-cycle/get-test-cycle.js +39 -0
  59. package/dist/zephyr/tool/test-cycle/get-test-cycles.js +2 -2
  60. package/dist/zephyr/tool/test-execution/get-test-execution.js +39 -0
  61. package/dist/zephyr/tool/test-execution/get-test-executions.js +45 -0
  62. package/package.json +4 -3
  63. /package/dist/{api-hub → swagger}/client/user-management-types.js +0 -0
@@ -0,0 +1,171 @@
1
+ import { MCP_SERVER_NAME, MCP_SERVER_VERSION } from "../../common/info.js";
2
+ import { QMETRY_DEFAULTS } from "../config/constants.js";
3
+ import { QMETRY_PATHS } from "../config/rest-endpoints.js";
4
+ import { DEFAULT_IMPORT_AUTOMATION_PAYLOAD } from "../types/automation.js";
5
+ import { qmetryRequest } from "./api/client-api.js";
6
+ import { handleQMetryApiError } from "./api/error-handler.js";
7
+ /**
8
+ * Imports automation test results into QMetry
9
+ *
10
+ * This function handles file upload via FormData to import automation test results
11
+ * from various frameworks (TestNG, JUnit, Cucumber, Robot, etc.)
12
+ *
13
+ * CRITICAL NOTES:
14
+ * - User MUST provide a valid result file (.json, .xml, or .zip up to 30 MB)
15
+ * - File should be base64 encoded or provided as file path
16
+ * - EntityType is required and determines the framework format
17
+ * - Various parameters control test case/suite creation and linking behavior
18
+ *
19
+ * @param token - QMetry API authentication token
20
+ * @param baseUrl - QMetry instance base URL
21
+ * @param project - Project key (used in header, can be overridden by projectID in payload)
22
+ * @param payload - Import configuration including file data, entityType, and optional parameters
23
+ * @returns Promise resolving to import result with test suite and execution details
24
+ */
25
+ export async function importAutomationResults(token, baseUrl, project, payload) {
26
+ // Merge with defaults
27
+ const finalPayload = {
28
+ ...DEFAULT_IMPORT_AUTOMATION_PAYLOAD,
29
+ ...payload,
30
+ };
31
+ // Create FormData for multipart/form-data upload
32
+ const formData = new FormData();
33
+ // Handle file upload
34
+ // The file should be provided as base64 string or file content
35
+ let fileBlob;
36
+ if (finalPayload.file.startsWith("data:")) {
37
+ // Base64 data URI format
38
+ const base64Data = finalPayload.file.split(",")[1];
39
+ const binaryData = atob(base64Data);
40
+ const bytes = new Uint8Array(binaryData.length);
41
+ for (let i = 0; i < binaryData.length; i++) {
42
+ bytes[i] = binaryData.charCodeAt(i);
43
+ }
44
+ fileBlob = new Blob([bytes]);
45
+ }
46
+ else if (finalPayload.file.startsWith("/") ||
47
+ finalPayload.file.includes(":\\")) {
48
+ // File path - read file from filesystem (Node.js only)
49
+ try {
50
+ const fs = await import("node:fs/promises");
51
+ const fileBuffer = await fs.readFile(finalPayload.file);
52
+ fileBlob = new Blob([new Uint8Array(fileBuffer)]);
53
+ }
54
+ catch (error) {
55
+ throw new Error(`Failed to read file from path: ${finalPayload.file}. Error: ${error instanceof Error ? error.message : String(error)}`);
56
+ }
57
+ }
58
+ else {
59
+ // Assume raw base64 string
60
+ try {
61
+ const binaryData = atob(finalPayload.file);
62
+ const bytes = new Uint8Array(binaryData.length);
63
+ for (let i = 0; i < binaryData.length; i++) {
64
+ bytes[i] = binaryData.charCodeAt(i);
65
+ }
66
+ fileBlob = new Blob([bytes]);
67
+ }
68
+ catch (_error) {
69
+ throw new Error("Invalid file format. Please provide base64 encoded file content or file path.");
70
+ }
71
+ }
72
+ // Add file to FormData
73
+ formData.append("file", fileBlob, finalPayload.fileName);
74
+ // Add required entityType
75
+ formData.append("entityType", finalPayload.entityType);
76
+ // Add optional parameters
77
+ if (finalPayload.automationHierarchy) {
78
+ formData.append("automationHierarchy", finalPayload.automationHierarchy);
79
+ }
80
+ if (finalPayload.testsuiteName) {
81
+ formData.append("testsuiteName", finalPayload.testsuiteName);
82
+ }
83
+ if (finalPayload.testsuiteId) {
84
+ formData.append("testsuiteId", finalPayload.testsuiteId);
85
+ }
86
+ if (finalPayload.tsFolderPath) {
87
+ formData.append("tsFolderPath", finalPayload.tsFolderPath);
88
+ }
89
+ if (finalPayload.tcFolderPath) {
90
+ formData.append("tcFolderPath", finalPayload.tcFolderPath);
91
+ }
92
+ if (finalPayload.platformID) {
93
+ formData.append("platformID", finalPayload.platformID);
94
+ }
95
+ if (finalPayload.projectID) {
96
+ formData.append("projectID", finalPayload.projectID);
97
+ }
98
+ if (finalPayload.releaseID) {
99
+ formData.append("releaseID", finalPayload.releaseID);
100
+ }
101
+ if (finalPayload.cycleID) {
102
+ formData.append("cycleID", finalPayload.cycleID);
103
+ }
104
+ if (finalPayload.buildID) {
105
+ formData.append("buildID", finalPayload.buildID);
106
+ }
107
+ if (finalPayload.testcase_fields) {
108
+ formData.append("testcase_fields", finalPayload.testcase_fields);
109
+ }
110
+ if (finalPayload.testsuite_fields) {
111
+ formData.append("testsuite_fields", finalPayload.testsuite_fields);
112
+ }
113
+ if (finalPayload.skipWarning) {
114
+ formData.append("skipWarning", finalPayload.skipWarning);
115
+ }
116
+ if (finalPayload.is_matching_required) {
117
+ formData.append("is_matching_required", finalPayload.is_matching_required);
118
+ }
119
+ // Make API request
120
+ const url = `${baseUrl || QMETRY_DEFAULTS.BASE_URL}${QMETRY_PATHS.AUTOMATION.IMPORT_RESULTS}`;
121
+ const headers = {
122
+ apikey: token,
123
+ project: finalPayload.projectID || project || QMETRY_DEFAULTS.PROJECT_KEY,
124
+ "User-Agent": `${MCP_SERVER_NAME}/${MCP_SERVER_VERSION}`,
125
+ // Note: Content-Type will be set automatically by fetch for FormData
126
+ };
127
+ let res;
128
+ try {
129
+ res = await fetch(url, {
130
+ method: "POST",
131
+ headers,
132
+ body: formData,
133
+ });
134
+ }
135
+ catch (error) {
136
+ throw new Error(`Failed to import automation results. Network error: ${error instanceof Error ? error.message : String(error)}\n\nPlease check:\n- QMetry server is accessible\n- File size is under 30 MB\n- File format is .json, .xml, or .zip`);
137
+ }
138
+ if (!res.ok) {
139
+ await handleQMetryApiError(res, baseUrl || QMETRY_DEFAULTS.BASE_URL, project || QMETRY_DEFAULTS.PROJECT_KEY, QMETRY_PATHS.AUTOMATION.IMPORT_RESULTS);
140
+ }
141
+ return await res.json();
142
+ }
143
+ /**
144
+ * Fetches automation status by request ID from QMetry
145
+ * @param token - QMetry API authentication token
146
+ * @param baseUrl - QMetry instance base URL
147
+ * @param requestID - Numeric request ID from import automation response
148
+ * @returns Promise resolving to automation status
149
+ */
150
+ export async function getAutomationStatus(token, baseUrl, project, requestID) {
151
+ let numericRequestID;
152
+ if (typeof requestID === "object" &&
153
+ requestID !== null &&
154
+ "requestID" in requestID &&
155
+ typeof requestID.requestID !== "undefined") {
156
+ numericRequestID = Number(requestID.requestID);
157
+ }
158
+ else {
159
+ numericRequestID = Number(requestID);
160
+ }
161
+ if (!numericRequestID || Number.isNaN(numericRequestID)) {
162
+ throw new Error("requestID must be a valid number");
163
+ }
164
+ return qmetryRequest({
165
+ method: "GET",
166
+ path: QMETRY_PATHS.AUTOMATION.GET_STATUS.replace(":requestID", String(numericRequestID)),
167
+ token,
168
+ baseUrl: baseUrl || QMETRY_DEFAULTS.BASE_URL,
169
+ project: project || QMETRY_DEFAULTS.PROJECT_KEY,
170
+ });
171
+ }
@@ -1,9 +1,10 @@
1
1
  import { QMetryToolsHandlers } from "../config/constants.js";
2
+ import { getAutomationStatus, importAutomationResults } from "./automation.js";
2
3
  import { createIssue, fetchIssues, fetchIssuesLinkedToTestCase, linkIssuesToTestcaseRun, updateIssue, } from "./issues.js";
3
- import { getBuilds, getPlatforms, getProjectInfo, getProjects, getReleasesCycles, } from "./project.js";
4
+ import { createCycle, createRelease, getBuilds, getPlatforms, getProjectInfo, getProjects, getReleasesCycles, updateCycle, } from "./project.js";
4
5
  import { fetchRequirementDetails, fetchRequirements, fetchRequirementsLinkedToTestCase, } from "./requirement.js";
5
6
  import { createTestCases, fetchTestCaseDetails, fetchTestCaseExecutions, fetchTestCaseSteps, fetchTestCases, fetchTestCasesLinkedToRequirement, fetchTestCaseVersionDetails, linkRequirementToTestCase, updateTestCase, } from "./testcase.js";
6
- import { createTestSuites, fetchExecutionsByTestSuite, fetchLinkedIssuesByTestCaseRun, fetchTestCaseRunsByTestSuiteRun, fetchTestCasesByTestSuite, fetchTestSuites, fetchTestSuitesForTestCase, linkPlatformsToTestSuite, linkTestCasesToTestSuite, reqLinkedTestCasesToTestSuite, updateTestSuite, } from "./testsuite.js";
7
+ import { bulkUpdateExecutionStatus, createTestSuites, fetchExecutionsByTestSuite, fetchLinkedIssuesByTestCaseRun, fetchTestCaseRunsByTestSuiteRun, fetchTestCasesByTestSuite, fetchTestSuites, fetchTestSuitesForTestCase, linkPlatformsToTestSuite, linkTestCasesToTestSuite, reqLinkedTestCasesToTestSuite, updateTestSuite, } from "./testsuite.js";
7
8
  export const QMETRY_HANDLER_MAP = {
8
9
  [QMetryToolsHandlers.FETCH_PROJECTS]: getProjects,
9
10
  [QMetryToolsHandlers.SET_PROJECT_INFO]: getProjectInfo,
@@ -11,6 +12,9 @@ export const QMETRY_HANDLER_MAP = {
11
12
  [QMetryToolsHandlers.FETCH_RELEASES_CYCLES]: getReleasesCycles,
12
13
  [QMetryToolsHandlers.FETCH_BUILDS]: getBuilds,
13
14
  [QMetryToolsHandlers.FETCH_PLATFORMS]: getPlatforms,
15
+ [QMetryToolsHandlers.CREATE_RELEASE]: createRelease,
16
+ [QMetryToolsHandlers.CREATE_CYCLE]: createCycle,
17
+ [QMetryToolsHandlers.UPDATE_CYCLE]: updateCycle,
14
18
  [QMetryToolsHandlers.CREATE_TEST_CASE]: createTestCases,
15
19
  [QMetryToolsHandlers.UPDATE_TEST_CASE]: updateTestCase,
16
20
  [QMetryToolsHandlers.FETCH_TEST_CASES]: fetchTestCases,
@@ -31,6 +35,7 @@ export const QMETRY_HANDLER_MAP = {
31
35
  [QMetryToolsHandlers.REQUIREMENTS_LINKED_TESTCASES_TO_TESTSUITE]: reqLinkedTestCasesToTestSuite,
32
36
  [QMetryToolsHandlers.FETCH_TESTCASES_BY_TESTSUITE]: fetchTestCasesByTestSuite,
33
37
  [QMetryToolsHandlers.FETCH_EXECUTIONS_BY_TESTSUITE]: fetchExecutionsByTestSuite,
38
+ [QMetryToolsHandlers.BULK_UPDATE_EXECUTION_STATUS]: bulkUpdateExecutionStatus,
34
39
  [QMetryToolsHandlers.FETCH_TESTCASE_RUNS_BY_TESTSUITE_RUN]: fetchTestCaseRunsByTestSuiteRun,
35
40
  [QMetryToolsHandlers.FETCH_LINKED_ISSUES_BY_TESTCASE_RUN]: fetchLinkedIssuesByTestCaseRun,
36
41
  [QMetryToolsHandlers.FETCH_ISSUES_LINKED_TO_TESTCASE]: fetchIssuesLinkedToTestCase,
@@ -39,4 +44,6 @@ export const QMETRY_HANDLER_MAP = {
39
44
  [QMetryToolsHandlers.FETCH_ISSUES]: fetchIssues,
40
45
  [QMetryToolsHandlers.LINK_ISSUES_TO_TESTCASE_RUN]: linkIssuesToTestcaseRun,
41
46
  [QMetryToolsHandlers.LINK_PLATFORMS_TO_TESTSUITE]: linkPlatformsToTestSuite,
47
+ [QMetryToolsHandlers.IMPORT_AUTOMATION_RESULTS]: importAutomationResults,
48
+ [QMetryToolsHandlers.FETCH_AUTOMATION_STATUS]: getAutomationStatus,
42
49
  };
@@ -1,7 +1,8 @@
1
1
  import { QMETRY_DEFAULTS } from "../config/constants.js";
2
2
  import { QMETRY_PATHS } from "../config/rest-endpoints.js";
3
- import { DEFAULT_FETCH_BUILD_PAYLOAD, DEFAULT_FETCH_PLATFORMS_PAYLOAD, DEFAULT_FETCH_PROJECTS_PAYLOAD, } from "../types/project.js";
3
+ import { DEFAULT_CREATE_CYCLE_PAYLOAD, DEFAULT_CREATE_RELEASE_PAYLOAD, DEFAULT_FETCH_BUILD_PAYLOAD, DEFAULT_FETCH_PLATFORMS_PAYLOAD, DEFAULT_FETCH_PROJECTS_PAYLOAD, } from "../types/project.js";
4
4
  import { qmetryRequest } from "./api/client-api.js";
5
+ import { resolveDefaults } from "./utils.js";
5
6
  /**
6
7
  * Retrieves project information from QMetry
7
8
  *
@@ -98,3 +99,88 @@ export async function getPlatforms(token, baseUrl, project, payload) {
98
99
  body,
99
100
  });
100
101
  }
102
+ /**
103
+ * Creates a new release in QMetry with optional cycle
104
+ *
105
+ * @param token - QMetry API authentication token
106
+ * @param baseUrl - QMetry instance base URL
107
+ * @param project - Project key
108
+ * @param payload - Release and cycle data
109
+ * @returns Promise resolving to the created release information
110
+ */
111
+ export async function createRelease(token, baseUrl, project, payload) {
112
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
113
+ const body = {
114
+ ...DEFAULT_CREATE_RELEASE_PAYLOAD,
115
+ ...payload,
116
+ };
117
+ if (typeof body.release.name !== "string") {
118
+ throw new Error("[createRelease] Missing or invalid required parameter: 'release.name'.");
119
+ }
120
+ if (body.cycle && typeof body.cycle.name !== "string") {
121
+ throw new Error("[createRelease] Missing or invalid required parameter: 'cycle.name'.");
122
+ }
123
+ return qmetryRequest({
124
+ method: "POST",
125
+ path: QMETRY_PATHS.PROJECT.CREATE_RELEASE,
126
+ token,
127
+ project: resolvedProject,
128
+ baseUrl: resolvedBaseUrl,
129
+ body,
130
+ });
131
+ }
132
+ /**
133
+ * Creates a new cycle within an existing release in QMetry
134
+ *
135
+ * @param token - QMetry API authentication token
136
+ * @param baseUrl - QMetry instance base URL
137
+ * @param project - Project key
138
+ * @param payload - Cycle data including releaseID
139
+ * @returns Promise resolving to the created cycle information
140
+ */
141
+ export async function createCycle(token, baseUrl, project, payload) {
142
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
143
+ const body = {
144
+ ...DEFAULT_CREATE_CYCLE_PAYLOAD.cycle,
145
+ ...payload,
146
+ };
147
+ if (typeof body.cycle.name !== "string") {
148
+ throw new Error("[createCycle] Missing or invalid required parameter: 'cycle.name'.");
149
+ }
150
+ if (typeof body.cycle.releaseID !== "number") {
151
+ throw new Error("[createCycle] Missing or invalid required parameter: 'cycle.releaseID'.");
152
+ }
153
+ return qmetryRequest({
154
+ method: "POST",
155
+ path: QMETRY_PATHS.PROJECT.CREATE_CYCLE,
156
+ token,
157
+ project: resolvedProject,
158
+ baseUrl: resolvedBaseUrl,
159
+ body,
160
+ });
161
+ }
162
+ /**
163
+ * Updates an existing cycle in QMetry
164
+ * @param token - QMetry API token
165
+ * @param baseUrl - QMetry base URL
166
+ * @param project - Project key
167
+ * @param payload - Cycle data including buildID and releaseID for identification
168
+ * @returns Promise resolving to the updated cycle information
169
+ */
170
+ export async function updateCycle(token, baseUrl, project, payload) {
171
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
172
+ if (typeof payload.cycle.buildID !== "number") {
173
+ throw new Error("[updateCycle] Missing or invalid required parameter: 'cycle.buildID'.");
174
+ }
175
+ if (typeof payload.cycle.releaseID !== "number") {
176
+ throw new Error("[updateCycle] Missing or invalid required parameter: 'cycle.releaseID'.");
177
+ }
178
+ return qmetryRequest({
179
+ method: "PUT",
180
+ path: QMETRY_PATHS.PROJECT.UPDATE_CYCLE,
181
+ token,
182
+ project: resolvedProject,
183
+ baseUrl: resolvedBaseUrl,
184
+ body: payload,
185
+ });
186
+ }
@@ -1,5 +1,5 @@
1
1
  import { QMETRY_PATHS } from "../config/rest-endpoints.js";
2
- import { DEFAULT_CREATE_TESTSUITE_PAYLOAD, DEFAULT_FETCH_EXECUTIONS_BY_TESTSUITE_PAYLOAD, DEFAULT_FETCH_LINKED_ISSUES_BY_TESTCASE_RUN_PAYLOAD, DEFAULT_FETCH_TESTCASE_RUNS_BY_TESTSUITE_RUN_PAYLOAD, DEFAULT_FETCH_TESTCASES_BY_TESTSUITE_PAYLOAD, DEFAULT_FETCH_TESTSUITES_FOR_TESTCASE_PAYLOAD, DEFAULT_FETCH_TESTSUITES_PAYLOAD, DEFAULT_LINKED_PLATFORMS_TO_TESTSUITE_PAYLOAD, DEFAULT_LINKED_TESTCASE_TO_TESTSUITE_PAYLOAD, DEFAULT_REQLINKED_TESTCASE_TO_TESTSUITE_PAYLOAD, DEFAULT_UPDATE_TESTSUITE_PAYLOAD, } from "../types/testsuite.js";
2
+ import { DEFAULT_BULK_UPDATE_EXECUTION_STATUS_PAYLOAD, DEFAULT_CREATE_TESTSUITE_PAYLOAD, DEFAULT_FETCH_EXECUTIONS_BY_TESTSUITE_PAYLOAD, DEFAULT_FETCH_LINKED_ISSUES_BY_TESTCASE_RUN_PAYLOAD, DEFAULT_FETCH_TESTCASE_RUNS_BY_TESTSUITE_RUN_PAYLOAD, DEFAULT_FETCH_TESTCASES_BY_TESTSUITE_PAYLOAD, DEFAULT_FETCH_TESTSUITES_FOR_TESTCASE_PAYLOAD, DEFAULT_FETCH_TESTSUITES_PAYLOAD, DEFAULT_LINKED_PLATFORMS_TO_TESTSUITE_PAYLOAD, DEFAULT_LINKED_TESTCASE_TO_TESTSUITE_PAYLOAD, DEFAULT_REQLINKED_TESTCASE_TO_TESTSUITE_PAYLOAD, DEFAULT_UPDATE_TESTSUITE_PAYLOAD, } from "../types/testsuite.js";
3
3
  import { qmetryRequest } from "./api/client-api.js";
4
4
  import { resolveDefaults } from "./utils.js";
5
5
  /**
@@ -270,3 +270,39 @@ export async function linkPlatformsToTestSuite(token, baseUrl, project, payload)
270
270
  body,
271
271
  });
272
272
  }
273
+ /**
274
+ * Bulk update execution status for test case runs.
275
+ * @throws If `entityIDs`, `entityType`, `qmTsRunId`, or `runStatusID` are missing/invalid.
276
+ */
277
+ export async function bulkUpdateExecutionStatus(token, baseUrl, project, payload) {
278
+ const { resolvedBaseUrl, resolvedProject } = resolveDefaults(baseUrl, project);
279
+ const body = {
280
+ ...DEFAULT_BULK_UPDATE_EXECUTION_STATUS_PAYLOAD,
281
+ ...payload,
282
+ };
283
+ if (!body.entityIDs ||
284
+ typeof body.entityIDs !== "string" ||
285
+ body.entityIDs.trim().length === 0) {
286
+ throw new Error("[bulkUpdateExecutionStatus] Missing or invalid required parameter: 'entityIDs'. It must be a non-empty comma-separated string of Test Case Run IDs.");
287
+ }
288
+ if (!body.entityType ||
289
+ (body.entityType !== "TCR" && body.entityType !== "TCSR")) {
290
+ throw new Error("[bulkUpdateExecutionStatus] Missing or invalid required parameter: 'entityType'. Must be 'TCR' or 'TCSR'.");
291
+ }
292
+ if (!body.qmTsRunId ||
293
+ typeof body.qmTsRunId !== "string" ||
294
+ body.qmTsRunId.trim().length === 0) {
295
+ throw new Error("[bulkUpdateExecutionStatus] Missing or invalid required parameter: 'qmTsRunId'. It must be a non-empty string.");
296
+ }
297
+ if (typeof body.runStatusID !== "number") {
298
+ throw new Error("[bulkUpdateExecutionStatus] Missing or invalid required parameter: 'runStatusID'. It must be a number.");
299
+ }
300
+ return qmetryRequest({
301
+ method: "PUT",
302
+ path: QMETRY_PATHS.TESTSUITE.BULK_UPDATE_EXECUTION_STATUS,
303
+ token,
304
+ project: resolvedProject,
305
+ baseUrl: resolvedBaseUrl,
306
+ body,
307
+ });
308
+ }
@@ -0,0 +1,290 @@
1
+ import { QMetryToolsHandlers } from "../../config/constants.js";
2
+ import { FetchAutomationStatusPayloadSchema, ImportAutomationResultsPayloadSchema, } from "../../types/common.js";
3
+ export const AUTOMATION_TOOLS = [
4
+ {
5
+ handler: QMetryToolsHandlers.IMPORT_AUTOMATION_RESULTS,
6
+ title: "Import Automation Test Results",
7
+ summary: "Import/Publish automation test results from TestNG, JUnit, Cucumber, Robot, HPUFT, or QAF frameworks into QMetry",
8
+ purpose: "Upload and import automation test result files to create test suites, test cases, and execution records in QMetry",
9
+ inputSchema: ImportAutomationResultsPayloadSchema,
10
+ useCases: [
11
+ "1. Import TestNG XML results after CI/CD pipeline execution",
12
+ "2. Publish JUnit test results to QMetry for tracking and reporting",
13
+ "3. Upload Cucumber JSON results with custom test suite organization",
14
+ "4. Import Robot Framework results with specific release/cycle mapping",
15
+ "5. Link automation results to existing test suites for version tracking",
16
+ "6. Create new test suites with custom names and folder structures",
17
+ "7. Map test results to specific platforms (browsers, OS, devices)",
18
+ "8. Associate imported results with releases, cycles, and builds",
19
+ "9. Bulk import multiple test results from ZIP archive",
20
+ "10. Configure test case/suite fields and user-defined fields during import",
21
+ ],
22
+ examples: [
23
+ {
24
+ description: "Basic TestNG result import",
25
+ parameters: {
26
+ file: "<base64_encoded_testng_xml_content>",
27
+ fileName: "testng-results.xml",
28
+ entityType: "TESTNG",
29
+ },
30
+ expectedOutput: "Auto-generated test suite created with UTC timestamp, test cases auto-linked, execution results updated, 'No Platform' linked",
31
+ },
32
+ {
33
+ description: "JUnit results with custom test suite name",
34
+ parameters: {
35
+ file: "<base64_encoded_junit_xml_content>",
36
+ fileName: "junit-results.xml",
37
+ entityType: "JUNIT",
38
+ testsuiteName: "Regression Suite - Build 123",
39
+ automationHierarchy: "1",
40
+ },
41
+ expectedOutput: "Test suite 'Regression Suite - Build 123' created with Test Case-Test Step hierarchy",
42
+ },
43
+ {
44
+ description: "Cucumber results with platform and release mapping",
45
+ parameters: {
46
+ file: "<base64_encoded_cucumber_json_content>",
47
+ fileName: "cucumber-results.json",
48
+ entityType: "CUCUMBER",
49
+ platformID: "Chrome 120",
50
+ releaseID: "Release 2.0",
51
+ cycleID: "Sprint 15",
52
+ testsuiteName: "API Automation Tests",
53
+ },
54
+ expectedOutput: "Test suite created, linked to Chrome platform, Release 2.0, and Sprint 15 cycle",
55
+ },
56
+ {
57
+ description: "Reuse existing test suite",
58
+ parameters: {
59
+ file: "<base64_encoded_testng_xml_content>",
60
+ fileName: "testng-regression.xml",
61
+ entityType: "TESTNG",
62
+ testsuiteId: "PROJ-TS-42",
63
+ },
64
+ expectedOutput: "Test cases auto-linked to existing test suite PROJ-TS-42, execution results updated",
65
+ },
66
+ {
67
+ description: "Import with folder organization",
68
+ parameters: {
69
+ file: "<base64_encoded_junit_xml_content>",
70
+ fileName: "junit-results.xml",
71
+ entityType: "JUNIT",
72
+ tsFolderPath: "/Automation/Regression",
73
+ tcFolderPath: "/Automation/API Tests",
74
+ testsuiteName: "API Regression Suite",
75
+ },
76
+ expectedOutput: "Test suite created in '/Automation/Regression' folder, test cases in '/Automation/API Tests' folder",
77
+ },
78
+ {
79
+ description: "Import with test case custom fields",
80
+ parameters: {
81
+ file: "<base64_encoded_testng_xml_content>",
82
+ fileName: "testng-results.xml",
83
+ entityType: "TESTNG",
84
+ testcase_fields: JSON.stringify({
85
+ priority: "High",
86
+ testCaseType: "Automated",
87
+ component: ["API", "Backend"],
88
+ testcaseOwner: "john.doe",
89
+ estimatedTime: "2h:30m:0s",
90
+ }),
91
+ },
92
+ expectedOutput: "Test cases created with High priority, Automated type, API and Backend components",
93
+ },
94
+ {
95
+ description: "Import ZIP file with multiple results",
96
+ parameters: {
97
+ file: "<base64_encoded_zip_content>",
98
+ fileName: "test-results.zip",
99
+ entityType: "JUNIT",
100
+ testsuiteName: "Full Regression Suite",
101
+ skipWarning: "1",
102
+ },
103
+ expectedOutput: "Multiple test results imported from ZIP, summaries truncated if >255 chars",
104
+ },
105
+ {
106
+ description: "Import with custom hierarchy for JUnit",
107
+ parameters: {
108
+ file: "<base64_encoded_junit_xml_content>",
109
+ fileName: "junit-results.xml",
110
+ entityType: "JUNIT",
111
+ automationHierarchy: "3",
112
+ projectID: "PROJ",
113
+ },
114
+ expectedOutput: "Multiple test suites created per <testsuite> tag, test cases per <testcase> tag",
115
+ },
116
+ {
117
+ description: "Import with build and platform mapping",
118
+ parameters: {
119
+ file: "<base64_encoded_testng_xml_content>",
120
+ fileName: "testng-results.xml",
121
+ entityType: "TESTNG",
122
+ buildID: "Build-1.2.3",
123
+ platformID: "Safari 17",
124
+ releaseID: "Release 1.2",
125
+ cycleID: "QA Cycle",
126
+ },
127
+ expectedOutput: "Results linked to Build 1.2.3, Safari 17 platform, Release 1.2, QA Cycle",
128
+ },
129
+ {
130
+ description: "Import with test suite and test case fields",
131
+ parameters: {
132
+ file: "<base64_encoded_cucumber_json_content>",
133
+ fileName: "cucumber-results.json",
134
+ entityType: "CUCUMBER",
135
+ testsuite_fields: JSON.stringify({
136
+ testSuiteState: "In Progress",
137
+ testsuiteOwner: "jane.smith",
138
+ description: "Sprint 15 automation results",
139
+ }),
140
+ testcase_fields: JSON.stringify({
141
+ priority: "Medium",
142
+ component: ["UI", "Frontend"],
143
+ userDefinedFields: {
144
+ reviewedDate: "11-20-2024",
145
+ environment: "Staging",
146
+ },
147
+ }),
148
+ },
149
+ expectedOutput: "Test suite and test cases created with custom fields and UDFs",
150
+ },
151
+ ],
152
+ hints: [
153
+ "1. CRITICAL: User MUST upload a valid result file before calling this tool",
154
+ "2. USER FILE UPLOAD REQUIRED: Ask user to provide file in chat - system will convert to base64",
155
+ "3. FILE REQUIREMENTS:",
156
+ " - Supported extensions: .json, .xml, .zip",
157
+ " - Maximum size: 30 MB",
158
+ " - ZIP files must contain files matching the specified entityType format",
159
+ "4. REQUIRED PARAMETERS:",
160
+ " - file: Base64 encoded content or file path",
161
+ " - fileName: Original filename with extension",
162
+ " - entityType: TESTNG, CUCUMBER, JUNIT, HPUFT, QAF, or ROBOT",
163
+ "5. ENTITY TYPES:",
164
+ " - TESTNG: TestNG XML format",
165
+ " - JUNIT: JUnit XML format",
166
+ " - CUCUMBER: Cucumber JSON format",
167
+ " - ROBOT: Robot Framework XML format",
168
+ " - HPUFT: HP UFT format",
169
+ " - QAF: QAF format",
170
+ "6. AUTOMATION HIERARCHY (TestNG/JUnit only):",
171
+ " - TestNG:",
172
+ " * 1 (default): <class name> = Test Case, <test-method> = Test Step",
173
+ " * 2: <test-method> = Test Case only",
174
+ " * 3: <name> under <test> = Test Case, <test-method> = Test Step",
175
+ " - JUnit:",
176
+ " * 1 (default): <testsuite> = Test Case, <testcase> = Test Step",
177
+ " * 2: <testcase> = Test Case only",
178
+ " * 3: <testsuite> = Test Suite, <testcase> = Test Case (creates multiple test suites)",
179
+ "7. TEST SUITE OPTIONS:",
180
+ " - testsuiteName: Custom name for new test suite",
181
+ " - testsuiteId: Reuse existing test suite by ID or Entity Key (e.g., 'PROJ-TS-42')",
182
+ " - tsFolderPath: Create test suite in specific folder (e.g., '/Automation/Regression')",
183
+ " - Note: testsuiteName/testsuiteId ignored if automationHierarchy=3 for JUnit or =2 for ROBOT",
184
+ "8. TEST CASE OPTIONS:",
185
+ " - tcFolderPath: Create test cases in specific folder (e.g., '/Automation/API Tests')",
186
+ " - Folders created automatically if they don't exist",
187
+ "9. LINKING OPTIONS:",
188
+ " - platformID: Platform ID or name (e.g., 'Chrome 120', 'Safari 17')",
189
+ " - projectID: Project ID, key, or name (overrides header project)",
190
+ " - releaseID: Release ID or name (requires projectID)",
191
+ " - cycleID: Cycle ID or name (requires releaseID and projectID)",
192
+ " - buildID: Build ID or name",
193
+ "10. GET IDs FROM OTHER TOOLS:",
194
+ " - Platform IDs: Use 'Platform/List' API (FETCH_PLATFORMS tool)",
195
+ " - Project IDs: Use 'Project/List' API (FETCH_PROJECTS tool)",
196
+ " - Release IDs: Use 'Release/List' API (FETCH_RELEASES_CYCLES tool)",
197
+ " - Cycle IDs: Use 'Cycle/List' API (FETCH_RELEASES_CYCLES tool)",
198
+ " - Build IDs: Use 'Build/List' API (FETCH_BUILDS tool)",
199
+ " - Test Suite IDs: Use 'Testsuite/Fetch' API (FETCH_TEST_SUITES tool)",
200
+ "11. CUSTOM FIELDS (testcase_fields):",
201
+ " - JSON string with system fields and UDFs",
202
+ " - System fields: component, priority, testCaseState, testCaseType, testcaseOwner, estimatedTime, description",
203
+ ' - Example: {"component":["API"], "priority":"High", "testcaseOwner":"user"}',
204
+ " - Ignored if reusing existing test case",
205
+ "12. CUSTOM FIELDS (testsuite_fields):",
206
+ " - JSON string with system fields and UDFs",
207
+ " - System fields: testSuiteState, testsuiteOwner, description",
208
+ ' - Example: {"testSuiteState":"Open", "testsuiteOwner":"user"}',
209
+ " - Ignored if reusing existing test suite",
210
+ "13. USER DEFINED FIELDS (UDFs):",
211
+ " - Include in testcase_fields or testsuite_fields under 'userDefinedFields' key",
212
+ ' - Example: {"userDefinedFields": {"reviewedDate": "11-20-2024", "environment": "Staging"}}',
213
+ " - UDF types: STRING, LARGETEXT, LOOKUPLIST, MULTILOOKUPLIST, DATEPICKER, NUMBER",
214
+ " - See tool metadata for UDF validation rules and auto-create behavior",
215
+ "14. SKIP WARNING OPTIONS:",
216
+ " - skipWarning='0' (default): Fail import if test case summary >255 characters",
217
+ " - skipWarning='1': Truncate summary to 255 characters and continue import",
218
+ "15. MATCHING BEHAVIOR:",
219
+ " - is_matching_required='true' (default): Create new TC/version if summary/steps don't match",
220
+ " - is_matching_required='false': Reuse existing TC version if entity key or summary matches",
221
+ "16. IMPORT BEHAVIOR EXAMPLES:",
222
+ " - Only file + entityType → Auto-generated test suite, 'No Platform', test cases auto-linked",
223
+ " - file + entityType + platformID → Auto-generated test suite with specified platform",
224
+ " - file + entityType + testsuiteId → Results updated in existing test suite",
225
+ " - file + entityType + platformID + testsuiteId → Results updated in existing test suite with platform",
226
+ "17. FOLDER CREATION:",
227
+ " - If tsFolderPath or tcFolderPath specified and doesn't exist, it will be created automatically",
228
+ " - Use forward slashes for folder paths (e.g., '/Parent/Child')",
229
+ "18. ESTIMATED TIME FORMAT:",
230
+ " - Format: '2h:30m:15s' or '4h' or '7m' or '0s'",
231
+ " - Range: 0 to 99999 minutes",
232
+ "19. OWNER FIELDS:",
233
+ " - Use userAlias (username) not display name",
234
+ " - testcaseOwner: User must have Test Case module rights",
235
+ " - testsuiteOwner: User must have Test Suite module rights",
236
+ " - Owner not set if user not found or lacks permissions",
237
+ "20. LOOKUPLIST/MULTILOOKUPLIST BEHAVIOR:",
238
+ " - If value doesn't exist and auto-create is ON: Value added to list",
239
+ " - If value doesn't exist and auto-create is OFF: Field blank or default value",
240
+ " - MULTILOOKUPLIST: New values added, old values persist",
241
+ "21. MANDATORY FIELD VALIDATION:",
242
+ " - If mandatory system/UDF field missing:",
243
+ " * Auto-create OFF + value doesn't exist = Import FAIL",
244
+ " * Auto-create ON + value doesn't exist = Import SUCCESS (value created)",
245
+ " * Value exists = Import SUCCESS",
246
+ "22. ERROR HANDLING:",
247
+ " - Check file size before upload (must be ≤30 MB)",
248
+ " - Validate file extension matches entityType",
249
+ " - Ensure required dependencies: cycleID requires releaseID and projectID",
250
+ " - If import fails, check QMetry UI for detailed error messages",
251
+ "23. WORKFLOW:",
252
+ " Step 1: Ask user to upload result file in chat",
253
+ " Step 2: System converts file to base64",
254
+ " Step 3: Collect entityType and optional parameters",
255
+ " Step 4: Call this tool with file data and configuration",
256
+ " Step 5: QMetry processes file and creates/updates test artifacts",
257
+ " Step 6: Return import results with test suite and execution details",
258
+ "24. USER INTERACTION REQUIRED:",
259
+ " - ALWAYS ask user to upload file before calling this tool",
260
+ " - Display supported formats: .json, .xml, .zip (up to 30 MB)",
261
+ " - Ask for entityType (framework used)",
262
+ " - Ask for optional parameters based on user's needs",
263
+ "25. PERFORMANCE TIPS:",
264
+ " - For large imports, consider using ZIP files",
265
+ " - Reusing existing test suites is faster than creating new ones",
266
+ " - Use automationHierarchy wisely to control test case/suite structure",
267
+ ],
268
+ },
269
+ {
270
+ handler: QMetryToolsHandlers.FETCH_AUTOMATION_STATUS,
271
+ title: "Fetch Automation Status",
272
+ summary: "Fetches the status of an automation import job by request ID.",
273
+ purpose: "Track the progress and result of an automation import operation in QMetry.",
274
+ inputSchema: FetchAutomationStatusPayloadSchema,
275
+ useCases: [
276
+ "1. Check if an automation import job is completed or still in progress.",
277
+ "2. Retrieve status, progress, and details for a specific automation import request.",
278
+ "3. Monitor automation result processing for CI/CD integrations.",
279
+ ],
280
+ examples: [
281
+ {
282
+ description: "Fetch status for request ID 12345",
283
+ parameters: {
284
+ requestID: 12345,
285
+ },
286
+ expectedOutput: "Status, progress, and details of the automation import job for request ID 12345.",
287
+ },
288
+ ],
289
+ },
290
+ ];
@@ -1,8 +1,10 @@
1
+ export { AUTOMATION_TOOLS } from "./automation-tools.js";
1
2
  export { ISSUE_TOOLS } from "./issue-tools.js";
2
3
  export { PROJECT_TOOLS } from "./project-tools.js";
3
4
  export { REQUIREMENT_TOOLS } from "./requirement-tools.js";
4
5
  export { TESTCASE_TOOLS } from "./testcase-tools.js";
5
6
  export { TESTSUITE_TOOLS } from "./testsuite-tools.js";
7
+ import { AUTOMATION_TOOLS } from "./automation-tools.js";
6
8
  import { ISSUE_TOOLS } from "./issue-tools.js";
7
9
  import { PROJECT_TOOLS } from "./project-tools.js";
8
10
  import { REQUIREMENT_TOOLS } from "./requirement-tools.js";
@@ -14,4 +16,5 @@ export const TOOLS = [
14
16
  ...REQUIREMENT_TOOLS,
15
17
  ...TESTSUITE_TOOLS,
16
18
  ...ISSUE_TOOLS,
19
+ ...AUTOMATION_TOOLS,
17
20
  ];