import { composeStories } from "@storybook/react" import { expect, userEvent, waitFor } from "storybook/test" import { test } from "vitest" import { expectNoAxeViolations } from "../expectNoAxeViolations.testHelpers.ts" import { mountStory } from "../mountStory.testHelpers.ts" import { expectAgentDrivable } from "../testing/index.ts" import { DESKTOP, setViewport, } from "../viewport.testHelpers.ts" import * as stories from "./DataTable.stories.tsx" const { AllVariants, Playground, Interactive, Responsive, LongColumnLabels, DenseComparison, StackedList, } = composeStories(stories) /** * The `` is the table's accessible name. Without one a * screen reader announces "table, 6 columns, 5 rows" and nothing a * reader could use to decide whether to enter it — and * `getByRole("table", { name })`, the query an agent writes, has * nothing to match on. */ test("the table is drivable by role and name", async () => { const { canvas, canvasElement } = await mountStory(Playground) const table = expectAgentDrivable(canvas, { name: "Tasks", role: "table", }) await expect(table.tagName).toBe("TABLE") await expectNoAxeViolations(canvasElement) }) /** * The composition, asserted rather than assumed: a sortable column * is a `SortableTableHeader`, so it is a `` carrying `aria-sort` * with a `