-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathschema.ts
More file actions
136 lines (124 loc) · 4.68 KB
/
schema.ts
File metadata and controls
136 lines (124 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import { z } from "zod";
import { PercyIntegrationTypeEnum } from "./types.js";
import {
SDKSupportedBrowserAutomationFrameworkEnum,
SDKSupportedTestingFrameworkEnum,
SDKSupportedLanguageEnum,
} from "./types.js";
// Platform enums for better validation
export const PlatformEnum = {
WINDOWS: "windows",
MACOS: "macos",
ANDROID: "android",
IOS: "ios",
} as const;
export const WindowsPlatformEnum = {
WINDOWS: "windows",
} as const;
export const MacOSPlatformEnum = {
MACOS: "macos",
} as const;
export const SetUpPercyParamsShape = {
projectName: z.string().describe("A unique name for your Percy project."),
detectedLanguage: z.nativeEnum(SDKSupportedLanguageEnum),
detectedBrowserAutomationFramework: z.nativeEnum(
SDKSupportedBrowserAutomationFrameworkEnum,
),
detectedTestingFramework: z.nativeEnum(SDKSupportedTestingFrameworkEnum),
integrationType: z
.nativeEnum(PercyIntegrationTypeEnum)
.describe(
"Specify the Percy integration type: web (Percy Web) or automate (Percy Automate). If not provided, always prompt the user with: 'Please specify the Percy integration type.' Do not proceed without an explicit selection. Never use a default.",
),
folderPaths: z
.array(z.string())
.optional()
.describe(
"An array of absolute folder paths containing UI test files. If not provided, analyze codebase for UI test folders by scanning for test patterns which contain UI test cases as per framework. Return empty array if none found.",
),
filePaths: z
.array(z.string())
.optional()
.describe(
"An array of absolute file paths to specific UI test files. Use this when you want to target specific test files rather than entire folders. If not provided, will use folderPaths instead.",
),
};
// Device schema for BrowserStack Automate (supports desktop and mobile)
const DeviceSchema = z.object({
platform: z
.enum(["windows", "macos", "android", "ios"])
.describe("Platform name, e.g. 'windows', 'macos', 'android', 'ios'"),
deviceName: z
.string()
.optional()
.describe(
"Device name for mobile platforms, e.g. 'iPhone 15', 'Samsung Galaxy S24'",
),
osVersion: z
.string()
.describe("OS version, e.g. '11', 'Sequoia', '14', '17', 'latest'"),
browser: z
.string()
.optional()
.describe("Browser name, e.g. 'chrome', 'safari', 'edge', 'firefox'"),
browserVersion: z
.string()
.optional()
.describe(
"Browser version for desktop platforms only (windows, macos), e.g. '132', 'latest', 'oldest'. Not used for mobile devices (android, ios).",
),
});
export const RunTestsOnBrowserStackParamsShape = {
projectName: z
.string()
.describe("A single name for your project to organize all your tests."),
detectedLanguage: z.nativeEnum(SDKSupportedLanguageEnum),
detectedBrowserAutomationFramework: z.nativeEnum(
SDKSupportedBrowserAutomationFrameworkEnum,
),
detectedTestingFramework: z.nativeEnum(SDKSupportedTestingFrameworkEnum),
devices: z
.array(DeviceSchema)
.max(3)
.default([])
.describe(
"Device objects array. Use the object format directly - no transformation needed. Add only when user explicitly requests devices. Examples: [{ platform: 'windows', osVersion: '11', browser: 'chrome', browserVersion: 'latest' }] or [{ platform: 'android', deviceName: 'Samsung Galaxy S24', osVersion: '14', browser: 'chrome' }].",
),
};
export const SetUpPercySchema = z.object(SetUpPercyParamsShape);
export const RunTestsOnBrowserStackSchema = z.object(
RunTestsOnBrowserStackParamsShape,
);
export type SetUpPercyInput = z.infer<typeof SetUpPercySchema>;
export type RunTestsOnBrowserStackInput = z.infer<
typeof RunTestsOnBrowserStackSchema
>;
export const RunPercyScanParamsShape = {
projectName: z.string().describe("The name of the project to run Percy on."),
percyRunCommand: z
.string()
.optional()
.describe(
"The test command to run with Percy. Optional — the LLM should try to infer it first from project context.",
),
integrationType: z
.nativeEnum(PercyIntegrationTypeEnum)
.describe(
"Specifies whether to integrate with Percy Web or Percy Automate. If not explicitly provided, prompt the user to select the desired integration type.",
),
};
export const FetchPercyChangesParamsShape = {
project_name: z
.string()
.describe(
"The name of the BrowserStack project. If not found, ask user directly.",
),
};
export const ManagePercyBuildApprovalParamsShape = {
buildId: z
.string()
.describe("The ID of the Percy build to approve or reject."),
action: z
.enum(["approve", "unapprove", "reject"])
.describe("The action to perform on the Percy build."),
};