forked from ChromeDevTools/chrome-devtools-mcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_webpage_issues_test.ts
More file actions
62 lines (58 loc) · 2 KB
/
fix_webpage_issues_test.ts
File metadata and controls
62 lines (58 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* @license
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*
* Eval scenario: user asks to fix issues with their webpage (no URL given).
* When no URL is provided, the model should pick the current frontend and run
* and inspect it. Verifies the MCP server is invoked and the model opens the
* frontend and inspects it (snapshot, console, or network).
*
* Note: Tools like performance_start_trace, take_snapshot, list_console_messages,
* and list_network_requests do not require a URL in the prompt—they operate on
* the currently selected page. Only navigate_page/new_page need a URL to open
* a page; the eval runner injects the test URL when htmlRoute is set.
*/
import assert from 'node:assert';
import type {TestScenario} from '../eval_gemini.ts';
const INSPECTION_TOOLS = [
'take_snapshot',
'list_console_messages',
'list_network_requests',
];
export const scenario: TestScenario = {
prompt: 'Can you fix issues with my webpage?',
maxTurns: 4,
htmlRoute: {
path: '/fix_issues_test.html',
htmlContent: `
<h1>Test Page</h1>
<p>Some content</p>
<script>
console.error('Intentional error for testing');
</script>
`,
},
expectations: calls => {
const NAVIGATION_TOOLS = ['navigate_page', 'new_page'];
assert.ok(
calls.length >= 2,
'Expected at least navigation and one inspection',
);
const navigationIndex = calls.findIndex(c =>
NAVIGATION_TOOLS.includes(c.name),
);
assert.ok(
navigationIndex !== -1,
`Expected a navigation call (${NAVIGATION_TOOLS.join(' or ')}), got: ${calls.map(c => c.name).join(', ')}`,
);
const afterNavigation = calls.slice(navigationIndex + 1);
const inspectionCalls = afterNavigation.filter(c =>
INSPECTION_TOOLS.includes(c.name),
);
assert.ok(
inspectionCalls.length >= 1,
`Expected at least one inspection tool (${INSPECTION_TOOLS.join(', ')}) after navigation, got: ${calls.map(c => c.name).join(', ')}`,
);
},
};