mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 13:00:55 +00:00
PromptService gains importSourceGroup, which finds or creates a source pointer group, grants the PUBLIC viewer role and rolls the group back if the grant fails. The Langfuse catalog sync calls it instead of four storage callbacks and two Mongo error predicates, and the prompt service is composed once in api/server/services/Prompts.js and passed to the prompt routes, linked instructions, instructions prompt access and the Langfuse sync runner. Co-authored-by: Rebase Probe <probe@example.com>
33 lines
1 KiB
JavaScript
33 lines
1 KiB
JavaScript
const mockDb = { marker: 'db' };
|
|
const mockGrantPermission = jest.fn();
|
|
const mockGetAppConfig = jest.fn();
|
|
const mockPromptServiceInstance = { marker: 'promptService' };
|
|
const mockCreatePromptService = jest.fn(() => mockPromptServiceInstance);
|
|
|
|
jest.mock('@librechat/api', () => ({
|
|
createPromptService: mockCreatePromptService,
|
|
}));
|
|
|
|
jest.mock('~/models', () => mockDb);
|
|
|
|
jest.mock('~/server/services/PermissionService', () => ({
|
|
grantPermission: mockGrantPermission,
|
|
}));
|
|
|
|
jest.mock('~/server/services/Config', () => ({
|
|
getAppConfig: mockGetAppConfig,
|
|
}));
|
|
|
|
describe('Prompts', () => {
|
|
it('builds the process prompt service once with the shared db, grantPermission and getAppConfig', () => {
|
|
const { promptService } = require('./Prompts');
|
|
|
|
expect(mockCreatePromptService).toHaveBeenCalledTimes(1);
|
|
expect(mockCreatePromptService).toHaveBeenCalledWith({
|
|
db: mockDb,
|
|
grantPermission: mockGrantPermission,
|
|
getAppConfig: mockGetAppConfig,
|
|
});
|
|
expect(promptService).toBe(mockPromptServiceInstance);
|
|
});
|
|
});
|