mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-22 11:20:15 +01:00
ci: update related tests
This commit is contained in:
parent
8f89fdc802
commit
1168a7d82e
10 changed files with 169 additions and 157 deletions
|
|
@ -13,8 +13,8 @@ const {
|
|||
deleteMessagesSince,
|
||||
} = require('./Message');
|
||||
|
||||
jest.mock('~/server/services/Config/getCustomConfig');
|
||||
const { getCustomConfig } = require('~/server/services/Config/getCustomConfig');
|
||||
jest.mock('~/server/services/Config/app');
|
||||
const { getAppConfig } = require('~/server/services/Config/app');
|
||||
|
||||
/**
|
||||
* @type {import('mongoose').Model<import('@librechat/data-schemas').IMessage>}
|
||||
|
|
@ -326,9 +326,9 @@ describe('Message Operations', () => {
|
|||
});
|
||||
|
||||
it('should save a message with expiredAt when isTemporary is true', async () => {
|
||||
// Mock custom config with 24 hour retention
|
||||
getCustomConfig.mockResolvedValue({
|
||||
interface: {
|
||||
// Mock app config with 24 hour retention
|
||||
getAppConfig.mockResolvedValue({
|
||||
interfaceConfig: {
|
||||
temporaryChatRetention: 24,
|
||||
},
|
||||
});
|
||||
|
|
@ -375,9 +375,9 @@ describe('Message Operations', () => {
|
|||
});
|
||||
|
||||
it('should use custom retention period from config', async () => {
|
||||
// Mock custom config with 48 hour retention
|
||||
getCustomConfig.mockResolvedValue({
|
||||
interface: {
|
||||
// Mock app config with 48 hour retention
|
||||
getAppConfig.mockResolvedValue({
|
||||
interfaceConfig: {
|
||||
temporaryChatRetention: 48,
|
||||
},
|
||||
});
|
||||
|
|
@ -402,9 +402,9 @@ describe('Message Operations', () => {
|
|||
});
|
||||
|
||||
it('should handle minimum retention period (1 hour)', async () => {
|
||||
// Mock custom config with less than minimum retention
|
||||
getCustomConfig.mockResolvedValue({
|
||||
interface: {
|
||||
// Mock app config with less than minimum retention
|
||||
getAppConfig.mockResolvedValue({
|
||||
interfaceConfig: {
|
||||
temporaryChatRetention: 0.5, // Half hour - should be clamped to 1 hour
|
||||
},
|
||||
});
|
||||
|
|
@ -429,9 +429,9 @@ describe('Message Operations', () => {
|
|||
});
|
||||
|
||||
it('should handle maximum retention period (8760 hours)', async () => {
|
||||
// Mock custom config with more than maximum retention
|
||||
getCustomConfig.mockResolvedValue({
|
||||
interface: {
|
||||
// Mock app config with more than maximum retention
|
||||
getAppConfig.mockResolvedValue({
|
||||
interfaceConfig: {
|
||||
temporaryChatRetention: 10000, // Should be clamped to 8760 hours
|
||||
},
|
||||
});
|
||||
|
|
@ -455,9 +455,9 @@ describe('Message Operations', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('should handle getCustomConfig errors gracefully', async () => {
|
||||
// Mock getCustomConfig to throw an error
|
||||
getCustomConfig.mockRejectedValue(new Error('Config service unavailable'));
|
||||
it('should handle getAppConfig errors gracefully', async () => {
|
||||
// Mock getAppConfig to throw an error
|
||||
getAppConfig.mockRejectedValue(new Error('Config service unavailable'));
|
||||
|
||||
mockReq.body = { isTemporary: true };
|
||||
|
||||
|
|
@ -469,8 +469,8 @@ describe('Message Operations', () => {
|
|||
});
|
||||
|
||||
it('should use default retention when config is not provided', async () => {
|
||||
// Mock getCustomConfig to return empty config
|
||||
getCustomConfig.mockResolvedValue({});
|
||||
// Mock getAppConfig to return empty config
|
||||
getAppConfig.mockResolvedValue({});
|
||||
|
||||
mockReq.body = { isTemporary: true };
|
||||
|
||||
|
|
@ -493,8 +493,8 @@ describe('Message Operations', () => {
|
|||
|
||||
it('should not update expiredAt on message update', async () => {
|
||||
// First save a temporary message
|
||||
getCustomConfig.mockResolvedValue({
|
||||
interface: {
|
||||
getAppConfig.mockResolvedValue({
|
||||
interfaceConfig: {
|
||||
temporaryChatRetention: 24,
|
||||
},
|
||||
});
|
||||
|
|
@ -520,8 +520,8 @@ describe('Message Operations', () => {
|
|||
|
||||
it('should preserve expiredAt when saving existing temporary message', async () => {
|
||||
// First save a temporary message
|
||||
getCustomConfig.mockResolvedValue({
|
||||
interface: {
|
||||
getAppConfig.mockResolvedValue({
|
||||
interfaceConfig: {
|
||||
temporaryChatRetention: 24,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue