test(tools): move get_location specs to specs/ and assert real tool registration

This commit is contained in:
Marco Beretta 2026-06-15 19:32:45 +02:00
parent f2379f7327
commit 32808e5dd2
No known key found for this signature in database
GPG key ID: D918033D8E74CC11
3 changed files with 12 additions and 20 deletions

View file

@ -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: [] });
});
});

View file

@ -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');
});
});

View file

@ -1,4 +1,4 @@
const GetLocation = require('./GetLocation');
const GetLocation = require('../GetLocation');
const makeReq = ({ location, featureEnabled = true } = {}) => ({
config: { location: { enabled: featureEnabled } },