mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
46 lines
1.6 KiB
JavaScript
46 lines
1.6 KiB
JavaScript
|
|
const { SystemRoles } = require('librechat-data-provider');
|
||
|
|
const { updatePromptsAccess } = require('~/models/Role');
|
||
|
|
const { loadDefaultInterface } = require('./interface');
|
||
|
|
|
||
|
|
jest.mock('~/models/Role', () => ({
|
||
|
|
updatePromptsAccess: jest.fn(),
|
||
|
|
}));
|
||
|
|
|
||
|
|
describe('loadDefaultInterface', () => {
|
||
|
|
it('should call updatePromptsAccess with the correct parameters when prompts is true', async () => {
|
||
|
|
const config = { interface: { prompts: true } };
|
||
|
|
const configDefaults = { interface: {} };
|
||
|
|
|
||
|
|
await loadDefaultInterface(config, configDefaults);
|
||
|
|
|
||
|
|
expect(updatePromptsAccess).toHaveBeenCalledWith(SystemRoles.USER, true);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('should call updatePromptsAccess with false when prompts is false', async () => {
|
||
|
|
const config = { interface: { prompts: false } };
|
||
|
|
const configDefaults = { interface: {} };
|
||
|
|
|
||
|
|
await loadDefaultInterface(config, configDefaults);
|
||
|
|
|
||
|
|
expect(updatePromptsAccess).toHaveBeenCalledWith(SystemRoles.USER, false);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('should call updatePromptsAccess with undefined when prompts is not specified in config', async () => {
|
||
|
|
const config = {};
|
||
|
|
const configDefaults = { interface: {} };
|
||
|
|
|
||
|
|
await loadDefaultInterface(config, configDefaults);
|
||
|
|
|
||
|
|
expect(updatePromptsAccess).toHaveBeenCalledWith(SystemRoles.USER, undefined);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('should call updatePromptsAccess with undefined when prompts is explicitly undefined', async () => {
|
||
|
|
const config = { interface: { prompts: undefined } };
|
||
|
|
const configDefaults = { interface: {} };
|
||
|
|
|
||
|
|
await loadDefaultInterface(config, configDefaults);
|
||
|
|
|
||
|
|
expect(updatePromptsAccess).toHaveBeenCalledWith(SystemRoles.USER, undefined);
|
||
|
|
});
|
||
|
|
});
|