|
| 1 | +/** |
| 2 | + * Copyright (c) Microsoft Corporation. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import { test, expect, parseResponse } from './fixtures'; |
| 18 | + |
| 19 | +test('reports missing required tool arguments', async ({ client }) => { |
| 20 | + const response = await client.callTool({ |
| 21 | + name: 'browser_navigate', |
| 22 | + arguments: {}, |
| 23 | + }); |
| 24 | + |
| 25 | + expect(response).toHaveResponse({ |
| 26 | + isError: true, |
| 27 | + error: expect.stringContaining('Invalid arguments for tool "browser_navigate":'), |
| 28 | + }); |
| 29 | + const parsed = parseResponse(response); |
| 30 | + expect(parsed.error).toContain('Invalid input: expected string'); |
| 31 | + expect(parsed.error).toContain('at url'); |
| 32 | +}); |
| 33 | + |
| 34 | +test('reports invalid tool argument types', async ({ client }) => { |
| 35 | + const response = await client.callTool({ |
| 36 | + name: 'browser_navigate', |
| 37 | + arguments: { url: 123 }, |
| 38 | + }); |
| 39 | + |
| 40 | + const parsed = parseResponse(response); |
| 41 | + expect(parsed.isError).toBe(true); |
| 42 | + expect(parsed.error).toContain('Invalid arguments for tool "browser_navigate":'); |
| 43 | + expect(parsed.error).toContain('Invalid input: expected string, received number'); |
| 44 | + expect(parsed.error).toContain('at url'); |
| 45 | +}); |
0 commit comments