theo-agent-dashboard

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

MessageList.test.tsx (1068B)


      1 import { describe, it, expect, vi, beforeEach } from "vitest";
      2 import { render, screen } from "@testing-library/react";
      3 import { MessageList } from "./MessageList";
      4 import type { Message } from "../../store/chat";
      5 
      6 beforeEach(() => {
      7   // Mock scrollIntoView for jsdom
      8   Element.prototype.scrollIntoView = vi.fn();
      9 });
     10 
     11 describe("MessageList", () => {
     12   it("shows empty state when no messages", () => {
     13     render(<MessageList messages={[]} />);
     14     expect(screen.getByText("Send a message to start")).toBeInTheDocument();
     15   });
     16 
     17   it("renders messages", () => {
     18     const messages: Message[] = [
     19       {
     20         id: "m1",
     21         role: "user",
     22         content: "Hello",
     23         toolCalls: [],
     24         timestamp: Date.now(),
     25       },
     26       {
     27         id: "m2",
     28         role: "assistant",
     29         content: "Hi there!",
     30         toolCalls: [],
     31         timestamp: Date.now(),
     32       },
     33     ];
     34     render(<MessageList messages={messages} />);
     35     expect(screen.getByText("Hello")).toBeInTheDocument();
     36     expect(screen.getByText("Hi there!")).toBeInTheDocument();
     37   });
     38 });