Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(ui): find the section copy button by role instead of the antd icon

Yuneng Jiangb4092f476f0a
diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/InputCard.test.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/InputCard.test.tsx
index 4a6773994ed..5bf97b16233 100644
--- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/InputCard.test.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/InputCard.test.tsx
@@ -111,16 +111,12 @@ describe("InputCard", () => {
render(<InputCard messages={messages} />);
- const copyButtons = screen.getAllByRole("button");
- const copyButton = copyButtons.find((button) => {
- const icon = button.querySelector('[aria-label="copy"]');
- return icon !== null;
- });
+ const copyButton = screen.getByRole("button", { name: /copy/i });
expect(copyButton).toBeInTheDocument();
await act(async () => {
- fireEvent.click(copyButton!);
+ fireEvent.click(copyButton);
});
await waitFor(() => {
@@ -209,11 +205,7 @@ describe("InputCard", () => {
},
];
render(<InputCard messages={messages} />);
- const copyButtons = screen.getAllByRole("button");
- const copyButton = copyButtons.find((button) => {
- const icon = button.querySelector('[aria-label="copy"]');
- return icon !== null;
- });
+ const copyButton = screen.getByRole("button", { name: /copy/i });
expect(copyButton).toBeInTheDocument();
});
});
diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/OutputCard.test.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/OutputCard.test.tsx
index 6cf3cdd1670..94616e40495 100644
--- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/OutputCard.test.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/OutputCard.test.tsx
@@ -66,16 +66,12 @@ describe("OutputCard", () => {
it("should copy message content when copy button is clicked", async () => {
render(<OutputCard message={mockMessage} />);
- const copyButtons = screen.getAllByRole("button");
- const copyButton = copyButtons.find((button) => {
- const icon = button.querySelector('[aria-label="copy"]');
- return icon !== null;
- });
+ const copyButton = screen.getByRole("button", { name: /copy/i });
expect(copyButton).toBeInTheDocument();
await act(async () => {
- fireEvent.click(copyButton!);
+ fireEvent.click(copyButton);
});
await waitFor(() => {
@@ -88,14 +84,10 @@ describe("OutputCard", () => {
render(<OutputCard message={null} />);
- const copyButtons = screen.getAllByRole("button");
- const copyButton = copyButtons.find((button) => {
- const icon = button.querySelector('[aria-label="copy"]');
- return icon !== null;
- });
+ const copyButton = screen.getByRole("button", { name: /copy/i });
expect(copyButton).toBeInTheDocument();
- await user.click(copyButton!);
+ await user.click(copyButton);
await waitFor(() => {
expect(mockWriteText).not.toHaveBeenCalled();