The platform for continuously improving AI agents.
// @vitest-environment jsdom
// covers: console-logic
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, expect, it } from "vitest";
import type { WorkshopDatasetActivity } from "@/openapi";
import { WorkshopHandoff } from "./workshop-handoff";
afterEach(cleanup);
it("keeps the handoff active until Workshop completes and retains its action summaries", () => {
const activity: WorkshopDatasetActivity = {
actions: [{ id: "action", status: "completed", text: "Checking partition overlap" }],
dataset: "dataset",
name: "Medical cases",
state: "running",
task: "task",
};
const { rerender } = render(<WorkshopHandoff activity={activity} />);
expect(screen.getByText("Working in Data Workshop")).toBeTruthy();
expect(screen.queryByText("Results returned to experiment chat")).toBeNull();
rerender(<WorkshopHandoff activity={{ ...activity, state: "blocked" }} />);
expect(screen.queryByText("Results returned to experiment chat")).toBeNull();
rerender(<WorkshopHandoff activity={{ ...activity, state: "completed" }} />);
expect(screen.getByText("Results returned to experiment chat").className).toContain(
"text-success"
);
expect(screen.getByText("Checking partition overlap")).toBeTruthy();
fireEvent.click(screen.getByRole("button"));
expect(screen.queryByText("Checking partition overlap")).toBeNull();
});