diff --git a/client/e2e/json-view-copy-button.spec.ts b/client/e2e/json-view-copy-button.spec.ts new file mode 100644 index 000000000..26f4eb5a2 --- /dev/null +++ b/client/e2e/json-view-copy-button.spec.ts @@ -0,0 +1,31 @@ +import { test, expect } from "@playwright/test"; + +const APP_URL = "http://localhost:6274/"; + +test.describe("JsonView Copy Button", () => { + test("copy button should not overlap with long text content", async ({ + page, + }) => { + // Navigate to tools tab which uses JsonView + await page.goto(`${APP_URL}#tools`); + + // Wait for the tools tab to be visible + await page.waitForSelector('[role="tabpanel"][data-state="active"]'); + + // Select a tool and run it to generate output + await page.click("text=List Tools"); + await page.waitForSelector(".font-mono"); // Wait for JsonView to render + + // Get the content area and copy button positions + const contentBox = await page.locator(".font-mono").boundingBox(); + const copyButton = await page + .locator("button:has(svg)") + .first() + .boundingBox(); + + if (contentBox && copyButton) { + // Verify button doesn't overlap with content area + expect(contentBox.x + contentBox.width).toBeLessThan(copyButton.x); + } + }); +}); diff --git a/client/src/components/JsonView.tsx b/client/src/components/JsonView.tsx index 1febff6a4..f7d596b9f 100644 --- a/client/src/components/JsonView.tsx +++ b/client/src/components/JsonView.tsx @@ -69,7 +69,7 @@ const JsonView = memo( )} )} -
+
{ + it("should have padding to prevent copy button overlap", () => { + const longText = + "This is a very long text that would normally flow under the copy button without proper padding applied to the content area"; + + const { container } = render( + , + ); + + // Check that the content div has right padding + const contentDiv = container.querySelector(".font-mono"); + expect(contentDiv).toHaveClass("pr-12"); + }); + + it("should render without copy button when withCopyButton is false", () => { + render(); + + // Copy button should not be present + const copyButton = screen.queryByRole("button"); + expect(copyButton).not.toBeInTheDocument(); + }); +});