mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-13 03:16:15 +01:00
* chore: linting for `loadCustomConfig` * refactor: decouple CDN init and variable/health checks from AppService * refactor: move AppService to packages/data-schemas * chore: update AppConfig import path to use data-schemas * chore: update JsonSchemaType import path to use data-schemas * refactor: update UserController to import webSearchKeys and redefine FunctionTool typedef * chore: remove AppService.js * refactor: update AppConfig interface to use Partial<TCustomConfig> and make paths and fileStrategies optional * refactor: update checkConfig function to accept Partial<TCustomConfig> * chore: fix types * refactor: move handleRateLimits to startup checks as is an effect * test: remove outdated rate limit tests from AppService.spec and add new handleRateLimits tests in checks.spec
157 lines
3.6 KiB
TypeScript
157 lines
3.6 KiB
TypeScript
jest.mock('@librechat/data-schemas', () => ({
|
|
...jest.requireActual('@librechat/data-schemas'),
|
|
logger: {
|
|
info: jest.fn(),
|
|
warn: jest.fn(),
|
|
error: jest.fn(),
|
|
},
|
|
}));
|
|
|
|
import { AppService } from '@librechat/data-schemas';
|
|
|
|
describe('AppService interface configuration', () => {
|
|
beforeEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
it('should set prompts to true when config specifies prompts as true', async () => {
|
|
const config = {
|
|
interface: {
|
|
prompts: true,
|
|
},
|
|
};
|
|
|
|
const result = await AppService({ config });
|
|
|
|
expect(result).toEqual(
|
|
expect.objectContaining({
|
|
interfaceConfig: expect.objectContaining({
|
|
prompts: true,
|
|
}),
|
|
}),
|
|
);
|
|
});
|
|
|
|
it('should set prompts and bookmarks to false when config specifies them as false', async () => {
|
|
const config = {
|
|
interface: {
|
|
prompts: false,
|
|
bookmarks: false,
|
|
},
|
|
};
|
|
|
|
const result = await AppService({ config });
|
|
|
|
expect(result).toEqual(
|
|
expect.objectContaining({
|
|
interfaceConfig: expect.objectContaining({
|
|
prompts: false,
|
|
bookmarks: false,
|
|
}),
|
|
}),
|
|
);
|
|
});
|
|
|
|
it('should not set prompts and bookmarks when not provided in config', async () => {
|
|
const config = {};
|
|
|
|
const result = await AppService({ config });
|
|
|
|
expect(result).toEqual(
|
|
expect.objectContaining({
|
|
interfaceConfig: expect.anything(),
|
|
}),
|
|
);
|
|
|
|
// Verify that prompts and bookmarks are undefined when not provided
|
|
expect(result.interfaceConfig?.prompts).toBeUndefined();
|
|
expect(result.interfaceConfig?.bookmarks).toBeUndefined();
|
|
});
|
|
|
|
it('should set prompts and bookmarks to different values when specified differently in config', async () => {
|
|
const config = {
|
|
interface: {
|
|
prompts: true,
|
|
bookmarks: false,
|
|
},
|
|
};
|
|
|
|
const result = await AppService({ config });
|
|
|
|
expect(result).toEqual(
|
|
expect.objectContaining({
|
|
interfaceConfig: expect.objectContaining({
|
|
prompts: true,
|
|
bookmarks: false,
|
|
}),
|
|
}),
|
|
);
|
|
});
|
|
|
|
it('should correctly configure peoplePicker permissions including roles', async () => {
|
|
const config = {
|
|
interface: {
|
|
peoplePicker: {
|
|
users: true,
|
|
groups: true,
|
|
roles: true,
|
|
},
|
|
},
|
|
};
|
|
|
|
const result = await AppService({ config });
|
|
|
|
expect(result).toEqual(
|
|
expect.objectContaining({
|
|
interfaceConfig: expect.objectContaining({
|
|
peoplePicker: expect.objectContaining({
|
|
users: true,
|
|
groups: true,
|
|
roles: true,
|
|
}),
|
|
}),
|
|
}),
|
|
);
|
|
});
|
|
|
|
it('should handle mixed peoplePicker permissions', async () => {
|
|
const config = {
|
|
interface: {
|
|
peoplePicker: {
|
|
users: true,
|
|
groups: false,
|
|
roles: true,
|
|
},
|
|
},
|
|
};
|
|
|
|
const result = await AppService({ config });
|
|
|
|
expect(result).toEqual(
|
|
expect.objectContaining({
|
|
interfaceConfig: expect.objectContaining({
|
|
peoplePicker: expect.objectContaining({
|
|
users: true,
|
|
groups: false,
|
|
roles: true,
|
|
}),
|
|
}),
|
|
}),
|
|
);
|
|
});
|
|
|
|
it('should not set peoplePicker when not provided in config', async () => {
|
|
const config = {};
|
|
|
|
const result = await AppService({ config });
|
|
|
|
expect(result).toEqual(
|
|
expect.objectContaining({
|
|
interfaceConfig: expect.anything(),
|
|
}),
|
|
);
|
|
|
|
// Verify that peoplePicker is undefined when not provided
|
|
expect(result.interfaceConfig?.peoplePicker).toBeUndefined();
|
|
});
|
|
});
|