@browserstack/mcp-server 1.2.18 → 1.2.19
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/tools/testmanagement-utils/TCG-utils/api.d.ts +9 -0
- package/dist/tools/testmanagement-utils/TCG-utils/api.js +14 -0
- package/dist/tools/testmanagement-utils/create-testcase.d.ts +2 -0
- package/dist/tools/testmanagement-utils/create-testcase.js +26 -2
- package/dist/tools/testmanagement-utils/update-testcase.js +1 -21
- package/package.json +1 -1
|
@@ -7,6 +7,15 @@ export declare function fetchFormFields(projectId: string, config: BrowserStackC
|
|
|
7
7
|
default_fields: any;
|
|
8
8
|
custom_fields: any;
|
|
9
9
|
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a default-field input (priority/case_type) to the form's display or
|
|
12
|
+
* internal name, matching case-insensitively. Returns undefined if no match.
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeDefaultFieldValue(fieldValues: Array<{
|
|
15
|
+
internal_name?: string | null;
|
|
16
|
+
name?: string;
|
|
17
|
+
value: any;
|
|
18
|
+
}>, input: string, emit: "name" | "internal_name"): string | undefined;
|
|
10
19
|
/**
|
|
11
20
|
* Trigger AI-based test case generation for a document.
|
|
12
21
|
*/
|
|
@@ -16,6 +16,20 @@ export async function fetchFormFields(projectId, config) {
|
|
|
16
16
|
});
|
|
17
17
|
return res.data;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolve a default-field input (priority/case_type) to the form's display or
|
|
21
|
+
* internal name, matching case-insensitively. Returns undefined if no match.
|
|
22
|
+
*/
|
|
23
|
+
export function normalizeDefaultFieldValue(fieldValues, input, emit) {
|
|
24
|
+
const normalized = input.toLowerCase().trim();
|
|
25
|
+
const match = fieldValues.find((v) => (v.internal_name ?? "").toLowerCase() === normalized ||
|
|
26
|
+
(v.name ?? "").toLowerCase() === normalized);
|
|
27
|
+
if (!match)
|
|
28
|
+
return undefined;
|
|
29
|
+
if (emit === "name")
|
|
30
|
+
return match.name;
|
|
31
|
+
return match.internal_name ?? match.name;
|
|
32
|
+
}
|
|
19
33
|
/**
|
|
20
34
|
* Trigger AI-based test case generation for a document.
|
|
21
35
|
*/
|
|
@@ -22,6 +22,7 @@ export interface TestCaseCreateRequest {
|
|
|
22
22
|
tags?: string[];
|
|
23
23
|
custom_fields?: Record<string, string>;
|
|
24
24
|
automation_status?: string;
|
|
25
|
+
priority?: string;
|
|
25
26
|
}
|
|
26
27
|
export interface TestCaseResponse {
|
|
27
28
|
data: {
|
|
@@ -70,6 +71,7 @@ export declare const CreateTestCaseSchema: z.ZodObject<{
|
|
|
70
71
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
71
72
|
custom_fields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
72
73
|
automation_status: z.ZodOptional<z.ZodString>;
|
|
74
|
+
priority: z.ZodOptional<z.ZodString>;
|
|
73
75
|
}, z.core.$strip>;
|
|
74
76
|
export declare function sanitizeArgs(args: any): any;
|
|
75
77
|
export declare function createTestCase(params: TestCaseCreateRequest, config: BrowserStackConfig): Promise<CallToolResult>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { apiClient } from "../../lib/apiClient.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { formatAxiosError } from "../../lib/error.js";
|
|
4
|
-
import { projectIdentifierToId } from "./TCG-utils/api.js";
|
|
4
|
+
import { fetchFormFields, normalizeDefaultFieldValue, projectIdentifierToId, } from "./TCG-utils/api.js";
|
|
5
5
|
import { getTMBaseURL } from "../../lib/tm-base-url.js";
|
|
6
|
+
import logger from "../../logger.js";
|
|
6
7
|
export const CreateTestCaseSchema = z.object({
|
|
7
8
|
project_identifier: z
|
|
8
9
|
.string()
|
|
@@ -54,6 +55,10 @@ export const CreateTestCaseSchema = z.object({
|
|
|
54
55
|
.string()
|
|
55
56
|
.optional()
|
|
56
57
|
.describe("Automation status of the test case. Common values include 'not_automated', 'automated', 'automation_not_required'."),
|
|
58
|
+
priority: z
|
|
59
|
+
.string()
|
|
60
|
+
.optional()
|
|
61
|
+
.describe("Priority of the test case. Accepts either display name (e.g. 'Critical', 'High', 'Medium', 'Low') or internal name (e.g. 'medium'). If omitted, the project default (usually 'Medium') is applied. Valid values are per-project and discoverable via the form-fields endpoint."),
|
|
57
62
|
});
|
|
58
63
|
export function sanitizeArgs(args) {
|
|
59
64
|
const cleaned = { ...args };
|
|
@@ -74,8 +79,27 @@ export function sanitizeArgs(args) {
|
|
|
74
79
|
return cleaned;
|
|
75
80
|
}
|
|
76
81
|
import { getBrowserStackAuth } from "../../lib/get-auth.js";
|
|
82
|
+
/**
|
|
83
|
+
* Normalize priority to the display name the create endpoint accepts (it
|
|
84
|
+
* rejects lowercase). On lookup failure, pass the raw value through.
|
|
85
|
+
*/
|
|
86
|
+
async function normalizePriority(projectIdentifier, priority, config) {
|
|
87
|
+
try {
|
|
88
|
+
const numericProjectId = await projectIdentifierToId(projectIdentifier, config);
|
|
89
|
+
const { default_fields } = await fetchFormFields(numericProjectId, config);
|
|
90
|
+
return (normalizeDefaultFieldValue(default_fields?.priority?.values ?? [], priority, "name") ?? priority);
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
logger.warn("Failed to normalize priority value; passing through as given: %s", err instanceof Error ? err.message : String(err));
|
|
94
|
+
return priority;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
77
97
|
export async function createTestCase(params, config) {
|
|
78
|
-
const
|
|
98
|
+
const testCaseParams = { ...params };
|
|
99
|
+
if (testCaseParams.priority !== undefined) {
|
|
100
|
+
testCaseParams.priority = await normalizePriority(params.project_identifier, testCaseParams.priority, config);
|
|
101
|
+
}
|
|
102
|
+
const body = { test_case: testCaseParams };
|
|
79
103
|
const authString = getBrowserStackAuth(config);
|
|
80
104
|
const [username, password] = authString.split(":");
|
|
81
105
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { apiClient } from "../../lib/apiClient.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { formatAxiosError } from "../../lib/error.js";
|
|
4
|
-
import { fetchFormFields, projectIdentifierToId } from "./TCG-utils/api.js";
|
|
4
|
+
import { fetchFormFields, normalizeDefaultFieldValue, projectIdentifierToId, } from "./TCG-utils/api.js";
|
|
5
5
|
import { getTMBaseURL } from "../../lib/tm-base-url.js";
|
|
6
6
|
import { getBrowserStackAuth } from "../../lib/get-auth.js";
|
|
7
7
|
import logger from "../../logger.js";
|
|
@@ -62,26 +62,6 @@ export const UpdateTestCaseSchema = z.object({
|
|
|
62
62
|
.optional()
|
|
63
63
|
.describe("Map of custom field name/id to value. Valid field names and value types are per-project; discover them via the project's form fields."),
|
|
64
64
|
});
|
|
65
|
-
/**
|
|
66
|
-
* Build a normalizer for a default field's accepted value.
|
|
67
|
-
* The TM PATCH endpoint accepts different casings for different default
|
|
68
|
-
* fields (Title-Case display name for priority/case_type, snake_case
|
|
69
|
-
* internal_name for automation_status). We accept either from the caller
|
|
70
|
-
* and emit the form the API actually wants.
|
|
71
|
-
*
|
|
72
|
-
* Returns undefined when no matching option is found — callers should
|
|
73
|
-
* pass the raw value through so the backend can surface its own error.
|
|
74
|
-
*/
|
|
75
|
-
function normalizeDefaultFieldValue(fieldValues, input, emit) {
|
|
76
|
-
const normalized = input.toLowerCase().trim();
|
|
77
|
-
const match = fieldValues.find((v) => (v.internal_name ?? "").toLowerCase() === normalized ||
|
|
78
|
-
(v.name ?? "").toLowerCase() === normalized);
|
|
79
|
-
if (!match)
|
|
80
|
-
return undefined;
|
|
81
|
-
if (emit === "name")
|
|
82
|
-
return match.name;
|
|
83
|
-
return match.internal_name ?? match.name;
|
|
84
|
-
}
|
|
85
65
|
/**
|
|
86
66
|
* Normalise default-field inputs (priority/case_type/automation_status) to
|
|
87
67
|
* what the TM PATCH endpoint accepts. Fetches the project's form-fields
|