Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,59 @@
|
||||
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(
|
||||
<MemoryRouter>
|
||||
<TabsWithIcons
|
||||
tabs={[
|
||||
{ name: "Overview", href: "/overview", current: true },
|
||||
{ name: "Settings", href: "/settings", current: false },
|
||||
{ name: "Recent", onClick: vi.fn(), current: false },
|
||||
{ name: "Pinned", onClick: vi.fn(), current: true },
|
||||
]}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
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(
|
||||
<MemoryRouter>
|
||||
<TabsWithIcons
|
||||
tabs={[
|
||||
{ name: "First", href: "/first", current: true },
|
||||
{ name: "Second", href: "/second", current: false },
|
||||
]}
|
||||
/>
|
||||
<TabsWithIcons
|
||||
tabs={[
|
||||
{ name: "Third", href: "/third", current: false },
|
||||
{ name: "Fourth", href: "/fourth", current: true },
|
||||
]}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user