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 * as stories from "./Checkbox.stories.tsx" const { AllStates, Playground, Interactive, WithDescriptions, WithValues, } = composeStories(stories) test("it is a checkbox a screen reader can name", async () => { const { canvas, canvasElement } = await mountStory(Playground) const checkbox = expectAgentDrivable(canvas, { name: "Delete originals after import", role: "checkbox", }) await expect(checkbox).not.toBeChecked() await expectNoAxeViolations(canvasElement) }) test("a press toggles it, and the label is part of the target", async () => { const { canvas } = await mountStory(Interactive) const checkbox = expectAgentDrivable(canvas, { name: "Delete originals after import", role: "checkbox", }) // The label wraps the control, so a click on the text is a click // on the box — which is the association `