Skip to content

Commit c2a5337

Browse files
committed
Add additional Playwright MCP validation tests and utilities
1 parent adf1b6b commit c2a5337

File tree

4 files changed

+711
-0
lines changed

4 files changed

+711
-0
lines changed
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
// Manual validation test for Playwright MCP template
2+
// This uses basic Node.js modules to avoid dependency issues
3+
4+
const fs = require('fs');
5+
const path = require('path');
6+
7+
// Simple test framework functions
8+
function describe(name, fn) {
9+
console.log(`\n--- ${name} ---`);
10+
fn();
11+
}
12+
13+
function it(name, fn) {
14+
try {
15+
fn();
16+
console.log(`✓ ${name}`);
17+
} catch (error) {
18+
console.log(`✗ ${name}: ${error.message}`);
19+
}
20+
}
21+
22+
function expect(actual) {
23+
return {
24+
toBe: (expected) => {
25+
if (actual !== expected) {
26+
throw new Error(`Expected ${expected}, got ${actual}`);
27+
}
28+
},
29+
toContain: (expected) => {
30+
if (!actual.includes(expected)) {
31+
throw new Error(`Expected to contain ${expected}`);
32+
}
33+
},
34+
toBeDefined: () => {
35+
if (actual === undefined) {
36+
throw new Error('Expected to be defined');
37+
}
38+
},
39+
toHaveLength: (expected) => {
40+
if (actual.length !== expected) {
41+
throw new Error(`Expected length ${expected}, got ${actual.length}`);
42+
}
43+
}
44+
};
45+
}
46+
47+
// Validation tests
48+
async function runValidation() {
49+
console.log('Running Playwright MCP Template Validation');
50+
51+
try {
52+
// Read template file
53+
const templatePath = 'C:\\Users\\orphe\\Downloads\\playwright-mcp.yaml';
54+
const templateContent = fs.readFileSync(templatePath, 'utf-8');
55+
56+
// Parse YAML manually (simple approach)
57+
const yamlLines = templateContent.split('\n');
58+
console.log(`Template loaded with ${yamlLines.length} lines`);
59+
60+
describe("Template File Structure", () => {
61+
it("should exist and be readable", () => {
62+
expect(templateContent).toBeDefined();
63+
expect(templateContent.length).toBe(templateContent.length); // Just verify it has content
64+
});
65+
66+
it("should contain required YAML structure", () => {
67+
expect(templateContent).toContain('items:');
68+
expect(templateContent).toContain('id: playwright-mcp');
69+
expect(templateContent).toContain('type: mcp');
70+
});
71+
72+
it("should have proper MCP metadata", () => {
73+
expect(templateContent).toContain('name: Playwright MCP');
74+
expect(templateContent).toContain('description:');
75+
expect(templateContent).toContain('author: "Microsoft"');
76+
expect(templateContent).toContain('url: "https://github.com/microsoft/playwright-mcp"');
77+
});
78+
});
79+
80+
describe("Installation Methods", () => {
81+
it("should have Node.js/NPM method", () => {
82+
expect(templateContent).toContain('name: Node.js/NPM');
83+
expect(templateContent).toContain('command": "node"');
84+
expect(templateContent).toContain('{{serverPath}}');
85+
});
86+
87+
it("should have Docker method", () => {
88+
expect(templateContent).toContain('name: Docker');
89+
expect(templateContent).toContain('command": "docker"');
90+
expect(templateContent).toContain('{{dockerHost}}');
91+
});
92+
});
93+
94+
describe("Parameters", () => {
95+
it("should have serverPath parameter", () => {
96+
expect(templateContent).toContain('key: serverPath');
97+
expect(templateContent).toContain('Playwright MCP Server Path');
98+
expect(templateContent).toContain('optional: false');
99+
});
100+
101+
it("should have dockerHost parameter", () => {
102+
expect(templateContent).toContain('key: dockerHost');
103+
expect(templateContent).toContain('Docker Host');
104+
expect(templateContent).toContain('optional: true');
105+
});
106+
});
107+
108+
describe("Prerequisites", () => {
109+
it("should have Node.js prerequisites", () => {
110+
expect(templateContent).toContain('Node.js (>=18)');
111+
expect(templateContent).toContain('git clone');
112+
expect(templateContent).toContain('npm install');
113+
});
114+
115+
it("should have Docker prerequisites", () => {
116+
expect(templateContent).toContain('Docker installed and running');
117+
expect(templateContent).toContain('docker pull');
118+
});
119+
});
120+
121+
describe("JSON Content Validation", () => {
122+
it("should have valid JSON in Node.js method content", () => {
123+
const nodeContentMatch = templateContent.match(/name: Node\.js\/NPM[\s\S]*?content: \|([\s\S]*?)parameters:/);
124+
if (nodeContentMatch) {
125+
const jsonContent = nodeContentMatch[1].trim();
126+
try {
127+
JSON.parse(jsonContent);
128+
console.log('✓ Node.js JSON content is valid');
129+
} catch (e) {
130+
throw new Error('Node.js JSON content is invalid: ' + e.message);
131+
}
132+
} else {
133+
throw new Error('Could not find Node.js content section');
134+
}
135+
});
136+
137+
it("should have valid JSON in Docker method content", () => {
138+
const dockerContentMatch = templateContent.match(/name: Docker[\s\S]*?content: \|([\s\S]*?)parameters:/);
139+
if (dockerContentMatch) {
140+
const jsonContent = dockerContentMatch[1].trim();
141+
try {
142+
JSON.parse(jsonContent);
143+
console.log('✓ Docker JSON content is valid');
144+
} catch (e) {
145+
throw new Error('Docker JSON content is invalid: ' + e.message);
146+
}
147+
} else {
148+
throw new Error('Could not find Docker content section');
149+
}
150+
});
151+
});
152+
153+
describe("Tags and Metadata", () => {
154+
it("should have appropriate tags", () => {
155+
expect(templateContent).toContain('automation');
156+
expect(templateContent).toContain('testing');
157+
expect(templateContent).toContain('browser');
158+
expect(templateContent).toContain('playwright');
159+
});
160+
});
161+
162+
console.log('\n🎉 All validation tests completed!');
163+
164+
} catch (error) {
165+
console.error('❌ Validation failed:', error.message);
166+
process.exit(1);
167+
}
168+
}
169+
170+
// Run the validation if this file is executed directly
171+
if (require.main === module) {
172+
runValidation();
173+
}
174+
175+
module.exports = { runValidation };
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
// Manual validation test for Playwright MCP template
2+
// This uses basic Node.js modules to avoid dependency issues
3+
4+
const fs = require('fs');
5+
const path = require('path');
6+
7+
// Simple test framework functions
8+
function describe(name, fn) {
9+
console.log(`\n--- ${name} ---`);
10+
fn();
11+
}
12+
13+
function it(name, fn) {
14+
try {
15+
fn();
16+
console.log(`✓ ${name}`);
17+
} catch (error) {
18+
console.log(`✗ ${name}: ${error.message}`);
19+
}
20+
}
21+
22+
function expect(actual) {
23+
return {
24+
toBe: (expected) => {
25+
if (actual !== expected) {
26+
throw new Error(`Expected ${expected}, got ${actual}`);
27+
}
28+
},
29+
toContain: (expected) => {
30+
if (!actual.includes(expected)) {
31+
throw new Error(`Expected to contain ${expected}`);
32+
}
33+
},
34+
toBeDefined: () => {
35+
if (actual === undefined) {
36+
throw new Error('Expected to be defined');
37+
}
38+
},
39+
toHaveLength: (expected) => {
40+
if (actual.length !== expected) {
41+
throw new Error(`Expected length ${expected}, got ${actual.length}`);
42+
}
43+
}
44+
};
45+
}
46+
47+
// Validation tests
48+
async function runValidation() {
49+
console.log('Running Playwright MCP Template Validation');
50+
51+
try {
52+
// Read template file
53+
const templatePath = 'C:\\Users\\orphe\\Downloads\\playwright-mcp.yaml';
54+
const templateContent = fs.readFileSync(templatePath, 'utf-8');
55+
56+
// Parse YAML manually (simple approach)
57+
const yamlLines = templateContent.split('\n');
58+
console.log(`Template loaded with ${yamlLines.length} lines`);
59+
60+
describe("Template File Structure", () => {
61+
it("should exist and be readable", () => {
62+
expect(templateContent).toBeDefined();
63+
expect(templateContent.length).toBe(templateContent.length); // Just verify it has content
64+
});
65+
66+
it("should contain required YAML structure", () => {
67+
expect(templateContent).toContain('items:');
68+
expect(templateContent).toContain('id: playwright-mcp');
69+
expect(templateContent).toContain('type: mcp');
70+
});
71+
72+
it("should have proper MCP metadata", () => {
73+
expect(templateContent).toContain('name: Playwright MCP');
74+
expect(templateContent).toContain('description:');
75+
expect(templateContent).toContain('author: Microsoft');
76+
expect(templateContent).toContain('url: https://github.com/microsoft/playwright-mcp');
77+
});
78+
});
79+
80+
describe("Installation Methods", () => {
81+
it("should have Node.js/NPM method", () => {
82+
expect(templateContent).toContain('name: Node.js/NPM');
83+
expect(templateContent).toContain('command": "node"');
84+
expect(templateContent).toContain('{{serverPath}}');
85+
});
86+
87+
it("should have Docker method", () => {
88+
expect(templateContent).toContain('name: Docker');
89+
expect(templateContent).toContain('command": "docker"');
90+
expect(templateContent).toContain('{{dockerHost}}');
91+
});
92+
});
93+
94+
describe("Parameters", () => {
95+
it("should have serverPath parameter", () => {
96+
expect(templateContent).toContain('key: serverPath');
97+
expect(templateContent).toContain('Playwright MCP Server Path');
98+
expect(templateContent).toContain('optional: false');
99+
});
100+
101+
it("should have dockerHost parameter", () => {
102+
expect(templateContent).toContain('key: dockerHost');
103+
expect(templateContent).toContain('Docker Host');
104+
expect(templateContent).toContain('optional: true');
105+
});
106+
});
107+
108+
describe("Prerequisites", () => {
109+
it("should have Node.js prerequisites", () => {
110+
expect(templateContent).toContain('Node.js (>=18)');
111+
expect(templateContent).toContain('git clone');
112+
expect(templateContent).toContain('npm install');
113+
});
114+
115+
it("should have Docker prerequisites", () => {
116+
expect(templateContent).toContain('Docker installed and running');
117+
expect(templateContent).toContain('docker pull');
118+
});
119+
});
120+
121+
describe("JSON Content Validation", () => {
122+
it("should have valid JSON in Node.js method content", () => {
123+
const nodeContentMatch = templateContent.match(/name: Node\.js\/NPM[\s\S]*?content: \|([\s\S]*?)parameters:/);
124+
if (nodeContentMatch) {
125+
const jsonContent = nodeContentMatch[1].trim();
126+
try {
127+
JSON.parse(jsonContent);
128+
console.log('✓ Node.js JSON content is valid');
129+
} catch (e) {
130+
throw new Error('Node.js JSON content is invalid: ' + e.message);
131+
}
132+
} else {
133+
throw new Error('Could not find Node.js content section');
134+
}
135+
});
136+
137+
it("should have valid JSON in Docker method content", () => {
138+
const dockerContentMatch = templateContent.match(/name: Docker[\s\S]*?content: \|([\s\S]*?)parameters:/);
139+
if (dockerContentMatch) {
140+
const jsonContent = dockerContentMatch[1].trim();
141+
try {
142+
JSON.parse(jsonContent);
143+
console.log('✓ Docker JSON content is valid');
144+
} catch (e) {
145+
throw new Error('Docker JSON content is invalid: ' + e.message);
146+
}
147+
} else {
148+
throw new Error('Could not find Docker content section');
149+
}
150+
});
151+
});
152+
153+
describe("Tags and Metadata", () => {
154+
it("should have appropriate tags", () => {
155+
expect(templateContent).toContain('automation');
156+
expect(templateContent).toContain('testing');
157+
expect(templateContent).toContain('browser');
158+
expect(templateContent).toContain('playwright');
159+
});
160+
});
161+
162+
console.log('\n🎉 All validation tests completed!');
163+
164+
} catch (error) {
165+
console.error('❌ Validation failed:', error.message);
166+
process.exit(1);
167+
}
168+
}
169+
170+
// Run the validation if this file is executed directly
171+
if (require.main === module) {
172+
runValidation();
173+
}
174+
175+
module.exports = { runValidation };

0 commit comments

Comments
 (0)