import "@testing-library/jest-dom";
import { render, screen, within } from "@testing-library/react";
import { MemoryRouter } from "react-router";
import { describe, expect, it, vi } from "vitest";
import { assertNoA11yViolations } from "~/utils/test/a11y";
import TabsWithIcons from "./TabsWithIcons";
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (key: string) => key }),
}));
describe("TabsWithIcons accessibility", () => {
it("exposes selected state for link tabs and button tabs", () => {
render(
);
expect(screen.getByRole("link", { name: "Overview" })).toHaveAttribute("aria-current", "page");
expect(screen.getByRole("link", { name: "Settings" })).not.toHaveAttribute("aria-current");
expect(screen.getByRole("button", { name: "Recent" })).toHaveAttribute("aria-pressed", "false");
expect(screen.getByRole("button", { name: "Pinned" })).toHaveAttribute("aria-pressed", "true");
});
it("keeps mobile select labels unique when multiple instances render", () => {
const { container } = render(
);
const selects = screen.getAllByRole("combobox", { name: "shared.select" });
expect(selects).toHaveLength(2);
expect(selects[0]).not.toHaveAttribute("id", selects[1].getAttribute("id") ?? "");
expect(within(selects[0]).getByRole("option", { name: "First" })).toBeInTheDocument();
expect(within(selects[1]).getByRole("option", { name: "Fourth" })).toBeInTheDocument();
assertNoA11yViolations(container);
});
});