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

920 B
Raw Blame
import React from 'react';
import userEvent from '@testing-library/user-event';
import { render, screen } from '@testing-library/react';
import { ChipModes } from '../Bar';

jest.mock('~/hooks', () => ({
  useLocalize: () => (key: string) => key,
}));

describe('ChipModes', () => {
  it('keeps a portaled menu choice from reaching the composer', async () => {
    const user = userEvent.setup();
    const onComposerClick = jest.fn();
    const onSelect = jest.fn();
    render(
      <div onClick={onComposerClick}>
        <ChipModes modes={[{ id: 'high', label: 'High', active: false, onSelect }]} />
      </div>,
    );

    await user.click(screen.getByRole('button', { name: 'com_ui_mode' }));
    onComposerClick.mockClear();
    await user.click(screen.getByRole('menuitemradio', { name: 'High' }));

    expect(onSelect).toHaveBeenCalledTimes(1);
    expect(onComposerClick).not.toHaveBeenCalled();
  });
});