@mablhq/mabl-cli 2.70.4 → 2.70.10

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.
@@ -5,16 +5,20 @@ const zod_1 = require("zod");
5
5
  const mablApiClientFactory_1 = require("../../../../api/mablApiClientFactory");
6
6
  const trainingSessions_1 = require("../../../../core/trainer/trainingSessions");
7
7
  const messaging_1 = require("../../../../core/messaging/messaging");
8
+ const mablApi_1 = require("../../../../mablApi");
9
+ const common_1 = require("./common");
8
10
  const runTest = (0, mcpMablTool_1.defineTool)({
9
11
  schema: {
10
12
  name: 'create-test',
11
13
  title: 'Create a mabl test',
12
- description: 'Create a mabl test',
14
+ description: 'Create a mabl browser or API test',
13
15
  inputSchema: zod_1.z.object({
14
16
  environmentId: zod_1.z
15
17
  .string()
16
18
  .describe('The id of the environment to run the test in'),
17
- url: zod_1.z.string().describe('The url of the application to test'),
19
+ url: zod_1.z
20
+ .string()
21
+ .describe('The url of the application to test. On API tests this will be the endpoint to test.'),
18
22
  name: zod_1.z.string().describe('The name of the test'),
19
23
  intent: zod_1.z.string().describe(`The intent of the test.
20
24
  Be as detailed as possible.
@@ -24,17 +28,29 @@ const runTest = (0, mcpMablTool_1.defineTool)({
24
28
  issueOrTicket: zod_1.z
25
29
  .string()
26
30
  .describe('The issue or ticket description that is being worked on. This will be used to generate the intent.'),
27
- steps: zod_1.z
28
- .string()
29
- .describe('List of steps to accomplish the intent. Put each step in a new line.'),
31
+ steps: zod_1.z.string().describe(`List of steps to accomplish the intent. Put each step in a new line.
32
+ If you are testing an API, include data to be sent in the request and the expected response.
33
+ `),
30
34
  intentUrl: zod_1.z
31
35
  .string()
32
36
  .describe('Optional URL to be included in the intent')
33
37
  .optional(),
38
+ isApiTest: zod_1.z
39
+ .boolean()
40
+ .describe('Whether the test is an API test. If true, the test will be created as an API test. False if the intent is unknown.'),
41
+ apiSpec: zod_1.z
42
+ .string()
43
+ .describe(`Optional API spec to be included in the intent.
44
+ If provided, the test will be created as an API test.
45
+ This is required when creating an API test.`)
46
+ .optional(),
34
47
  }),
35
48
  type: 'destructive',
36
49
  },
37
50
  handle: async (params, apiKey) => {
51
+ if (params.isApiTest && !params.apiSpec) {
52
+ return (0, common_1.stringToToolResult)('apiSpec is required when creating an API test.', true);
53
+ }
38
54
  const mablApiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClientFromOptionalApiKey(apiKey);
39
55
  const workspaceId = (await mablApiClient.getApiKeyDetails()).workspace_id;
40
56
  messaging_1.mablEventEmitter.resetOutputEventChannel();
@@ -48,6 +64,9 @@ const runTest = (0, mcpMablTool_1.defineTool)({
48
64
  if (params.issueOrTicket) {
49
65
  fullIntent += `\n\nIssue or ticket: ${params.issueOrTicket}`;
50
66
  }
67
+ if (params.apiSpec) {
68
+ fullIntent += `\n\nAPI spec: ${params.apiSpec}`;
69
+ }
51
70
  await (0, trainingSessions_1.trainNewTest)({
52
71
  environmentId: params.environmentId,
53
72
  url: params.url,
@@ -56,6 +75,8 @@ const runTest = (0, mcpMablTool_1.defineTool)({
56
75
  autoLogin: false,
57
76
  workspaceId,
58
77
  intent: fullIntent,
78
+ testType: params.isApiTest ? mablApi_1.TestTypeEnum.Api : mablApi_1.TestTypeEnum.Browser,
79
+ apiDescription: params.apiSpec,
59
80
  }, mablApiClient, false);
60
81
  return {
61
82
  content: [
@@ -27,7 +27,7 @@ async function trainNewTest(trainingSessionOptions, mablApiClient, waitProcessTo
27
27
  (await (0, util_1.getApiClientFromOptions)(trainingSessionOptions, true));
28
28
  const branchName = trainingSessionOptions.branchName ?? constants_1.DefaultBranchName;
29
29
  const { authToken, autoBranch, dataTableIds, intent: testIntent, ...passThroughFields } = trainingSessionOptions;
30
- const { applicationId, autoLogin, credentialsId, environmentId, height, planId, testDescription, testName, url, width, workspaceId, } = passThroughFields;
30
+ const { apiDescription, applicationId, autoLogin, credentialsId, environmentId, height, planId, testDescription, testName, url, width, testType, workspaceId, } = passThroughFields;
31
31
  if (branchName !== 'master') {
32
32
  await (0, branches_1.checkBranchNameAndAutoBranchMaybe)(workspaceId, apiClient, branchName, autoBranch);
33
33
  }
@@ -62,6 +62,8 @@ async function trainNewTest(trainingSessionOptions, mablApiClient, waitProcessTo
62
62
  (0, testsUtil_1.logTestInfoIfPresent)(`Credentials ID: `, credentialsId);
63
63
  (0, testsUtil_1.logTestInfoIfPresent)(`Datatable ID(s): `, dataTableIds?.join(', '));
64
64
  (0, testsUtil_1.logTestInfoIfPresent)(`Test description: `, testDescription);
65
+ (0, testsUtil_1.logTestInfoIfPresent)(`Test type: `, testType);
66
+ (0, testsUtil_1.logTestInfoIfPresent)(`API description: `, apiDescription);
65
67
  const scriptConfig = {
66
68
  ...passThroughFields,
67
69
  accountId: account.id,