feat: Geutebruck GeViScope/GeViSoft Action Mapping System - MVP
This MVP release provides a complete full-stack solution for managing action mappings in Geutebruck's GeViScope and GeViSoft video surveillance systems. ## Features ### Flutter Web Application (Port 8081) - Modern, responsive UI for managing action mappings - Action picker dialog with full parameter configuration - Support for both GSC (GeViScope) and G-Core server actions - Consistent UI for input and output actions with edit/delete capabilities - Real-time action mapping creation, editing, and deletion - Server categorization (GSC: prefix for GeViScope, G-Core: prefix for G-Core servers) ### FastAPI REST Backend (Port 8000) - RESTful API for action mapping CRUD operations - Action template service with comprehensive action catalog (247 actions) - Server management (G-Core and GeViScope servers) - Configuration tree reading and writing - JWT authentication with role-based access control - PostgreSQL database integration ### C# SDK Bridge (gRPC, Port 50051) - Native integration with GeViSoft SDK (GeViProcAPINET_4_0.dll) - Action mapping creation with correct binary format - Support for GSC and G-Core action types - Proper Camera parameter inclusion in action strings (fixes CrossSwitch bug) - Action ID lookup table with server-specific action IDs - Configuration reading/writing via SetupClient ## Bug Fixes - **CrossSwitch Bug**: GSC and G-Core actions now correctly display camera/PTZ head parameters in GeViSet - Action strings now include Camera parameter: `@ PanLeft (Comment: "", Camera: 101028)` - Proper filter flags and VideoInput=0 for action mappings - Correct action ID assignment (4198 for GSC, 9294 for G-Core PanLeft) ## Technical Stack - **Frontend**: Flutter Web, Dart, Dio HTTP client - **Backend**: Python FastAPI, PostgreSQL, Redis - **SDK Bridge**: C# .NET 8.0, gRPC, GeViSoft SDK - **Authentication**: JWT tokens - **Configuration**: GeViSoft .set files (binary format) ## Credentials - GeViSoft/GeViScope: username=sysadmin, password=masterkey - Default admin: username=admin, password=admin123 ## Deployment All services run on localhost: - Flutter Web: http://localhost:8081 - FastAPI: http://localhost:8000 - SDK Bridge gRPC: localhost:50051 - GeViServer: localhost (default port) Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
108
.playwright-mcp/node_modules/playwright/lib/mcp/test/browserBackend.js
generated
vendored
Normal file
108
.playwright-mcp/node_modules/playwright/lib/mcp/test/browserBackend.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
"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 browserBackend_exports = {};
|
||||
__export(browserBackend_exports, {
|
||||
createCustomMessageHandler: () => createCustomMessageHandler
|
||||
});
|
||||
module.exports = __toCommonJS(browserBackend_exports);
|
||||
var import_config = require("../browser/config");
|
||||
var import_browserServerBackend = require("../browser/browserServerBackend");
|
||||
var import_tab = require("../browser/tab");
|
||||
var import_util = require("../../util");
|
||||
function createCustomMessageHandler(testInfo, context) {
|
||||
let backend;
|
||||
return async (data) => {
|
||||
if (data.initialize) {
|
||||
if (backend)
|
||||
throw new Error("MCP backend is already initialized");
|
||||
backend = new import_browserServerBackend.BrowserServerBackend({ ...import_config.defaultConfig, capabilities: ["testing"] }, identityFactory(context));
|
||||
await backend.initialize(data.initialize.clientInfo);
|
||||
const pausedMessage = await generatePausedMessage(testInfo, context);
|
||||
return { initialize: { pausedMessage } };
|
||||
}
|
||||
if (data.listTools) {
|
||||
if (!backend)
|
||||
throw new Error("MCP backend is not initialized");
|
||||
return { listTools: await backend.listTools() };
|
||||
}
|
||||
if (data.callTool) {
|
||||
if (!backend)
|
||||
throw new Error("MCP backend is not initialized");
|
||||
return { callTool: await backend.callTool(data.callTool.name, data.callTool.arguments) };
|
||||
}
|
||||
if (data.close) {
|
||||
backend?.serverClosed();
|
||||
backend = void 0;
|
||||
return { close: {} };
|
||||
}
|
||||
throw new Error("Unknown MCP request");
|
||||
};
|
||||
}
|
||||
async function generatePausedMessage(testInfo, context) {
|
||||
const lines = [];
|
||||
if (testInfo.errors.length) {
|
||||
lines.push(`### Paused on error:`);
|
||||
for (const error of testInfo.errors)
|
||||
lines.push((0, import_util.stripAnsiEscapes)(error.message || ""));
|
||||
} else {
|
||||
lines.push(`### Paused at end of test. ready for interaction`);
|
||||
}
|
||||
for (let i = 0; i < context.pages().length; i++) {
|
||||
const page = context.pages()[i];
|
||||
const stateSuffix = context.pages().length > 1 ? i + 1 + " of " + context.pages().length : "state";
|
||||
lines.push(
|
||||
"",
|
||||
`### Page ${stateSuffix}`,
|
||||
`- Page URL: ${page.url()}`,
|
||||
`- Page Title: ${await page.title()}`.trim()
|
||||
);
|
||||
let console = testInfo.errors.length ? await import_tab.Tab.collectConsoleMessages(page) : [];
|
||||
console = console.filter((msg) => !msg.type || msg.type === "error");
|
||||
if (console.length) {
|
||||
lines.push("- Console Messages:");
|
||||
for (const message of console)
|
||||
lines.push(` - ${message.toString()}`);
|
||||
}
|
||||
lines.push(
|
||||
`- Page Snapshot:`,
|
||||
"```yaml",
|
||||
(await page._snapshotForAI()).full,
|
||||
"```"
|
||||
);
|
||||
}
|
||||
lines.push("");
|
||||
if (testInfo.errors.length)
|
||||
lines.push(`### Task`, `Try recovering from the error prior to continuing`);
|
||||
return lines.join("\n");
|
||||
}
|
||||
function identityFactory(browserContext) {
|
||||
return {
|
||||
createContext: async (clientInfo, abortSignal, toolName) => {
|
||||
return {
|
||||
browserContext,
|
||||
close: async () => {
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
createCustomMessageHandler
|
||||
});
|
||||
122
.playwright-mcp/node_modules/playwright/lib/mcp/test/generatorTools.js
generated
vendored
Normal file
122
.playwright-mcp/node_modules/playwright/lib/mcp/test/generatorTools.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
"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 generatorTools_exports = {};
|
||||
__export(generatorTools_exports, {
|
||||
generatorReadLog: () => generatorReadLog,
|
||||
generatorWriteTest: () => generatorWriteTest,
|
||||
setupPage: () => setupPage
|
||||
});
|
||||
module.exports = __toCommonJS(generatorTools_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_path = __toESM(require("path"));
|
||||
var import_bundle = require("../sdk/bundle");
|
||||
var import_testTool = require("./testTool");
|
||||
var import_testContext = require("./testContext");
|
||||
const setupPage = (0, import_testTool.defineTestTool)({
|
||||
schema: {
|
||||
name: "generator_setup_page",
|
||||
title: "Setup generator page",
|
||||
description: "Setup the page for test.",
|
||||
inputSchema: import_bundle.z.object({
|
||||
plan: import_bundle.z.string().describe("The plan for the test. This should be the actual test plan with all the steps."),
|
||||
project: import_bundle.z.string().optional().describe('Project to use for setup. For example: "chromium", if no project is provided uses the first project in the config.'),
|
||||
seedFile: import_bundle.z.string().optional().describe('A seed file contains a single test that is used to setup the page for testing, for example: "tests/seed.spec.ts". If no seed file is provided, a default seed file is created.')
|
||||
}),
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (context, params) => {
|
||||
const seed = await context.getOrCreateSeedFile(params.seedFile, params.project);
|
||||
context.generatorJournal = new import_testContext.GeneratorJournal(context.rootPath, params.plan, seed);
|
||||
const { output, status } = await context.runSeedTest(seed.file, seed.projectName);
|
||||
return { content: [{ type: "text", text: output }], isError: status !== "paused" };
|
||||
}
|
||||
});
|
||||
const generatorReadLog = (0, import_testTool.defineTestTool)({
|
||||
schema: {
|
||||
name: "generator_read_log",
|
||||
title: "Retrieve test log",
|
||||
description: "Retrieve the performed test log",
|
||||
inputSchema: import_bundle.z.object({}),
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (context) => {
|
||||
if (!context.generatorJournal)
|
||||
throw new Error(`Please setup page using "${setupPage.schema.name}" first.`);
|
||||
const result = context.generatorJournal.journal();
|
||||
return { content: [{
|
||||
type: "text",
|
||||
text: result
|
||||
}] };
|
||||
}
|
||||
});
|
||||
const generatorWriteTest = (0, import_testTool.defineTestTool)({
|
||||
schema: {
|
||||
name: "generator_write_test",
|
||||
title: "Write test",
|
||||
description: "Write the generated test to the test file",
|
||||
inputSchema: import_bundle.z.object({
|
||||
fileName: import_bundle.z.string().describe("The file to write the test to"),
|
||||
code: import_bundle.z.string().describe("The generated test code")
|
||||
}),
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (context, params) => {
|
||||
if (!context.generatorJournal)
|
||||
throw new Error(`Please setup page using "${setupPage.schema.name}" first.`);
|
||||
const testRunner = context.existingTestRunner();
|
||||
if (!testRunner)
|
||||
throw new Error("No test runner found, please setup page and perform actions first.");
|
||||
const config = await testRunner.loadConfig();
|
||||
const dirs = [];
|
||||
for (const project of config.projects) {
|
||||
const testDir = import_path.default.relative(context.rootPath, project.project.testDir).replace(/\\/g, "/");
|
||||
const fileName = params.fileName.replace(/\\/g, "/");
|
||||
if (fileName.startsWith(testDir)) {
|
||||
const resolvedFile = import_path.default.resolve(context.rootPath, fileName);
|
||||
await import_fs.default.promises.mkdir(import_path.default.dirname(resolvedFile), { recursive: true });
|
||||
await import_fs.default.promises.writeFile(resolvedFile, params.code);
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
text: `### Result
|
||||
Test written to ${params.fileName}`
|
||||
}]
|
||||
};
|
||||
}
|
||||
dirs.push(testDir);
|
||||
}
|
||||
throw new Error(`Test file did not match any of the test dirs: ${dirs.join(", ")}`);
|
||||
}
|
||||
});
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
generatorReadLog,
|
||||
generatorWriteTest,
|
||||
setupPage
|
||||
});
|
||||
144
.playwright-mcp/node_modules/playwright/lib/mcp/test/plannerTools.js
generated
vendored
Normal file
144
.playwright-mcp/node_modules/playwright/lib/mcp/test/plannerTools.js
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
"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 plannerTools_exports = {};
|
||||
__export(plannerTools_exports, {
|
||||
saveTestPlan: () => saveTestPlan,
|
||||
setupPage: () => setupPage,
|
||||
submitTestPlan: () => submitTestPlan
|
||||
});
|
||||
module.exports = __toCommonJS(plannerTools_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_path = __toESM(require("path"));
|
||||
var import_bundle = require("../sdk/bundle");
|
||||
var import_testTool = require("./testTool");
|
||||
const setupPage = (0, import_testTool.defineTestTool)({
|
||||
schema: {
|
||||
name: "planner_setup_page",
|
||||
title: "Setup planner page",
|
||||
description: "Setup the page for test planning",
|
||||
inputSchema: import_bundle.z.object({
|
||||
project: import_bundle.z.string().optional().describe('Project to use for setup. For example: "chromium", if no project is provided uses the first project in the config.'),
|
||||
seedFile: import_bundle.z.string().optional().describe('A seed file contains a single test that is used to setup the page for testing, for example: "tests/seed.spec.ts". If no seed file is provided, a default seed file is created.')
|
||||
}),
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (context, params) => {
|
||||
const seed = await context.getOrCreateSeedFile(params.seedFile, params.project);
|
||||
const { output, status } = await context.runSeedTest(seed.file, seed.projectName);
|
||||
return { content: [{ type: "text", text: output }], isError: status !== "paused" };
|
||||
}
|
||||
});
|
||||
const planSchema = import_bundle.z.object({
|
||||
overview: import_bundle.z.string().describe("A brief overview of the application to be tested"),
|
||||
suites: import_bundle.z.array(import_bundle.z.object({
|
||||
name: import_bundle.z.string().describe("The name of the suite"),
|
||||
seedFile: import_bundle.z.string().describe("A seed file that was used to setup the page for testing."),
|
||||
tests: import_bundle.z.array(import_bundle.z.object({
|
||||
name: import_bundle.z.string().describe("The name of the test"),
|
||||
file: import_bundle.z.string().describe('The file the test should be saved to, for example: "tests/<suite-name>/<test-name>.spec.ts".'),
|
||||
steps: import_bundle.z.array(import_bundle.z.string().describe(`The steps to be executed to perform the test. For example: 'Click on the "Submit" button'`)),
|
||||
expectedResults: import_bundle.z.array(import_bundle.z.string().describe("The expected results of the steps for test to verify."))
|
||||
}))
|
||||
}))
|
||||
});
|
||||
const submitTestPlan = (0, import_testTool.defineTestTool)({
|
||||
schema: {
|
||||
name: "planner_submit_plan",
|
||||
title: "Submit test plan",
|
||||
description: "Submit the test plan to the test planner",
|
||||
inputSchema: planSchema,
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (context, params) => {
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
text: JSON.stringify(params, null, 2)
|
||||
}]
|
||||
};
|
||||
}
|
||||
});
|
||||
const saveTestPlan = (0, import_testTool.defineTestTool)({
|
||||
schema: {
|
||||
name: "planner_save_plan",
|
||||
title: "Save test plan as markdown file",
|
||||
description: "Save the test plan as a markdown file",
|
||||
inputSchema: planSchema.extend({
|
||||
name: import_bundle.z.string().describe('The name of the test plan, for example: "Test Plan".'),
|
||||
fileName: import_bundle.z.string().describe('The file to save the test plan to, for example: "spec/test.plan.md". Relative to the workspace root.')
|
||||
}),
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (context, params) => {
|
||||
const lines = [];
|
||||
lines.push(`# ${params.name}`);
|
||||
lines.push(``);
|
||||
lines.push(`## Application Overview`);
|
||||
lines.push(``);
|
||||
lines.push(params.overview);
|
||||
lines.push(``);
|
||||
lines.push(`## Test Scenarios`);
|
||||
for (let i = 0; i < params.suites.length; i++) {
|
||||
lines.push(``);
|
||||
const suite = params.suites[i];
|
||||
lines.push(`### ${i + 1}. ${suite.name}`);
|
||||
lines.push(``);
|
||||
lines.push(`**Seed:** \`${suite.seedFile}\``);
|
||||
for (let j = 0; j < suite.tests.length; j++) {
|
||||
lines.push(``);
|
||||
const test = suite.tests[j];
|
||||
lines.push(`#### ${i + 1}.${j + 1}. ${test.name}`);
|
||||
lines.push(``);
|
||||
lines.push(`**File:** \`${test.file}\``);
|
||||
lines.push(``);
|
||||
lines.push(`**Steps:**`);
|
||||
for (let k = 0; k < test.steps.length; k++)
|
||||
lines.push(` ${k + 1}. ${test.steps[k]}`);
|
||||
lines.push(``);
|
||||
lines.push(`**Expected Results:**`);
|
||||
for (const result of test.expectedResults)
|
||||
lines.push(` - ${result}`);
|
||||
}
|
||||
}
|
||||
lines.push(``);
|
||||
await import_fs.default.promises.writeFile(import_path.default.resolve(context.rootPath, params.fileName), lines.join("\n"));
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
text: `Test plan saved to ${params.fileName}`
|
||||
}]
|
||||
};
|
||||
}
|
||||
});
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
saveTestPlan,
|
||||
setupPage,
|
||||
submitTestPlan
|
||||
});
|
||||
82
.playwright-mcp/node_modules/playwright/lib/mcp/test/seed.js
generated
vendored
Normal file
82
.playwright-mcp/node_modules/playwright/lib/mcp/test/seed.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
"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 seed_exports = {};
|
||||
__export(seed_exports, {
|
||||
defaultSeedFile: () => defaultSeedFile,
|
||||
ensureSeedFile: () => ensureSeedFile,
|
||||
findSeedFile: () => findSeedFile,
|
||||
seedFileContent: () => seedFileContent,
|
||||
seedProject: () => seedProject
|
||||
});
|
||||
module.exports = __toCommonJS(seed_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_path = __toESM(require("path"));
|
||||
var import_utils = require("playwright-core/lib/utils");
|
||||
var import_projectUtils = require("../../runner/projectUtils");
|
||||
function seedProject(config, projectName) {
|
||||
if (!projectName)
|
||||
return (0, import_projectUtils.findTopLevelProjects)(config)[0];
|
||||
const project = config.projects.find((p) => p.project.name === projectName);
|
||||
if (!project)
|
||||
throw new Error(`Project ${projectName} not found`);
|
||||
return project;
|
||||
}
|
||||
async function findSeedFile(project) {
|
||||
const files = await (0, import_projectUtils.collectFilesForProject)(project);
|
||||
return files.find((file) => import_path.default.basename(file).includes("seed"));
|
||||
}
|
||||
function defaultSeedFile(project) {
|
||||
const testDir = project.project.testDir;
|
||||
return import_path.default.resolve(testDir, "seed.spec.ts");
|
||||
}
|
||||
async function ensureSeedFile(project) {
|
||||
const seedFile = await findSeedFile(project);
|
||||
if (seedFile)
|
||||
return seedFile;
|
||||
const seedFilePath = defaultSeedFile(project);
|
||||
await (0, import_utils.mkdirIfNeeded)(seedFilePath);
|
||||
await import_fs.default.promises.writeFile(seedFilePath, seedFileContent);
|
||||
return seedFilePath;
|
||||
}
|
||||
const seedFileContent = `import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Test group', () => {
|
||||
test('seed', async ({ page }) => {
|
||||
// generate code here.
|
||||
});
|
||||
});
|
||||
`;
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
defaultSeedFile,
|
||||
ensureSeedFile,
|
||||
findSeedFile,
|
||||
seedFileContent,
|
||||
seedProject
|
||||
});
|
||||
44
.playwright-mcp/node_modules/playwright/lib/mcp/test/streams.js
generated
vendored
Normal file
44
.playwright-mcp/node_modules/playwright/lib/mcp/test/streams.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
"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 streams_exports = {};
|
||||
__export(streams_exports, {
|
||||
StringWriteStream: () => StringWriteStream
|
||||
});
|
||||
module.exports = __toCommonJS(streams_exports);
|
||||
var import_stream = require("stream");
|
||||
var import_util = require("../../util");
|
||||
class StringWriteStream extends import_stream.Writable {
|
||||
constructor(output, stdio) {
|
||||
super();
|
||||
this._output = output;
|
||||
this._prefix = stdio === "stdout" ? "" : "[err] ";
|
||||
}
|
||||
_write(chunk, encoding, callback) {
|
||||
let text = (0, import_util.stripAnsiEscapes)(chunk.toString());
|
||||
if (text.endsWith("\n"))
|
||||
text = text.slice(0, -1);
|
||||
if (text)
|
||||
this._output.push(this._prefix + text);
|
||||
callback();
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
StringWriteStream
|
||||
});
|
||||
99
.playwright-mcp/node_modules/playwright/lib/mcp/test/testBackend.js
generated
vendored
Normal file
99
.playwright-mcp/node_modules/playwright/lib/mcp/test/testBackend.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
"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 testBackend_exports = {};
|
||||
__export(testBackend_exports, {
|
||||
TestServerBackend: () => TestServerBackend
|
||||
});
|
||||
module.exports = __toCommonJS(testBackend_exports);
|
||||
var mcp = __toESM(require("../sdk/exports"));
|
||||
var import_testContext = require("./testContext");
|
||||
var testTools = __toESM(require("./testTools.js"));
|
||||
var generatorTools = __toESM(require("./generatorTools.js"));
|
||||
var plannerTools = __toESM(require("./plannerTools.js"));
|
||||
var import_tools = require("../browser/tools");
|
||||
var import_bundle = require("../sdk/bundle");
|
||||
class TestServerBackend {
|
||||
constructor(configOption, options) {
|
||||
this.name = "Playwright";
|
||||
this.version = "0.0.1";
|
||||
this._tools = [
|
||||
plannerTools.saveTestPlan,
|
||||
plannerTools.setupPage,
|
||||
plannerTools.submitTestPlan,
|
||||
generatorTools.setupPage,
|
||||
generatorTools.generatorReadLog,
|
||||
generatorTools.generatorWriteTest,
|
||||
testTools.listTests,
|
||||
testTools.runTests,
|
||||
testTools.debugTest,
|
||||
...import_tools.browserTools.map((tool) => wrapBrowserTool(tool))
|
||||
];
|
||||
this._options = options || {};
|
||||
this._configOption = configOption;
|
||||
}
|
||||
async initialize(clientInfo) {
|
||||
this._context = new import_testContext.TestContext(clientInfo, this._configOption, this._options);
|
||||
}
|
||||
async listTools() {
|
||||
return this._tools.map((tool) => mcp.toMcpTool(tool.schema));
|
||||
}
|
||||
async callTool(name, args) {
|
||||
const tool = this._tools.find((tool2) => tool2.schema.name === name);
|
||||
if (!tool)
|
||||
throw new Error(`Tool not found: ${name}. Available tools: ${this._tools.map((tool2) => tool2.schema.name).join(", ")}`);
|
||||
try {
|
||||
return await tool.handle(this._context, tool.schema.inputSchema.parse(args || {}));
|
||||
} catch (e) {
|
||||
return { content: [{ type: "text", text: String(e) }], isError: true };
|
||||
}
|
||||
}
|
||||
serverClosed() {
|
||||
void this._context.close();
|
||||
}
|
||||
}
|
||||
const typesWithIntent = ["action", "assertion", "input"];
|
||||
function wrapBrowserTool(tool) {
|
||||
const inputSchema = typesWithIntent.includes(tool.schema.type) ? tool.schema.inputSchema.extend({
|
||||
intent: import_bundle.z.string().describe("The intent of the call, for example the test step description plan idea")
|
||||
}) : tool.schema.inputSchema;
|
||||
return {
|
||||
schema: {
|
||||
...tool.schema,
|
||||
inputSchema
|
||||
},
|
||||
handle: async (context, params) => {
|
||||
const response = await context.sendMessageToPausedTest({ callTool: { name: tool.schema.name, arguments: params } });
|
||||
return response.callTool;
|
||||
}
|
||||
};
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
TestServerBackend
|
||||
});
|
||||
279
.playwright-mcp/node_modules/playwright/lib/mcp/test/testContext.js
generated
vendored
Normal file
279
.playwright-mcp/node_modules/playwright/lib/mcp/test/testContext.js
generated
vendored
Normal file
@@ -0,0 +1,279 @@
|
||||
"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 testContext_exports = {};
|
||||
__export(testContext_exports, {
|
||||
GeneratorJournal: () => GeneratorJournal,
|
||||
TestContext: () => TestContext,
|
||||
createScreen: () => createScreen
|
||||
});
|
||||
module.exports = __toCommonJS(testContext_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_os = __toESM(require("os"));
|
||||
var import_path = __toESM(require("path"));
|
||||
var import_utils = require("playwright-core/lib/utils");
|
||||
var import_base = require("../../reporters/base");
|
||||
var import_list = __toESM(require("../../reporters/list"));
|
||||
var import_streams = require("./streams");
|
||||
var import_util = require("../../util");
|
||||
var import_testRunner = require("../../runner/testRunner");
|
||||
var import_seed = require("./seed");
|
||||
var import_exports = require("../sdk/exports");
|
||||
var import_configLoader = require("../../common/configLoader");
|
||||
var import_response = require("../browser/response");
|
||||
var import_log = require("../log");
|
||||
class GeneratorJournal {
|
||||
constructor(rootPath, plan, seed) {
|
||||
this._rootPath = rootPath;
|
||||
this._plan = plan;
|
||||
this._seed = seed;
|
||||
this._steps = [];
|
||||
}
|
||||
logStep(title, code) {
|
||||
if (title)
|
||||
this._steps.push({ title, code });
|
||||
}
|
||||
journal() {
|
||||
const result = [];
|
||||
result.push(`# Plan`);
|
||||
result.push(this._plan);
|
||||
result.push(`# Seed file: ${import_path.default.relative(this._rootPath, this._seed.file)}`);
|
||||
result.push("```ts");
|
||||
result.push(this._seed.content);
|
||||
result.push("```");
|
||||
result.push(`# Steps`);
|
||||
result.push(this._steps.map((step) => `### ${step.title}
|
||||
\`\`\`ts
|
||||
${step.code}
|
||||
\`\`\``).join("\n\n"));
|
||||
result.push(bestPracticesMarkdown);
|
||||
return result.join("\n\n");
|
||||
}
|
||||
}
|
||||
class TestContext {
|
||||
constructor(clientInfo, configPath, options) {
|
||||
this._clientInfo = clientInfo;
|
||||
const rootPath = (0, import_exports.firstRootPath)(clientInfo);
|
||||
this._configLocation = (0, import_configLoader.resolveConfigLocation)(configPath || rootPath);
|
||||
this.rootPath = rootPath || this._configLocation.configDir;
|
||||
if (options?.headless !== void 0)
|
||||
this.computedHeaded = !options.headless;
|
||||
else
|
||||
this.computedHeaded = !process.env.CI && !(import_os.default.platform() === "linux" && !process.env.DISPLAY);
|
||||
}
|
||||
existingTestRunner() {
|
||||
return this._testRunnerAndScreen?.testRunner;
|
||||
}
|
||||
async _cleanupTestRunner() {
|
||||
if (!this._testRunnerAndScreen)
|
||||
return;
|
||||
await this._testRunnerAndScreen.testRunner.stopTests();
|
||||
this._testRunnerAndScreen.claimStdio();
|
||||
try {
|
||||
await this._testRunnerAndScreen.testRunner.runGlobalTeardown();
|
||||
} finally {
|
||||
this._testRunnerAndScreen.releaseStdio();
|
||||
this._testRunnerAndScreen = void 0;
|
||||
}
|
||||
}
|
||||
async createTestRunner() {
|
||||
await this._cleanupTestRunner();
|
||||
const testRunner = new import_testRunner.TestRunner(this._configLocation, {});
|
||||
await testRunner.initialize({});
|
||||
const testPaused = new import_utils.ManualPromise();
|
||||
const testRunnerAndScreen = {
|
||||
...createScreen(),
|
||||
testRunner,
|
||||
waitForTestPaused: () => testPaused
|
||||
};
|
||||
this._testRunnerAndScreen = testRunnerAndScreen;
|
||||
testRunner.on(import_testRunner.TestRunnerEvent.TestPaused, (params) => {
|
||||
testRunnerAndScreen.sendMessageToPausedTest = params.sendMessage;
|
||||
testPaused.resolve();
|
||||
});
|
||||
return testRunnerAndScreen;
|
||||
}
|
||||
async getOrCreateSeedFile(seedFile, projectName) {
|
||||
const configDir = this._configLocation.configDir;
|
||||
const { testRunner } = await this.createTestRunner();
|
||||
const config = await testRunner.loadConfig();
|
||||
const project = (0, import_seed.seedProject)(config, projectName);
|
||||
if (!seedFile) {
|
||||
seedFile = await (0, import_seed.ensureSeedFile)(project);
|
||||
} else {
|
||||
const candidateFiles = [];
|
||||
const testDir = project.project.testDir;
|
||||
candidateFiles.push(import_path.default.resolve(testDir, seedFile));
|
||||
candidateFiles.push(import_path.default.resolve(configDir, seedFile));
|
||||
candidateFiles.push(import_path.default.resolve(this.rootPath, seedFile));
|
||||
let resolvedSeedFile;
|
||||
for (const candidateFile of candidateFiles) {
|
||||
if (await (0, import_util.fileExistsAsync)(candidateFile)) {
|
||||
resolvedSeedFile = candidateFile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!resolvedSeedFile)
|
||||
throw new Error("seed test not found.");
|
||||
seedFile = resolvedSeedFile;
|
||||
}
|
||||
const seedFileContent = await import_fs.default.promises.readFile(seedFile, "utf8");
|
||||
return {
|
||||
file: seedFile,
|
||||
content: seedFileContent,
|
||||
projectName: project.project.name
|
||||
};
|
||||
}
|
||||
async runSeedTest(seedFile, projectName) {
|
||||
const result = await this.runTestsWithGlobalSetupAndPossiblePause({
|
||||
headed: this.computedHeaded,
|
||||
locations: ["/" + (0, import_utils.escapeRegExp)(seedFile) + "/"],
|
||||
projects: [projectName],
|
||||
timeout: 0,
|
||||
workers: 1,
|
||||
pauseAtEnd: true,
|
||||
disableConfigReporters: true,
|
||||
failOnLoadErrors: true
|
||||
});
|
||||
if (result.status === "passed")
|
||||
result.output += "\nError: seed test not found.";
|
||||
else if (result.status !== "paused")
|
||||
result.output += "\nError while running the seed test.";
|
||||
return result;
|
||||
}
|
||||
async runTestsWithGlobalSetupAndPossiblePause(params) {
|
||||
const configDir = this._configLocation.configDir;
|
||||
const testRunnerAndScreen = await this.createTestRunner();
|
||||
const { testRunner, screen, claimStdio, releaseStdio } = testRunnerAndScreen;
|
||||
claimStdio();
|
||||
try {
|
||||
const setupReporter = new import_list.default({ configDir, screen, includeTestId: true });
|
||||
const { status: status2 } = await testRunner.runGlobalSetup([setupReporter]);
|
||||
if (status2 !== "passed")
|
||||
return { output: testRunnerAndScreen.output.join("\n"), status: status2 };
|
||||
} finally {
|
||||
releaseStdio();
|
||||
}
|
||||
let status = "passed";
|
||||
const cleanup = async () => {
|
||||
claimStdio();
|
||||
try {
|
||||
const result = await testRunner.runGlobalTeardown();
|
||||
if (status === "passed")
|
||||
status = result.status;
|
||||
} finally {
|
||||
releaseStdio();
|
||||
}
|
||||
};
|
||||
try {
|
||||
const reporter = new import_list.default({ configDir, screen, includeTestId: true });
|
||||
status = await Promise.race([
|
||||
testRunner.runTests(reporter, params).then((result) => result.status),
|
||||
testRunnerAndScreen.waitForTestPaused().then(() => "paused")
|
||||
]);
|
||||
if (status === "paused") {
|
||||
const response = await testRunnerAndScreen.sendMessageToPausedTest({ request: { initialize: { clientInfo: this._clientInfo } } });
|
||||
if (response.error)
|
||||
throw new Error(response.error.message);
|
||||
testRunnerAndScreen.output.push(response.response.initialize.pausedMessage);
|
||||
return { output: testRunnerAndScreen.output.join("\n"), status };
|
||||
}
|
||||
} catch (e) {
|
||||
status = "failed";
|
||||
testRunnerAndScreen.output.push(String(e));
|
||||
await cleanup();
|
||||
return { output: testRunnerAndScreen.output.join("\n"), status };
|
||||
}
|
||||
await cleanup();
|
||||
return { output: testRunnerAndScreen.output.join("\n"), status };
|
||||
}
|
||||
async close() {
|
||||
await this._cleanupTestRunner().catch(import_log.logUnhandledError);
|
||||
}
|
||||
async sendMessageToPausedTest(request) {
|
||||
const sendMessage = this._testRunnerAndScreen?.sendMessageToPausedTest;
|
||||
if (!sendMessage)
|
||||
throw new Error("Must setup test before interacting with the page");
|
||||
const result = await sendMessage({ request });
|
||||
if (result.error)
|
||||
throw new Error(result.error.message);
|
||||
if (typeof request?.callTool?.arguments?.["intent"] === "string") {
|
||||
const response = (0, import_response.parseResponse)(result.response.callTool);
|
||||
if (response && !response.isError && response.code)
|
||||
this.generatorJournal?.logStep(request.callTool.arguments["intent"], response.code);
|
||||
}
|
||||
return result.response;
|
||||
}
|
||||
}
|
||||
function createScreen() {
|
||||
const output = [];
|
||||
const stdout = new import_streams.StringWriteStream(output, "stdout");
|
||||
const stderr = new import_streams.StringWriteStream(output, "stderr");
|
||||
const screen = {
|
||||
...import_base.terminalScreen,
|
||||
isTTY: false,
|
||||
colors: import_utils.noColors,
|
||||
stdout,
|
||||
stderr
|
||||
};
|
||||
const originalStdoutWrite = process.stdout.write;
|
||||
const originalStderrWrite = process.stderr.write;
|
||||
const claimStdio = () => {
|
||||
process.stdout.write = (chunk) => {
|
||||
stdout.write(chunk);
|
||||
return true;
|
||||
};
|
||||
process.stderr.write = (chunk) => {
|
||||
stderr.write(chunk);
|
||||
return true;
|
||||
};
|
||||
};
|
||||
const releaseStdio = () => {
|
||||
process.stdout.write = originalStdoutWrite;
|
||||
process.stderr.write = originalStderrWrite;
|
||||
};
|
||||
return { screen, claimStdio, releaseStdio, output };
|
||||
}
|
||||
const bestPracticesMarkdown = `
|
||||
# Best practices
|
||||
- Do not improvise, do not add directives that were not asked for
|
||||
- Use clear, descriptive assertions to validate the expected behavior
|
||||
- Use reliable locators from this log
|
||||
- Use local variables for locators that are used multiple times
|
||||
- Use Playwright waiting assertions and best practices from this log
|
||||
- NEVER! use page.waitForLoadState()
|
||||
- NEVER! use page.waitForNavigation()
|
||||
- NEVER! use page.waitForTimeout()
|
||||
- NEVER! use page.evaluate()
|
||||
`;
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
GeneratorJournal,
|
||||
TestContext,
|
||||
createScreen
|
||||
});
|
||||
30
.playwright-mcp/node_modules/playwright/lib/mcp/test/testTool.js
generated
vendored
Normal file
30
.playwright-mcp/node_modules/playwright/lib/mcp/test/testTool.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 __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 testTool_exports = {};
|
||||
__export(testTool_exports, {
|
||||
defineTestTool: () => defineTestTool
|
||||
});
|
||||
module.exports = __toCommonJS(testTool_exports);
|
||||
function defineTestTool(tool) {
|
||||
return tool;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
defineTestTool
|
||||
});
|
||||
106
.playwright-mcp/node_modules/playwright/lib/mcp/test/testTools.js
generated
vendored
Normal file
106
.playwright-mcp/node_modules/playwright/lib/mcp/test/testTools.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
"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 testTools_exports = {};
|
||||
__export(testTools_exports, {
|
||||
debugTest: () => debugTest,
|
||||
listTests: () => listTests,
|
||||
runTests: () => runTests
|
||||
});
|
||||
module.exports = __toCommonJS(testTools_exports);
|
||||
var import_bundle = require("../sdk/bundle");
|
||||
var import_listModeReporter = __toESM(require("../../reporters/listModeReporter"));
|
||||
var import_testTool = require("./testTool");
|
||||
const listTests = (0, import_testTool.defineTestTool)({
|
||||
schema: {
|
||||
name: "test_list",
|
||||
title: "List tests",
|
||||
description: "List tests",
|
||||
inputSchema: import_bundle.z.object({}),
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (context) => {
|
||||
const { testRunner, screen, output } = await context.createTestRunner();
|
||||
const reporter = new import_listModeReporter.default({ screen, includeTestId: true });
|
||||
await testRunner.listTests(reporter, {});
|
||||
return { content: output.map((text) => ({ type: "text", text })) };
|
||||
}
|
||||
});
|
||||
const runTests = (0, import_testTool.defineTestTool)({
|
||||
schema: {
|
||||
name: "test_run",
|
||||
title: "Run tests",
|
||||
description: "Run tests",
|
||||
inputSchema: import_bundle.z.object({
|
||||
locations: import_bundle.z.array(import_bundle.z.string()).optional().describe('Folder, file or location to run: "test/e2e" or "test/e2e/file.spec.ts" or "test/e2e/file.spec.ts:20"'),
|
||||
projects: import_bundle.z.array(import_bundle.z.string()).optional().describe('Projects to run, projects from playwright.config.ts, by default runs all projects. Running with "chromium" is a good start')
|
||||
}),
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (context, params) => {
|
||||
const { output } = await context.runTestsWithGlobalSetupAndPossiblePause({
|
||||
locations: params.locations,
|
||||
projects: params.projects,
|
||||
disableConfigReporters: true
|
||||
});
|
||||
return { content: [{ type: "text", text: output }] };
|
||||
}
|
||||
});
|
||||
const debugTest = (0, import_testTool.defineTestTool)({
|
||||
schema: {
|
||||
name: "test_debug",
|
||||
title: "Debug single test",
|
||||
description: "Debug single test",
|
||||
inputSchema: import_bundle.z.object({
|
||||
test: import_bundle.z.object({
|
||||
id: import_bundle.z.string().describe("Test ID to debug."),
|
||||
title: import_bundle.z.string().describe("Human readable test title for granting permission to debug the test.")
|
||||
})
|
||||
}),
|
||||
type: "readOnly"
|
||||
},
|
||||
handle: async (context, params) => {
|
||||
const { output, status } = await context.runTestsWithGlobalSetupAndPossiblePause({
|
||||
headed: context.computedHeaded,
|
||||
testIds: [params.test.id],
|
||||
// For automatic recovery
|
||||
timeout: 0,
|
||||
workers: 1,
|
||||
pauseOnError: true,
|
||||
disableConfigReporters: true,
|
||||
actionTimeout: 5e3
|
||||
});
|
||||
return { content: [{ type: "text", text: output }], isError: status !== "paused" && status !== "passed" };
|
||||
}
|
||||
});
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
debugTest,
|
||||
listTests,
|
||||
runTests
|
||||
});
|
||||
Reference in New Issue
Block a user