@browserstack/mcp-server 1.0.14 → 1.1.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/config.js +6 -2
- package/dist/index.js +34 -31
- package/dist/lib/api.js +9 -3
- package/dist/lib/constants.js +6 -3
- package/dist/lib/device-cache.js +21 -14
- package/dist/lib/error.js +6 -3
- package/dist/lib/fuzzy.js +4 -1
- package/dist/lib/inmemory-store.js +4 -1
- package/dist/lib/instrumentation.js +18 -12
- package/dist/lib/local.js +35 -27
- package/dist/lib/utils.js +15 -6
- package/dist/logger.js +6 -4
- package/dist/tools/accessibility.js +54 -18
- package/dist/tools/accessiblity-utils/report-fetcher.js +35 -0
- package/dist/tools/accessiblity-utils/report-parser.js +57 -0
- package/dist/tools/accessiblity-utils/scanner.js +87 -0
- package/dist/tools/appautomate-utils/appautomate.js +27 -17
- package/dist/tools/appautomate.js +35 -29
- package/dist/tools/applive-utils/fuzzy-search.js +6 -3
- package/dist/tools/applive-utils/start-session.js +20 -14
- package/dist/tools/applive-utils/upload-app.js +51 -12
- package/dist/tools/applive.js +25 -18
- package/dist/tools/automate-utils/fetch-screenshots.js +14 -8
- package/dist/tools/automate.js +21 -14
- package/dist/tools/bstack-sdk.js +18 -14
- package/dist/tools/failurelogs-utils/app-automate.js +26 -15
- package/dist/tools/failurelogs-utils/automate.js +23 -13
- package/dist/tools/getFailureLogs.js +49 -42
- package/dist/tools/live-utils/desktop-filter.js +11 -8
- package/dist/tools/live-utils/mobile-filter.js +10 -7
- package/dist/tools/live-utils/start-session.js +23 -17
- package/dist/tools/live-utils/types.js +5 -2
- package/dist/tools/live-utils/version-resolver.js +4 -1
- package/dist/tools/live.js +29 -23
- package/dist/tools/observability.js +19 -12
- package/dist/tools/sdk-utils/constants.js +9 -3
- package/dist/tools/sdk-utils/instructions.js +9 -4
- package/dist/tools/sdk-utils/types.js +2 -1
- package/dist/tools/testmanagement-utils/TCG-utils/api.js +38 -26
- package/dist/tools/testmanagement-utils/TCG-utils/config.js +10 -5
- package/dist/tools/testmanagement-utils/TCG-utils/helpers.js +8 -3
- package/dist/tools/testmanagement-utils/TCG-utils/types.js +8 -5
- package/dist/tools/testmanagement-utils/add-test-result.js +24 -17
- package/dist/tools/testmanagement-utils/create-project-folder.js +28 -21
- package/dist/tools/testmanagement-utils/create-testcase.js +38 -30
- package/dist/tools/testmanagement-utils/create-testrun.js +30 -23
- package/dist/tools/testmanagement-utils/list-testcases.js +22 -15
- package/dist/tools/testmanagement-utils/list-testruns.js +19 -12
- package/dist/tools/testmanagement-utils/testcase-from-file.js +22 -16
- package/dist/tools/testmanagement-utils/update-testrun.js +22 -15
- package/dist/tools/testmanagement-utils/upload-file.js +29 -22
- package/dist/tools/testmanagement.js +76 -61
- package/package.json +4 -2
- package/dist/tools/accessiblity-utils/accessibility.js +0 -74
|
@@ -1,27 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CreateProjFoldSchema = void 0;
|
|
7
|
+
exports.createProjectOrFolder = createProjectOrFolder;
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const config_js_1 = __importDefault(require("../../config.js"));
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const error_js_1 = require("../../lib/error.js"); // or correct path
|
|
5
12
|
// Schema for combined project/folder creation
|
|
6
|
-
|
|
7
|
-
project_name: z
|
|
13
|
+
exports.CreateProjFoldSchema = zod_1.z.object({
|
|
14
|
+
project_name: zod_1.z
|
|
8
15
|
.string()
|
|
9
16
|
.optional()
|
|
10
17
|
.describe("Name of the project to create."),
|
|
11
|
-
project_description: z
|
|
18
|
+
project_description: zod_1.z
|
|
12
19
|
.string()
|
|
13
20
|
.optional()
|
|
14
21
|
.describe("Description for the new project."),
|
|
15
|
-
project_identifier: z
|
|
22
|
+
project_identifier: zod_1.z
|
|
16
23
|
.string()
|
|
17
24
|
.optional()
|
|
18
25
|
.describe("Existing project identifier to use for folder creation."),
|
|
19
|
-
folder_name: z.string().optional().describe("Name of the folder to create."),
|
|
20
|
-
folder_description: z
|
|
26
|
+
folder_name: zod_1.z.string().optional().describe("Name of the folder to create."),
|
|
27
|
+
folder_description: zod_1.z
|
|
21
28
|
.string()
|
|
22
29
|
.optional()
|
|
23
30
|
.describe("Description for the new folder."),
|
|
24
|
-
parent_id: z
|
|
31
|
+
parent_id: zod_1.z
|
|
25
32
|
.number()
|
|
26
33
|
.optional()
|
|
27
34
|
.describe("Parent folder ID; if omitted, folder is created at root."),
|
|
@@ -29,8 +36,8 @@ export const CreateProjFoldSchema = z.object({
|
|
|
29
36
|
/**
|
|
30
37
|
* Creates a project and/or folder in BrowserStack Test Management.
|
|
31
38
|
*/
|
|
32
|
-
|
|
33
|
-
const { project_name, project_description, project_identifier, folder_name, folder_description, parent_id, } = CreateProjFoldSchema.parse(args);
|
|
39
|
+
async function createProjectOrFolder(args) {
|
|
40
|
+
const { project_name, project_description, project_identifier, folder_name, folder_description, parent_id, } = exports.CreateProjFoldSchema.parse(args);
|
|
34
41
|
if (!project_name && !project_identifier && !folder_name) {
|
|
35
42
|
throw new Error("Provide project_name (to create project), or project_identifier and folder_name (to create folder).");
|
|
36
43
|
}
|
|
@@ -38,10 +45,10 @@ export async function createProjectOrFolder(args) {
|
|
|
38
45
|
// Step 1: Create project if project_name provided
|
|
39
46
|
if (project_name) {
|
|
40
47
|
try {
|
|
41
|
-
const res = await
|
|
48
|
+
const res = await axios_1.default.post("https://test-management.browserstack.com/api/v2/projects", { project: { name: project_name, description: project_description } }, {
|
|
42
49
|
auth: {
|
|
43
|
-
username:
|
|
44
|
-
password:
|
|
50
|
+
username: config_js_1.default.browserstackUsername,
|
|
51
|
+
password: config_js_1.default.browserstackAccessKey,
|
|
45
52
|
},
|
|
46
53
|
headers: { "Content-Type": "application/json" },
|
|
47
54
|
});
|
|
@@ -52,7 +59,7 @@ export async function createProjectOrFolder(args) {
|
|
|
52
59
|
projId = res.data.project.identifier;
|
|
53
60
|
}
|
|
54
61
|
catch (err) {
|
|
55
|
-
return formatAxiosError(err, "Failed to create project..");
|
|
62
|
+
return (0, error_js_1.formatAxiosError)(err, "Failed to create project..");
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
// Step 2: Create folder if folder_name provided
|
|
@@ -60,7 +67,7 @@ export async function createProjectOrFolder(args) {
|
|
|
60
67
|
if (!projId)
|
|
61
68
|
throw new Error("Cannot create folder without project_identifier.");
|
|
62
69
|
try {
|
|
63
|
-
const res = await
|
|
70
|
+
const res = await axios_1.default.post(`https://test-management.browserstack.com/api/v2/projects/${encodeURIComponent(projId)}/folders`, {
|
|
64
71
|
folder: {
|
|
65
72
|
name: folder_name,
|
|
66
73
|
description: folder_description,
|
|
@@ -68,8 +75,8 @@ export async function createProjectOrFolder(args) {
|
|
|
68
75
|
},
|
|
69
76
|
}, {
|
|
70
77
|
auth: {
|
|
71
|
-
username:
|
|
72
|
-
password:
|
|
78
|
+
username: config_js_1.default.browserstackUsername,
|
|
79
|
+
password: config_js_1.default.browserstackAccessKey,
|
|
73
80
|
},
|
|
74
81
|
headers: { "Content-Type": "application/json" },
|
|
75
82
|
});
|
|
@@ -88,7 +95,7 @@ export async function createProjectOrFolder(args) {
|
|
|
88
95
|
};
|
|
89
96
|
}
|
|
90
97
|
catch (err) {
|
|
91
|
-
return formatAxiosError(err, "Failed to create folder.");
|
|
98
|
+
return (0, error_js_1.formatAxiosError)(err, "Failed to create folder.");
|
|
92
99
|
}
|
|
93
100
|
}
|
|
94
101
|
// Only project was created
|
|
@@ -1,56 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CreateTestCaseSchema = void 0;
|
|
7
|
+
exports.sanitizeArgs = sanitizeArgs;
|
|
8
|
+
exports.createTestCase = createTestCase;
|
|
9
|
+
const axios_1 = __importDefault(require("axios"));
|
|
10
|
+
const config_js_1 = __importDefault(require("../../config.js"));
|
|
11
|
+
const zod_1 = require("zod");
|
|
12
|
+
const error_js_1 = require("../../lib/error.js"); // or correct
|
|
13
|
+
exports.CreateTestCaseSchema = zod_1.z.object({
|
|
14
|
+
project_identifier: zod_1.z
|
|
7
15
|
.string()
|
|
8
16
|
.describe("The ID of the BrowserStack project where the test case should be created. If no project identifier is provided, ask the user if they would like to create a new project using the createProjectOrFolder tool."),
|
|
9
|
-
folder_id: z
|
|
17
|
+
folder_id: zod_1.z
|
|
10
18
|
.string()
|
|
11
19
|
.describe("The ID of the folder within the project where the test case should be created. If not provided, ask the user if they would like to create a new folder using the createProjectOrFolder tool."),
|
|
12
|
-
name: z.string().describe("Name of the test case."),
|
|
13
|
-
description: z
|
|
20
|
+
name: zod_1.z.string().describe("Name of the test case."),
|
|
21
|
+
description: zod_1.z
|
|
14
22
|
.string()
|
|
15
23
|
.optional()
|
|
16
24
|
.describe("Brief description of the test case."),
|
|
17
|
-
owner: z
|
|
25
|
+
owner: zod_1.z
|
|
18
26
|
.string()
|
|
19
27
|
.email()
|
|
20
28
|
.describe("Email of the test case owner.")
|
|
21
29
|
.optional(),
|
|
22
|
-
preconditions: z
|
|
30
|
+
preconditions: zod_1.z
|
|
23
31
|
.string()
|
|
24
32
|
.optional()
|
|
25
33
|
.describe("Any preconditions (HTML allowed)."),
|
|
26
|
-
test_case_steps: z
|
|
27
|
-
.array(z.object({
|
|
28
|
-
step: z.string().describe("Action to perform in this step."),
|
|
29
|
-
result: z.string().describe("Expected result of this step."),
|
|
34
|
+
test_case_steps: zod_1.z
|
|
35
|
+
.array(zod_1.z.object({
|
|
36
|
+
step: zod_1.z.string().describe("Action to perform in this step."),
|
|
37
|
+
result: zod_1.z.string().describe("Expected result of this step."),
|
|
30
38
|
}))
|
|
31
39
|
.describe("List of steps and expected results."),
|
|
32
|
-
issues: z
|
|
33
|
-
.array(z.string())
|
|
40
|
+
issues: zod_1.z
|
|
41
|
+
.array(zod_1.z.string())
|
|
34
42
|
.optional()
|
|
35
43
|
.describe("List of the linked Jira, Asana or Azure issues ID's. This should be strictly in array format not the string of json."),
|
|
36
|
-
issue_tracker: z
|
|
44
|
+
issue_tracker: zod_1.z
|
|
37
45
|
.object({
|
|
38
|
-
name: z
|
|
46
|
+
name: zod_1.z
|
|
39
47
|
.string()
|
|
40
48
|
.describe("Issue tracker name, For example, use jira for Jira, azure for Azure DevOps, or asana for Asana."),
|
|
41
|
-
host: z.string().url().describe("Base URL of the issue tracker."),
|
|
49
|
+
host: zod_1.z.string().url().describe("Base URL of the issue tracker."),
|
|
42
50
|
})
|
|
43
51
|
.optional(),
|
|
44
|
-
tags: z
|
|
45
|
-
.array(z.string())
|
|
52
|
+
tags: zod_1.z
|
|
53
|
+
.array(zod_1.z.string())
|
|
46
54
|
.optional()
|
|
47
55
|
.describe("Tags to attach to the test case. This should be strictly in array format not the string of json"),
|
|
48
|
-
custom_fields: z
|
|
49
|
-
.record(z.string(), z.string())
|
|
56
|
+
custom_fields: zod_1.z
|
|
57
|
+
.record(zod_1.z.string(), zod_1.z.string())
|
|
50
58
|
.optional()
|
|
51
59
|
.describe("Map of custom field names to values."),
|
|
52
60
|
});
|
|
53
|
-
|
|
61
|
+
function sanitizeArgs(args) {
|
|
54
62
|
const cleaned = { ...args };
|
|
55
63
|
if (cleaned.description === null)
|
|
56
64
|
delete cleaned.description;
|
|
@@ -66,13 +74,13 @@ export function sanitizeArgs(args) {
|
|
|
66
74
|
}
|
|
67
75
|
return cleaned;
|
|
68
76
|
}
|
|
69
|
-
|
|
77
|
+
async function createTestCase(params) {
|
|
70
78
|
const body = { test_case: params };
|
|
71
79
|
try {
|
|
72
|
-
const response = await
|
|
80
|
+
const response = await axios_1.default.post(`https://test-management.browserstack.com/api/v2/projects/${encodeURIComponent(params.project_identifier)}/folders/${encodeURIComponent(params.folder_id)}/test-cases`, body, {
|
|
73
81
|
auth: {
|
|
74
|
-
username:
|
|
75
|
-
password:
|
|
82
|
+
username: config_js_1.default.browserstackUsername,
|
|
83
|
+
password: config_js_1.default.browserstackAccessKey,
|
|
76
84
|
},
|
|
77
85
|
headers: { "Content-Type": "application/json" },
|
|
78
86
|
});
|
|
@@ -102,6 +110,6 @@ export async function createTestCase(params) {
|
|
|
102
110
|
}
|
|
103
111
|
catch (err) {
|
|
104
112
|
// Delegate to our centralized Axios error formatter
|
|
105
|
-
return formatAxiosError(err, "Failed to create test case");
|
|
113
|
+
return (0, error_js_1.formatAxiosError)(err, "Failed to create test case");
|
|
106
114
|
}
|
|
107
115
|
}
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CreateTestRunSchema = void 0;
|
|
7
|
+
exports.createTestRun = createTestRun;
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const config_js_1 = __importDefault(require("../../config.js"));
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const error_js_1 = require("../../lib/error.js");
|
|
5
12
|
/**
|
|
6
13
|
* Schema for creating a test run.
|
|
7
14
|
*/
|
|
8
|
-
|
|
9
|
-
project_identifier: z
|
|
15
|
+
exports.CreateTestRunSchema = zod_1.z.object({
|
|
16
|
+
project_identifier: zod_1.z
|
|
10
17
|
.string()
|
|
11
18
|
.describe("Identifier of the project in which to create the test run."),
|
|
12
|
-
test_run: z.object({
|
|
13
|
-
name: z.string().describe("Name of the test run"),
|
|
14
|
-
description: z
|
|
19
|
+
test_run: zod_1.z.object({
|
|
20
|
+
name: zod_1.z.string().describe("Name of the test run"),
|
|
21
|
+
description: zod_1.z
|
|
15
22
|
.string()
|
|
16
23
|
.optional()
|
|
17
24
|
.describe("Brief information about the test run"),
|
|
18
|
-
run_state: z
|
|
25
|
+
run_state: zod_1.z
|
|
19
26
|
.enum([
|
|
20
27
|
"new_run",
|
|
21
28
|
"in_progress",
|
|
@@ -26,17 +33,17 @@ export const CreateTestRunSchema = z.object({
|
|
|
26
33
|
])
|
|
27
34
|
.optional()
|
|
28
35
|
.describe("State of the test run. One of new_run, in_progress, under_review, rejected, done, closed"),
|
|
29
|
-
issues: z.array(z.string()).optional().describe("Linked issue IDs"),
|
|
30
|
-
issue_tracker: z
|
|
31
|
-
.object({ name: z.string(), host: z.string().url() })
|
|
36
|
+
issues: zod_1.z.array(zod_1.z.string()).optional().describe("Linked issue IDs"),
|
|
37
|
+
issue_tracker: zod_1.z
|
|
38
|
+
.object({ name: zod_1.z.string(), host: zod_1.z.string().url() })
|
|
32
39
|
.optional()
|
|
33
40
|
.describe("Issue tracker configuration"),
|
|
34
|
-
test_cases: z
|
|
35
|
-
.array(z.string())
|
|
41
|
+
test_cases: zod_1.z
|
|
42
|
+
.array(zod_1.z.string())
|
|
36
43
|
.optional()
|
|
37
44
|
.describe("List of test case IDs"),
|
|
38
|
-
folder_ids: z
|
|
39
|
-
.array(z.number())
|
|
45
|
+
folder_ids: zod_1.z
|
|
46
|
+
.array(zod_1.z.number())
|
|
40
47
|
.optional()
|
|
41
48
|
.describe("Folder IDs to include"),
|
|
42
49
|
}),
|
|
@@ -44,7 +51,7 @@ export const CreateTestRunSchema = z.object({
|
|
|
44
51
|
/**
|
|
45
52
|
* Creates a test run via BrowserStack Test Management API.
|
|
46
53
|
*/
|
|
47
|
-
|
|
54
|
+
async function createTestRun(rawArgs) {
|
|
48
55
|
try {
|
|
49
56
|
const inputArgs = {
|
|
50
57
|
...rawArgs,
|
|
@@ -53,12 +60,12 @@ export async function createTestRun(rawArgs) {
|
|
|
53
60
|
include_all: false,
|
|
54
61
|
},
|
|
55
62
|
};
|
|
56
|
-
const args = CreateTestRunSchema.parse(inputArgs);
|
|
63
|
+
const args = exports.CreateTestRunSchema.parse(inputArgs);
|
|
57
64
|
const url = `https://test-management.browserstack.com/api/v2/projects/${encodeURIComponent(args.project_identifier)}/test-runs`;
|
|
58
|
-
const response = await
|
|
65
|
+
const response = await axios_1.default.post(url, { test_run: args.test_run }, {
|
|
59
66
|
auth: {
|
|
60
|
-
username:
|
|
61
|
-
password:
|
|
67
|
+
username: config_js_1.default.browserstackUsername,
|
|
68
|
+
password: config_js_1.default.browserstackAccessKey,
|
|
62
69
|
},
|
|
63
70
|
headers: { "Content-Type": "application/json" },
|
|
64
71
|
});
|
|
@@ -78,6 +85,6 @@ export async function createTestRun(rawArgs) {
|
|
|
78
85
|
};
|
|
79
86
|
}
|
|
80
87
|
catch (err) {
|
|
81
|
-
return formatAxiosError(err, "Failed to create test run");
|
|
88
|
+
return (0, error_js_1.formatAxiosError)(err, "Failed to create test run");
|
|
82
89
|
}
|
|
83
90
|
}
|
|
@@ -1,32 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ListTestCasesSchema = void 0;
|
|
7
|
+
exports.listTestCases = listTestCases;
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const config_js_1 = __importDefault(require("../../config.js"));
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const error_js_1 = require("../../lib/error.js");
|
|
5
12
|
/**
|
|
6
13
|
* Schema for listing test cases with optional filters.
|
|
7
14
|
*/
|
|
8
|
-
|
|
9
|
-
project_identifier: z
|
|
15
|
+
exports.ListTestCasesSchema = zod_1.z.object({
|
|
16
|
+
project_identifier: zod_1.z
|
|
10
17
|
.string()
|
|
11
18
|
.describe("Identifier of the project to fetch test cases from. This id starts with a PR- and is followed by a number."),
|
|
12
|
-
folder_id: z
|
|
19
|
+
folder_id: zod_1.z
|
|
13
20
|
.string()
|
|
14
21
|
.optional()
|
|
15
22
|
.describe("If provided, only return cases in this folder."),
|
|
16
|
-
case_type: z
|
|
23
|
+
case_type: zod_1.z
|
|
17
24
|
.string()
|
|
18
25
|
.optional()
|
|
19
26
|
.describe("Comma-separated list of case types (e.g. functional,regression)."),
|
|
20
|
-
priority: z
|
|
27
|
+
priority: zod_1.z
|
|
21
28
|
.string()
|
|
22
29
|
.optional()
|
|
23
30
|
.describe("Comma-separated list of priorities (e.g. critical,medium,low)."),
|
|
24
|
-
p: z.number().optional().describe("Page number."),
|
|
31
|
+
p: zod_1.z.number().optional().describe("Page number."),
|
|
25
32
|
});
|
|
26
33
|
/**
|
|
27
34
|
* Calls BrowserStack Test Management to list test cases with filters.
|
|
28
35
|
*/
|
|
29
|
-
|
|
36
|
+
async function listTestCases(args) {
|
|
30
37
|
try {
|
|
31
38
|
// Build query string
|
|
32
39
|
const params = new URLSearchParams();
|
|
@@ -39,10 +46,10 @@ export async function listTestCases(args) {
|
|
|
39
46
|
if (args.p !== undefined)
|
|
40
47
|
params.append("p", args.p.toString());
|
|
41
48
|
const url = `https://test-management.browserstack.com/api/v2/projects/${encodeURIComponent(args.project_identifier)}/test-cases?${params.toString()}`;
|
|
42
|
-
const resp = await
|
|
49
|
+
const resp = await axios_1.default.get(url, {
|
|
43
50
|
auth: {
|
|
44
|
-
username:
|
|
45
|
-
password:
|
|
51
|
+
username: config_js_1.default.browserstackUsername,
|
|
52
|
+
password: config_js_1.default.browserstackAccessKey,
|
|
46
53
|
},
|
|
47
54
|
});
|
|
48
55
|
const resp_data = resp.data;
|
|
@@ -78,6 +85,6 @@ export async function listTestCases(args) {
|
|
|
78
85
|
};
|
|
79
86
|
}
|
|
80
87
|
catch (err) {
|
|
81
|
-
return formatAxiosError(err, "Failed to list test cases");
|
|
88
|
+
return (0, error_js_1.formatAxiosError)(err, "Failed to list test cases");
|
|
82
89
|
}
|
|
83
90
|
}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ListTestRunsSchema = void 0;
|
|
7
|
+
exports.listTestRuns = listTestRuns;
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const config_js_1 = __importDefault(require("../../config.js"));
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const error_js_1 = require("../../lib/error.js");
|
|
5
12
|
/**
|
|
6
13
|
* Schema for listing test runs with optional filters.
|
|
7
14
|
*/
|
|
8
|
-
|
|
9
|
-
project_identifier: z
|
|
15
|
+
exports.ListTestRunsSchema = zod_1.z.object({
|
|
16
|
+
project_identifier: zod_1.z
|
|
10
17
|
.string()
|
|
11
18
|
.describe("Identifier of the project to fetch test runs from (usually starts with PR-)."),
|
|
12
|
-
run_state: z
|
|
19
|
+
run_state: zod_1.z
|
|
13
20
|
.string()
|
|
14
21
|
.optional()
|
|
15
22
|
.describe("Return all test runs with this state (comma-separated)"),
|
|
@@ -17,17 +24,17 @@ export const ListTestRunsSchema = z.object({
|
|
|
17
24
|
/**
|
|
18
25
|
* Fetches and formats the list of test runs for a project.
|
|
19
26
|
*/
|
|
20
|
-
|
|
27
|
+
async function listTestRuns(args) {
|
|
21
28
|
try {
|
|
22
29
|
const params = new URLSearchParams();
|
|
23
30
|
if (args.run_state) {
|
|
24
31
|
params.set("run_state", args.run_state);
|
|
25
32
|
}
|
|
26
33
|
const url = `https://test-management.browserstack.com/api/v2/projects/${encodeURIComponent(args.project_identifier)}/test-runs?` + params.toString();
|
|
27
|
-
const resp = await
|
|
34
|
+
const resp = await axios_1.default.get(url, {
|
|
28
35
|
auth: {
|
|
29
|
-
username:
|
|
30
|
-
password:
|
|
36
|
+
username: config_js_1.default.browserstackUsername,
|
|
37
|
+
password: config_js_1.default.browserstackAccessKey,
|
|
31
38
|
},
|
|
32
39
|
});
|
|
33
40
|
const data = resp.data;
|
|
@@ -56,6 +63,6 @@ export async function listTestRuns(args) {
|
|
|
56
63
|
};
|
|
57
64
|
}
|
|
58
65
|
catch (err) {
|
|
59
|
-
return formatAxiosError(err, "Failed to list test runs");
|
|
66
|
+
return (0, error_js_1.formatAxiosError)(err, "Failed to list test runs");
|
|
60
67
|
}
|
|
61
68
|
}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createTestCasesFromFile = createTestCasesFromFile;
|
|
7
|
+
const api_js_1 = require("./TCG-utils/api.js");
|
|
8
|
+
const helpers_js_1 = require("./TCG-utils/helpers.js");
|
|
9
|
+
const inmemory_store_js_1 = require("../../lib/inmemory-store.js");
|
|
10
|
+
const logger_js_1 = __importDefault(require("../../logger.js"));
|
|
11
|
+
const api_js_2 = require("./TCG-utils/api.js");
|
|
12
|
+
async function createTestCasesFromFile(args, context) {
|
|
13
|
+
logger_js_1.default.info(`createTestCasesFromFile called with projectId: ${args.projectReferenceId}, folderId: ${args.folderId}`);
|
|
8
14
|
if (args.projectReferenceId.startsWith("PR-")) {
|
|
9
|
-
args.projectReferenceId = await projectIdentifierToId(args.projectReferenceId);
|
|
15
|
+
args.projectReferenceId = await (0, api_js_2.projectIdentifierToId)(args.projectReferenceId);
|
|
10
16
|
}
|
|
11
|
-
const { default_fields, custom_fields } = await fetchFormFields(args.projectReferenceId);
|
|
12
|
-
const fieldMaps = buildDefaultFieldMaps(default_fields);
|
|
13
|
-
const booleanFieldId = findBooleanFieldId(custom_fields);
|
|
14
|
-
const documentObj = signedUrlMap.get(args.documentId);
|
|
17
|
+
const { default_fields, custom_fields } = await (0, api_js_1.fetchFormFields)(args.projectReferenceId);
|
|
18
|
+
const fieldMaps = (0, helpers_js_1.buildDefaultFieldMaps)(default_fields);
|
|
19
|
+
const booleanFieldId = (0, helpers_js_1.findBooleanFieldId)(custom_fields);
|
|
20
|
+
const documentObj = inmemory_store_js_1.signedUrlMap.get(args.documentId);
|
|
15
21
|
if (!documentObj) {
|
|
16
22
|
return {
|
|
17
23
|
content: [
|
|
@@ -27,10 +33,10 @@ export async function createTestCasesFromFile(args, context) {
|
|
|
27
33
|
const documentId = documentObj.fileId;
|
|
28
34
|
const document = documentObj.downloadUrl;
|
|
29
35
|
const source = "jira-on-prem";
|
|
30
|
-
const traceId = await triggerTestCaseGeneration(document, documentId, args.folderId, args.projectReferenceId, source);
|
|
31
|
-
const scenariosMap = await pollScenariosTestDetails(args, traceId, context, documentId, source);
|
|
32
|
-
const resultString = await bulkCreateTestCases(scenariosMap, args.projectReferenceId, args.folderId, fieldMaps, booleanFieldId, traceId, context, documentId);
|
|
33
|
-
signedUrlMap.delete(args.documentId);
|
|
36
|
+
const traceId = await (0, api_js_1.triggerTestCaseGeneration)(document, documentId, args.folderId, args.projectReferenceId, source);
|
|
37
|
+
const scenariosMap = await (0, api_js_1.pollScenariosTestDetails)(args, traceId, context, documentId, source);
|
|
38
|
+
const resultString = await (0, api_js_1.bulkCreateTestCases)(scenariosMap, args.projectReferenceId, args.folderId, fieldMaps, booleanFieldId, traceId, context, documentId);
|
|
39
|
+
inmemory_store_js_1.signedUrlMap.delete(args.documentId);
|
|
34
40
|
return {
|
|
35
41
|
content: [
|
|
36
42
|
{
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.UpdateTestRunSchema = void 0;
|
|
7
|
+
exports.updateTestRun = updateTestRun;
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const config_js_1 = __importDefault(require("../../config.js"));
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const error_js_1 = require("../../lib/error.js");
|
|
5
12
|
/**
|
|
6
13
|
* Schema for updating a test run with partial fields.
|
|
7
14
|
*/
|
|
8
|
-
|
|
9
|
-
project_identifier: z
|
|
15
|
+
exports.UpdateTestRunSchema = zod_1.z.object({
|
|
16
|
+
project_identifier: zod_1.z
|
|
10
17
|
.string()
|
|
11
18
|
.describe("Identifier of the project (Starts with 'PR-')"),
|
|
12
|
-
test_run_id: z.string().describe("Test run identifier (e.g., TR-678)"),
|
|
13
|
-
test_run: z.object({
|
|
14
|
-
name: z.string().optional().describe("New name of the test run"),
|
|
15
|
-
run_state: z
|
|
19
|
+
test_run_id: zod_1.z.string().describe("Test run identifier (e.g., TR-678)"),
|
|
20
|
+
test_run: zod_1.z.object({
|
|
21
|
+
name: zod_1.z.string().optional().describe("New name of the test run"),
|
|
22
|
+
run_state: zod_1.z
|
|
16
23
|
.enum([
|
|
17
24
|
"new_run",
|
|
18
25
|
"in_progress",
|
|
@@ -28,14 +35,14 @@ export const UpdateTestRunSchema = z.object({
|
|
|
28
35
|
/**
|
|
29
36
|
* Partially updates an existing test run.
|
|
30
37
|
*/
|
|
31
|
-
|
|
38
|
+
async function updateTestRun(args) {
|
|
32
39
|
try {
|
|
33
40
|
const body = { test_run: args.test_run };
|
|
34
41
|
const url = `https://test-management.browserstack.com/api/v2/projects/${encodeURIComponent(args.project_identifier)}/test-runs/${encodeURIComponent(args.test_run_id)}/update`;
|
|
35
|
-
const resp = await
|
|
42
|
+
const resp = await axios_1.default.patch(url, body, {
|
|
36
43
|
auth: {
|
|
37
|
-
username:
|
|
38
|
-
password:
|
|
44
|
+
username: config_js_1.default.browserstackUsername,
|
|
45
|
+
password: config_js_1.default.browserstackAccessKey,
|
|
39
46
|
},
|
|
40
47
|
});
|
|
41
48
|
const data = resp.data;
|
|
@@ -62,6 +69,6 @@ export async function updateTestRun(args) {
|
|
|
62
69
|
};
|
|
63
70
|
}
|
|
64
71
|
catch (err) {
|
|
65
|
-
return formatAxiosError(err, "Failed to update test run");
|
|
72
|
+
return (0, error_js_1.formatAxiosError)(err, "Failed to update test run");
|
|
66
73
|
}
|
|
67
74
|
}
|