Skip to content

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

1.2 KB
Raw Blame
import { render, screen, waitFor } from '@testing-library/react';
import QueryDevtoolsGate, { shouldEnableQueryDevtools } from '../QueryDevtoolsGate';

jest.mock('@tanstack/react-query-devtools/production', () => ({
  ReactQueryDevtools: () => <div data-testid="query-devtools" />,
}));

describe('QueryDevtoolsGate', () => {
  it('keeps query devtools disabled in production by default', () => {
    expect(shouldEnableQueryDevtools({ isDevelopment: false, config: undefined })).toBe(false);

    const { container } = render(<QueryDevtoolsGate isDevelopment={false} config={undefined} />);

    expect(container).toBeEmptyDOMElement();
    expect(screen.queryByTestId('query-devtools')).not.toBeInTheDocument();
  });

  it('enables query devtools in local development', async () => {
    render(<QueryDevtoolsGate isDevelopment={true} config={undefined} />);

    await waitFor(() => expect(screen.getByTestId('query-devtools')).toBeInTheDocument());
  });

  it('enables query devtools in production when the server-injected flag is true', async () => {
    render(<QueryDevtoolsGate isDevelopment={false} config={{ enableQueryDevtools: true }} />);

    await waitFor(() => expect(screen.getByTestId('query-devtools')).toBeInTheDocument());
  });
});