Skip to content

The platform for continuously improving AI agents.

970 B
Raw Blame
// @vitest-environment jsdom
// covers: console-logic
import { useState } from "react";

import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, expect, it } from "vitest";

import { ExecutionCard } from "./execution-card";

afterEach(cleanup);

function Card() {
  const [open, setOpen] = useState(false);
  return (
    <ExecutionCard onOpenChange={setOpen} open={open} status="running" title="Training run">
      <p>Train loss</p>
    </ExecutionCard>
  );
}

it("keeps the run report collapsed until opened", () => {
  render(<Card />);
  const toggle = screen.getByRole("button", { name: /Training run/ });
  expect(toggle.getAttribute("aria-expanded")).toBe("false");
  expect(screen.queryByText("Train loss")).toBeNull();
  expect(screen.getByText("Running")).toBeTruthy();
  fireEvent.click(toggle);
  expect(screen.getByText("Train loss")).toBeTruthy();
  expect(toggle.getAttribute("aria-expanded")).toBe("true");
});