retestkit 1.4.1 → 1.5.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.
Files changed (238) hide show
  1. package/README.md +59 -40
  2. package/dist/config.js +8 -8
  3. package/dist/config.js.map +1 -1
  4. package/dist/logger.js +1 -1
  5. package/dist/logger.js.map +1 -1
  6. package/dist/prompts/index.d.ts +1 -1
  7. package/dist/prompts/index.d.ts.map +1 -1
  8. package/dist/prompts/index.js +21 -21
  9. package/dist/prompts/index.js.map +1 -1
  10. package/dist/prompts/templates/mcp/retest-crawl.md +7 -0
  11. package/{src/prompts/templates/mcp/webtest-discover-flows.md → dist/prompts/templates/mcp/retest-discover-flows.md} +1 -1
  12. package/{src/prompts/templates/mcp/webtest-discover.md → dist/prompts/templates/mcp/retest-discover.md} +2 -2
  13. package/dist/prompts/templates/mcp/retest-full-workflow.md +12 -0
  14. package/{src/prompts/templates/mcp/webtest-generate-tests.md → dist/prompts/templates/mcp/retest-generate-tests.md} +1 -1
  15. package/{src/prompts/templates/mcp/webtest-run-test.md → dist/prompts/templates/mcp/retest-run-test.md} +1 -1
  16. package/{src/prompts/templates/mcp/webtest-start.md → dist/prompts/templates/mcp/retest-start.md} +1 -1
  17. package/{src → dist}/prompts/templates/sampling/system-prefix.md +1 -1
  18. package/dist/resources/index.js +7 -7
  19. package/dist/resources/index.js.map +1 -1
  20. package/dist/schemas/config.js +2 -2
  21. package/dist/schemas/config.js.map +1 -1
  22. package/dist/security/index.js +1 -1
  23. package/dist/security/index.js.map +1 -1
  24. package/dist/server.js +3 -3
  25. package/dist/server.js.map +1 -1
  26. package/dist/test-utils/mock-context.js +22 -22
  27. package/dist/test-utils/mock-context.js.map +1 -1
  28. package/dist/tools/index.d.ts +1 -1
  29. package/dist/tools/index.d.ts.map +1 -1
  30. package/dist/tools/index.js +5 -5
  31. package/dist/tools/index.js.map +1 -1
  32. package/dist/tools/retest/crawl.d.ts.map +1 -0
  33. package/dist/tools/{webtest → retest}/crawl.js +7 -7
  34. package/dist/tools/retest/crawl.js.map +1 -0
  35. package/dist/tools/retest/discover-features.d.ts.map +1 -0
  36. package/dist/tools/{webtest → retest}/discover-features.js +6 -6
  37. package/dist/tools/retest/discover-features.js.map +1 -0
  38. package/dist/tools/retest/discover-flows.d.ts.map +1 -0
  39. package/dist/tools/{webtest → retest}/discover-flows.js +6 -6
  40. package/dist/tools/retest/discover-flows.js.map +1 -0
  41. package/dist/tools/retest/generate-tests.d.ts.map +1 -0
  42. package/dist/tools/{webtest → retest}/generate-tests.js +5 -5
  43. package/dist/tools/retest/generate-tests.js.map +1 -0
  44. package/dist/tools/retest/index.d.ts.map +1 -0
  45. package/dist/tools/retest/index.js.map +1 -0
  46. package/dist/tools/retest/run-test-case.d.ts.map +1 -0
  47. package/dist/tools/{webtest → retest}/run-test-case.js +3 -3
  48. package/dist/tools/retest/run-test-case.js.map +1 -0
  49. package/dist/tools/retest/schemas.d.ts.map +1 -0
  50. package/dist/tools/retest/schemas.js.map +1 -0
  51. package/dist/tools/retest/start-analysis.d.ts.map +1 -0
  52. package/dist/tools/{webtest → retest}/start-analysis.js +5 -5
  53. package/dist/tools/retest/start-analysis.js.map +1 -0
  54. package/dist/workspace/index.js +8 -8
  55. package/dist/workspace/index.js.map +1 -1
  56. package/dist/workspace/types.d.ts +2 -2
  57. package/dist/workspace/types.d.ts.map +1 -1
  58. package/package.json +6 -2
  59. package/.claude/commands/openspec/apply.md +0 -23
  60. package/.claude/commands/openspec/archive.md +0 -27
  61. package/.claude/commands/openspec/proposal.md +0 -28
  62. package/.gemini/commands/openspec/apply.toml +0 -21
  63. package/.gemini/commands/openspec/archive.toml +0 -25
  64. package/.gemini/commands/openspec/proposal.toml +0 -26
  65. package/.github/prompts/openspec-apply.prompt.md +0 -22
  66. package/.github/prompts/openspec-archive.prompt.md +0 -26
  67. package/.github/prompts/openspec-proposal.prompt.md +0 -27
  68. package/.github/workflows/release.yml +0 -33
  69. package/.kilocode/workflows/openspec-apply.md +0 -17
  70. package/.kilocode/workflows/openspec-archive.md +0 -21
  71. package/.kilocode/workflows/openspec-proposal.md +0 -22
  72. package/.mcp.json +0 -23
  73. package/.opencode/command/openspec-apply.md +0 -25
  74. package/.opencode/command/openspec-archive.md +0 -28
  75. package/.opencode/command/openspec-proposal.md +0 -30
  76. package/.roo/commands/openspec-apply.md +0 -20
  77. package/.roo/commands/openspec-archive.md +0 -24
  78. package/.roo/commands/openspec-proposal.md +0 -25
  79. package/.vscode/mcp.json +0 -23
  80. package/AGENTS.md +0 -18
  81. package/CLAUDE.md +0 -18
  82. package/dist/tools/webtest/crawl.d.ts.map +0 -1
  83. package/dist/tools/webtest/crawl.js.map +0 -1
  84. package/dist/tools/webtest/discover-features.d.ts.map +0 -1
  85. package/dist/tools/webtest/discover-features.js.map +0 -1
  86. package/dist/tools/webtest/discover-flows.d.ts.map +0 -1
  87. package/dist/tools/webtest/discover-flows.js.map +0 -1
  88. package/dist/tools/webtest/generate-tests.d.ts.map +0 -1
  89. package/dist/tools/webtest/generate-tests.js.map +0 -1
  90. package/dist/tools/webtest/index.d.ts.map +0 -1
  91. package/dist/tools/webtest/index.js.map +0 -1
  92. package/dist/tools/webtest/run-test-case.d.ts.map +0 -1
  93. package/dist/tools/webtest/run-test-case.js.map +0 -1
  94. package/dist/tools/webtest/schemas.d.ts.map +0 -1
  95. package/dist/tools/webtest/schemas.js.map +0 -1
  96. package/dist/tools/webtest/start-analysis.d.ts.map +0 -1
  97. package/dist/tools/webtest/start-analysis.js.map +0 -1
  98. package/openspec/AGENTS.md +0 -456
  99. package/openspec/changes/archive/2025-12-18-add-hybrid-artifact-paths/proposal.md +0 -33
  100. package/openspec/changes/archive/2025-12-18-add-hybrid-artifact-paths/specs/webtest-resources/spec.md +0 -27
  101. package/openspec/changes/archive/2025-12-18-add-hybrid-artifact-paths/specs/webtest-tools/spec.md +0 -304
  102. package/openspec/changes/archive/2025-12-18-add-hybrid-artifact-paths/tasks.md +0 -43
  103. package/openspec/changes/archive/2025-12-18-add-mcp-server-foundation/design.md +0 -209
  104. package/openspec/changes/archive/2025-12-18-add-mcp-server-foundation/proposal.md +0 -41
  105. package/openspec/changes/archive/2025-12-18-add-mcp-server-foundation/specs/mcp-server-core/spec.md +0 -183
  106. package/openspec/changes/archive/2025-12-18-add-mcp-server-foundation/tasks.md +0 -112
  107. package/openspec/changes/archive/2025-12-18-add-webtest-orchestrator/design.md +0 -333
  108. package/openspec/changes/archive/2025-12-18-add-webtest-orchestrator/proposal.md +0 -66
  109. package/openspec/changes/archive/2025-12-18-add-webtest-orchestrator/specs/mcp-server-core/spec.md +0 -129
  110. package/openspec/changes/archive/2025-12-18-add-webtest-orchestrator/specs/webtest-lifecycle/spec.md +0 -138
  111. package/openspec/changes/archive/2025-12-18-add-webtest-orchestrator/specs/webtest-logging/spec.md +0 -211
  112. package/openspec/changes/archive/2025-12-18-add-webtest-orchestrator/specs/webtest-prompts/spec.md +0 -157
  113. package/openspec/changes/archive/2025-12-18-add-webtest-orchestrator/specs/webtest-resources/spec.md +0 -213
  114. package/openspec/changes/archive/2025-12-18-add-webtest-orchestrator/specs/webtest-sampling/spec.md +0 -257
  115. package/openspec/changes/archive/2025-12-18-add-webtest-orchestrator/specs/webtest-tools/spec.md +0 -501
  116. package/openspec/changes/archive/2025-12-18-add-webtest-orchestrator/tasks.md +0 -264
  117. package/openspec/changes/archive/2025-12-18-allow-analysis-of-incomplete-crawls/proposal.md +0 -24
  118. package/openspec/changes/archive/2025-12-18-allow-analysis-of-incomplete-crawls/specs/webtest-tools/spec.md +0 -80
  119. package/openspec/changes/archive/2025-12-18-allow-analysis-of-incomplete-crawls/tasks.md +0 -8
  120. package/openspec/changes/archive/2025-12-18-fix-crawl-loop-stability/design.md +0 -90
  121. package/openspec/changes/archive/2025-12-18-fix-crawl-loop-stability/proposal.md +0 -28
  122. package/openspec/changes/archive/2025-12-18-fix-crawl-loop-stability/specs/webtest-sampling/spec.md +0 -90
  123. package/openspec/changes/archive/2025-12-18-fix-crawl-loop-stability/tasks.md +0 -33
  124. package/openspec/changes/archive/2025-12-18-use-markdown-artifacts/design.md +0 -558
  125. package/openspec/changes/archive/2025-12-18-use-markdown-artifacts/proposal.md +0 -119
  126. package/openspec/changes/archive/2025-12-18-use-markdown-artifacts/specs/webtest-resources/spec.md +0 -109
  127. package/openspec/changes/archive/2025-12-18-use-markdown-artifacts/specs/webtest-tools/spec.md +0 -121
  128. package/openspec/changes/archive/2025-12-18-use-markdown-artifacts/tasks.md +0 -133
  129. package/openspec/changes/extract-prompts-to-markdown/design.md +0 -86
  130. package/openspec/changes/extract-prompts-to-markdown/proposal.md +0 -50
  131. package/openspec/changes/extract-prompts-to-markdown/specs/webtest-prompts/spec.md +0 -74
  132. package/openspec/changes/extract-prompts-to-markdown/tasks.md +0 -40
  133. package/openspec/changes/refactor-webtest-naming/design.md +0 -95
  134. package/openspec/changes/refactor-webtest-naming/proposal.md +0 -66
  135. package/openspec/changes/refactor-webtest-naming/specs/webtest-prompts/spec.md +0 -79
  136. package/openspec/changes/refactor-webtest-naming/specs/webtest-resources/spec.md +0 -80
  137. package/openspec/changes/refactor-webtest-naming/specs/webtest-sampling/spec.md +0 -122
  138. package/openspec/changes/refactor-webtest-naming/specs/webtest-tools/spec.md +0 -113
  139. package/openspec/changes/refactor-webtest-naming/tasks.md +0 -119
  140. package/openspec/changes/rename-package-to-retest/proposal.md +0 -52
  141. package/openspec/changes/rename-package-to-retest/specs/mcp-server-core/spec.md +0 -53
  142. package/openspec/changes/rename-package-to-retest/specs/retest-lifecycle/spec.md +0 -68
  143. package/openspec/changes/rename-package-to-retest/specs/retest-logging/spec.md +0 -35
  144. package/openspec/changes/rename-package-to-retest/specs/retest-prompts/spec.md +0 -159
  145. package/openspec/changes/rename-package-to-retest/specs/retest-resources/spec.md +0 -251
  146. package/openspec/changes/rename-package-to-retest/specs/retest-sampling/spec.md +0 -99
  147. package/openspec/changes/rename-package-to-retest/specs/retest-tools/spec.md +0 -295
  148. package/openspec/changes/rename-package-to-retest/tasks.md +0 -71
  149. package/openspec/project.md +0 -31
  150. package/openspec/specs/mcp-server-core/spec.md +0 -178
  151. package/openspec/specs/webtest-lifecycle/spec.md +0 -136
  152. package/openspec/specs/webtest-logging/spec.md +0 -209
  153. package/openspec/specs/webtest-prompts/spec.md +0 -155
  154. package/openspec/specs/webtest-resources/spec.md +0 -248
  155. package/openspec/specs/webtest-sampling/spec.md +0 -344
  156. package/openspec/specs/webtest-tools/spec.md +0 -282
  157. package/release.config.js +0 -9
  158. package/src/config.test.ts +0 -96
  159. package/src/config.ts +0 -32
  160. package/src/elicitation/index.test.ts +0 -399
  161. package/src/elicitation/index.ts +0 -171
  162. package/src/elicitation/types.ts +0 -68
  163. package/src/index.ts +0 -83
  164. package/src/lifecycle/index.test.ts +0 -260
  165. package/src/lifecycle/index.ts +0 -101
  166. package/src/logger.redaction.test.ts +0 -322
  167. package/src/logger.test.ts +0 -123
  168. package/src/logger.ts +0 -229
  169. package/src/playwright-client/index.ts +0 -392
  170. package/src/playwright-client/types.ts +0 -99
  171. package/src/progress/index.test.ts +0 -327
  172. package/src/progress/index.ts +0 -170
  173. package/src/progress/types.ts +0 -25
  174. package/src/prompts/index.test.ts +0 -451
  175. package/src/prompts/index.ts +0 -246
  176. package/src/prompts/loader.test.ts +0 -100
  177. package/src/prompts/loader.ts +0 -59
  178. package/src/prompts/templates/mcp/webtest-crawl.md +0 -7
  179. package/src/prompts/templates/mcp/webtest-full-workflow.md +0 -12
  180. package/src/resources/index.ts +0 -250
  181. package/src/resources/subscriptions.ts +0 -37
  182. package/src/sampling/index.test.ts +0 -414
  183. package/src/sampling/index.ts +0 -286
  184. package/src/sampling/prompts.ts +0 -194
  185. package/src/sampling/types.ts +0 -60
  186. package/src/schemas/config.ts +0 -39
  187. package/src/security/index.test.ts +0 -441
  188. package/src/security/index.ts +0 -361
  189. package/src/security/security-scenarios.test.ts +0 -468
  190. package/src/server.ts +0 -211
  191. package/src/test-utils/index.ts +0 -6
  192. package/src/test-utils/mock-context.ts +0 -426
  193. package/src/test-utils/mock-playwright-client.ts +0 -422
  194. package/src/tools/index.ts +0 -11
  195. package/src/tools/webtest/crawl.test.ts +0 -834
  196. package/src/tools/webtest/crawl.ts +0 -901
  197. package/src/tools/webtest/discover-features.ts +0 -412
  198. package/src/tools/webtest/discover-flows.ts +0 -408
  199. package/src/tools/webtest/generate-tests.test.ts +0 -532
  200. package/src/tools/webtest/generate-tests.ts +0 -425
  201. package/src/tools/webtest/index.ts +0 -7
  202. package/src/tools/webtest/integration.test.ts +0 -536
  203. package/src/tools/webtest/run-test-case.test.ts +0 -659
  204. package/src/tools/webtest/run-test-case.ts +0 -508
  205. package/src/tools/webtest/schemas.ts +0 -201
  206. package/src/tools/webtest/start-analysis.test.ts +0 -151
  207. package/src/tools/webtest/start-analysis.ts +0 -158
  208. package/src/transports/http.ts +0 -19
  209. package/src/transports/index.ts +0 -30
  210. package/src/transports/stdio.ts +0 -7
  211. package/src/types/capabilities.test.ts +0 -193
  212. package/src/types/capabilities.ts +0 -50
  213. package/src/types/context.ts +0 -21
  214. package/src/types/tool.ts +0 -11
  215. package/src/workspace/index.ts +0 -945
  216. package/src/workspace/markdown.ts +0 -272
  217. package/src/workspace/types.ts +0 -186
  218. package/tests/integration/server.test.ts +0 -89
  219. package/tests/integration/tools.test.ts +0 -99
  220. package/tsconfig.json +0 -20
  221. package/vitest.config.ts +0 -9
  222. package/vitest.integration.config.ts +0 -10
  223. /package/{src → dist}/prompts/templates/sampling/crawl-action.md +0 -0
  224. /package/{src → dist}/prompts/templates/sampling/feature-discovery.md +0 -0
  225. /package/{src → dist}/prompts/templates/sampling/flow-discovery.md +0 -0
  226. /package/{src → dist}/prompts/templates/sampling/page-content-wrapper.md +0 -0
  227. /package/{src → dist}/prompts/templates/sampling/test-evaluation.md +0 -0
  228. /package/{src → dist}/prompts/templates/sampling/test-generation.md +0 -0
  229. /package/dist/tools/{webtest → retest}/crawl.d.ts +0 -0
  230. /package/dist/tools/{webtest → retest}/discover-features.d.ts +0 -0
  231. /package/dist/tools/{webtest → retest}/discover-flows.d.ts +0 -0
  232. /package/dist/tools/{webtest → retest}/generate-tests.d.ts +0 -0
  233. /package/dist/tools/{webtest → retest}/index.d.ts +0 -0
  234. /package/dist/tools/{webtest → retest}/index.js +0 -0
  235. /package/dist/tools/{webtest → retest}/run-test-case.d.ts +0 -0
  236. /package/dist/tools/{webtest → retest}/schemas.d.ts +0 -0
  237. /package/dist/tools/{webtest → retest}/schemas.js +0 -0
  238. /package/dist/tools/{webtest → retest}/start-analysis.d.ts +0 -0
@@ -1,422 +0,0 @@
1
- /**
2
- * Mock Playwright MCP Client for testing
3
- *
4
- * Provides a controllable mock implementation of PlaywrightClient
5
- * for testing crawl, test execution, and other Playwright-dependent flows.
6
- */
7
-
8
- import { vi } from "vitest";
9
- import type {
10
- PlaywrightClient,
11
- PlaywrightSnapshot,
12
- PlaywrightScreenshot,
13
- } from "../playwright-client/index.js";
14
- import type { PlaywrightToolMapping, PlaywrightToolCallResult } from "../playwright-client/types.js";
15
-
16
- export interface MockPage {
17
- url: string;
18
- title: string;
19
- html: string;
20
- links?: Array<{ selector: string; href: string; text: string }>;
21
- forms?: Array<{ selector: string; action: string; inputs: string[] }>;
22
- buttons?: Array<{ selector: string; text: string }>;
23
- }
24
-
25
- export interface MockPlaywrightClientOptions {
26
- /** Starting pages - keyed by URL */
27
- pages: Record<string, MockPage>;
28
- /** Custom tool call handler for testing specific behaviors */
29
- onToolCall?: (
30
- tool: keyof PlaywrightToolMapping,
31
- args: Record<string, unknown>
32
- ) => PlaywrightToolCallResult | undefined;
33
- /** Simulated errors by tool name */
34
- errors?: Partial<Record<keyof PlaywrightToolMapping, string>>;
35
- /** Delay in ms to simulate network latency */
36
- latencyMs?: number;
37
- }
38
-
39
- export interface MockPlaywrightClient extends PlaywrightClient {
40
- /** Get the current page state */
41
- getCurrentPage(): MockPage | undefined;
42
- /** Set custom pages for testing */
43
- setPages(pages: Record<string, MockPage>): void;
44
- /** Get action history */
45
- getActionHistory(): Array<{ tool: string; args: Record<string, unknown> }>;
46
- /** Clear action history */
47
- clearActionHistory(): void;
48
- /** Set error for specific tool */
49
- setError(tool: keyof PlaywrightToolMapping, message: string | null): void;
50
- }
51
-
52
- export function createMockPlaywrightClient(
53
- options: MockPlaywrightClientOptions
54
- ): MockPlaywrightClient {
55
- let pages = { ...options.pages };
56
- let currentUrl: string | undefined;
57
- let connected = false;
58
- const actionHistory: Array<{ tool: string; args: Record<string, unknown> }> = [];
59
- const errors: Partial<Record<keyof PlaywrightToolMapping, string>> = {
60
- ...options.errors,
61
- };
62
-
63
- const toolMapping: PlaywrightToolMapping = {
64
- snapshot: "browser_snapshot",
65
- screenshot: "browser_take_screenshot",
66
- click: "browser_click",
67
- type: "browser_type",
68
- navigate: "browser_navigate",
69
- fill: "browser_type", // Microsoft Playwright MCP uses browser_type for fill
70
- hover: "browser_hover",
71
- select: "browser_select_option",
72
- evaluate: "browser_evaluate",
73
- press: "browser_press_key",
74
- scroll: "browser_scroll",
75
- wait: "browser_wait",
76
- };
77
-
78
- function getCurrentPage(): MockPage | undefined {
79
- if (!currentUrl) return undefined;
80
- return pages[currentUrl];
81
- }
82
-
83
- async function delay(): Promise<void> {
84
- if (options.latencyMs) {
85
- await new Promise((resolve) => setTimeout(resolve, options.latencyMs));
86
- }
87
- }
88
-
89
- function recordAction(tool: string, args: Record<string, unknown>): void {
90
- actionHistory.push({ tool, args });
91
- }
92
-
93
- const client: MockPlaywrightClient = {
94
- connect: vi.fn().mockImplementation(async () => {
95
- await delay();
96
- connected = true;
97
- }),
98
-
99
- disconnect: vi.fn().mockImplementation(async () => {
100
- await delay();
101
- connected = false;
102
- currentUrl = undefined;
103
- }),
104
-
105
- isConnected: vi.fn().mockImplementation(() => {
106
- return connected;
107
- }),
108
-
109
- getToolMapping: vi.fn().mockImplementation(() => {
110
- return connected ? toolMapping : null;
111
- }),
112
-
113
- callTool: vi.fn().mockImplementation(async (
114
- canonicalName: keyof PlaywrightToolMapping,
115
- args: Record<string, unknown>
116
- ): Promise<PlaywrightToolCallResult> => {
117
- await delay();
118
- recordAction(canonicalName, args);
119
-
120
- // Check for configured errors
121
- if (errors[canonicalName]) {
122
- return {
123
- content: [{ type: "text", text: `Error: ${errors[canonicalName]}` }],
124
- isError: true,
125
- };
126
- }
127
-
128
- // Check for custom handler
129
- if (options.onToolCall) {
130
- const customResult = options.onToolCall(canonicalName, args);
131
- if (customResult) return customResult;
132
- }
133
-
134
- // Default implementations
135
- const actualName = toolMapping[canonicalName];
136
- return {
137
- content: [{ type: "text", text: `${actualName} executed successfully` }],
138
- };
139
- }),
140
-
141
- snapshot: vi.fn().mockImplementation(async (): Promise<PlaywrightSnapshot> => {
142
- await delay();
143
- recordAction("snapshot", {});
144
-
145
- if (errors.snapshot) {
146
- throw new Error(errors.snapshot);
147
- }
148
-
149
- const page = getCurrentPage();
150
- if (!page) {
151
- return {
152
- url: currentUrl || "",
153
- title: "",
154
- content: "No page loaded",
155
- };
156
- }
157
-
158
- return {
159
- url: page.url,
160
- title: page.title,
161
- content: JSON.stringify({
162
- url: page.url,
163
- title: page.title,
164
- links: page.links,
165
- forms: page.forms,
166
- buttons: page.buttons,
167
- }),
168
- };
169
- }),
170
-
171
- screenshot: vi.fn().mockImplementation(async (): Promise<PlaywrightScreenshot> => {
172
- await delay();
173
- recordAction("screenshot", {});
174
-
175
- if (errors.screenshot) {
176
- throw new Error(errors.screenshot);
177
- }
178
-
179
- // Return a minimal valid PNG (1x1 transparent pixel)
180
- const minimalPng =
181
- "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";
182
-
183
- return {
184
- data: minimalPng,
185
- mimeType: "image/png",
186
- };
187
- }),
188
-
189
- navigate: vi.fn().mockImplementation(async (url: string): Promise<void> => {
190
- await delay();
191
- recordAction("navigate", { url });
192
-
193
- if (errors.navigate) {
194
- throw new Error(errors.navigate);
195
- }
196
-
197
- currentUrl = url;
198
-
199
- // Auto-create a default page if not defined
200
- if (!pages[url]) {
201
- pages[url] = {
202
- url,
203
- title: `Page: ${url}`,
204
- html: `<html><head><title>Page: ${url}</title></head><body></body></html>`,
205
- };
206
- }
207
- }),
208
-
209
- click: vi.fn().mockImplementation(async (element: string, ref: string): Promise<void> => {
210
- await delay();
211
- recordAction("click", { element, ref });
212
-
213
- if (errors.click) {
214
- throw new Error(errors.click);
215
- }
216
-
217
- // Check if clicking a link triggers navigation (use ref as selector for mock lookup)
218
- const page = getCurrentPage();
219
- if (page?.links) {
220
- const link = page.links.find((l) => l.selector === ref || l.text === element);
221
- if (link?.href) {
222
- currentUrl = link.href;
223
- }
224
- }
225
- }),
226
-
227
- type: vi.fn().mockImplementation(async (
228
- element: string,
229
- ref: string,
230
- text: string,
231
- options?: { submit?: boolean; slowly?: boolean }
232
- ): Promise<void> => {
233
- await delay();
234
- recordAction("type", { element, ref, text, submit: options?.submit, slowly: options?.slowly });
235
-
236
- if (errors.type) {
237
- throw new Error(errors.type);
238
- }
239
- }),
240
-
241
- fill: vi.fn().mockImplementation(async (element: string, ref: string, value: string): Promise<void> => {
242
- await delay();
243
- recordAction("fill", { element, ref, value });
244
-
245
- if (errors.fill) {
246
- throw new Error(errors.fill);
247
- }
248
- }),
249
-
250
- hover: vi.fn().mockImplementation(async (element: string, ref: string): Promise<void> => {
251
- await delay();
252
- recordAction("hover", { element, ref });
253
-
254
- if (errors.hover) {
255
- throw new Error(errors.hover);
256
- }
257
- }),
258
-
259
- select: vi.fn().mockImplementation(async (element: string, ref: string, values: string[]): Promise<void> => {
260
- await delay();
261
- recordAction("select", { element, ref, values });
262
-
263
- if (errors.select) {
264
- throw new Error(errors.select);
265
- }
266
- }),
267
-
268
- evaluate: vi.fn().mockImplementation(async (fn: string, element?: string, ref?: string): Promise<unknown> => {
269
- await delay();
270
- const args: Record<string, unknown> = { function: fn };
271
- if (element) args.element = element;
272
- if (ref) args.ref = ref;
273
- recordAction("evaluate", args);
274
-
275
- if (errors.evaluate) {
276
- throw new Error(errors.evaluate);
277
- }
278
-
279
- // Return the current page HTML as a default evaluation result
280
- const page = getCurrentPage();
281
- return page?.html || "";
282
- }),
283
-
284
- press: vi.fn().mockImplementation(async (key: string): Promise<void> => {
285
- await delay();
286
- recordAction("press", { key });
287
-
288
- if (errors.press) {
289
- throw new Error(errors.press);
290
- }
291
- }),
292
-
293
- scroll: vi.fn().mockImplementation(async (x: number, y: number): Promise<void> => {
294
- await delay();
295
- recordAction("scroll", { x, y });
296
-
297
- if (errors.scroll) {
298
- throw new Error(errors.scroll);
299
- }
300
- }),
301
-
302
- wait: vi.fn().mockImplementation(async (ms: number): Promise<void> => {
303
- await delay();
304
- recordAction("wait", { ms });
305
-
306
- if (errors.wait) {
307
- throw new Error(errors.wait);
308
- }
309
-
310
- // Actually wait for the specified time
311
- await new Promise((resolve) => setTimeout(resolve, ms));
312
- }),
313
-
314
- // Test helpers
315
- getCurrentPage,
316
-
317
- setPages(newPages: Record<string, MockPage>): void {
318
- pages = { ...newPages };
319
- },
320
-
321
- getActionHistory(): Array<{ tool: string; args: Record<string, unknown> }> {
322
- return [...actionHistory];
323
- },
324
-
325
- clearActionHistory(): void {
326
- actionHistory.length = 0;
327
- },
328
-
329
- setError(tool: keyof PlaywrightToolMapping, message: string | null): void {
330
- if (message === null) {
331
- delete errors[tool];
332
- } else {
333
- errors[tool] = message;
334
- }
335
- },
336
- };
337
-
338
- return client;
339
- }
340
-
341
- /**
342
- * Create a simple mock page for testing
343
- */
344
- export function createMockPage(
345
- url: string,
346
- options: Partial<MockPage> = {}
347
- ): MockPage {
348
- const hostname = new URL(url).hostname;
349
- return {
350
- url,
351
- title: options.title || `Page - ${hostname}`,
352
- html:
353
- options.html ||
354
- `<html><head><title>${options.title || hostname}</title></head><body><h1>Welcome</h1></body></html>`,
355
- links: options.links || [],
356
- forms: options.forms || [],
357
- buttons: options.buttons || [],
358
- };
359
- }
360
-
361
- /**
362
- * Create a typical e-commerce site mock for testing
363
- */
364
- export function createEcommerceMock(): Record<string, MockPage> {
365
- const baseUrl = "https://shop.example.com";
366
-
367
- return {
368
- [baseUrl]: createMockPage(baseUrl, {
369
- title: "Shop - Home",
370
- links: [
371
- { selector: 'a[href="/products"]', href: `${baseUrl}/products`, text: "Products" },
372
- { selector: 'a[href="/cart"]', href: `${baseUrl}/cart`, text: "Cart" },
373
- { selector: 'a[href="/login"]', href: `${baseUrl}/login`, text: "Login" },
374
- ],
375
- buttons: [{ selector: "button.search", text: "Search" }],
376
- }),
377
- [`${baseUrl}/products`]: createMockPage(`${baseUrl}/products`, {
378
- title: "Shop - Products",
379
- links: [
380
- { selector: 'a[href="/"]', href: baseUrl, text: "Home" },
381
- { selector: 'a[href="/product/1"]', href: `${baseUrl}/product/1`, text: "Product 1" },
382
- { selector: 'a[href="/product/2"]', href: `${baseUrl}/product/2`, text: "Product 2" },
383
- ],
384
- }),
385
- [`${baseUrl}/product/1`]: createMockPage(`${baseUrl}/product/1`, {
386
- title: "Product 1 - Shop",
387
- buttons: [
388
- { selector: "button.add-to-cart", text: "Add to Cart" },
389
- { selector: "button.buy-now", text: "Buy Now" },
390
- ],
391
- }),
392
- [`${baseUrl}/cart`]: createMockPage(`${baseUrl}/cart`, {
393
- title: "Shopping Cart - Shop",
394
- buttons: [
395
- { selector: "button.checkout", text: "Checkout" },
396
- { selector: "button.continue-shopping", text: "Continue Shopping" },
397
- ],
398
- }),
399
- [`${baseUrl}/login`]: createMockPage(`${baseUrl}/login`, {
400
- title: "Login - Shop",
401
- forms: [
402
- {
403
- selector: "form#login",
404
- action: "/auth/login",
405
- inputs: ["email", "password"],
406
- },
407
- ],
408
- buttons: [{ selector: "button.submit", text: "Sign In" }],
409
- }),
410
- [`${baseUrl}/checkout`]: createMockPage(`${baseUrl}/checkout`, {
411
- title: "Checkout - Shop",
412
- forms: [
413
- {
414
- selector: "form#checkout",
415
- action: "/process-order",
416
- inputs: ["name", "address", "card"],
417
- },
418
- ],
419
- buttons: [{ selector: "button.place-order", text: "Place Order" }],
420
- }),
421
- };
422
- }
@@ -1,11 +0,0 @@
1
- // Tools are now registered directly in server.ts via the webtest tools
2
- // This file is kept for backwards compatibility but tools array is empty
3
- // The hello tool has been removed as part of the webtest orchestrator implementation
4
-
5
- import type { McpTool } from "../types/tool.js";
6
-
7
- // Webtest tools are exported from the webtest module
8
- export * from "./webtest/index.js";
9
-
10
- // Legacy tools array - empty since webtest tools are registered differently
11
- export const tools: McpTool[] = [];