@probebrowser/trace-mcp 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,288 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { TOOLS } from '../src/tools.js';
3
+
4
+ describe('Tools Definition', () => {
5
+ describe('Structure', () => {
6
+ it('should export TOOLS object with all required tools', () => {
7
+ expect(TOOLS).toBeDefined();
8
+ expect(typeof TOOLS).toBe('object');
9
+ });
10
+
11
+ it('should have trace_connect tool for browser connection', () => {
12
+ expect(TOOLS.trace_connect).toBeDefined();
13
+ expect(TOOLS.trace_connect.method).toBe('connect');
14
+ expect(TOOLS.trace_connect.description).toContain('Connect');
15
+ });
16
+
17
+ it('should have trace_p tool for AI debugging', () => {
18
+ expect(TOOLS.trace_p).toBeDefined();
19
+ expect(TOOLS.trace_p.method).toBe('deep_debug');
20
+ expect(TOOLS.trace_p.description).toContain('AI');
21
+ });
22
+ });
23
+
24
+ describe('Console Tools', () => {
25
+ it('should have console error tool', () => {
26
+ expect(TOOLS.trace_get_console_errors).toBeDefined();
27
+ expect(TOOLS.trace_get_console_errors.method).toBe('get_console_errors');
28
+ });
29
+
30
+ it('should have console summary tool', () => {
31
+ expect(TOOLS.trace_get_console_summary).toBeDefined();
32
+ expect(TOOLS.trace_get_console_summary.method).toBe('get_console_summary');
33
+ });
34
+
35
+ it('should have error grouping tool', () => {
36
+ expect(TOOLS.trace_get_error_groups).toBeDefined();
37
+ expect(TOOLS.trace_get_error_groups.method).toBe('get_error_groups');
38
+ });
39
+
40
+ it('should have suggest fix tool', () => {
41
+ expect(TOOLS.trace_suggest_fix).toBeDefined();
42
+ expect(TOOLS.trace_suggest_fix.method).toBe('suggest_fix');
43
+ });
44
+ });
45
+
46
+ describe('Network Tools', () => {
47
+ it('should have network summary tool', () => {
48
+ expect(TOOLS.trace_get_network_summary).toBeDefined();
49
+ expect(TOOLS.trace_get_network_summary.method).toBe('get_network_summary');
50
+ });
51
+
52
+ it('should have network failed tool', () => {
53
+ expect(TOOLS.trace_get_network_failed).toBeDefined();
54
+ expect(TOOLS.trace_get_network_failed.method).toBe('get_network_failed');
55
+ });
56
+
57
+ it('should have request headers tool with requestId param', () => {
58
+ expect(TOOLS.trace_get_request_headers).toBeDefined();
59
+ expect(TOOLS.trace_get_request_headers.schema).toBeDefined();
60
+ });
61
+
62
+ it('should have response body tool', () => {
63
+ expect(TOOLS.trace_get_response_body).toBeDefined();
64
+ expect(TOOLS.trace_get_response_body.method).toBe('get_response_body');
65
+ });
66
+
67
+ it('should have timing breakdown tool', () => {
68
+ expect(TOOLS.trace_get_timing_breakdown).toBeDefined();
69
+ expect(TOOLS.trace_get_timing_breakdown.method).toBe('get_timing_breakdown');
70
+ });
71
+
72
+ it('should have replay request tool', () => {
73
+ expect(TOOLS.trace_replay_request).toBeDefined();
74
+ expect(TOOLS.trace_replay_request.method).toBe('replay_request');
75
+ });
76
+ });
77
+
78
+ describe('DOM Tools', () => {
79
+ it('should have inspect element tool', () => {
80
+ expect(TOOLS.trace_inspect_element).toBeDefined();
81
+ expect(TOOLS.trace_inspect_element.method).toBe('inspect_element');
82
+ });
83
+
84
+ it('should have find elements tool', () => {
85
+ expect(TOOLS.trace_find_elements).toBeDefined();
86
+ expect(TOOLS.trace_find_elements.method).toBe('find_elements');
87
+ });
88
+
89
+ it('should have get DOM tree tool', () => {
90
+ expect(TOOLS.trace_get_dom_tree).toBeDefined();
91
+ expect(TOOLS.trace_get_dom_tree.method).toBe('get_dom_tree');
92
+ });
93
+
94
+ it('should have analyze visibility tool', () => {
95
+ expect(TOOLS.trace_analyze_visibility).toBeDefined();
96
+ expect(TOOLS.trace_analyze_visibility.method).toBe('analyze_visibility');
97
+ });
98
+
99
+ it('should have why hidden tool as alias', () => {
100
+ expect(TOOLS.trace_why_hidden).toBeDefined();
101
+ expect(TOOLS.trace_why_hidden.method).toBe('why_hidden');
102
+ });
103
+ });
104
+
105
+ describe('Debugger Tools', () => {
106
+ it('should have debugger state tool', () => {
107
+ expect(TOOLS.trace_get_debugger_state).toBeDefined();
108
+ expect(TOOLS.trace_get_debugger_state.method).toBe('get_debugger_state');
109
+ });
110
+
111
+ it('should have call stack tool', () => {
112
+ expect(TOOLS.trace_get_call_stack).toBeDefined();
113
+ expect(TOOLS.trace_get_call_stack.method).toBe('get_call_stack');
114
+ });
115
+
116
+ it('should have set breakpoint tool', () => {
117
+ expect(TOOLS.trace_set_breakpoint).toBeDefined();
118
+ expect(TOOLS.trace_set_breakpoint.method).toBe('set_breakpoint');
119
+ });
120
+
121
+ it('should have step debugger tool with action enum', () => {
122
+ expect(TOOLS.trace_step_debugger).toBeDefined();
123
+ expect(TOOLS.trace_step_debugger.method).toBe('step_debugger');
124
+ });
125
+
126
+ it('should have evaluate expression tool', () => {
127
+ expect(TOOLS.trace_evaluate_expression).toBeDefined();
128
+ expect(TOOLS.trace_evaluate_expression.method).toBe('evaluate_expression');
129
+ });
130
+
131
+ it('should have logpoint tool', () => {
132
+ expect(TOOLS.trace_set_logpoint).toBeDefined();
133
+ expect(TOOLS.trace_set_logpoint.method).toBe('set_logpoint');
134
+ });
135
+
136
+ it('should have DOM breakpoint tool', () => {
137
+ expect(TOOLS.trace_set_dom_breakpoint_by_selector).toBeDefined();
138
+ expect(TOOLS.trace_set_dom_breakpoint_by_selector.method).toBe('set_dom_breakpoint_by_selector');
139
+ });
140
+ });
141
+
142
+ describe('Performance Tools', () => {
143
+ it('should have performance metrics tool', () => {
144
+ expect(TOOLS.trace_get_performance_metrics).toBeDefined();
145
+ expect(TOOLS.trace_get_performance_metrics.method).toBe('get_performance_metrics');
146
+ });
147
+
148
+ it('should have heap snapshot tool', () => {
149
+ expect(TOOLS.trace_take_heap_snapshot).toBeDefined();
150
+ expect(TOOLS.trace_take_heap_snapshot.method).toBe('take_heap_snapshot');
151
+ });
152
+
153
+ it('should have CPU profile tools', () => {
154
+ expect(TOOLS.trace_start_cpu_profile).toBeDefined();
155
+ expect(TOOLS.trace_stop_cpu_profile).toBeDefined();
156
+ });
157
+ });
158
+
159
+ describe('Storage Tools', () => {
160
+ it('should have cookies tool', () => {
161
+ expect(TOOLS.trace_get_cookies).toBeDefined();
162
+ expect(TOOLS.trace_get_cookies.method).toBe('get_cookies');
163
+ });
164
+
165
+ it('should have local storage tool', () => {
166
+ expect(TOOLS.trace_get_local_storage).toBeDefined();
167
+ expect(TOOLS.trace_get_local_storage.method).toBe('get_local_storage');
168
+ });
169
+
170
+ it('should have session storage tool', () => {
171
+ expect(TOOLS.trace_get_session_storage).toBeDefined();
172
+ expect(TOOLS.trace_get_session_storage.method).toBe('get_session_storage');
173
+ });
174
+
175
+ it('should have indexeddb tool', () => {
176
+ expect(TOOLS.trace_get_indexeddb_databases).toBeDefined();
177
+ expect(TOOLS.trace_get_indexeddb_databases.method).toBe('get_indexeddb_databases');
178
+ });
179
+
180
+ it('should have service workers tool', () => {
181
+ expect(TOOLS.trace_get_service_workers).toBeDefined();
182
+ expect(TOOLS.trace_get_service_workers.method).toBe('get_service_workers');
183
+ });
184
+ });
185
+
186
+ describe('Security Tools', () => {
187
+ it('should have security info tool', () => {
188
+ expect(TOOLS.trace_get_security_info).toBeDefined();
189
+ expect(TOOLS.trace_get_security_info.method).toBe('get_security_info');
190
+ });
191
+
192
+ it('should have mixed content check tool', () => {
193
+ expect(TOOLS.trace_check_mixed_content).toBeDefined();
194
+ expect(TOOLS.trace_check_mixed_content.method).toBe('check_mixed_content');
195
+ });
196
+
197
+ it('should have certificate info tool', () => {
198
+ expect(TOOLS.trace_get_certificate_info).toBeDefined();
199
+ expect(TOOLS.trace_get_certificate_info.method).toBe('get_certificate_info');
200
+ });
201
+ });
202
+
203
+ describe('Interaction Tools', () => {
204
+ it('should have click tool', () => {
205
+ expect(TOOLS.trace_click).toBeDefined();
206
+ expect(TOOLS.trace_click.method).toBe('click');
207
+ });
208
+
209
+ it('should have type tool', () => {
210
+ expect(TOOLS.trace_type).toBeDefined();
211
+ expect(TOOLS.trace_type.method).toBe('type');
212
+ });
213
+
214
+ it('should have hover tool', () => {
215
+ expect(TOOLS.trace_hover).toBeDefined();
216
+ expect(TOOLS.trace_hover.method).toBe('hover');
217
+ });
218
+
219
+ it('should have scroll tool', () => {
220
+ expect(TOOLS.trace_scroll).toBeDefined();
221
+ expect(TOOLS.trace_scroll.method).toBe('scroll');
222
+ });
223
+
224
+ it('should have wait for tool', () => {
225
+ expect(TOOLS.trace_wait_for).toBeDefined();
226
+ expect(TOOLS.trace_wait_for.method).toBe('wait_for');
227
+ });
228
+ });
229
+
230
+ describe('Code Tools', () => {
231
+ it('should have read file tool', () => {
232
+ expect(TOOLS.trace_read_file).toBeDefined();
233
+ expect(TOOLS.trace_read_file.method).toBe('read_file');
234
+ });
235
+
236
+ it('should have search code tool', () => {
237
+ expect(TOOLS.trace_search_code).toBeDefined();
238
+ expect(TOOLS.trace_search_code.method).toBe('search_code');
239
+ });
240
+
241
+ it('should have git blame tool', () => {
242
+ expect(TOOLS.trace_git_blame).toBeDefined();
243
+ expect(TOOLS.trace_git_blame.method).toBe('git_blame');
244
+ });
245
+
246
+ it('should have find usages tool', () => {
247
+ expect(TOOLS.trace_find_usages).toBeDefined();
248
+ expect(TOOLS.trace_find_usages.method).toBe('find_usages');
249
+ });
250
+ });
251
+
252
+ describe('Tool Count', () => {
253
+ it('should have at least 100 tools defined', () => {
254
+ const toolCount = Object.keys(TOOLS).length;
255
+ expect(toolCount).toBeGreaterThanOrEqual(100);
256
+ });
257
+
258
+ it('should have unique method names for each tool', () => {
259
+ const methods = Object.values(TOOLS).map(t => t.method);
260
+ const uniqueMethods = new Set(methods);
261
+ // Allow some duplicates for aliases (e.g., why_hidden = analyze_visibility)
262
+ expect(uniqueMethods.size).toBeGreaterThan(90);
263
+ });
264
+ });
265
+
266
+ describe('Schema Validation', () => {
267
+ it('all tools should have a schema', () => {
268
+ for (const [name, tool] of Object.entries(TOOLS)) {
269
+ expect(tool.schema, `Tool ${name} should have schema`).toBeDefined();
270
+ }
271
+ });
272
+
273
+ it('all tools should have a description', () => {
274
+ for (const [name, tool] of Object.entries(TOOLS)) {
275
+ expect(tool.description, `Tool ${name} should have description`).toBeDefined();
276
+ expect(typeof tool.description).toBe('string');
277
+ expect(tool.description.length).toBeGreaterThan(0);
278
+ }
279
+ });
280
+
281
+ it('all tools should have a method', () => {
282
+ for (const [name, tool] of Object.entries(TOOLS)) {
283
+ expect(tool.method, `Tool ${name} should have method`).toBeDefined();
284
+ expect(typeof tool.method).toBe('string');
285
+ }
286
+ });
287
+ });
288
+ });
@@ -0,0 +1,17 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: 'node',
7
+ include: ['tests/**/*.test.ts'],
8
+ testTimeout: 30000,
9
+ hookTimeout: 30000,
10
+ coverage: {
11
+ provider: 'v8',
12
+ reporter: ['text', 'json', 'html'],
13
+ include: ['src/**/*.ts'],
14
+ exclude: ['src/index.ts'],
15
+ },
16
+ },
17
+ });