Add SPA session validation and buglist, update migration docs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-12-03 21:28:08 +00:00
parent 9be3dfc14e
commit cff287e870
24169 changed files with 10223 additions and 7120 deletions

60
node_modules/playwright/lib/mcp/test/testBackend.js generated vendored Normal file → Executable file
View File

@@ -37,60 +37,62 @@ 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");
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
testTools.debugTest,
...import_tools.browserTools.map((tool) => wrapBrowserTool(tool))
];
this._context = new import_testContext.TestContext(options);
this._options = 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 initialize(clientInfo) {
this._context = new import_testContext.TestContext(clientInfo, this._configOption, this._options);
}
async listTools() {
return [
...this._tools.map((tool) => mcp.toMcpTool(tool.schema)),
...import_tools.browserTools.map((tool) => mcp.toMcpTool(tool.schema, { addIntent: true }))
];
return this._tools.map((tool) => mcp.toMcpTool(tool.schema));
}
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) {
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(", ")}`);
const parsedArguments = tool.schema.inputSchema.parse(args || {});
return await tool.handle(this._context, parsedArguments, progress);
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