Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions website-src/src/__tests__/copy-button.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/** @vitest-environment jsdom */
import { afterEach, describe, expect, it, vi } from "vitest";
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
import CopyButton from "../components/CopyButton.jsx";

afterEach(() => { cleanup(); vi.restoreAllMocks(); });

describe("CopyButton", () => {
it("uses title-case Copy with an icon and copies the exact command", async () => {
const writeText = vi.fn().mockResolvedValue(undefined);
Object.defineProperty(navigator, "clipboard", { configurable: true, value: { writeText } });
const command = "npm install -g agent-skill-manager";
render(<CopyButton text={command} />);
const button = screen.getByRole("button", { name: "Copy to clipboard" });
expect(button.textContent).toBe("Copy");
expect(button.querySelector("svg")).not.toBeNull();
fireEvent.click(button);
await waitFor(() => expect(button.textContent).toContain("copied!"));
expect(writeText).toHaveBeenCalledWith(command);
expect(button.querySelector("svg")).not.toBeNull();
fireEvent.click(button);
await waitFor(() => expect(writeText).toHaveBeenCalledTimes(2));
});
});
2 changes: 1 addition & 1 deletion website-src/src/components/BundleDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default function BundleDetail({ bundle }) {
<CopyButton
text={skillInstall}
size="sm"
label="copy"
label="Copy"
ariaLabel={`Copy install command for ${sk.name}`}
/>
)}
Expand Down
2 changes: 1 addition & 1 deletion website-src/src/components/CopyButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function CopyButton({
text,
className = "",
size = "default",
label = "copy",
label = "Copy",
ariaLabel,
variant = "outline",
}) {
Expand Down
Loading