|
f7eb47b…
|
lmata
|
1 |
"use strict"; |
|
f7eb47b…
|
lmata
|
2 |
var __create = Object.create; |
|
f7eb47b…
|
lmata
|
3 |
var __defProp = Object.defineProperty; |
|
f7eb47b…
|
lmata
|
4 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
|
f7eb47b…
|
lmata
|
5 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
|
f7eb47b…
|
lmata
|
6 |
var __getProtoOf = Object.getPrototypeOf; |
|
f7eb47b…
|
lmata
|
7 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
|
f7eb47b…
|
lmata
|
8 |
var __export = (target, all) => { |
|
f7eb47b…
|
lmata
|
9 |
for (var name in all) |
|
f7eb47b…
|
lmata
|
10 |
__defProp(target, name, { get: all[name], enumerable: true }); |
|
f7eb47b…
|
lmata
|
11 |
}; |
|
f7eb47b…
|
lmata
|
12 |
var __copyProps = (to, from, except, desc) => { |
|
f7eb47b…
|
lmata
|
13 |
if (from && typeof from === "object" || typeof from === "function") { |
|
f7eb47b…
|
lmata
|
14 |
for (let key of __getOwnPropNames(from)) |
|
f7eb47b…
|
lmata
|
15 |
if (!__hasOwnProp.call(to, key) && key !== except) |
|
f7eb47b…
|
lmata
|
16 |
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
|
f7eb47b…
|
lmata
|
17 |
} |
|
f7eb47b…
|
lmata
|
18 |
return to; |
|
f7eb47b…
|
lmata
|
19 |
}; |
|
f7eb47b…
|
lmata
|
20 |
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
|
f7eb47b…
|
lmata
|
21 |
// If the importer is in node compatibility mode or this is not an ESM |
|
f7eb47b…
|
lmata
|
22 |
// file that has been converted to a CommonJS file using a Babel- |
|
f7eb47b…
|
lmata
|
23 |
// compatible transform (i.e. "__esModule" has not been set), then set |
|
f7eb47b…
|
lmata
|
24 |
// "default" to the CommonJS "module.exports" for node compatibility. |
|
f7eb47b…
|
lmata
|
25 |
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
|
f7eb47b…
|
lmata
|
26 |
mod |
|
f7eb47b…
|
lmata
|
27 |
)); |
|
f7eb47b…
|
lmata
|
28 |
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
|
f7eb47b…
|
lmata
|
29 |
var plannerTools_exports = {}; |
|
f7eb47b…
|
lmata
|
30 |
__export(plannerTools_exports, { |
|
f7eb47b…
|
lmata
|
31 |
saveTestPlan: () => saveTestPlan, |
|
f7eb47b…
|
lmata
|
32 |
setupPage: () => setupPage, |
|
f7eb47b…
|
lmata
|
33 |
submitTestPlan: () => submitTestPlan |
|
f7eb47b…
|
lmata
|
34 |
}); |
|
f7eb47b…
|
lmata
|
35 |
module.exports = __toCommonJS(plannerTools_exports); |
|
f7eb47b…
|
lmata
|
36 |
var import_fs = __toESM(require("fs")); |
|
f7eb47b…
|
lmata
|
37 |
var import_path = __toESM(require("path")); |
|
f7eb47b…
|
lmata
|
38 |
var import_mcpBundle = require("playwright-core/lib/mcpBundle"); |
|
f7eb47b…
|
lmata
|
39 |
var import_testTool = require("./testTool"); |
|
f7eb47b…
|
lmata
|
40 |
const setupPage = (0, import_testTool.defineTestTool)({ |
|
f7eb47b…
|
lmata
|
41 |
schema: { |
|
f7eb47b…
|
lmata
|
42 |
name: "planner_setup_page", |
|
f7eb47b…
|
lmata
|
43 |
title: "Setup planner page", |
|
f7eb47b…
|
lmata
|
44 |
description: "Setup the page for test planning", |
|
f7eb47b…
|
lmata
|
45 |
inputSchema: import_mcpBundle.z.object({ |
|
f7eb47b…
|
lmata
|
46 |
project: import_mcpBundle.z.string().optional().describe('Project to use for setup. For example: "chromium", if no project is provided uses the first project in the config.'), |
|
f7eb47b…
|
lmata
|
47 |
seedFile: import_mcpBundle.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.') |
|
f7eb47b…
|
lmata
|
48 |
}), |
|
f7eb47b…
|
lmata
|
49 |
type: "readOnly" |
|
f7eb47b…
|
lmata
|
50 |
}, |
|
f7eb47b…
|
lmata
|
51 |
handle: async (context, params) => { |
|
f7eb47b…
|
lmata
|
52 |
const seed = await context.getOrCreateSeedFile(params.seedFile, params.project); |
|
f7eb47b…
|
lmata
|
53 |
const { output, status } = await context.runSeedTest(seed.file, seed.projectName); |
|
f7eb47b…
|
lmata
|
54 |
return { content: [{ type: "text", text: output }], isError: status !== "paused" }; |
|
f7eb47b…
|
lmata
|
55 |
} |
|
f7eb47b…
|
lmata
|
56 |
}); |
|
f7eb47b…
|
lmata
|
57 |
const planSchema = import_mcpBundle.z.object({ |
|
f7eb47b…
|
lmata
|
58 |
overview: import_mcpBundle.z.string().describe("A brief overview of the application to be tested"), |
|
f7eb47b…
|
lmata
|
59 |
suites: import_mcpBundle.z.array(import_mcpBundle.z.object({ |
|
f7eb47b…
|
lmata
|
60 |
name: import_mcpBundle.z.string().describe("The name of the suite"), |
|
f7eb47b…
|
lmata
|
61 |
seedFile: import_mcpBundle.z.string().describe("A seed file that was used to setup the page for testing."), |
|
f7eb47b…
|
lmata
|
62 |
tests: import_mcpBundle.z.array(import_mcpBundle.z.object({ |
|
f7eb47b…
|
lmata
|
63 |
name: import_mcpBundle.z.string().describe("The name of the test"), |
|
f7eb47b…
|
lmata
|
64 |
file: import_mcpBundle.z.string().describe('The file the test should be saved to, for example: "tests/<suite-name>/<test-name>.spec.ts".'), |
|
f7eb47b…
|
lmata
|
65 |
steps: import_mcpBundle.z.array(import_mcpBundle.z.object({ |
|
f7eb47b…
|
lmata
|
66 |
perform: import_mcpBundle.z.string().optional().describe(`Action to perform. For example: 'Click on the "Submit" button'.`), |
|
f7eb47b…
|
lmata
|
67 |
expect: import_mcpBundle.z.string().array().describe(`Expected result of the action where appropriate. For example: 'The page should show the "Thank you for your submission" message'`) |
|
f7eb47b…
|
lmata
|
68 |
})) |
|
f7eb47b…
|
lmata
|
69 |
})) |
|
f7eb47b…
|
lmata
|
70 |
})) |
|
f7eb47b…
|
lmata
|
71 |
}); |
|
f7eb47b…
|
lmata
|
72 |
const submitTestPlan = (0, import_testTool.defineTestTool)({ |
|
f7eb47b…
|
lmata
|
73 |
schema: { |
|
f7eb47b…
|
lmata
|
74 |
name: "planner_submit_plan", |
|
f7eb47b…
|
lmata
|
75 |
title: "Submit test plan", |
|
f7eb47b…
|
lmata
|
76 |
description: "Submit the test plan to the test planner", |
|
f7eb47b…
|
lmata
|
77 |
inputSchema: planSchema, |
|
f7eb47b…
|
lmata
|
78 |
type: "readOnly" |
|
f7eb47b…
|
lmata
|
79 |
}, |
|
f7eb47b…
|
lmata
|
80 |
handle: async (context, params) => { |
|
f7eb47b…
|
lmata
|
81 |
return { |
|
f7eb47b…
|
lmata
|
82 |
content: [{ |
|
f7eb47b…
|
lmata
|
83 |
type: "text", |
|
f7eb47b…
|
lmata
|
84 |
text: JSON.stringify(params, null, 2) |
|
f7eb47b…
|
lmata
|
85 |
}] |
|
f7eb47b…
|
lmata
|
86 |
}; |
|
f7eb47b…
|
lmata
|
87 |
} |
|
f7eb47b…
|
lmata
|
88 |
}); |
|
f7eb47b…
|
lmata
|
89 |
const saveTestPlan = (0, import_testTool.defineTestTool)({ |
|
f7eb47b…
|
lmata
|
90 |
schema: { |
|
f7eb47b…
|
lmata
|
91 |
name: "planner_save_plan", |
|
f7eb47b…
|
lmata
|
92 |
title: "Save test plan as markdown file", |
|
f7eb47b…
|
lmata
|
93 |
description: "Save the test plan as a markdown file", |
|
f7eb47b…
|
lmata
|
94 |
inputSchema: planSchema.extend({ |
|
f7eb47b…
|
lmata
|
95 |
name: import_mcpBundle.z.string().describe('The name of the test plan, for example: "Test Plan".'), |
|
f7eb47b…
|
lmata
|
96 |
fileName: import_mcpBundle.z.string().describe('The file to save the test plan to, for example: "spec/test.plan.md". Relative to the workspace root.') |
|
f7eb47b…
|
lmata
|
97 |
}), |
|
f7eb47b…
|
lmata
|
98 |
type: "readOnly" |
|
f7eb47b…
|
lmata
|
99 |
}, |
|
f7eb47b…
|
lmata
|
100 |
handle: async (context, params) => { |
|
f7eb47b…
|
lmata
|
101 |
const lines = []; |
|
f7eb47b…
|
lmata
|
102 |
lines.push(`# ${params.name}`); |
|
f7eb47b…
|
lmata
|
103 |
lines.push(``); |
|
f7eb47b…
|
lmata
|
104 |
lines.push(`## Application Overview`); |
|
f7eb47b…
|
lmata
|
105 |
lines.push(``); |
|
f7eb47b…
|
lmata
|
106 |
lines.push(params.overview); |
|
f7eb47b…
|
lmata
|
107 |
lines.push(``); |
|
f7eb47b…
|
lmata
|
108 |
lines.push(`## Test Scenarios`); |
|
f7eb47b…
|
lmata
|
109 |
for (let i = 0; i < params.suites.length; i++) { |
|
f7eb47b…
|
lmata
|
110 |
lines.push(``); |
|
f7eb47b…
|
lmata
|
111 |
const suite = params.suites[i]; |
|
f7eb47b…
|
lmata
|
112 |
lines.push(`### ${i + 1}. ${suite.name}`); |
|
f7eb47b…
|
lmata
|
113 |
lines.push(``); |
|
f7eb47b…
|
lmata
|
114 |
lines.push(`**Seed:** \`${suite.seedFile}\``); |
|
f7eb47b…
|
lmata
|
115 |
for (let j = 0; j < suite.tests.length; j++) { |
|
f7eb47b…
|
lmata
|
116 |
lines.push(``); |
|
f7eb47b…
|
lmata
|
117 |
const test = suite.tests[j]; |
|
f7eb47b…
|
lmata
|
118 |
lines.push(`#### ${i + 1}.${j + 1}. ${test.name}`); |
|
f7eb47b…
|
lmata
|
119 |
lines.push(``); |
|
f7eb47b…
|
lmata
|
120 |
lines.push(`**File:** \`${test.file}\``); |
|
f7eb47b…
|
lmata
|
121 |
lines.push(``); |
|
f7eb47b…
|
lmata
|
122 |
lines.push(`**Steps:**`); |
|
f7eb47b…
|
lmata
|
123 |
for (let k = 0; k < test.steps.length; k++) { |
|
f7eb47b…
|
lmata
|
124 |
lines.push(` ${k + 1}. ${test.steps[k].perform ?? "-"}`); |
|
f7eb47b…
|
lmata
|
125 |
for (const expect of test.steps[k].expect) |
|
f7eb47b…
|
lmata
|
126 |
lines.push(` - expect: ${expect}`); |
|
f7eb47b…
|
lmata
|
127 |
} |
|
f7eb47b…
|
lmata
|
128 |
} |
|
f7eb47b…
|
lmata
|
129 |
} |
|
f7eb47b…
|
lmata
|
130 |
lines.push(``); |
|
f7eb47b…
|
lmata
|
131 |
await import_fs.default.promises.writeFile(import_path.default.resolve(context.rootPath, params.fileName), lines.join("\n")); |
|
f7eb47b…
|
lmata
|
132 |
return { |
|
f7eb47b…
|
lmata
|
133 |
content: [{ |
|
f7eb47b…
|
lmata
|
134 |
type: "text", |
|
f7eb47b…
|
lmata
|
135 |
text: `Test plan saved to ${params.fileName}` |
|
f7eb47b…
|
lmata
|
136 |
}] |
|
f7eb47b…
|
lmata
|
137 |
}; |
|
f7eb47b…
|
lmata
|
138 |
} |
|
f7eb47b…
|
lmata
|
139 |
}); |
|
f7eb47b…
|
lmata
|
140 |
// Annotate the CommonJS export names for ESM import in node: |
|
f7eb47b…
|
lmata
|
141 |
0 && (module.exports = { |
|
f7eb47b…
|
lmata
|
142 |
saveTestPlan, |
|
f7eb47b…
|
lmata
|
143 |
setupPage, |
|
f7eb47b…
|
lmata
|
144 |
submitTestPlan |
|
f7eb47b…
|
lmata
|
145 |
}); |