feat: secure and document book reviews system
Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Failing after 10m3s

Added rate limiting to APIs, cleaned up docs, implemented fallback logic for reviews without text, and added comprehensive n8n guide.
This commit is contained in:
2026-02-15 22:32:49 +01:00
parent 0766b46cc8
commit 6998a0e7a1
22 changed files with 3141 additions and 4135 deletions

View File

@@ -0,0 +1,53 @@
import React from "react";
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
import { ThemeToggle } from "@/app/components/ThemeToggle";
import { useTheme } from "next-themes";
// Mock next-themes
jest.mock("next-themes", () => ({
useTheme: jest.fn(),
}));
describe("ThemeToggle Component", () => {
const setThemeMock = jest.fn();
beforeEach(() => {
jest.clearAllMocks();
(useTheme as jest.Mock).mockReturnValue({
theme: "light",
setTheme: setThemeMock,
});
});
it("renders a placeholder initially (to avoid hydration mismatch)", () => {
const { container } = render(<ThemeToggle />);
// Initial render should be the loading div
expect(container.firstChild).toHaveClass("w-9 h-9");
});
it("toggles to dark mode when clicked", async () => {
render(<ThemeToggle />);
// Wait for effect to set mounted=true
const button = await screen.findByRole("button", { name: /toggle theme/i });
fireEvent.click(button);
expect(setThemeMock).toHaveBeenCalledWith("dark");
});
it("toggles to light mode when clicked if currently dark", async () => {
(useTheme as jest.Mock).mockReturnValue({
theme: "dark",
setTheme: setThemeMock,
});
render(<ThemeToggle />);
const button = await screen.findByRole("button", { name: /toggle theme/i });
fireEvent.click(button);
expect(setThemeMock).toHaveBeenCalledWith("light");
});
});