@smartbear/mcp 0.29.0 → 0.30.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/common/server.js +5 -1
- package/dist/package.json.js +1 -1
- package/dist/pactflow/client/tools.js +408 -0
- package/dist/pactflow/client.js +4 -11
- package/dist/reflect/client.js +5 -1
- package/dist/reflect/tool/tests/create-segment.js +18 -0
- package/dist/reflect/tool/tests/create-test.js +18 -0
- package/dist/reflect/tool/tests/definition.js +190 -0
- package/dist/swagger/client/functional-testing-api.js +107 -113
- package/dist/swagger/client/functional-testing-tools.js +10 -1
- package/dist/swagger/client/functional-testing-types.js +6 -0
- package/dist/swagger/client/portal-types.js +144 -10
- package/dist/swagger/client/registry-types.js +60 -1
- package/dist/swagger/client/tool-constants.js +20 -0
- package/dist/swagger/client/tools.js +87 -29
- package/dist/swagger/client/user-management-types.js +14 -0
- package/dist/swagger/client.js +8 -2
- package/package.json +1 -1
package/dist/pactflow/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import zod__default from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { getUserAgent } from "../common/info.js";
|
|
3
3
|
import { isSamplingPolyfillResult } from "../common/pollyfills.js";
|
|
4
4
|
import { getRequestHeader } from "../common/request-context.js";
|
|
5
5
|
import { ToolError } from "../common/tools.js";
|
|
@@ -170,10 +170,6 @@ class PactflowClient {
|
|
|
170
170
|
if (Array.isArray(contextToken)) {
|
|
171
171
|
contextToken = contextToken[0];
|
|
172
172
|
}
|
|
173
|
-
const clientInfo = this._server?.getClientInfo();
|
|
174
|
-
const sourceApplicationHeader = {
|
|
175
|
-
SOURCE_APPLICATION: clientInfo ? `${clientInfo.name}/${clientInfo.version}` : "unknown"
|
|
176
|
-
};
|
|
177
173
|
if (contextToken) {
|
|
178
174
|
let authHeader = contextToken;
|
|
179
175
|
if (!contextToken.startsWith("Basic ") && !contextToken.startsWith("Bearer ")) {
|
|
@@ -182,8 +178,7 @@ class PactflowClient {
|
|
|
182
178
|
return {
|
|
183
179
|
Authorization: authHeader,
|
|
184
180
|
"Content-Type": "application/json",
|
|
185
|
-
"User-Agent":
|
|
186
|
-
...sourceApplicationHeader
|
|
181
|
+
"User-Agent": getUserAgent()
|
|
187
182
|
};
|
|
188
183
|
}
|
|
189
184
|
if (this.token) {
|
|
@@ -194,16 +189,14 @@ class PactflowClient {
|
|
|
194
189
|
return {
|
|
195
190
|
Authorization: authHeader,
|
|
196
191
|
"Content-Type": "application/json",
|
|
197
|
-
"User-Agent":
|
|
198
|
-
...sourceApplicationHeader
|
|
192
|
+
"User-Agent": getUserAgent()
|
|
199
193
|
};
|
|
200
194
|
} else if (this.username && this.password) {
|
|
201
195
|
const authString = `${this.username}:${this.password}`;
|
|
202
196
|
return {
|
|
203
197
|
Authorization: `Basic ${Buffer.from(authString).toString("base64")}`,
|
|
204
198
|
"Content-Type": "application/json",
|
|
205
|
-
"User-Agent":
|
|
206
|
-
...sourceApplicationHeader
|
|
199
|
+
"User-Agent": getUserAgent()
|
|
207
200
|
};
|
|
208
201
|
}
|
|
209
202
|
return void 0;
|
package/dist/reflect/client.js
CHANGED
|
@@ -14,6 +14,8 @@ import { ExecuteSuite } from "./tool/suites/execute-suite.js";
|
|
|
14
14
|
import { GetSuiteExecutionStatus } from "./tool/suites/get-suite-execution-status.js";
|
|
15
15
|
import { ListSuiteExecutions } from "./tool/suites/list-suite-executions.js";
|
|
16
16
|
import { ListSuites } from "./tool/suites/list-suites.js";
|
|
17
|
+
import { CreateSegment } from "./tool/tests/create-segment.js";
|
|
18
|
+
import { CreateTest } from "./tool/tests/create-test.js";
|
|
17
19
|
import { GetTestDetail } from "./tool/tests/get-test-detail.js";
|
|
18
20
|
import { GetTestStatus } from "./tool/tests/get-test-status.js";
|
|
19
21
|
import { ListSegments } from "./tool/tests/list-segments.js";
|
|
@@ -123,7 +125,9 @@ class ReflectClient {
|
|
|
123
125
|
new ListTests(this),
|
|
124
126
|
new GetTestDetail(this),
|
|
125
127
|
new RunTest(this),
|
|
126
|
-
new GetTestStatus(this)
|
|
128
|
+
new GetTestStatus(this),
|
|
129
|
+
new CreateTest(this),
|
|
130
|
+
new CreateSegment(this)
|
|
127
131
|
];
|
|
128
132
|
const oAuthAndAPISupportedTools = [
|
|
129
133
|
new ListSegments(this),
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Tool } from "../../../common/tools.js";
|
|
2
|
+
import { buildCreateDefinitionSchema, createReflectDefinition } from "./definition.js";
|
|
3
|
+
class CreateSegment extends Tool {
|
|
4
|
+
specification = {
|
|
5
|
+
title: "Create Segment",
|
|
6
|
+
toolset: "Tests",
|
|
7
|
+
summary: "Create a new Reflect segment which contains an ordered list of steps. Segments are reusable groups of steps that can be referenced from tests, and cannot reference other segments.",
|
|
8
|
+
readOnly: false,
|
|
9
|
+
idempotent: false,
|
|
10
|
+
inputSchema: buildCreateDefinitionSchema({ isSegment: true })
|
|
11
|
+
};
|
|
12
|
+
handle = async (args) => {
|
|
13
|
+
return createReflectDefinition(this.client, "segments", "segment", args);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
CreateSegment
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Tool } from "../../../common/tools.js";
|
|
2
|
+
import { buildCreateDefinitionSchema, createReflectDefinition } from "./definition.js";
|
|
3
|
+
class CreateTest extends Tool {
|
|
4
|
+
specification = {
|
|
5
|
+
title: "Create Test",
|
|
6
|
+
toolset: "Tests",
|
|
7
|
+
summary: "Create a new Reflect test which contains an ordered list of steps.",
|
|
8
|
+
readOnly: false,
|
|
9
|
+
idempotent: false,
|
|
10
|
+
inputSchema: buildCreateDefinitionSchema({ isSegment: false })
|
|
11
|
+
};
|
|
12
|
+
handle = async (args) => {
|
|
13
|
+
return createReflectDefinition(this.client, "tests", "test", args);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
CreateTest
|
|
18
|
+
};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ToolError } from "../../../common/tools.js";
|
|
3
|
+
import { API_HOSTNAME } from "../../config/constants.js";
|
|
4
|
+
const BASE_STEP_TYPES = [
|
|
5
|
+
"click",
|
|
6
|
+
"text-validation",
|
|
7
|
+
"input",
|
|
8
|
+
"submit",
|
|
9
|
+
"scroll",
|
|
10
|
+
"focus",
|
|
11
|
+
"hover",
|
|
12
|
+
"drag-and-drop",
|
|
13
|
+
"text-highlight",
|
|
14
|
+
"browser-navigate",
|
|
15
|
+
"browser-back",
|
|
16
|
+
"browser-forward",
|
|
17
|
+
"browser-refresh",
|
|
18
|
+
"api",
|
|
19
|
+
"javascript",
|
|
20
|
+
"appium",
|
|
21
|
+
"prompt",
|
|
22
|
+
"update-parameters",
|
|
23
|
+
"wait",
|
|
24
|
+
"receive-email",
|
|
25
|
+
"receive-sms",
|
|
26
|
+
"rotate-device",
|
|
27
|
+
"reset-device",
|
|
28
|
+
"deeplink",
|
|
29
|
+
"set-device-location"
|
|
30
|
+
];
|
|
31
|
+
const TEST_STEP_TYPES = ["segment", ...BASE_STEP_TYPES];
|
|
32
|
+
const headerSchema = z.object({
|
|
33
|
+
name: z.string().describe("Header name."),
|
|
34
|
+
value: z.string().describe("Header value.")
|
|
35
|
+
});
|
|
36
|
+
const parameterSchema = z.object({
|
|
37
|
+
name: z.string().describe("Parameter name."),
|
|
38
|
+
value: z.string().optional().describe("Default value for the parameter.")
|
|
39
|
+
});
|
|
40
|
+
const emailFilterSchema = z.object({
|
|
41
|
+
fromAddress: z.string().optional().describe("Only match emails sent from this address."),
|
|
42
|
+
fromName: z.string().optional().describe("Only match emails sent from this sender name."),
|
|
43
|
+
subject: z.string().optional().describe("Only match emails with this subject."),
|
|
44
|
+
toAddress: z.string().optional().describe("Only match emails sent to this address.")
|
|
45
|
+
});
|
|
46
|
+
const emailSchema = z.object({
|
|
47
|
+
text: z.string().optional().describe("Text to extract from, or validate against, the matched email."),
|
|
48
|
+
filters: emailFilterSchema.describe(
|
|
49
|
+
"Filters selecting which inbound email this step waits for."
|
|
50
|
+
)
|
|
51
|
+
});
|
|
52
|
+
const smsFilterSchema = z.object({
|
|
53
|
+
fromNumber: z.string().optional().describe("Only match SMS messages sent from this number."),
|
|
54
|
+
toNumber: z.string().optional().describe("Only match SMS messages sent to this number.")
|
|
55
|
+
});
|
|
56
|
+
const smsSchema = z.object({
|
|
57
|
+
text: z.string().optional().describe("Text to extract from, or validate against, the matched SMS."),
|
|
58
|
+
filters: smsFilterSchema.optional().describe("Filters selecting which inbound SMS this step waits for.")
|
|
59
|
+
});
|
|
60
|
+
function buildStepSchema(stepTypes, { includeSegmentReference }) {
|
|
61
|
+
return z.object({
|
|
62
|
+
type: z.enum(stepTypes).describe(
|
|
63
|
+
"The kind of step to perform. Determines which of the other fields are required."
|
|
64
|
+
),
|
|
65
|
+
description: z.string().optional().describe(
|
|
66
|
+
"Human-readable description of the step. For 'prompt' steps, this field holds the natural-language instruction to execute."
|
|
67
|
+
),
|
|
68
|
+
selector: z.string().optional().describe(
|
|
69
|
+
"CSS selector of the target element. Used by 'click', 'input', 'submit', 'scroll', 'focus', 'hover', 'text-validation', 'text-highlight', and the source element of 'drag-and-drop'."
|
|
70
|
+
),
|
|
71
|
+
tag: z.string().optional().describe("Tag name of the target element (e.g. 'button', 'input')."),
|
|
72
|
+
toSelector: z.string().optional().describe(
|
|
73
|
+
"CSS selector of the destination element for a 'drag-and-drop' step."
|
|
74
|
+
),
|
|
75
|
+
toTag: z.string().optional().describe(
|
|
76
|
+
"Tag name of the destination element for a 'drag-and-drop' step."
|
|
77
|
+
),
|
|
78
|
+
inputText: z.string().optional().describe("Text to type. Used by 'input' steps."),
|
|
79
|
+
url: z.string().optional().describe(
|
|
80
|
+
"Target URL. Required by 'api' steps; used as the navigation URL for 'browser-navigate' and as the deep link for 'deeplink'."
|
|
81
|
+
),
|
|
82
|
+
script: z.string().optional().describe("JavaScript source to execute. Used by 'javascript' steps."),
|
|
83
|
+
command: z.string().optional().describe("Appium command to run. Required by 'appium' steps."),
|
|
84
|
+
argument: z.string().optional().describe("Argument for the Appium command in an 'appium' step."),
|
|
85
|
+
httpMethod: z.string().optional().describe(
|
|
86
|
+
"HTTP method for an 'api' step (e.g. 'GET', 'POST'). Defaults to 'GET'."
|
|
87
|
+
),
|
|
88
|
+
requestBody: z.string().optional().describe("Request body for an 'api' step."),
|
|
89
|
+
requestHeaders: z.array(headerSchema).optional().describe("Request headers for an 'api' step."),
|
|
90
|
+
followRedirects: z.boolean().optional().describe("Whether an 'api' step should follow HTTP redirects."),
|
|
91
|
+
email: emailSchema.optional().describe("Configuration for a 'receive-email' step."),
|
|
92
|
+
sms: smsSchema.optional().describe("Configuration for a 'receive-sms' step."),
|
|
93
|
+
expectedText: z.string().optional().describe(
|
|
94
|
+
"Text expected on the page. Used by 'text-validation' steps, which require an exact match of the target element's text (not a substring or case-insensitive match)."
|
|
95
|
+
),
|
|
96
|
+
title: z.string().optional().describe(
|
|
97
|
+
"Expected page title for a navigation step ('browser-navigate', 'browser-back', 'browser-forward', 'browser-refresh')."
|
|
98
|
+
),
|
|
99
|
+
expectedResult: z.string().optional().describe("Expected result text for a 'prompt' step."),
|
|
100
|
+
promptType: z.enum(["action", "assert", "query"]).optional().describe(
|
|
101
|
+
"The kind of AI 'prompt' step (required for 'prompt' steps): 'action' performs an action; 'assert' checks a condition; 'query' answers a question. Prompt steps only take into account what is currently visible on the screen."
|
|
102
|
+
),
|
|
103
|
+
expectedResponse: z.union([z.boolean(), z.string()]).optional().describe(
|
|
104
|
+
"Expected response for a 'prompt' step: a boolean for an 'assert' prompt, or a string for a 'query' prompt."
|
|
105
|
+
),
|
|
106
|
+
latitude: z.number().optional().describe("Latitude for a 'set-device-location' step."),
|
|
107
|
+
longitude: z.number().optional().describe("Longitude for a 'set-device-location' step."),
|
|
108
|
+
seconds: z.number().optional().describe("Number of seconds to pause. Used by 'wait' steps."),
|
|
109
|
+
// Only tests can reference segments, so this field is omitted from segment steps.
|
|
110
|
+
...includeSegmentReference ? {
|
|
111
|
+
id: z.number().optional().describe(
|
|
112
|
+
"Id of the segment to reference. Required for 'segment' steps."
|
|
113
|
+
)
|
|
114
|
+
} : {},
|
|
115
|
+
name: z.string().optional().describe("Optional display name for the step."),
|
|
116
|
+
parameters: z.array(parameterSchema).optional().describe(
|
|
117
|
+
"Parameter name/value assignments applied by an 'update-parameters' step."
|
|
118
|
+
)
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function buildCreateDefinitionSchema({
|
|
122
|
+
isSegment
|
|
123
|
+
}) {
|
|
124
|
+
const definitionType = isSegment ? "segment" : "test";
|
|
125
|
+
const stepSchema = buildStepSchema(
|
|
126
|
+
isSegment ? BASE_STEP_TYPES : TEST_STEP_TYPES,
|
|
127
|
+
{ includeSegmentReference: !isSegment }
|
|
128
|
+
);
|
|
129
|
+
const selectorGuidance = "Prefer deterministic, selector-based steps ('click', 'input', 'submit', 'text-validation', 'hover', etc.) over AI-driven 'prompt' steps whenever a stable selector is available. Reserve 'prompt' steps for behavior that can't be expressed with a selector.";
|
|
130
|
+
const referenceGuidance = `Any text field in a step (e.g. 'inputText', 'url', 'expectedText', 'requestBody', header values, prompt text) may embed Reflect variable and function references using '\${...}' syntax, which are resolved at run time: '\${var(name)}' inserts the value of a parameter/variable named 'name' (declare parameters via the top-level 'parameters' field, or assign them mid-run with an 'update-parameters' step); '\${sec(name)}' inserts the value of the account secret 'name'. Functions generate dynamic values: '\${alphanum(n)}', '\${alpha(n)}', '\${num(n)}' (random alphanumeric / alphabetic / numeric string of length n), '\${range(min, max)}' (random integer, inclusive), '\${time(offsetMs)}' and '\${datetime(offsetMs)}' (current epoch-millis / date-time, with an optional millisecond offset), and '\${date(format, offsetDays)}' (current date formatted with tokens like 'MM/dd/yyyy', with an optional day offset).`;
|
|
131
|
+
const stepsDescription = isSegment ? `Ordered list of steps that make up the segment. Segments cannot reference other segments. ${selectorGuidance} ${referenceGuidance}` : `Ordered list of steps that make up the test. Web tests must begin with a 'browser-navigate' step. ${selectorGuidance} ${referenceGuidance}`;
|
|
132
|
+
return z.object({
|
|
133
|
+
name: z.string().describe(`Name of the ${definitionType} to create.`),
|
|
134
|
+
type: z.enum(["web", "api", "native-mobile"]).describe(`Platform of the ${definitionType}.`),
|
|
135
|
+
description: z.string().optional().describe(`Optional description of the ${definitionType}.`),
|
|
136
|
+
deviceProfile: z.string().optional().describe(
|
|
137
|
+
`Device profile id. Required for a 'web' ${definitionType}; ignored for 'api' and 'native-mobile'. One of: 'desktop', 'tablet', 'mobile'.`
|
|
138
|
+
),
|
|
139
|
+
steps: z.array(stepSchema).describe(stepsDescription),
|
|
140
|
+
parameters: z.array(parameterSchema).optional().describe(
|
|
141
|
+
`Optional named parameters (variables) for the ${definitionType}, each with a 'name' and optional default 'value'. Reference a parameter's value inside any step text field with '\${var(name)}'.`
|
|
142
|
+
)
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
async function readErrorMessage(response) {
|
|
146
|
+
try {
|
|
147
|
+
const text = await response.text();
|
|
148
|
+
if (!text) {
|
|
149
|
+
return "";
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
const parsed = JSON.parse(text);
|
|
153
|
+
return parsed.message ? `: ${parsed.message}` : `: ${text}`;
|
|
154
|
+
} catch {
|
|
155
|
+
return `: ${text}`;
|
|
156
|
+
}
|
|
157
|
+
} catch {
|
|
158
|
+
return "";
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async function createReflectDefinition(client, endpoint, noun, body) {
|
|
162
|
+
const response = await fetch(`https://${API_HOSTNAME}/v1/${endpoint}`, {
|
|
163
|
+
method: "POST",
|
|
164
|
+
headers: client.getHeaders(),
|
|
165
|
+
body: JSON.stringify(body)
|
|
166
|
+
});
|
|
167
|
+
if (!response.ok) {
|
|
168
|
+
const detail = await readErrorMessage(response);
|
|
169
|
+
throw new ToolError(
|
|
170
|
+
`Failed to create ${noun}: ${response.status} ${response.statusText}${detail}`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
const data = await response.json();
|
|
174
|
+
return {
|
|
175
|
+
content: [
|
|
176
|
+
{
|
|
177
|
+
type: "text",
|
|
178
|
+
text: JSON.stringify({
|
|
179
|
+
success: true,
|
|
180
|
+
id: data.id,
|
|
181
|
+
message: `Created ${noun} with id ${data.id}`
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
export {
|
|
188
|
+
buildCreateDefinitionSchema,
|
|
189
|
+
createReflectDefinition
|
|
190
|
+
};
|
|
@@ -20,10 +20,18 @@ class FunctionalTestingAPI {
|
|
|
20
20
|
"User-Agent": appendClientIdentity(this.userAgent)
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Wrapper around the fetch function for the Functional Testing API. It generates the full URL and performs
|
|
25
|
+
* common error handling.
|
|
26
|
+
* @param relativePath Path of the resource to fetch relative to the base URL
|
|
27
|
+
* @param init RequestInit passed to the fetch function
|
|
28
|
+
* @param onFailure Handler that generates the error message for failed responses
|
|
29
|
+
* @returns Response having asserted it has not failed (status is 2xx)
|
|
30
|
+
*/
|
|
31
|
+
async ftFetch(relativePath, init, onFailure) {
|
|
24
32
|
let response;
|
|
25
33
|
try {
|
|
26
|
-
response = await fetch(
|
|
34
|
+
response = await fetch(`${this.baseUrl}/${relativePath}`, init);
|
|
27
35
|
} catch {
|
|
28
36
|
throw new ToolError(
|
|
29
37
|
"Swagger Functional Testing service is currently unreachable. Retry after a moment."
|
|
@@ -34,34 +42,32 @@ class FunctionalTestingAPI {
|
|
|
34
42
|
"Authentication failed. Verify your API token is valid and has not expired."
|
|
35
43
|
);
|
|
36
44
|
}
|
|
45
|
+
if (!response.ok) {
|
|
46
|
+
throw new ToolError(onFailure(response));
|
|
47
|
+
}
|
|
37
48
|
return response;
|
|
38
49
|
}
|
|
39
50
|
async listTests() {
|
|
40
|
-
const response = await this.ftFetch(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
51
|
+
const response = await this.ftFetch(
|
|
52
|
+
`tests`,
|
|
53
|
+
{
|
|
54
|
+
method: "GET",
|
|
55
|
+
headers: this.getFtHeaders()
|
|
56
|
+
},
|
|
57
|
+
errorMessageFor(`list Functional Testing tests`)
|
|
58
|
+
);
|
|
49
59
|
return response.json();
|
|
50
60
|
}
|
|
51
61
|
async runTest(args) {
|
|
52
62
|
if (!args.testId) throw new ToolError("testId argument is required");
|
|
53
63
|
const response = await this.ftFetch(
|
|
54
|
-
|
|
64
|
+
`tests/${encodeURIComponent(args.testId)}/executions`,
|
|
55
65
|
{
|
|
56
66
|
method: "POST",
|
|
57
67
|
headers: this.getFtHeaders()
|
|
58
|
-
}
|
|
68
|
+
},
|
|
69
|
+
errorMessageFor(`run test`)
|
|
59
70
|
);
|
|
60
|
-
if (!response.ok) {
|
|
61
|
-
throw new ToolError(
|
|
62
|
-
`Failed to run test: ${response.status} ${response.statusText}`
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
71
|
return response.json();
|
|
66
72
|
}
|
|
67
73
|
async getTestExecution(args) {
|
|
@@ -69,17 +75,13 @@ class FunctionalTestingAPI {
|
|
|
69
75
|
throw new ToolError("executionId argument is required");
|
|
70
76
|
}
|
|
71
77
|
const response = await this.ftFetch(
|
|
72
|
-
|
|
78
|
+
`executions/${encodeURIComponent(args.executionId)}`,
|
|
73
79
|
{
|
|
74
80
|
method: "GET",
|
|
75
81
|
headers: this.getFtHeaders()
|
|
76
|
-
}
|
|
82
|
+
},
|
|
83
|
+
errorMessageFor("get test status")
|
|
77
84
|
);
|
|
78
|
-
if (!response.ok) {
|
|
79
|
-
throw new ToolError(
|
|
80
|
-
`Failed to get test status: ${response.status} ${response.statusText}`
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
85
|
const data = await response.json();
|
|
84
86
|
if (Array.isArray(data.tests)) {
|
|
85
87
|
for (const test of data.tests) {
|
|
@@ -94,15 +96,25 @@ class FunctionalTestingAPI {
|
|
|
94
96
|
async listSuiteExecutions(args) {
|
|
95
97
|
if (!args.suiteId) throw new ToolError("suiteId argument is required");
|
|
96
98
|
const response = await this.ftFetch(
|
|
97
|
-
|
|
99
|
+
`suites/${encodeURIComponent(args.suiteId)}/executions`,
|
|
98
100
|
{
|
|
99
101
|
method: "GET",
|
|
100
102
|
headers: this.getFtHeaders()
|
|
101
|
-
}
|
|
103
|
+
},
|
|
104
|
+
handleStatus(
|
|
105
|
+
/* @__PURE__ */ new Map([
|
|
106
|
+
// Defensive: the Reflect API currently returns 200 with an empty
|
|
107
|
+
// `executions.data` list for an unknown suiteId rather than a 404, so this
|
|
108
|
+
// branch is not expected to fire today. Kept in case the API starts
|
|
109
|
+
// returning 404 for missing suites.
|
|
110
|
+
[
|
|
111
|
+
404,
|
|
112
|
+
"Test suite not found. Verify the suiteId is correct and belongs to your workspace."
|
|
113
|
+
]
|
|
114
|
+
]),
|
|
115
|
+
errorMessageFor("list suite executions")
|
|
116
|
+
)
|
|
102
117
|
);
|
|
103
|
-
if (!response.ok) {
|
|
104
|
-
throw new ToolError(suiteExecutionsErrorMessage(response));
|
|
105
|
-
}
|
|
106
118
|
const data = await response.json();
|
|
107
119
|
return {
|
|
108
120
|
...data,
|
|
@@ -118,15 +130,14 @@ class FunctionalTestingAPI {
|
|
|
118
130
|
};
|
|
119
131
|
}
|
|
120
132
|
async listSuites() {
|
|
121
|
-
const response = await this.ftFetch(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
133
|
+
const response = await this.ftFetch(
|
|
134
|
+
`suites`,
|
|
135
|
+
{
|
|
136
|
+
method: "GET",
|
|
137
|
+
headers: this.getFtHeaders()
|
|
138
|
+
},
|
|
139
|
+
errorMessageFor("list Functional Testing suites")
|
|
140
|
+
);
|
|
130
141
|
return response.json();
|
|
131
142
|
}
|
|
132
143
|
async cancelSuiteExecution(args) {
|
|
@@ -135,15 +146,25 @@ class FunctionalTestingAPI {
|
|
|
135
146
|
throw new ToolError("executionId argument is required");
|
|
136
147
|
}
|
|
137
148
|
const response = await this.ftFetch(
|
|
138
|
-
|
|
149
|
+
`suites/${encodeURIComponent(args.suiteId)}/executions/${encodeURIComponent(args.executionId)}/cancel`,
|
|
139
150
|
{
|
|
140
151
|
method: "PATCH",
|
|
141
152
|
headers: this.getFtHeaders()
|
|
142
|
-
}
|
|
153
|
+
},
|
|
154
|
+
handleStatus(
|
|
155
|
+
/* @__PURE__ */ new Map([
|
|
156
|
+
[
|
|
157
|
+
404,
|
|
158
|
+
"Suite execution not found. Verify the suiteId and executionId are correct and belong to your workspace."
|
|
159
|
+
],
|
|
160
|
+
[
|
|
161
|
+
409,
|
|
162
|
+
"Suite execution cannot be cancelled because it has already finished."
|
|
163
|
+
]
|
|
164
|
+
]),
|
|
165
|
+
errorMessageFor("cancel suite execution")
|
|
166
|
+
)
|
|
143
167
|
);
|
|
144
|
-
if (!response.ok) {
|
|
145
|
-
throw new ToolError(cancelSuiteExecutionErrorMessage(response));
|
|
146
|
-
}
|
|
147
168
|
return response.json();
|
|
148
169
|
}
|
|
149
170
|
async runSuite(args) {
|
|
@@ -151,31 +172,15 @@ class FunctionalTestingAPI {
|
|
|
151
172
|
const body = args.tunnelAgentName ? JSON.stringify({
|
|
152
173
|
overrides: { agent: { name: args.tunnelAgentName } }
|
|
153
174
|
}) : void 0;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
);
|
|
164
|
-
} catch {
|
|
165
|
-
throw new ToolError(
|
|
166
|
-
"Swagger Functional Testing service is currently unreachable. Retry after a moment."
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
if (response.status === 401 || response.status === 403) {
|
|
170
|
-
throw new ToolError(
|
|
171
|
-
"Authentication failed. Verify your API token is valid and has not expired."
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
if (!response.ok) {
|
|
175
|
-
throw new ToolError(
|
|
176
|
-
`Failed to run suite: ${response.status} ${response.statusText}`
|
|
177
|
-
);
|
|
178
|
-
}
|
|
175
|
+
const response = await this.ftFetch(
|
|
176
|
+
`suites/${args.suiteId}/executions`,
|
|
177
|
+
{
|
|
178
|
+
method: "POST",
|
|
179
|
+
headers: this.getFtHeaders(),
|
|
180
|
+
body
|
|
181
|
+
},
|
|
182
|
+
errorMessageFor("run suite")
|
|
183
|
+
);
|
|
179
184
|
return this.withoutField("url", response);
|
|
180
185
|
}
|
|
181
186
|
async getSuiteExecution(args) {
|
|
@@ -183,30 +188,14 @@ class FunctionalTestingAPI {
|
|
|
183
188
|
if (!args.executionId) {
|
|
184
189
|
throw new ToolError("executionId argument is required");
|
|
185
190
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
);
|
|
195
|
-
} catch {
|
|
196
|
-
throw new ToolError(
|
|
197
|
-
"Swagger Functional Testing service is currently unreachable. Retry after a moment."
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
if (response.status === 401 || response.status === 403) {
|
|
201
|
-
throw new ToolError(
|
|
202
|
-
"Authentication failed. Verify your API token is valid and has not expired."
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
if (!response.ok) {
|
|
206
|
-
throw new ToolError(
|
|
207
|
-
`Failed to get suite execution status: ${response.status} ${response.statusText}`
|
|
208
|
-
);
|
|
209
|
-
}
|
|
191
|
+
const response = await this.ftFetch(
|
|
192
|
+
`suites/${args.suiteId}/executions/${args.executionId}`,
|
|
193
|
+
{
|
|
194
|
+
method: "GET",
|
|
195
|
+
headers: this.getFtHeaders()
|
|
196
|
+
},
|
|
197
|
+
errorMessageFor("get suite execution status")
|
|
198
|
+
);
|
|
210
199
|
const data = await this.withoutField("url", response);
|
|
211
200
|
const testsData = data.tests?.data;
|
|
212
201
|
if (Array.isArray(testsData)) {
|
|
@@ -220,33 +209,38 @@ class FunctionalTestingAPI {
|
|
|
220
209
|
}
|
|
221
210
|
return data;
|
|
222
211
|
}
|
|
212
|
+
async getTestHistory(args) {
|
|
213
|
+
if (!args.testId) throw new ToolError("testId argument is required");
|
|
214
|
+
const params = new URLSearchParams();
|
|
215
|
+
if (args.limit !== void 0) params.set("limit", String(args.limit));
|
|
216
|
+
if (args.offset !== void 0) params.set("offset", String(args.offset));
|
|
217
|
+
const query = params.toString() ? `?${params.toString()}` : "";
|
|
218
|
+
const response = await this.ftFetch(
|
|
219
|
+
`tests/${encodeURIComponent(args.testId)}/runs${query}`,
|
|
220
|
+
{
|
|
221
|
+
method: "GET",
|
|
222
|
+
headers: this.getFtHeaders()
|
|
223
|
+
},
|
|
224
|
+
handleStatus(
|
|
225
|
+
/* @__PURE__ */ new Map([
|
|
226
|
+
[404, "Test not found. Verify the testId belongs to your workspace."]
|
|
227
|
+
]),
|
|
228
|
+
errorMessageFor("get test execution history")
|
|
229
|
+
)
|
|
230
|
+
);
|
|
231
|
+
return response.json();
|
|
232
|
+
}
|
|
223
233
|
async withoutField(field, response) {
|
|
224
234
|
const data = await response.json();
|
|
225
235
|
delete data[field];
|
|
226
236
|
return data;
|
|
227
237
|
}
|
|
228
238
|
}
|
|
229
|
-
function
|
|
230
|
-
|
|
231
|
-
// Defensive: the Reflect API currently returns 200 with an empty
|
|
232
|
-
// `executions.data` list for an unknown suiteId rather than a 404, so this
|
|
233
|
-
// branch is not expected to fire today. Kept in case the API starts
|
|
234
|
-
// returning 404 for missing suites.
|
|
235
|
-
case 404:
|
|
236
|
-
return "Test suite not found. Verify the suiteId is correct and belongs to your workspace.";
|
|
237
|
-
default:
|
|
238
|
-
return `Failed to list suite executions: ${response.status} ${response.statusText}`;
|
|
239
|
-
}
|
|
239
|
+
function handleStatus(messages, defaultMessage) {
|
|
240
|
+
return (response) => messages.get(response.status) || defaultMessage(response);
|
|
240
241
|
}
|
|
241
|
-
function
|
|
242
|
-
|
|
243
|
-
case 404:
|
|
244
|
-
return "Suite execution not found. Verify the suiteId and executionId are correct and belong to your workspace.";
|
|
245
|
-
case 409:
|
|
246
|
-
return "Suite execution cannot be cancelled because it has already finished.";
|
|
247
|
-
default:
|
|
248
|
-
return `Failed to cancel suite execution: ${response.status} ${response.statusText}`;
|
|
249
|
-
}
|
|
242
|
+
function errorMessageFor(operation) {
|
|
243
|
+
return (response) => `Failed to ${operation}: ${response.status} ${response.statusText}`;
|
|
250
244
|
}
|
|
251
245
|
export {
|
|
252
246
|
FUNCTIONAL_TESTING_API_KEY_HEADER,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RunFunctionalTestingTestParamsSchema, GetFunctionalTestingExecutionTestSchema, ListFunctionalTestingSuiteExecutionsSchema, CancelFunctionalTestingSuiteExecutionSchema, RunFunctionalTestingSuiteParamsSchema, GetFunctionalTestingSuiteExecutionSchema } from "./functional-testing-types.js";
|
|
1
|
+
import { RunFunctionalTestingTestParamsSchema, GetFunctionalTestingExecutionTestSchema, ListFunctionalTestingSuiteExecutionsSchema, CancelFunctionalTestingSuiteExecutionSchema, RunFunctionalTestingSuiteParamsSchema, GetFunctionalTestingSuiteExecutionSchema, GetFunctionalTestHistoryParamsSchema } from "./functional-testing-types.js";
|
|
2
2
|
const FUNCTIONAL_TESTING_TOOLS = [
|
|
3
3
|
{
|
|
4
4
|
title: "List Tests",
|
|
@@ -69,6 +69,15 @@ const FUNCTIONAL_TESTING_TOOLS = [
|
|
|
69
69
|
handler: "getFunctionalTestingSuiteExecution",
|
|
70
70
|
idempotent: true,
|
|
71
71
|
readOnly: true
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
title: "Get Test Execution History",
|
|
75
|
+
toolset: "Functional Testing",
|
|
76
|
+
summary: "Retrieves the execution history for a given test in your Swagger Functional Testing workspace. Returns a list of past runs, each including pass/fail status, run time, creation timestamp, and — for failed runs — a per-step breakdown of failure details. Use this tool when you need to check past run results, identify failures, or assess test reliability over time. Do not use this tool to run a test or retrieve suite-level execution results.",
|
|
77
|
+
inputSchema: GetFunctionalTestHistoryParamsSchema,
|
|
78
|
+
handler: "getFunctionalTestingTestHistory",
|
|
79
|
+
idempotent: true,
|
|
80
|
+
readOnly: true
|
|
72
81
|
}
|
|
73
82
|
];
|
|
74
83
|
export {
|
|
@@ -22,8 +22,14 @@ const GetFunctionalTestingSuiteExecutionSchema = z.object({
|
|
|
22
22
|
suiteId: z.string().describe("ID of the Functional Testing suite").trim().min(1),
|
|
23
23
|
executionId: z.string().describe("ID of the Functional Testing suite execution").trim().min(1)
|
|
24
24
|
});
|
|
25
|
+
const GetFunctionalTestHistoryParamsSchema = z.object({
|
|
26
|
+
testId: z.string().describe("ID of the Functional Testing test").trim().min(1),
|
|
27
|
+
limit: z.number().int().min(1).max(100).optional().describe("Number of most recent runs to return (default: 25, max: 100)"),
|
|
28
|
+
offset: z.number().int().min(0).optional().describe("Pagination offset (default: 0)")
|
|
29
|
+
});
|
|
25
30
|
export {
|
|
26
31
|
CancelFunctionalTestingSuiteExecutionSchema,
|
|
32
|
+
GetFunctionalTestHistoryParamsSchema,
|
|
27
33
|
GetFunctionalTestingExecutionTestSchema,
|
|
28
34
|
GetFunctionalTestingSuiteExecutionSchema,
|
|
29
35
|
ListFunctionalTestingSuiteExecutionsSchema,
|