test(ui): cover keyboard activation of the log drawer collapse rows

The migration turned each collapse row into a real button, but the existing
tests only click, so a regression in Enter or Space activation would still
pass. Add one test per component that tabs to the row, expands with Enter and
collapses with Space, asserting visibility rather than markup.

Both fail against the antd version and pass against the migrated one.
This commit is contained in:
Yuneng Jiang 2026-08-12 22:39:29 -07:00
parent 49c697ee89
commit 266a35b88c
No known key found for this signature in database
2 changed files with 32 additions and 0 deletions

View file

@ -37,4 +37,18 @@ describe("CollapsibleMessage", () => {
await user.click(screen.getByText("SYSTEM"));
expect(screen.getByText("Toggle me")).toBeInTheDocument();
});
it("should expand with Enter and collapse with Space from the keyboard", async () => {
const user = userEvent.setup();
render(<CollapsibleMessage label="SYSTEM" content="Toggle me" defaultExpanded={false} />);
expect(screen.getByText("Toggle me")).not.toBeVisible();
await user.tab();
await user.keyboard("{Enter}");
expect(screen.getByText("Toggle me")).toBeVisible();
await user.keyboard(" ");
expect(screen.getByText("Toggle me")).not.toBeVisible();
});
});

View file

@ -41,4 +41,22 @@ describe("HistoryTree", () => {
expect(screen.getByText("Hello")).toBeInTheDocument();
expect(screen.getByText("Hi there")).toBeInTheDocument();
});
it("should expand with Enter and collapse with Space from the keyboard", async () => {
const user = userEvent.setup();
const messages: ParsedMessage[] = [
{ role: "user", content: "Hello" },
{ role: "assistant", content: "Hi there" },
];
render(<HistoryTree messages={messages} />);
expect(screen.getByText("Hello")).not.toBeVisible();
await user.tab();
await user.keyboard("{Enter}");
expect(screen.getByText("Hello")).toBeVisible();
await user.keyboard(" ");
expect(screen.getByText("Hello")).not.toBeVisible();
});
});