Enhance refactor commands with controller-aware Route() updates and fix code quality violations
Add semantic token highlighting for 'that' variable and comment file references in VS Code extension Add Phone_Text_Input and Currency_Input components with formatting utilities Implement client widgets, form standardization, and soft delete functionality Add modal scroll lock and update documentation Implement comprehensive modal system with form integration and validation Fix modal component instantiation using jQuery plugin API Implement modal system with responsive sizing, queuing, and validation support Implement form submission with validation, error handling, and loading states Implement country/state selectors with dynamic data loading and Bootstrap styling Revert Rsx::Route() highlighting in Blade/PHP files Target specific PHP scopes for Rsx::Route() highlighting in Blade Expand injection selector for Rsx::Route() highlighting Add custom syntax highlighting for Rsx::Route() and Rsx.Route() calls Update jqhtml packages to v2.2.165 Add bundle path validation for common mistakes (development mode only) Create Ajax_Select_Input widget and Rsx_Reference_Data controller Create Country_Select_Input widget with default country support Initialize Tom Select on Select_Input widgets Add Tom Select bundle for enhanced select dropdowns Implement ISO 3166 geographic data system for country/region selection Implement widget-based form system with disabled state support 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
98
node_modules/playwright/lib/mcp/test/browserBackend.js
generated
vendored
Executable file
98
node_modules/playwright/lib/mcp/test/browserBackend.js
generated
vendored
Executable file
@@ -0,0 +1,98 @@
|
||||
"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 browserBackend_exports = {};
|
||||
__export(browserBackend_exports, {
|
||||
runBrowserBackendAtEnd: () => runBrowserBackendAtEnd
|
||||
});
|
||||
module.exports = __toCommonJS(browserBackend_exports);
|
||||
var mcp = __toESM(require("../sdk/exports"));
|
||||
var import_globals = require("../../common/globals");
|
||||
var import_util = require("../../util");
|
||||
var import_config = require("../browser/config");
|
||||
var import_browserServerBackend = require("../browser/browserServerBackend");
|
||||
var import_tab = require("../browser/tab");
|
||||
async function runBrowserBackendAtEnd(context, errorMessage) {
|
||||
const testInfo = (0, import_globals.currentTestInfo)();
|
||||
if (!testInfo)
|
||||
return;
|
||||
const shouldPause = errorMessage ? testInfo?._pauseOnError() : testInfo?._pauseAtEnd();
|
||||
if (!shouldPause)
|
||||
return;
|
||||
const lines = [];
|
||||
if (errorMessage)
|
||||
lines.push(`### Paused on error:`, (0, import_util.stripAnsiEscapes)(errorMessage));
|
||||
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 = errorMessage ? 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(),
|
||||
"```"
|
||||
);
|
||||
}
|
||||
lines.push("");
|
||||
if (errorMessage)
|
||||
lines.push(`### Task`, `Try recovering from the error prior to continuing`);
|
||||
const config = {
|
||||
...import_config.defaultConfig,
|
||||
capabilities: ["testing"]
|
||||
};
|
||||
await mcp.runOnPauseBackendLoop(new import_browserServerBackend.BrowserServerBackend(config, identityFactory(context)), 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 = {
|
||||
runBrowserBackendAtEnd
|
||||
});
|
||||
122
node_modules/playwright/lib/mcp/test/generatorTools.js
generated
vendored
Executable file
122
node_modules/playwright/lib/mcp/test/generatorTools.js
generated
vendored
Executable 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, progress) => {
|
||||
const seed = await context.getOrCreateSeedFile(params.seedFile, params.project);
|
||||
context.generatorJournal = new import_testContext.GeneratorJournal(context.rootPath, params.plan, seed);
|
||||
await context.runSeedTest(seed.file, seed.projectName, progress);
|
||||
return { content: [] };
|
||||
}
|
||||
});
|
||||
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
|
||||
});
|
||||
46
node_modules/playwright/lib/mcp/test/plannerTools.js
generated
vendored
Executable file
46
node_modules/playwright/lib/mcp/test/plannerTools.js
generated
vendored
Executable file
@@ -0,0 +1,46 @@
|
||||
"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 plannerTools_exports = {};
|
||||
__export(plannerTools_exports, {
|
||||
setupPage: () => setupPage
|
||||
});
|
||||
module.exports = __toCommonJS(plannerTools_exports);
|
||||
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, progress) => {
|
||||
const seed = await context.getOrCreateSeedFile(params.seedFile, params.project);
|
||||
await context.runSeedTest(seed.file, seed.projectName, progress);
|
||||
return { content: [] };
|
||||
}
|
||||
});
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
setupPage
|
||||
});
|
||||
72
node_modules/playwright/lib/mcp/test/seed.js
generated
vendored
Executable file
72
node_modules/playwright/lib/mcp/test/seed.js
generated
vendored
Executable file
@@ -0,0 +1,72 @@
|
||||
"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, {
|
||||
ensureSeedTest: () => ensureSeedTest,
|
||||
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 ensureSeedTest(project, logNew) {
|
||||
const files = await (0, import_projectUtils.collectFilesForProject)(project);
|
||||
const seed = files.find((file) => import_path.default.basename(file).includes("seed"));
|
||||
if (seed)
|
||||
return seed;
|
||||
const testDir = project.project.testDir;
|
||||
const seedFile = import_path.default.resolve(testDir, "seed.spec.ts");
|
||||
if (logNew) {
|
||||
console.log(`Writing file: ${import_path.default.relative(process.cwd(), seedFile)}`);
|
||||
}
|
||||
await (0, import_utils.mkdirIfNeeded)(seedFile);
|
||||
await import_fs.default.promises.writeFile(seedFile, `import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Test group', () => {
|
||||
test('seed', async ({ page }) => {
|
||||
// generate code here.
|
||||
});
|
||||
});
|
||||
`);
|
||||
return seedFile;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
ensureSeedTest,
|
||||
seedProject
|
||||
});
|
||||
39
node_modules/playwright/lib/mcp/test/streams.js
generated
vendored
Executable file
39
node_modules/playwright/lib/mcp/test/streams.js
generated
vendored
Executable file
@@ -0,0 +1,39 @@
|
||||
"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");
|
||||
class StringWriteStream extends import_stream.Writable {
|
||||
constructor(progress) {
|
||||
super();
|
||||
this._progress = progress;
|
||||
}
|
||||
_write(chunk, encoding, callback) {
|
||||
const text = chunk.toString();
|
||||
this._progress({ message: text.endsWith("\n") ? text.slice(0, -1) : text });
|
||||
callback();
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
StringWriteStream
|
||||
});
|
||||
97
node_modules/playwright/lib/mcp/test/testBackend.js
generated
vendored
Executable file
97
node_modules/playwright/lib/mcp/test/testBackend.js
generated
vendored
Executable file
@@ -0,0 +1,97 @@
|
||||
"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_configLoader = require("../../common/configLoader");
|
||||
var import_response = require("../browser/response");
|
||||
class TestServerBackend {
|
||||
constructor(configOption, options) {
|
||||
this.name = "Playwright";
|
||||
this.version = "0.0.1";
|
||||
this._tools = [
|
||||
plannerTools.setupPage,
|
||||
generatorTools.setupPage,
|
||||
generatorTools.generatorReadLog,
|
||||
generatorTools.generatorWriteTest,
|
||||
testTools.listTests,
|
||||
testTools.runTests,
|
||||
testTools.debugTest
|
||||
];
|
||||
this._context = new import_testContext.TestContext(options);
|
||||
this._configOption = configOption;
|
||||
}
|
||||
async initialize(server, clientInfo) {
|
||||
const rootPath = mcp.firstRootPath(clientInfo);
|
||||
if (this._configOption) {
|
||||
this._context.initialize(rootPath, (0, import_configLoader.resolveConfigLocation)(this._configOption));
|
||||
return;
|
||||
}
|
||||
if (rootPath) {
|
||||
this._context.initialize(rootPath, (0, import_configLoader.resolveConfigLocation)(rootPath));
|
||||
return;
|
||||
}
|
||||
this._context.initialize(rootPath, (0, import_configLoader.resolveConfigLocation)(void 0));
|
||||
}
|
||||
async listTools() {
|
||||
return [
|
||||
...this._tools.map((tool) => mcp.toMcpTool(tool.schema)),
|
||||
...import_tools.browserTools.map((tool) => mcp.toMcpTool(tool.schema, { addIntent: true }))
|
||||
];
|
||||
}
|
||||
async afterCallTool(name, args, result) {
|
||||
if (!import_tools.browserTools.find((tool) => tool.schema.name === name))
|
||||
return;
|
||||
const response = (0, import_response.parseResponse)(result);
|
||||
if (response && !response.isError && response.code && typeof args?.["intent"] === "string")
|
||||
this._context.generatorJournal?.logStep(args["intent"], response.code);
|
||||
}
|
||||
async callTool(name, args, progress) {
|
||||
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(", ")}`);
|
||||
const parsedArguments = tool.schema.inputSchema.parse(args || {});
|
||||
return await tool.handle(this._context, parsedArguments, progress);
|
||||
}
|
||||
serverClosed() {
|
||||
void this._context.close();
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
TestServerBackend
|
||||
});
|
||||
176
node_modules/playwright/lib/mcp/test/testContext.js
generated
vendored
Executable file
176
node_modules/playwright/lib/mcp/test/testContext.js
generated
vendored
Executable file
@@ -0,0 +1,176 @@
|
||||
"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
|
||||
});
|
||||
module.exports = __toCommonJS(testContext_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
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");
|
||||
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(options) {
|
||||
this.options = options;
|
||||
}
|
||||
initialize(rootPath, configLocation) {
|
||||
this.configLocation = configLocation;
|
||||
this.rootPath = rootPath || configLocation.configDir;
|
||||
}
|
||||
existingTestRunner() {
|
||||
return this._testRunner;
|
||||
}
|
||||
async createTestRunner() {
|
||||
if (this._testRunner)
|
||||
await this._testRunner.stopTests();
|
||||
const testRunner = new import_testRunner.TestRunner(this.configLocation, {});
|
||||
await testRunner.initialize({});
|
||||
this._testRunner = testRunner;
|
||||
testRunner.on(import_testRunner.TestRunnerEvent.TestFilesChanged, (testFiles) => {
|
||||
this._testRunner?.emit(import_testRunner.TestRunnerEvent.TestFilesChanged, testFiles);
|
||||
});
|
||||
this._testRunner = testRunner;
|
||||
return testRunner;
|
||||
}
|
||||
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.ensureSeedTest)(project, false);
|
||||
} 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, progress) {
|
||||
const { screen } = this.createScreen(progress);
|
||||
const configDir = this.configLocation.configDir;
|
||||
const reporter = new import_list.default({ configDir, screen });
|
||||
const testRunner = await this.createTestRunner();
|
||||
const result = await testRunner.runTests(reporter, {
|
||||
headed: !this.options?.headless,
|
||||
locations: ["/" + (0, import_utils.escapeRegExp)(seedFile) + "/"],
|
||||
projects: [projectName],
|
||||
timeout: 0,
|
||||
workers: 1,
|
||||
pauseAtEnd: true,
|
||||
disableConfigReporters: true,
|
||||
failOnLoadErrors: true
|
||||
});
|
||||
if (result.status === "passed" && !reporter.suite?.allTests().length)
|
||||
throw new Error("seed test not found.");
|
||||
if (result.status !== "passed")
|
||||
throw new Error("Errors while running the seed test.");
|
||||
}
|
||||
createScreen(progress) {
|
||||
const stream = new import_streams.StringWriteStream(progress);
|
||||
const screen = {
|
||||
...import_base.terminalScreen,
|
||||
isTTY: false,
|
||||
colors: import_utils.noColors,
|
||||
stdout: stream,
|
||||
stderr: stream
|
||||
};
|
||||
return { screen, stream };
|
||||
}
|
||||
async close() {
|
||||
}
|
||||
}
|
||||
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
|
||||
});
|
||||
30
node_modules/playwright/lib/mcp/test/testTool.js
generated
vendored
Executable file
30
node_modules/playwright/lib/mcp/test/testTool.js
generated
vendored
Executable 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
|
||||
});
|
||||
115
node_modules/playwright/lib/mcp/test/testTools.js
generated
vendored
Executable file
115
node_modules/playwright/lib/mcp/test/testTools.js
generated
vendored
Executable file
@@ -0,0 +1,115 @@
|
||||
"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_list = __toESM(require("../../reporters/list"));
|
||||
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, _, progress) => {
|
||||
const { screen } = context.createScreen(progress);
|
||||
const reporter = new import_listModeReporter.default({ screen, includeTestId: true });
|
||||
const testRunner = await context.createTestRunner();
|
||||
await testRunner.listTests(reporter, {});
|
||||
return { content: [] };
|
||||
}
|
||||
});
|
||||
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, progress) => {
|
||||
const { screen } = context.createScreen(progress);
|
||||
const configDir = context.configLocation.configDir;
|
||||
const reporter = new import_list.default({ configDir, screen, includeTestId: true, prefixStdio: "out" });
|
||||
const testRunner = await context.createTestRunner();
|
||||
await testRunner.runTests(reporter, {
|
||||
locations: params.locations,
|
||||
projects: params.projects,
|
||||
disableConfigReporters: true
|
||||
});
|
||||
return { content: [] };
|
||||
}
|
||||
});
|
||||
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, progress) => {
|
||||
const { screen } = context.createScreen(progress);
|
||||
const configDir = context.configLocation.configDir;
|
||||
const reporter = new import_list.default({ configDir, screen, includeTestId: true, prefixStdio: "out" });
|
||||
const testRunner = await context.createTestRunner();
|
||||
await testRunner.runTests(reporter, {
|
||||
headed: !context.options?.headless,
|
||||
testIds: [params.test.id],
|
||||
// For automatic recovery
|
||||
timeout: 0,
|
||||
workers: 1,
|
||||
pauseOnError: true,
|
||||
disableConfigReporters: true
|
||||
});
|
||||
return { content: [] };
|
||||
}
|
||||
});
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
debugTest,
|
||||
listTests,
|
||||
runTests
|
||||
});
|
||||
Reference in New Issue
Block a user