/* eslint-disable formatjs/no-literal-string-in-jsx */ import { describe, expect, it, afterEach } from "vitest" import { render, screen, cleanup } from "@testing-library/react" import userEvent from "@testing-library/user-event" import { ChipStatic } from "./ChipStatic" afterEach(() => { cleanup() }) describe("ChipStatic accessibility", () => { describe("semantic HTML", () => { it("uses span element (non-interactive)", () => { render(Static Label) const chip = screen.getByText("Static Label") expect(chip.tagName).toBe("SPAN") }) it("is not a button or link", () => { render(Not Interactive) expect(screen.queryByRole("button")).toBeNull() expect(screen.queryByRole("link")).toBeNull() }) it("content is visible and readable", () => { render(Readable Content) expect(screen.getByText("Readable Content")).toBeTruthy() }) }) describe("non-interactive behavior", () => { it("is not focusable by default", async () => { const user = userEvent.setup() render(
Static Chip
) await user.tab() // Focus should skip the static chip and go directly to the button expect(document.activeElement).toBe( screen.getByRole("button", { name: "Focusable Button" }) ) }) it("does not receive focus when tabbing through page", async () => { const user = userEvent.setup() render(
Static
) const firstButton = screen.getByRole("button", { name: "First" }) const secondButton = screen.getByRole("button", { name: "Second" }) await user.tab() expect(document.activeElement).toBe(firstButton) await user.tab() expect(document.activeElement).toBe(secondButton) }) }) describe("screen reader support", () => { it("has visible text content", () => { render(Screen Reader Text) const chip = screen.getByText("Screen Reader Text") expect(chip.textContent?.trim().length).toBeGreaterThan(0) }) it("text content is accessible in the DOM", () => { render(Status: Active) expect(screen.getByText("Status: Active")).toBeTruthy() }) }) describe("color contrast considerations", () => { it("Neutral color variant renders", () => { render(Neutral) expect(screen.getByText("Neutral")).toBeTruthy() }) it("Subtle color variant renders", () => { render(Subtle) expect(screen.getByText("Subtle")).toBeTruthy() }) it("Disabled color variant renders", () => { render(Disabled) expect(screen.getByText("Disabled")).toBeTruthy() }) }) describe("text sizing", () => { it("xs size renders readable text", () => { render(Extra Small) expect(screen.getByText("Extra Small")).toBeTruthy() }) it("sm size renders readable text", () => { render(Small) expect(screen.getByText("Small")).toBeTruthy() }) it("lg size renders readable text", () => { render(Large) expect(screen.getByText("Large")).toBeTruthy() }) }) })