mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 08:12:00 +02:00

* refactor: Update staticCache to use oneDayInSeconds for sMaxAge and maxAge * refactor: role updates * style: first pass cursor * style: Update nested list styles in style.css * feat: setIsSubmitting to true in message handler to prevent edge case where submitting turns false during message stream * feat: Add logic to redirect to conversation page after creating a new conversation * refactor: Trim code string before copying in CodeBlock component * feat: configSchema bookmarks and presets defaults * feat: Update loadDefaultInterface to handle undefined config * refactor: use for compression check * feat: first pass, query params * fix: styling issues for prompt cards * feat: anthropic prompt caching UI switch * chore: Update static file cache control defaults/comments in .env.example * ci: fix tests * ci: fix tests * chore: use "submitting" class server error connection suspense fallback
87 lines
2.9 KiB
JavaScript
87 lines
2.9 KiB
JavaScript
jest.mock('~/models/Role', () => ({
|
|
initializeRoles: jest.fn(),
|
|
updateAccessPermissions: jest.fn(),
|
|
getRoleByName: jest.fn(),
|
|
updateRoleByName: jest.fn(),
|
|
}));
|
|
|
|
jest.mock('~/config', () => ({
|
|
logger: {
|
|
info: jest.fn(),
|
|
warn: jest.fn(),
|
|
error: jest.fn(),
|
|
},
|
|
}));
|
|
|
|
jest.mock('./Config/loadCustomConfig', () => jest.fn());
|
|
jest.mock('./start/interface', () => ({
|
|
loadDefaultInterface: jest.fn(),
|
|
}));
|
|
jest.mock('./ToolService', () => ({
|
|
loadAndFormatTools: jest.fn().mockReturnValue({}),
|
|
}));
|
|
jest.mock('./start/checks', () => ({
|
|
checkVariables: jest.fn(),
|
|
checkHealth: jest.fn(),
|
|
checkConfig: jest.fn(),
|
|
checkAzureVariables: jest.fn(),
|
|
}));
|
|
|
|
const AppService = require('./AppService');
|
|
const { loadDefaultInterface } = require('./start/interface');
|
|
|
|
describe('AppService interface configuration', () => {
|
|
let app;
|
|
let mockLoadCustomConfig;
|
|
|
|
beforeEach(() => {
|
|
app = { locals: {} };
|
|
jest.resetModules();
|
|
jest.clearAllMocks();
|
|
mockLoadCustomConfig = require('./Config/loadCustomConfig');
|
|
});
|
|
|
|
it('should set prompts and bookmarks to true when loadDefaultInterface returns true for both', async () => {
|
|
mockLoadCustomConfig.mockResolvedValue({});
|
|
loadDefaultInterface.mockResolvedValue({ prompts: true, bookmarks: true });
|
|
|
|
await AppService(app);
|
|
|
|
expect(app.locals.interfaceConfig.prompts).toBe(true);
|
|
expect(app.locals.interfaceConfig.bookmarks).toBe(true);
|
|
expect(loadDefaultInterface).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should set prompts and bookmarks to false when loadDefaultInterface returns false for both', async () => {
|
|
mockLoadCustomConfig.mockResolvedValue({ interface: { prompts: false, bookmarks: false } });
|
|
loadDefaultInterface.mockResolvedValue({ prompts: false, bookmarks: false });
|
|
|
|
await AppService(app);
|
|
|
|
expect(app.locals.interfaceConfig.prompts).toBe(false);
|
|
expect(app.locals.interfaceConfig.bookmarks).toBe(false);
|
|
expect(loadDefaultInterface).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should not set prompts and bookmarks when loadDefaultInterface returns undefined for both', async () => {
|
|
mockLoadCustomConfig.mockResolvedValue({});
|
|
loadDefaultInterface.mockResolvedValue({});
|
|
|
|
await AppService(app);
|
|
|
|
expect(app.locals.interfaceConfig.prompts).toBeUndefined();
|
|
expect(app.locals.interfaceConfig.bookmarks).toBeUndefined();
|
|
expect(loadDefaultInterface).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should set prompts and bookmarks to different values when loadDefaultInterface returns different values', async () => {
|
|
mockLoadCustomConfig.mockResolvedValue({ interface: { prompts: true, bookmarks: false } });
|
|
loadDefaultInterface.mockResolvedValue({ prompts: true, bookmarks: false });
|
|
|
|
await AppService(app);
|
|
|
|
expect(app.locals.interfaceConfig.prompts).toBe(true);
|
|
expect(app.locals.interfaceConfig.bookmarks).toBe(false);
|
|
expect(loadDefaultInterface).toHaveBeenCalled();
|
|
});
|
|
});
|