🔐 feat: Toggle Access to Prompts via librechat.yaml (#3735)

* chore: update CONFIG_VERSION to '1.1.6'

* chore: update package version to 0.7.415

* feat: toggle USER role access to prompts via librechat.yaml

* refactor: set prompts to true when loadDefaultInterface returns true

* ci(AppService): mock updatePromptsAccess
This commit is contained in:
Danny Avila 2024-08-21 19:57:34 -04:00 committed by GitHub
parent 0c5568b80b
commit 596ecc6969
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 176 additions and 11 deletions

View file

@ -0,0 +1,45 @@
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);
});
});