Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
import { QueryKeys, TERMS_NOT_ACCEPTED_CODE } from 'librechat-data-provider';
import type { QueryClient } from '@tanstack/react-query';
import { hasTermsRefusal, reopenTermsOnRefusal } from '../terms';
describe('terms refusal helpers', () => {
it.each([
[{ code: TERMS_NOT_ACCEPTED_CODE }, true],
[{ error: { code: TERMS_NOT_ACCEPTED_CODE } }, true],
[{ code: 'other' }, false],
[null, false],
['terms_not_accepted', false],
])('detects a refusal in %j', (data, expected) => {
expect(hasTermsRefusal(data)).toBe(expected);
});
it('refetches the startup config and terms status only for a refusal', () => {
const invalidateQueries = jest.fn();
const queryClient = { invalidateQueries } as unknown as QueryClient;
expect(reopenTermsOnRefusal(queryClient, { code: 'other' })).toBe(false);
expect(invalidateQueries).not.toHaveBeenCalled();
expect(reopenTermsOnRefusal(queryClient, { code: TERMS_NOT_ACCEPTED_CODE })).toBe(true);
expect(invalidateQueries).toHaveBeenCalledWith([QueryKeys.startupConfig]);
expect(invalidateQueries).toHaveBeenCalledWith([QueryKeys.userTerms]);
});
});