Implement comprehensive frontend integration testing with Playwright
- Add Playwright E2E testing framework with cross-browser support (Chrome, Firefox) - Create authentication helpers for CalDAV server integration - Implement calendar interaction helpers with event creation, drag-and-drop, and view switching - Add comprehensive drag-and-drop test suite with event cleanup - Configure CI/CD integration with Gitea Actions for headless testing - Support both local development and CI environments with proper dependency management - Include video recording, screenshots, and HTML reporting for test debugging - Handle Firefox-specific timing and interaction challenges with force clicks and timeouts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
		
							
								
								
									
										59
									
								
								frontend/e2e/node_modules/playwright/lib/mcp/bundle.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								frontend/e2e/node_modules/playwright/lib/mcp/bundle.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,59 @@ | ||||
| "use strict"; | ||||
| var __defProp = Object.defineProperty; | ||||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||||
| var __export = (target, all) => { | ||||
|   for (var name in all) | ||||
|     __defProp(target, name, { get: all[name], enumerable: true }); | ||||
| }; | ||||
| var __copyProps = (to, from, except, desc) => { | ||||
|   if (from && typeof from === "object" || typeof from === "function") { | ||||
|     for (let key of __getOwnPropNames(from)) | ||||
|       if (!__hasOwnProp.call(to, key) && key !== except) | ||||
|         __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||||
|   } | ||||
|   return to; | ||||
| }; | ||||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||||
| var bundle_exports = {}; | ||||
| __export(bundle_exports, { | ||||
|   CallToolRequestSchema: () => CallToolRequestSchema, | ||||
|   Client: () => Client, | ||||
|   ListRootsRequestSchema: () => ListRootsRequestSchema, | ||||
|   ListToolsRequestSchema: () => ListToolsRequestSchema, | ||||
|   PingRequestSchema: () => PingRequestSchema, | ||||
|   SSEServerTransport: () => SSEServerTransport, | ||||
|   Server: () => Server, | ||||
|   StdioServerTransport: () => StdioServerTransport, | ||||
|   StreamableHTTPServerTransport: () => StreamableHTTPServerTransport, | ||||
|   z: () => z, | ||||
|   zodToJsonSchema: () => zodToJsonSchema | ||||
| }); | ||||
| module.exports = __toCommonJS(bundle_exports); | ||||
| const bundle = require("./mcpBundleImpl"); | ||||
| const zodToJsonSchema = require("./mcpBundleImpl").zodToJsonSchema; | ||||
| const Client = bundle.Client; | ||||
| const Server = bundle.Server; | ||||
| const SSEServerTransport = bundle.SSEServerTransport; | ||||
| const StdioServerTransport = bundle.StdioServerTransport; | ||||
| const StreamableHTTPServerTransport = bundle.StreamableHTTPServerTransport; | ||||
| const CallToolRequestSchema = bundle.CallToolRequestSchema; | ||||
| const ListRootsRequestSchema = bundle.ListRootsRequestSchema; | ||||
| const ListToolsRequestSchema = bundle.ListToolsRequestSchema; | ||||
| const PingRequestSchema = bundle.PingRequestSchema; | ||||
| const z = bundle.z; | ||||
| // Annotate the CommonJS export names for ESM import in node: | ||||
| 0 && (module.exports = { | ||||
|   CallToolRequestSchema, | ||||
|   Client, | ||||
|   ListRootsRequestSchema, | ||||
|   ListToolsRequestSchema, | ||||
|   PingRequestSchema, | ||||
|   SSEServerTransport, | ||||
|   Server, | ||||
|   StdioServerTransport, | ||||
|   StreamableHTTPServerTransport, | ||||
|   z, | ||||
|   zodToJsonSchema | ||||
| }); | ||||
							
								
								
									
										30
									
								
								frontend/e2e/node_modules/playwright/lib/mcp/exports.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								frontend/e2e/node_modules/playwright/lib/mcp/exports.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| "use strict"; | ||||
| var __defProp = Object.defineProperty; | ||||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||||
| var __copyProps = (to, from, except, desc) => { | ||||
|   if (from && typeof from === "object" || typeof from === "function") { | ||||
|     for (let key of __getOwnPropNames(from)) | ||||
|       if (!__hasOwnProp.call(to, key) && key !== except) | ||||
|         __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||||
|   } | ||||
|   return to; | ||||
| }; | ||||
| var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); | ||||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||||
| var exports_exports = {}; | ||||
| module.exports = __toCommonJS(exports_exports); | ||||
| __reExport(exports_exports, require("./inProcessTransport.js"), module.exports); | ||||
| __reExport(exports_exports, require("./proxyBackend.js"), module.exports); | ||||
| __reExport(exports_exports, require("./server.js"), module.exports); | ||||
| __reExport(exports_exports, require("./tool.js"), module.exports); | ||||
| __reExport(exports_exports, require("./transport.js"), module.exports); | ||||
| // Annotate the CommonJS export names for ESM import in node: | ||||
| 0 && (module.exports = { | ||||
|   ...require("./inProcessTransport.js"), | ||||
|   ...require("./proxyBackend.js"), | ||||
|   ...require("./server.js"), | ||||
|   ...require("./tool.js"), | ||||
|   ...require("./transport.js") | ||||
| }); | ||||
							
								
								
									
										71
									
								
								frontend/e2e/node_modules/playwright/lib/mcp/inProcessTransport.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								frontend/e2e/node_modules/playwright/lib/mcp/inProcessTransport.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,71 @@ | ||||
| "use strict"; | ||||
| var __defProp = Object.defineProperty; | ||||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||||
| var __export = (target, all) => { | ||||
|   for (var name in all) | ||||
|     __defProp(target, name, { get: all[name], enumerable: true }); | ||||
| }; | ||||
| var __copyProps = (to, from, except, desc) => { | ||||
|   if (from && typeof from === "object" || typeof from === "function") { | ||||
|     for (let key of __getOwnPropNames(from)) | ||||
|       if (!__hasOwnProp.call(to, key) && key !== except) | ||||
|         __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||||
|   } | ||||
|   return to; | ||||
| }; | ||||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||||
| var inProcessTransport_exports = {}; | ||||
| __export(inProcessTransport_exports, { | ||||
|   InProcessTransport: () => InProcessTransport | ||||
| }); | ||||
| module.exports = __toCommonJS(inProcessTransport_exports); | ||||
| class InProcessTransport { | ||||
|   constructor(server) { | ||||
|     this._connected = false; | ||||
|     this._server = server; | ||||
|     this._serverTransport = new InProcessServerTransport(this); | ||||
|   } | ||||
|   async start() { | ||||
|     if (this._connected) | ||||
|       throw new Error("InprocessTransport already started!"); | ||||
|     await this._server.connect(this._serverTransport); | ||||
|     this._connected = true; | ||||
|   } | ||||
|   async send(message, options) { | ||||
|     if (!this._connected) | ||||
|       throw new Error("Transport not connected"); | ||||
|     this._serverTransport._receiveFromClient(message); | ||||
|   } | ||||
|   async close() { | ||||
|     if (this._connected) { | ||||
|       this._connected = false; | ||||
|       this.onclose?.(); | ||||
|       this._serverTransport.onclose?.(); | ||||
|     } | ||||
|   } | ||||
|   _receiveFromServer(message, extra) { | ||||
|     this.onmessage?.(message, extra); | ||||
|   } | ||||
| } | ||||
| class InProcessServerTransport { | ||||
|   constructor(clientTransport) { | ||||
|     this._clientTransport = clientTransport; | ||||
|   } | ||||
|   async start() { | ||||
|   } | ||||
|   async send(message, options) { | ||||
|     this._clientTransport._receiveFromServer(message); | ||||
|   } | ||||
|   async close() { | ||||
|     this.onclose?.(); | ||||
|   } | ||||
|   _receiveFromClient(message) { | ||||
|     this.onmessage?.(message); | ||||
|   } | ||||
| } | ||||
| // Annotate the CommonJS export names for ESM import in node: | ||||
| 0 && (module.exports = { | ||||
|   InProcessTransport | ||||
| }); | ||||
							
								
								
									
										123
									
								
								frontend/e2e/node_modules/playwright/lib/mcp/proxyBackend.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										123
									
								
								frontend/e2e/node_modules/playwright/lib/mcp/proxyBackend.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,123 @@ | ||||
| "use strict"; | ||||
| var __create = Object.create; | ||||
| var __defProp = Object.defineProperty; | ||||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||||
| var __getProtoOf = Object.getPrototypeOf; | ||||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||||
| var __export = (target, all) => { | ||||
|   for (var name in all) | ||||
|     __defProp(target, name, { get: all[name], enumerable: true }); | ||||
| }; | ||||
| var __copyProps = (to, from, except, desc) => { | ||||
|   if (from && typeof from === "object" || typeof from === "function") { | ||||
|     for (let key of __getOwnPropNames(from)) | ||||
|       if (!__hasOwnProp.call(to, key) && key !== except) | ||||
|         __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||||
|   } | ||||
|   return to; | ||||
| }; | ||||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||||
|   // If the importer is in node compatibility mode or this is not an ESM | ||||
|   // file that has been converted to a CommonJS file using a Babel- | ||||
|   // compatible transform (i.e. "__esModule" has not been set), then set | ||||
|   // "default" to the CommonJS "module.exports" for node compatibility. | ||||
|   isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||||
|   mod | ||||
| )); | ||||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||||
| var proxyBackend_exports = {}; | ||||
| __export(proxyBackend_exports, { | ||||
|   ProxyBackend: () => ProxyBackend | ||||
| }); | ||||
| module.exports = __toCommonJS(proxyBackend_exports); | ||||
| var import_utilsBundle = require("playwright-core/lib/utilsBundle"); | ||||
| var mcpBundle = __toESM(require("./bundle")); | ||||
| const errorsDebug = (0, import_utilsBundle.debug)("pw:mcp:errors"); | ||||
| class ProxyBackend { | ||||
|   constructor(name, version, mcpProviders) { | ||||
|     this._roots = []; | ||||
|     this.name = name; | ||||
|     this.version = version; | ||||
|     this._mcpProviders = mcpProviders; | ||||
|     this._contextSwitchTool = this._defineContextSwitchTool(); | ||||
|   } | ||||
|   async initialize(clientVersion, roots) { | ||||
|     this._roots = roots; | ||||
|     await this._setCurrentClient(this._mcpProviders[0]); | ||||
|   } | ||||
|   async listTools() { | ||||
|     const response = await this._currentClient.listTools(); | ||||
|     if (this._mcpProviders.length === 1) | ||||
|       return response.tools; | ||||
|     return [ | ||||
|       ...response.tools, | ||||
|       this._contextSwitchTool | ||||
|     ]; | ||||
|   } | ||||
|   async callTool(name, args) { | ||||
|     if (name === this._contextSwitchTool.name) | ||||
|       return this._callContextSwitchTool(args); | ||||
|     return await this._currentClient.callTool({ | ||||
|       name, | ||||
|       arguments: args | ||||
|     }); | ||||
|   } | ||||
|   serverClosed() { | ||||
|     void this._currentClient?.close().catch(errorsDebug); | ||||
|   } | ||||
|   async _callContextSwitchTool(params) { | ||||
|     try { | ||||
|       const factory = this._mcpProviders.find((factory2) => factory2.name === params.name); | ||||
|       if (!factory) | ||||
|         throw new Error("Unknown connection method: " + params.name); | ||||
|       await this._setCurrentClient(factory); | ||||
|       return { | ||||
|         content: [{ type: "text", text: "### Result\nSuccessfully changed connection method.\n" }] | ||||
|       }; | ||||
|     } catch (error) { | ||||
|       return { | ||||
|         content: [{ type: "text", text: `### Result | ||||
| Error: ${error} | ||||
| ` }], | ||||
|         isError: true | ||||
|       }; | ||||
|     } | ||||
|   } | ||||
|   _defineContextSwitchTool() { | ||||
|     return { | ||||
|       name: "browser_connect", | ||||
|       description: [ | ||||
|         "Connect to a browser using one of the available methods:", | ||||
|         ...this._mcpProviders.map((factory) => `- "${factory.name}": ${factory.description}`) | ||||
|       ].join("\n"), | ||||
|       inputSchema: mcpBundle.zodToJsonSchema(mcpBundle.z.object({ | ||||
|         name: mcpBundle.z.enum(this._mcpProviders.map((factory) => factory.name)).default(this._mcpProviders[0].name).describe("The method to use to connect to the browser") | ||||
|       }), { strictUnions: true }), | ||||
|       annotations: { | ||||
|         title: "Connect to a browser context", | ||||
|         readOnlyHint: true, | ||||
|         openWorldHint: false | ||||
|       } | ||||
|     }; | ||||
|   } | ||||
|   async _setCurrentClient(factory) { | ||||
|     await this._currentClient?.close(); | ||||
|     this._currentClient = void 0; | ||||
|     const client = new mcpBundle.Client({ name: this.name, version: this.version }); | ||||
|     client.registerCapabilities({ | ||||
|       roots: { | ||||
|         listRoots: true | ||||
|       } | ||||
|     }); | ||||
|     client.setRequestHandler(mcpBundle.ListRootsRequestSchema, () => ({ roots: this._roots })); | ||||
|     client.setRequestHandler(mcpBundle.PingRequestSchema, () => ({})); | ||||
|     const transport = await factory.connect(); | ||||
|     await client.connect(transport); | ||||
|     this._currentClient = client; | ||||
|   } | ||||
| } | ||||
| // Annotate the CommonJS export names for ESM import in node: | ||||
| 0 && (module.exports = { | ||||
|   ProxyBackend | ||||
| }); | ||||
							
								
								
									
										118
									
								
								frontend/e2e/node_modules/playwright/lib/mcp/server.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										118
									
								
								frontend/e2e/node_modules/playwright/lib/mcp/server.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,118 @@ | ||||
| "use strict"; | ||||
| var __create = Object.create; | ||||
| var __defProp = Object.defineProperty; | ||||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||||
| var __getProtoOf = Object.getPrototypeOf; | ||||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||||
| var __export = (target, all) => { | ||||
|   for (var name in all) | ||||
|     __defProp(target, name, { get: all[name], enumerable: true }); | ||||
| }; | ||||
| var __copyProps = (to, from, except, desc) => { | ||||
|   if (from && typeof from === "object" || typeof from === "function") { | ||||
|     for (let key of __getOwnPropNames(from)) | ||||
|       if (!__hasOwnProp.call(to, key) && key !== except) | ||||
|         __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||||
|   } | ||||
|   return to; | ||||
| }; | ||||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||||
|   // If the importer is in node compatibility mode or this is not an ESM | ||||
|   // file that has been converted to a CommonJS file using a Babel- | ||||
|   // compatible transform (i.e. "__esModule" has not been set), then set | ||||
|   // "default" to the CommonJS "module.exports" for node compatibility. | ||||
|   isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||||
|   mod | ||||
| )); | ||||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||||
| var server_exports = {}; | ||||
| __export(server_exports, { | ||||
|   connect: () => connect, | ||||
|   createServer: () => createServer | ||||
| }); | ||||
| module.exports = __toCommonJS(server_exports); | ||||
| var import_utilsBundle = require("playwright-core/lib/utilsBundle"); | ||||
| var mcpBundle = __toESM(require("./bundle")); | ||||
| const serverDebug = (0, import_utilsBundle.debug)("pw:mcp:server"); | ||||
| const errorsDebug = (0, import_utilsBundle.debug)("pw:mcp:errors"); | ||||
| async function connect(serverBackendFactory, transport, runHeartbeat) { | ||||
|   const backend = serverBackendFactory(); | ||||
|   const server = createServer(backend, runHeartbeat); | ||||
|   await server.connect(transport); | ||||
| } | ||||
| function createServer(backend, runHeartbeat) { | ||||
|   let initializedCallback = () => { | ||||
|   }; | ||||
|   const initializedPromise = new Promise((resolve) => initializedCallback = resolve); | ||||
|   const server = new mcpBundle.Server({ name: backend.name, version: backend.version }, { | ||||
|     capabilities: { | ||||
|       tools: {} | ||||
|     } | ||||
|   }); | ||||
|   server.setRequestHandler(mcpBundle.ListToolsRequestSchema, async () => { | ||||
|     serverDebug("listTools"); | ||||
|     await initializedPromise; | ||||
|     const tools = await backend.listTools(); | ||||
|     return { tools }; | ||||
|   }); | ||||
|   let heartbeatRunning = false; | ||||
|   server.setRequestHandler(mcpBundle.CallToolRequestSchema, async (request) => { | ||||
|     serverDebug("callTool", request); | ||||
|     await initializedPromise; | ||||
|     if (runHeartbeat && !heartbeatRunning) { | ||||
|       heartbeatRunning = true; | ||||
|       startHeartbeat(server); | ||||
|     } | ||||
|     try { | ||||
|       return await backend.callTool(request.params.name, request.params.arguments || {}); | ||||
|     } catch (error) { | ||||
|       return { | ||||
|         content: [{ type: "text", text: "### Result\n" + String(error) }], | ||||
|         isError: true | ||||
|       }; | ||||
|     } | ||||
|   }); | ||||
|   addServerListener(server, "initialized", async () => { | ||||
|     try { | ||||
|       const capabilities = server.getClientCapabilities(); | ||||
|       let clientRoots = []; | ||||
|       if (capabilities?.roots) { | ||||
|         const { roots } = await server.listRoots(void 0, { timeout: 2e3 }).catch(() => ({ roots: [] })); | ||||
|         clientRoots = roots; | ||||
|       } | ||||
|       const clientVersion = server.getClientVersion() ?? { name: "unknown", version: "unknown" }; | ||||
|       await backend.initialize?.(clientVersion, clientRoots); | ||||
|       initializedCallback(); | ||||
|     } catch (e) { | ||||
|       errorsDebug(e); | ||||
|     } | ||||
|   }); | ||||
|   addServerListener(server, "close", () => backend.serverClosed?.()); | ||||
|   return server; | ||||
| } | ||||
| const startHeartbeat = (server) => { | ||||
|   const beat = () => { | ||||
|     Promise.race([ | ||||
|       server.ping(), | ||||
|       new Promise((_, reject) => setTimeout(() => reject(new Error("ping timeout")), 5e3)) | ||||
|     ]).then(() => { | ||||
|       setTimeout(beat, 3e3); | ||||
|     }).catch(() => { | ||||
|       void server.close(); | ||||
|     }); | ||||
|   }; | ||||
|   beat(); | ||||
| }; | ||||
| function addServerListener(server, event, listener) { | ||||
|   const oldListener = server[`on${event}`]; | ||||
|   server[`on${event}`] = () => { | ||||
|     oldListener?.(); | ||||
|     listener(); | ||||
|   }; | ||||
| } | ||||
| // Annotate the CommonJS export names for ESM import in node: | ||||
| 0 && (module.exports = { | ||||
|   connect, | ||||
|   createServer | ||||
| }); | ||||
							
								
								
									
										41
									
								
								frontend/e2e/node_modules/playwright/lib/mcp/tool.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								frontend/e2e/node_modules/playwright/lib/mcp/tool.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| "use strict"; | ||||
| var __defProp = Object.defineProperty; | ||||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||||
| var __export = (target, all) => { | ||||
|   for (var name in all) | ||||
|     __defProp(target, name, { get: all[name], enumerable: true }); | ||||
| }; | ||||
| var __copyProps = (to, from, except, desc) => { | ||||
|   if (from && typeof from === "object" || typeof from === "function") { | ||||
|     for (let key of __getOwnPropNames(from)) | ||||
|       if (!__hasOwnProp.call(to, key) && key !== except) | ||||
|         __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||||
|   } | ||||
|   return to; | ||||
| }; | ||||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||||
| var tool_exports = {}; | ||||
| __export(tool_exports, { | ||||
|   toMcpTool: () => toMcpTool | ||||
| }); | ||||
| module.exports = __toCommonJS(tool_exports); | ||||
| var import_bundle = require("./bundle"); | ||||
| function toMcpTool(tool) { | ||||
|   return { | ||||
|     name: tool.name, | ||||
|     description: tool.description, | ||||
|     inputSchema: (0, import_bundle.zodToJsonSchema)(tool.inputSchema, { strictUnions: true }), | ||||
|     annotations: { | ||||
|       title: tool.title, | ||||
|       readOnlyHint: tool.type === "readOnly", | ||||
|       destructiveHint: tool.type === "destructive", | ||||
|       openWorldHint: true | ||||
|     } | ||||
|   }; | ||||
| } | ||||
| // Annotate the CommonJS export names for ESM import in node: | ||||
| 0 && (module.exports = { | ||||
|   toMcpTool | ||||
| }); | ||||
							
								
								
									
										161
									
								
								frontend/e2e/node_modules/playwright/lib/mcp/transport.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										161
									
								
								frontend/e2e/node_modules/playwright/lib/mcp/transport.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,161 @@ | ||||
| "use strict"; | ||||
| var __create = Object.create; | ||||
| var __defProp = Object.defineProperty; | ||||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||||
| var __getProtoOf = Object.getPrototypeOf; | ||||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||||
| var __export = (target, all) => { | ||||
|   for (var name in all) | ||||
|     __defProp(target, name, { get: all[name], enumerable: true }); | ||||
| }; | ||||
| var __copyProps = (to, from, except, desc) => { | ||||
|   if (from && typeof from === "object" || typeof from === "function") { | ||||
|     for (let key of __getOwnPropNames(from)) | ||||
|       if (!__hasOwnProp.call(to, key) && key !== except) | ||||
|         __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||||
|   } | ||||
|   return to; | ||||
| }; | ||||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||||
|   // If the importer is in node compatibility mode or this is not an ESM | ||||
|   // file that has been converted to a CommonJS file using a Babel- | ||||
|   // compatible transform (i.e. "__esModule" has not been set), then set | ||||
|   // "default" to the CommonJS "module.exports" for node compatibility. | ||||
|   isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||||
|   mod | ||||
| )); | ||||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||||
| var transport_exports = {}; | ||||
| __export(transport_exports, { | ||||
|   start: () => start | ||||
| }); | ||||
| module.exports = __toCommonJS(transport_exports); | ||||
| var import_assert = __toESM(require("assert")); | ||||
| var import_http = __toESM(require("http")); | ||||
| var import_crypto = __toESM(require("crypto")); | ||||
| var import_utilsBundle = require("playwright-core/lib/utilsBundle"); | ||||
| var mcpBundle = __toESM(require("./bundle")); | ||||
| var mcpServer = __toESM(require("./server")); | ||||
| async function start(serverBackendFactory, options) { | ||||
|   if (options.port !== void 0) { | ||||
|     const httpServer = await startHttpServer(options); | ||||
|     startHttpTransport(httpServer, serverBackendFactory); | ||||
|   } else { | ||||
|     await startStdioTransport(serverBackendFactory); | ||||
|   } | ||||
| } | ||||
| async function startStdioTransport(serverBackendFactory) { | ||||
|   await mcpServer.connect(serverBackendFactory, new mcpBundle.StdioServerTransport(), false); | ||||
| } | ||||
| const testDebug = (0, import_utilsBundle.debug)("pw:mcp:test"); | ||||
| async function handleSSE(serverBackendFactory, req, res, url, sessions) { | ||||
|   if (req.method === "POST") { | ||||
|     const sessionId = url.searchParams.get("sessionId"); | ||||
|     if (!sessionId) { | ||||
|       res.statusCode = 400; | ||||
|       return res.end("Missing sessionId"); | ||||
|     } | ||||
|     const transport = sessions.get(sessionId); | ||||
|     if (!transport) { | ||||
|       res.statusCode = 404; | ||||
|       return res.end("Session not found"); | ||||
|     } | ||||
|     return await transport.handlePostMessage(req, res); | ||||
|   } else if (req.method === "GET") { | ||||
|     const transport = new mcpBundle.SSEServerTransport("/sse", res); | ||||
|     sessions.set(transport.sessionId, transport); | ||||
|     testDebug(`create SSE session: ${transport.sessionId}`); | ||||
|     await mcpServer.connect(serverBackendFactory, transport, false); | ||||
|     res.on("close", () => { | ||||
|       testDebug(`delete SSE session: ${transport.sessionId}`); | ||||
|       sessions.delete(transport.sessionId); | ||||
|     }); | ||||
|     return; | ||||
|   } | ||||
|   res.statusCode = 405; | ||||
|   res.end("Method not allowed"); | ||||
| } | ||||
| async function handleStreamable(serverBackendFactory, req, res, sessions) { | ||||
|   const sessionId = req.headers["mcp-session-id"]; | ||||
|   if (sessionId) { | ||||
|     const transport = sessions.get(sessionId); | ||||
|     if (!transport) { | ||||
|       res.statusCode = 404; | ||||
|       res.end("Session not found"); | ||||
|       return; | ||||
|     } | ||||
|     return await transport.handleRequest(req, res); | ||||
|   } | ||||
|   if (req.method === "POST") { | ||||
|     const transport = new mcpBundle.StreamableHTTPServerTransport({ | ||||
|       sessionIdGenerator: () => import_crypto.default.randomUUID(), | ||||
|       onsessioninitialized: async (sessionId2) => { | ||||
|         testDebug(`create http session: ${transport.sessionId}`); | ||||
|         await mcpServer.connect(serverBackendFactory, transport, true); | ||||
|         sessions.set(sessionId2, transport); | ||||
|       } | ||||
|     }); | ||||
|     transport.onclose = () => { | ||||
|       if (!transport.sessionId) | ||||
|         return; | ||||
|       sessions.delete(transport.sessionId); | ||||
|       testDebug(`delete http session: ${transport.sessionId}`); | ||||
|     }; | ||||
|     await transport.handleRequest(req, res); | ||||
|     return; | ||||
|   } | ||||
|   res.statusCode = 400; | ||||
|   res.end("Invalid request"); | ||||
| } | ||||
| function startHttpTransport(httpServer, serverBackendFactory) { | ||||
|   const sseSessions = /* @__PURE__ */ new Map(); | ||||
|   const streamableSessions = /* @__PURE__ */ new Map(); | ||||
|   httpServer.on("request", async (req, res) => { | ||||
|     const url2 = new URL(`http://localhost${req.url}`); | ||||
|     if (url2.pathname.startsWith("/sse")) | ||||
|       await handleSSE(serverBackendFactory, req, res, url2, sseSessions); | ||||
|     else | ||||
|       await handleStreamable(serverBackendFactory, req, res, streamableSessions); | ||||
|   }); | ||||
|   const url = httpAddressToString(httpServer.address()); | ||||
|   const message = [ | ||||
|     `Listening on ${url}`, | ||||
|     "Put this in your client config:", | ||||
|     JSON.stringify({ | ||||
|       "mcpServers": { | ||||
|         "playwright": { | ||||
|           "url": `${url}/mcp` | ||||
|         } | ||||
|       } | ||||
|     }, void 0, 2), | ||||
|     "For legacy SSE transport support, you can use the /sse endpoint instead." | ||||
|   ].join("\n"); | ||||
|   console.error(message); | ||||
| } | ||||
| async function startHttpServer(config) { | ||||
|   const { host, port } = config; | ||||
|   const httpServer = import_http.default.createServer(); | ||||
|   await new Promise((resolve, reject) => { | ||||
|     httpServer.on("error", reject); | ||||
|     httpServer.listen(port, host, () => { | ||||
|       resolve(); | ||||
|       httpServer.removeListener("error", reject); | ||||
|     }); | ||||
|   }); | ||||
|   return httpServer; | ||||
| } | ||||
| function httpAddressToString(address) { | ||||
|   (0, import_assert.default)(address, "Could not bind server socket"); | ||||
|   if (typeof address === "string") | ||||
|     return address; | ||||
|   const resolvedPort = address.port; | ||||
|   let resolvedHost = address.family === "IPv4" ? address.address : `[${address.address}]`; | ||||
|   if (resolvedHost === "0.0.0.0" || resolvedHost === "[::]") | ||||
|     resolvedHost = "localhost"; | ||||
|   return `http://${resolvedHost}:${resolvedPort}`; | ||||
| } | ||||
| // Annotate the CommonJS export names for ESM import in node: | ||||
| 0 && (module.exports = { | ||||
|   start | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user
	 Connor Johnstone
					Connor Johnstone