From 08bcf341bb30aa049ccfdcd149edc3c9b0faafe6 Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Wed, 3 Jun 2026 09:29:02 +0000
Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20[testing=20improvement]=20Add=20?=
=?UTF-8?q?tests=20for=20ActionButtons=20component?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
---
src/components/ActionButtons.test.tsx | 106 ++++++++++++++++++++++++++
vitest.config.ts | 1 +
2 files changed, 107 insertions(+)
create mode 100644 src/components/ActionButtons.test.tsx
diff --git a/src/components/ActionButtons.test.tsx b/src/components/ActionButtons.test.tsx
new file mode 100644
index 00000000..0acd1e23
--- /dev/null
+++ b/src/components/ActionButtons.test.tsx
@@ -0,0 +1,106 @@
+import { render, screen, fireEvent } from "@testing-library/react";
+import { describe, it, expect, vi, beforeEach } from "vitest";
+import { ActionButtons } from "./ActionButtons";
+
+describe("ActionButtons", () => {
+ const mockHandleCopy = vi.fn();
+ const mockHandleDownload = vi.fn();
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it("renders both buttons", () => {
+ render(
+
+ );
+
+ expect(screen.getByRole("button", { name: /copy image/i })).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: /download png/i })).toBeInTheDocument();
+ });
+
+ it("disables buttons when previewUrl is null", () => {
+ render(
+
+ );
+
+ const copyButton = screen.getByRole("button", { name: /copy image/i });
+ const downloadButton = screen.getByRole("button", { name: /download png/i });
+
+ expect(copyButton).toBeDisabled();
+ expect(downloadButton).toBeDisabled();
+ });
+
+ it("enables buttons when previewUrl is provided", () => {
+ render(
+
+ );
+
+ const copyButton = screen.getByRole("button", { name: /copy image/i });
+ const downloadButton = screen.getByRole("button", { name: /download png/i });
+
+ expect(copyButton).not.toBeDisabled();
+ expect(downloadButton).not.toBeDisabled();
+ });
+
+ it("calls handleCopy when copy button is clicked", () => {
+ render(
+
+ );
+
+ const copyButton = screen.getByRole("button", { name: /copy image/i });
+ fireEvent.click(copyButton);
+
+ expect(mockHandleCopy).toHaveBeenCalledTimes(1);
+ });
+
+ it("calls handleDownload when download button is clicked", () => {
+ render(
+
+ );
+
+ const downloadButton = screen.getByRole("button", { name: /download png/i });
+ fireEvent.click(downloadButton);
+
+ expect(mockHandleDownload).toHaveBeenCalledTimes(1);
+ });
+
+ it("shows 'Copied!' text and icon when copyStatus is 'copied'", () => {
+ render(
+
+ );
+
+ expect(screen.getByRole("button", { name: /copied!/i })).toBeInTheDocument();
+ expect(screen.queryByRole("button", { name: /copy image/i })).not.toBeInTheDocument();
+ });
+});
diff --git a/vitest.config.ts b/vitest.config.ts
index 8ab92149..ed9eede9 100644
--- a/vitest.config.ts
+++ b/vitest.config.ts
@@ -22,6 +22,7 @@ export default defineConfig({
"src/components/SkillsCard.tsx",
"src/components/LayoutEditor.tsx",
"src/lib/rateLimit.ts",
+ "src/components/ActionButtons.tsx",
],
thresholds: {
lines: 80,