import { expect, within } from "storybook/test";
import type { Meta, StoryObj } from "@storybook/react-vite";
import { Text } from "../primitives/Text";
import { View } from "../primitives/View";
import { Story } from "../story-components/Story";
import { Separator } from "./Separator";
export default {
title: "alouette/Layout/Separator",
component: Separator,
parameters: {
componentSubtitle:
"A flexible divider component for creating visual separation between content",
docs: {
description: {
component: `### Features
- Horizontal (default) and vertical orientations
- Picks up the current theme's \`border-sharp\` color
### Variants
- \`vertical\`: switches orientation
### Usage
~~~tsx
Left
Right
~~~`,
},
},
},
} satisfies Meta;
export const PreviewSeparatorStory: StoryObj = {
parameters: {
layout: "padded",
chromatic: { disableSnapshot: true },
},
render: () => ,
};
export const Variants: StoryObj = {
render: () => (
Left
Right
),
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// Every divider is announced as a separator with its orientation, without
// the caller passing a role.
const orientations = canvas
.getAllByRole("separator")
.map((separator) => separator.getAttribute("aria-orientation"));
await expect(orientations).toContain("horizontal");
await expect(orientations).toContain("vertical");
await expect(
orientations.every(
(orientation) =>
orientation === "horizontal" || orientation === "vertical",
),
).toBe(true);
},
};