| 1 | import { test, expect } from "vitest"; |
| 2 | import { getConfigDependentToolDefinitions } from "./index"; |
| 3 | import { BuiltInToolNames } from "./builtIn"; |
| 4 | |
| 5 | test("searchWeb tool is only available when user is signed in", () => { |
| 6 | // Test with signed-in user |
| 7 | const signedInTools = getConfigDependentToolDefinitions({ |
| 8 | rules: [], |
| 9 | enableExperimentalTools: false, |
| 10 | isSignedIn: true, |
| 11 | }); |
| 12 | |
| 13 | const searchWebToolSignedIn = signedInTools.find( |
| 14 | (tool) => tool.function.name === BuiltInToolNames.SearchWeb, |
| 15 | ); |
| 16 | expect(searchWebToolSignedIn).toBeDefined(); |
| 17 | expect(searchWebToolSignedIn?.displayTitle).toBe("Search Web"); |
| 18 | |
| 19 | // Test with non-signed-in user |
| 20 | const notSignedInTools = getConfigDependentToolDefinitions({ |
| 21 | rules: [], |
| 22 | enableExperimentalTools: false, |
| 23 | isSignedIn: false, |
| 24 | }); |
| 25 | |
| 26 | const searchWebToolNotSignedIn = notSignedInTools.find( |
| 27 | (tool) => tool.function.name === BuiltInToolNames.SearchWeb, |
| 28 | ); |
| 29 | expect(searchWebToolNotSignedIn).toBeUndefined(); |
| 30 | }); |