@smartbear/mcp 0.31.0 → 0.32.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.
- package/dist/package.json.js +1 -1
- package/dist/qtm4j/client.js +14 -0
- package/dist/qtm4j/config/constants.js +83 -2
- package/dist/qtm4j/config/field-resolution.types.js +12 -2
- package/dist/qtm4j/http/api-client.js +30 -4
- package/dist/qtm4j/http/auth-service.js +3 -2
- package/dist/qtm4j/resolver/resolver-registry.js +37 -1
- package/dist/qtm4j/resolver/resolvers/build-resolver.js +51 -0
- package/dist/qtm4j/resolver/resolvers/common-attribute-resolver.js +1 -3
- package/dist/qtm4j/resolver/resolvers/component-resolver.js +1 -1
- package/dist/qtm4j/resolver/resolvers/defect-id-resolver.js +44 -0
- package/dist/qtm4j/resolver/resolvers/defect-priority-resolver.js +55 -0
- package/dist/qtm4j/resolver/resolvers/defect-status-resolver.js +55 -0
- package/dist/qtm4j/resolver/resolvers/environment-resolver.js +51 -0
- package/dist/qtm4j/resolver/resolvers/execution-context-resolver.js +58 -0
- package/dist/qtm4j/resolver/resolvers/label-resolver.js +1 -1
- package/dist/qtm4j/resolver/resolvers/requirement-id-resolver.js +3 -4
- package/dist/qtm4j/resolver/resolvers/step-execution-context-resolver.js +62 -0
- package/dist/qtm4j/resolver/resolvers/test-case-uid-resolver.js +3 -4
- package/dist/qtm4j/resolver/resolvers/test-cycle-uid-resolver.js +3 -4
- package/dist/qtm4j/schema/get-bugs.schema.js +101 -0
- package/dist/qtm4j/schema/get-test-case.schema.js +3 -3
- package/dist/qtm4j/schema/link-bugs.schema.js +63 -0
- package/dist/qtm4j/schema/start-execution.schema.js +45 -0
- package/dist/qtm4j/schema/test-cycle.link.schema.js +10 -1
- package/dist/qtm4j/schema/update-test-case-execution.schema.js +41 -0
- package/dist/qtm4j/schema/update-test-step-execution.schema.js +41 -0
- package/dist/qtm4j/tool/project/get-projects.js +3 -3
- package/dist/qtm4j/tool/project/set-project-context.js +1 -1
- package/dist/qtm4j/tool/test-automation/get-automation-history.js +4 -7
- package/dist/qtm4j/tool/test-automation/upload-automation-result.js +4 -2
- package/dist/qtm4j/tool/test-execution/get-test-case-bugs.js +119 -0
- package/dist/qtm4j/tool/test-execution/get-test-step-bugs.js +122 -0
- package/dist/qtm4j/tool/test-execution/link-test-case-bugs.js +135 -0
- package/dist/qtm4j/tool/test-execution/link-test-step-bugs.js +140 -0
- package/dist/qtm4j/tool/test-execution/start-execution.js +150 -0
- package/dist/qtm4j/tool/test-execution/update-test-case-execution.js +123 -0
- package/dist/qtm4j/tool/test-execution/update-test-step-execution.js +126 -0
- package/dist/swagger/client/api.js +8 -1
- package/dist/swagger/client/user-management-types.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Tool, ToolError } from "../../../common/tools.js";
|
|
2
|
+
import { TOOL_NAMES, TOOLSETS, ENDPOINTS } from "../../config/constants.js";
|
|
3
|
+
import { ResolverKeys } from "../../config/field-resolution.types.js";
|
|
4
|
+
import { UpdateTestCaseExecutionResponse, UpdateTestCaseExecutionBody } from "../../schema/update-test-case-execution.schema.js";
|
|
5
|
+
const FIELD_CONFIG = {
|
|
6
|
+
executionResultId: ResolverKeys.CommonAttribute.EXECUTION_RESULT,
|
|
7
|
+
environmentId: ResolverKeys.SearchableField.ENVIRONMENT,
|
|
8
|
+
buildId: ResolverKeys.SearchableField.BUILD
|
|
9
|
+
};
|
|
10
|
+
class UpdateTestCaseExecution extends Tool {
|
|
11
|
+
specification = {
|
|
12
|
+
title: TOOL_NAMES.UPDATE_TEST_CASE_EXECUTION.TITLE,
|
|
13
|
+
toolset: TOOLSETS.TEST_EXECUTIONS,
|
|
14
|
+
summary: TOOL_NAMES.UPDATE_TEST_CASE_EXECUTION.SUMMARY,
|
|
15
|
+
readOnly: false,
|
|
16
|
+
idempotent: true,
|
|
17
|
+
inputSchema: UpdateTestCaseExecutionBody,
|
|
18
|
+
outputSchema: UpdateTestCaseExecutionResponse,
|
|
19
|
+
purpose: "Update an existing test case execution.",
|
|
20
|
+
useCases: [
|
|
21
|
+
"Set a test case execution result (e.g. Pass, Fail, Blocked)",
|
|
22
|
+
"Update comment, environment, build, assignee, planned date, or actual time on an execution"
|
|
23
|
+
],
|
|
24
|
+
examples: [
|
|
25
|
+
{
|
|
26
|
+
description: "Mark test case as Pass",
|
|
27
|
+
parameters: {
|
|
28
|
+
testCycleKey: "PROJ-TR-101",
|
|
29
|
+
testCaseKey: "PROJ-TC-42",
|
|
30
|
+
executionResultId: "Pass"
|
|
31
|
+
},
|
|
32
|
+
expectedOutput: "{ testCycleKey: 'PROJ-TR-101', testCaseKey: 'PROJ-TC-42', updated: true }"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
description: "Update with comment, environment, and actual time",
|
|
36
|
+
parameters: {
|
|
37
|
+
testCycleKey: "PROJ-TR-101",
|
|
38
|
+
testCaseKey: "PROJ-TC-42",
|
|
39
|
+
executionResultId: "Pass",
|
|
40
|
+
comment: "All smoke tests passed.",
|
|
41
|
+
environmentId: "Production",
|
|
42
|
+
actualTime: "01:30:00"
|
|
43
|
+
},
|
|
44
|
+
expectedOutput: "{ testCycleKey: 'PROJ-TR-101', testCaseKey: 'PROJ-TC-42', updated: true }"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
description: "Clear comment",
|
|
48
|
+
parameters: {
|
|
49
|
+
testCycleKey: "PROJ-TR-101",
|
|
50
|
+
testCaseKey: "PROJ-TC-42",
|
|
51
|
+
comment: null
|
|
52
|
+
},
|
|
53
|
+
expectedOutput: "{ testCycleKey: 'PROJ-TR-101', testCaseKey: 'PROJ-TC-42', updated: true }"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
hints: [
|
|
57
|
+
"Call set_project_context before this tool.",
|
|
58
|
+
"At least one updatable field must be provided.",
|
|
59
|
+
"environmentId and buildId accept environment/build name as strings that are resolved to numeric IDs; unresolved names are dropped and a warning is returned.",
|
|
60
|
+
"actualTime must be in 'HH:mm:ss' format (e.g. '01:30:00'). Always include seconds"
|
|
61
|
+
],
|
|
62
|
+
outputDescription: "Confirmation object with testCycleKey, testCaseKey, and updated: true. Warnings are returned in content if any resolvable field (executionResultId, environmentId, buildId) could not be resolved and was dropped."
|
|
63
|
+
};
|
|
64
|
+
handle = async (rawArgs) => {
|
|
65
|
+
const { testCycleKey, testCaseKey, ...bodyArgs } = UpdateTestCaseExecutionBody.parse(rawArgs);
|
|
66
|
+
if (!Object.values(bodyArgs).some((v) => v !== void 0)) {
|
|
67
|
+
throw new ToolError("Provide at least one updatable field.");
|
|
68
|
+
}
|
|
69
|
+
const fieldResolver = this.client.getResolverRegistry();
|
|
70
|
+
const context = fieldResolver.requireProjectContext();
|
|
71
|
+
const warnings = [];
|
|
72
|
+
const testCaseExecutionId = await this.resolveTestCaseExecutionId(
|
|
73
|
+
fieldResolver,
|
|
74
|
+
context,
|
|
75
|
+
testCycleKey,
|
|
76
|
+
testCaseKey
|
|
77
|
+
);
|
|
78
|
+
const body = { ...bodyArgs };
|
|
79
|
+
await Promise.all(
|
|
80
|
+
Object.entries(FIELD_CONFIG).map(
|
|
81
|
+
([inputField, resolverKey]) => fieldResolver.getResolver(resolverKey).resolve(inputField, resolverKey, body, context, warnings)
|
|
82
|
+
)
|
|
83
|
+
);
|
|
84
|
+
if (Object.keys(body).length === 0) {
|
|
85
|
+
throw new ToolError(
|
|
86
|
+
`No updatable fields remain after resolution. ${warnings.join(" | ")}`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
await this.client.getApiClient().put(
|
|
90
|
+
ENDPOINTS.UPDATE_TEST_CASE_EXECUTION(testCycleKey, testCaseExecutionId),
|
|
91
|
+
body
|
|
92
|
+
);
|
|
93
|
+
const validated = UpdateTestCaseExecutionResponse.parse({
|
|
94
|
+
testCycleKey,
|
|
95
|
+
testCaseKey,
|
|
96
|
+
updated: true
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
structuredContent: validated,
|
|
100
|
+
content: warnings.length > 0 ? [{ type: "text", text: `Note: ${warnings.join(" | ")}` }] : []
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
async resolveTestCaseExecutionId(fieldResolver, context, testCycleKey, testCaseKey) {
|
|
104
|
+
const result = await fieldResolver.getResolver(ResolverKeys.SearchableField.EXECUTION_CONTEXT).resolveAndReturn(context.projectKey, context.projectId, testCycleKey, [
|
|
105
|
+
testCaseKey
|
|
106
|
+
]);
|
|
107
|
+
const entry = result[testCaseKey];
|
|
108
|
+
if (!entry) {
|
|
109
|
+
throw new ToolError(
|
|
110
|
+
`Test case '${testCaseKey}' is not linked to test cycle '${testCycleKey}'. Verify the key and ensure it belongs to the cycle.`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
if (entry.testCaseExecutionId == null) {
|
|
114
|
+
throw new ToolError(
|
|
115
|
+
`No execution has been started for test case '${testCaseKey}' in cycle '${testCycleKey}'. Use start_new_execution first.`
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
return entry.testCaseExecutionId;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export {
|
|
122
|
+
UpdateTestCaseExecution
|
|
123
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Tool, ToolError } from "../../../common/tools.js";
|
|
2
|
+
import { TOOL_NAMES, TOOLSETS, ENDPOINTS } from "../../config/constants.js";
|
|
3
|
+
import { ResolverKeys } from "../../config/field-resolution.types.js";
|
|
4
|
+
import { UpdateTestStepExecutionResponse, UpdateTestStepExecutionBody } from "../../schema/update-test-step-execution.schema.js";
|
|
5
|
+
const FIELD_CONFIG = {
|
|
6
|
+
executionResultId: ResolverKeys.CommonAttribute.EXECUTION_RESULT
|
|
7
|
+
};
|
|
8
|
+
class UpdateTestStepExecution extends Tool {
|
|
9
|
+
specification = {
|
|
10
|
+
title: TOOL_NAMES.UPDATE_TEST_STEP_EXECUTION.TITLE,
|
|
11
|
+
toolset: TOOLSETS.TEST_EXECUTIONS,
|
|
12
|
+
summary: TOOL_NAMES.UPDATE_TEST_STEP_EXECUTION.SUMMARY,
|
|
13
|
+
readOnly: false,
|
|
14
|
+
idempotent: true,
|
|
15
|
+
inputSchema: UpdateTestStepExecutionBody,
|
|
16
|
+
outputSchema: UpdateTestStepExecutionResponse,
|
|
17
|
+
purpose: "Update an existing test step execution.",
|
|
18
|
+
useCases: [
|
|
19
|
+
"Set a test step execution result (e.g. Pass, Fail, Blocked)",
|
|
20
|
+
"Update actualResult or comment on a test step execution"
|
|
21
|
+
],
|
|
22
|
+
examples: [
|
|
23
|
+
{
|
|
24
|
+
description: "Mark step 2 as Pass",
|
|
25
|
+
parameters: {
|
|
26
|
+
testCycleKey: "PROJ-TR-101",
|
|
27
|
+
testCaseKey: "PROJ-TC-42",
|
|
28
|
+
testStepSeqNo: 2,
|
|
29
|
+
executionResultId: "Pass"
|
|
30
|
+
},
|
|
31
|
+
expectedOutput: "{ testCycleKey: 'PROJ-TR-101', testCaseKey: 'PROJ-TC-42', testStepSeqNo: 2, executionResultName: 'Pass', updated: true }"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
description: "Update step 3 with actualResult and comment",
|
|
35
|
+
parameters: {
|
|
36
|
+
testCycleKey: "PROJ-TR-101",
|
|
37
|
+
testCaseKey: "PROJ-TC-42",
|
|
38
|
+
testStepSeqNo: 3,
|
|
39
|
+
executionResultId: "Fail",
|
|
40
|
+
actualResult: "Button not found on page.",
|
|
41
|
+
comment: "Reproduced consistently in Chrome."
|
|
42
|
+
},
|
|
43
|
+
expectedOutput: "{ testCycleKey: 'PROJ-TR-101', testCaseKey: 'PROJ-TC-42', testStepSeqNo: 3, executionResultName: 'Fail', updated: true }"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
description: "Clear actualResult on step 1",
|
|
47
|
+
parameters: {
|
|
48
|
+
testCycleKey: "PROJ-TR-101",
|
|
49
|
+
testCaseKey: "PROJ-TC-42",
|
|
50
|
+
testStepSeqNo: 1,
|
|
51
|
+
actualResult: null
|
|
52
|
+
},
|
|
53
|
+
expectedOutput: "{ testCycleKey: 'PROJ-TR-101', testCaseKey: 'PROJ-TC-42', testStepSeqNo: 1, updated: true }"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
hints: [
|
|
57
|
+
"Call set_project_context before this tool.",
|
|
58
|
+
"At least one updatable field must be provided."
|
|
59
|
+
],
|
|
60
|
+
outputDescription: "Confirmation object with testCycleKey, testCaseKey, testStepSeqNo, and updated: true. executionResultName is included when the server returns it. Warnings are returned in content if executionResultId name could not be resolved."
|
|
61
|
+
};
|
|
62
|
+
handle = async (rawArgs) => {
|
|
63
|
+
const { testCycleKey, testCaseKey, testStepSeqNo, ...bodyArgs } = UpdateTestStepExecutionBody.parse(rawArgs);
|
|
64
|
+
if (!Object.values(bodyArgs).some((v) => v !== void 0)) {
|
|
65
|
+
throw new ToolError("Provide at least one updatable field.");
|
|
66
|
+
}
|
|
67
|
+
const fieldResolver = this.client.getResolverRegistry();
|
|
68
|
+
const context = fieldResolver.requireProjectContext();
|
|
69
|
+
const warnings = [];
|
|
70
|
+
const testStepExecutionId = await this.resolveTestStepExecutionId(
|
|
71
|
+
fieldResolver,
|
|
72
|
+
context,
|
|
73
|
+
testCycleKey,
|
|
74
|
+
testCaseKey,
|
|
75
|
+
testStepSeqNo
|
|
76
|
+
);
|
|
77
|
+
const body = { ...bodyArgs };
|
|
78
|
+
await Promise.all(
|
|
79
|
+
Object.entries(FIELD_CONFIG).map(
|
|
80
|
+
([inputField, resolverKey]) => fieldResolver.getResolver(resolverKey).resolve(inputField, resolverKey, body, context, warnings)
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
if (Object.keys(body).length === 0) {
|
|
84
|
+
throw new ToolError(
|
|
85
|
+
`No updatable fields remain after resolution. ${warnings.join(" | ")}`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
const apiResponse = await this.client.getApiClient().put(
|
|
89
|
+
ENDPOINTS.UPDATE_TEST_STEP_EXECUTION(testCycleKey, testStepExecutionId),
|
|
90
|
+
body
|
|
91
|
+
);
|
|
92
|
+
const validated = UpdateTestStepExecutionResponse.parse({
|
|
93
|
+
testCycleKey,
|
|
94
|
+
testCaseKey,
|
|
95
|
+
testStepSeqNo,
|
|
96
|
+
...apiResponse?.executionResultName !== void 0 && {
|
|
97
|
+
executionResultName: apiResponse.executionResultName
|
|
98
|
+
},
|
|
99
|
+
updated: true
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
structuredContent: validated,
|
|
103
|
+
content: warnings.length > 0 ? [{ type: "text", text: `Note: ${warnings.join(" | ")}` }] : []
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
async resolveTestStepExecutionId(fieldResolver, context, testCycleKey, testCaseKey, testStepSeqNo) {
|
|
107
|
+
const stepCtxResult = await fieldResolver.getResolver(ResolverKeys.SearchableField.STEP_EXECUTION_CONTEXT).resolveAndReturn(
|
|
108
|
+
context.projectKey,
|
|
109
|
+
context.projectId,
|
|
110
|
+
testCycleKey,
|
|
111
|
+
testCaseKey,
|
|
112
|
+
[testStepSeqNo]
|
|
113
|
+
);
|
|
114
|
+
const stepMap = stepCtxResult[testCaseKey] ?? {};
|
|
115
|
+
const testStepExecutionId = stepMap[testStepSeqNo];
|
|
116
|
+
if (testStepExecutionId == null) {
|
|
117
|
+
throw new ToolError(
|
|
118
|
+
`Step ${testStepSeqNo} was not found in this execution.`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return testStepExecutionId;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
UpdateTestStepExecution
|
|
126
|
+
};
|
|
@@ -129,7 +129,14 @@ class SwaggerAPI {
|
|
|
129
129
|
response,
|
|
130
130
|
defaultResponse
|
|
131
131
|
);
|
|
132
|
-
|
|
132
|
+
const list = result;
|
|
133
|
+
if (list.items) {
|
|
134
|
+
list.items = list.items.map((org) => {
|
|
135
|
+
const { email: _email, ...rest } = org;
|
|
136
|
+
return rest;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return list;
|
|
133
140
|
}
|
|
134
141
|
async createPortal(body) {
|
|
135
142
|
const response = await fetch(`${this.config.portalBasePath}/portals`, {
|
|
@@ -16,7 +16,8 @@ const OrganizationsListOutputSchema = z.object({
|
|
|
16
16
|
z.looseObject({
|
|
17
17
|
id: z.string().optional(),
|
|
18
18
|
name: z.string().optional(),
|
|
19
|
-
|
|
19
|
+
description: z.string().optional(),
|
|
20
|
+
url: z.string().optional(),
|
|
20
21
|
memberCount: z.number().optional()
|
|
21
22
|
})
|
|
22
23
|
).optional()
|