Skip to content

Commit 09da1d2

Browse files
committed
Address comments
1 parent f84c6cc commit 09da1d2

4 files changed

Lines changed: 31 additions & 13 deletions

File tree

src/swagger/client.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import "./config-utils";
1313
import {
1414
FUNCTIONAL_TESTING_API_KEY_HEADER,
1515
FunctionalTestingAPI,
16+
FunctionalTestingApiEnv,
1617
} from "./client/functional-testing-api";
1718
import type {
1819
GetFunctionalTestingExecutionParams,
@@ -117,6 +118,7 @@ export class SwaggerClient implements Client {
117118
this.ftApi = new FunctionalTestingAPI(
118119
() => this.getFtAuthToken(),
119120
USER_AGENT,
121+
this.getFtEnv(),
120122
);
121123
}
122124
}
@@ -151,6 +153,12 @@ export class SwaggerClient implements Client {
151153
return this._ftApiToken || null;
152154
}
153155

156+
getFtEnv(): FunctionalTestingApiEnv {
157+
return process.env.NODE_ENV === "development"
158+
? FunctionalTestingApiEnv.Development
159+
: FunctionalTestingApiEnv.Production;
160+
}
161+
154162
isConfigured(): boolean {
155163
return this.api !== undefined || this.ftApi !== undefined;
156164
}

src/swagger/client/functional-testing-api.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,23 @@ const API_HOSTNAME = "api.reflect.run";
99

1010
export const FUNCTIONAL_TESTING_API_KEY_HEADER = "X-API-KEY";
1111

12+
export enum FunctionalTestingApiEnv {
13+
Production,
14+
Development,
15+
}
16+
17+
const URL_BASES: Record<FunctionalTestingApiEnv, string> = {
18+
[FunctionalTestingApiEnv.Development]: `http://${API_HOSTNAME_DEV}/api`,
19+
[FunctionalTestingApiEnv.Production]: `https://${API_HOSTNAME}/v1`,
20+
};
21+
1222
export class FunctionalTestingAPI {
1323
private urlBase: string | undefined;
1424

1525
constructor(
1626
private readonly getToken: () => string | null,
1727
private readonly userAgent: string,
28+
private readonly env: FunctionalTestingApiEnv = FunctionalTestingApiEnv.Production,
1829
) {}
1930

2031
getFtHeaders(): Record<string, string> {
@@ -89,18 +100,13 @@ export class FunctionalTestingAPI {
89100
}
90101

91102
/**
92-
* Get the URL base for API calls. When running against a local environment (NODE_ENV: development),
93-
* the endpoints are exposed at the `/api` path. When running against production, the endpoints
94-
* are exposed at `/v1`.
95-
*
96-
* If NODE_ENV is anything other than `development`, defaults to the production URL
103+
* Get the URL base for API calls. When running against a local environment,
104+
* the endpoints are exposed at the `/api` path. When running against production,
105+
* the endpoints are exposed at `/v1`.
97106
*/
98107
private getUrlBase(): string {
99108
if (!this.urlBase) {
100-
this.urlBase =
101-
process.env.NODE_ENV === "development"
102-
? `http://${API_HOSTNAME_DEV}/api`
103-
: `https://${API_HOSTNAME}/v1`;
109+
this.urlBase = URL_BASES[this.env];
104110
}
105111

106112
return this.urlBase;

src/swagger/client/functional-testing-tools.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ export const FUNCTIONAL_TESTING_TOOLS: SwaggerToolParams[] = [
1818
title: "Run Test",
1919
toolset: "Functional Testing",
2020
summary:
21-
"Runs a specific API test in your Swagger Functional Testing workspace and returns the result. " +
22-
"Use this tool when you need to verify expected API functionality by executing a single test.",
21+
"Runs a specific API test in your Swagger Functional Testing workspace. The execution is asynchronous — it returns an executionId, not the result directly. Use swagger_get_test_status with that executionId to track progress and retrieve the final result.",
2322
inputSchema: RunFunctionalTestingTestParamsSchema,
2423
handler: "runFunctionalTestingTest",
2524
},
2625
{
2726
title: "Get Test Status",
2827
toolset: "Functional Testing",
29-
summary: "Get the status of a Swagger Functional Testing test execution",
28+
summary:
29+
"Get the status of a Swagger Functional Testing test execution. It returns information about the execution such as its status (running, passed or failed), run time, as well as the break down of the status of each test step.",
3030
inputSchema: GetFunctionalTestingExecutionSchema,
3131
handler: "getFunctionalTestingExecution",
3232
},

src/tests/unit/swagger/functional-testing/functional-testing-api.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { beforeEach, describe, expect, it, vi } from "vitest";
22
import createFetchMock from "vitest-fetch-mock";
3-
import { FunctionalTestingAPI } from "../../../../swagger/client/functional-testing-api";
3+
import {
4+
FunctionalTestingAPI,
5+
FunctionalTestingApiEnv,
6+
} from "../../../../swagger/client/functional-testing-api";
47

58
const fetchMock = createFetchMock(vi);
69
fetchMock.enableMocks();
@@ -18,6 +21,7 @@ describe("FunctionalTestingAPI", () => {
1821
api = new FunctionalTestingAPI(
1922
() => "test-api-key",
2023
"SmartBear MCP Server/test",
24+
FunctionalTestingApiEnv.Production,
2125
);
2226
});
2327

0 commit comments

Comments
 (0)