File size: 2,452 Bytes
c2a37bc 38a90cc c2a37bc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | import { fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import AssistantWorkspace, { AssistantSetupPanel } from "./AssistantWorkspace";
describe("AssistantWorkspace", () => {
it("collapses setup after the first conversation turn and allows reopening it", () => {
const { rerender } = render(
<AssistantSetupPanel summary="Use setup before starting." hasConversation={false}>
<div>Setup body</div>
</AssistantSetupPanel>
);
expect(screen.getByText("Use setup before starting.")).toBeInTheDocument();
expect(screen.getByText("Setup body")).toBeInTheDocument();
rerender(
<AssistantSetupPanel summary="Use setup before starting." hasConversation>
<div>Setup body</div>
</AssistantSetupPanel>
);
expect(screen.queryByText("Use setup before starting.")).not.toBeInTheDocument();
expect(screen.queryByText("Setup body")).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Show setup" }));
expect(screen.getByText("Setup body")).toBeInTheDocument();
});
it("shows setup by default before the conversation starts", () => {
render(
<AssistantWorkspace
title="Assistant shell"
description="Conversation first."
setupSummary="Use setup before starting."
hasConversation={false}
setupContent={<div>Setup body</div>}
toolsContent={<div>Tools body</div>}
conversationContent={<div>Conversation body</div>}
secondaryRail={<div>Prompt rail</div>}
/>
);
expect(screen.getByText("Use setup before starting.")).toBeInTheDocument();
expect(screen.getByText("Setup body")).toBeInTheDocument();
expect(screen.getByText("Tools body")).toBeInTheDocument();
});
it("reopens setup after the conversation is reset", () => {
const { rerender } = render(
<AssistantSetupPanel summary="Use setup before starting." hasConversation>
<div>Setup body</div>
</AssistantSetupPanel>
);
expect(screen.queryByText("Setup body")).not.toBeInTheDocument();
rerender(
<AssistantSetupPanel summary="Use setup before starting." hasConversation={false}>
<div>Setup body</div>
</AssistantSetupPanel>
);
expect(screen.getByText("Use setup before starting.")).toBeInTheDocument();
expect(screen.getByText("Setup body")).toBeInTheDocument();
});
});
|