From 32808e5dd2069f7f9306cad0832595bb4182fe90 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Mon, 15 Jun 2026 19:32:45 +0200 Subject: [PATCH] test(tools): move get_location specs to specs/ and assert real tool registration --- .../GetLocation.registration.spec.js | 19 ------------------- .../specs/GetLocation.registration.spec.js | 11 +++++++++++ .../{ => specs}/GetLocation.spec.js | 2 +- 3 files changed, 12 insertions(+), 20 deletions(-) delete mode 100644 api/app/clients/tools/structured/__tests__/GetLocation.registration.spec.js create mode 100644 api/app/clients/tools/structured/specs/GetLocation.registration.spec.js rename api/app/clients/tools/structured/{ => specs}/GetLocation.spec.js (96%) diff --git a/api/app/clients/tools/structured/__tests__/GetLocation.registration.spec.js b/api/app/clients/tools/structured/__tests__/GetLocation.registration.spec.js deleted file mode 100644 index bcd3a37918..0000000000 --- a/api/app/clients/tools/structured/__tests__/GetLocation.registration.spec.js +++ /dev/null @@ -1,19 +0,0 @@ -const { Tool } = require('@librechat/agents/langchain/tools'); -const GetLocation = require('../GetLocation'); - -describe('get_location tool registration', () => { - it('GetLocation is a Tool subclass so loadAndFormatTools discovers it', () => { - expect(GetLocation.prototype instanceof Tool).toBe(true); - }); - - it('can be instantiated with override for discovery without request context', () => { - const tool = new GetLocation({ override: true }); - expect(tool.name).toBe('get_location'); - expect(tool.schema).toBeDefined(); - }); - - it('has a plain-object schema compatible with loadAndFormatTools (non-Zod)', () => { - const tool = new GetLocation({ override: true }); - expect(tool.schema).toEqual({ type: 'object', properties: {}, required: [] }); - }); -}); diff --git a/api/app/clients/tools/structured/specs/GetLocation.registration.spec.js b/api/app/clients/tools/structured/specs/GetLocation.registration.spec.js new file mode 100644 index 0000000000..3a7d0de6a0 --- /dev/null +++ b/api/app/clients/tools/structured/specs/GetLocation.registration.spec.js @@ -0,0 +1,11 @@ +const path = require('path'); +const { loadAndFormatTools } = require('~/server/services/start/tools'); + +describe('get_location tool registration', () => { + it('is discovered by loadAndFormatTools so it shows in the picker and survives agent save', () => { + const directory = path.resolve(__dirname, '..'); + const tools = loadAndFormatTools({ directory, adminFilter: [], adminIncluded: [] }); + expect(tools.get_location).toBeDefined(); + expect(tools.get_location.function.name).toBe('get_location'); + }); +}); diff --git a/api/app/clients/tools/structured/GetLocation.spec.js b/api/app/clients/tools/structured/specs/GetLocation.spec.js similarity index 96% rename from api/app/clients/tools/structured/GetLocation.spec.js rename to api/app/clients/tools/structured/specs/GetLocation.spec.js index 0fc2be5f4e..9f1d855e3c 100644 --- a/api/app/clients/tools/structured/GetLocation.spec.js +++ b/api/app/clients/tools/structured/specs/GetLocation.spec.js @@ -1,4 +1,4 @@ -const GetLocation = require('./GetLocation'); +const GetLocation = require('../GetLocation'); const makeReq = ({ location, featureEnabled = true } = {}) => ({ config: { location: { enabled: featureEnabled } },