mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
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:
parent
49c697ee89
commit
266a35b88c
2 changed files with 32 additions and 0 deletions
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue