mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-21 21:50:49 +02:00

WIP: pre-granular-permissions commit
feat: Add category and support contact fields to Agent schema and UI components
Revert "feat: Add category and support contact fields to Agent schema and UI components"
This reverts commit c43a52b4c9
.
Fix: Update import for renderHook in useAgentCategories.spec.tsx
fix: Update icon rendering in AgentCategoryDisplay tests to use empty spans
refactor: Improve category synchronization logic and clean up AgentConfig component
refactor: Remove unused UI flow translations from translation.json
feat: agent marketplace features
🔐 feat: Granular Role-based Permissions + Entra ID Group Discovery (#7804)
91 lines
3 KiB
JavaScript
91 lines
3 KiB
JavaScript
jest.mock('~/models', () => ({
|
|
initializeRoles: jest.fn(),
|
|
seedDefaultRoles: jest.fn(),
|
|
}));
|
|
jest.mock('~/models/Role', () => ({
|
|
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(),
|
|
checkWebSearchConfig: 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();
|
|
});
|
|
});
|