import { render, screen, cleanup } from "@testing-library/react"; import { describe, test, expect, afterEach } from "vitest"; import ContentLockup from "../../app/components/ContentLockup"; afterEach(() => { cleanup(); }); describe("ContentLockup Integration", () => { test("renders hero variant with all content", () => { render( , ); expect( screen.getByRole("heading", { name: "Welcome" }), ).toBeInTheDocument(); expect( screen.getByRole("heading", { name: "Get Started" }), ).toBeInTheDocument(); expect(screen.getByText("This is a description")).toBeInTheDocument(); expect(screen.getAllByRole("button", { name: "Get Started" })).toHaveLength( 3, ); }); test("renders feature variant with link", () => { render( , ); expect( screen.getByRole("heading", { name: "Feature Title" }), ).toBeInTheDocument(); expect( screen.getByRole("link", { name: "Learn More" }), ).toBeInTheDocument(); expect(screen.getByRole("link", { name: "Learn More" })).toHaveAttribute( "href", "/learn", ); }); test("renders ask variant with simplified structure", () => { render( , ); expect( screen.getByRole("heading", { name: "Ask Question" }), ).toBeInTheDocument(); expect( screen.getByRole("heading", { name: "Ask subtitle" }), ).toBeInTheDocument(); // Ask variant should not have description or CTA expect(screen.queryByRole("button")).not.toBeInTheDocument(); }); test("handles left alignment", () => { render( , ); const container = screen .getByRole("heading", { name: "Left Aligned" }) .closest("div"); expect(container).toHaveClass("justify-start"); }); test("renders responsive buttons correctly", () => { render( , ); // Should render all three button variants for different breakpoints const buttons = screen.getAllByRole("button", { name: "Click Me" }); expect(buttons).toHaveLength(3); }); test("applies custom button className", () => { render( , ); const buttons = screen.getAllByRole("button", { name: "Custom" }); // The large button (md breakpoint) should have the custom class expect(buttons[1]).toHaveClass("custom-button-class"); }); test("handles missing optional props gracefully", () => { render(); expect( screen.getByRole("heading", { name: "Minimal" }), ).toBeInTheDocument(); // Should not crash without subtitle, description, or CTA expect(screen.queryByRole("button")).not.toBeInTheDocument(); }); test("renders decorative shape for hero variant", () => { render(); const shape = screen.getByRole("presentation"); expect(shape).toBeInTheDocument(); expect(shape).toHaveAttribute("src", "/assets/Shapes_1.svg"); expect(shape).toHaveAttribute("alt", ""); }); test("does not render shape for non-hero variants", () => { render(); expect(screen.queryByRole("presentation")).not.toBeInTheDocument(); }); test("link has proper accessibility attributes", () => { render( , ); const link = screen.getByRole("link", { name: "Accessible Link" }); expect(link).toHaveAttribute("href", "/accessible"); expect(link).toHaveClass("focus:outline-none", "focus:ring-2"); }); });