Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

974 B
Raw Blame
/**
 * @vitest-environment jsdom
 */
import { ErrorCode } from '@activepieces/core-utils';
import { fireEvent, render, screen } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';

import { ChatMessageList } from '@/features/chat';

vi.mock('@/components/providers/theme-provider', () => ({
  useTheme: () => ({ resolvedTheme: 'light' }),
}));

describe('flow chat error bubble', () => {
  it('resends the failed message when the retry button is clicked', () => {
    const sendMessage = vi.fn();
    render(
      <ChatMessageList
        messages={[{ role: 'user', textContent: 'hello' }]}
        sendingError={{ code: ErrorCode.NO_CHAT_RESPONSE, params: {} }}
        isSending={false}
        flowId="flow-1"
        sendMessage={sendMessage}
      />,
    );

    fireEvent.click(screen.getByRole('button'));

    expect(sendMessage).toHaveBeenCalledTimes(1);
    expect(sendMessage).toHaveBeenCalledWith({ isRetrying: true });
  });
});