import React from 'react' import { type Meta, type StoryObj } from '@storybook/react' import { expect, waitFor, within } from '@storybook/test' import { InformationTile } from '~components/Tile' import { TileGrid } from '../index' const meta = { title: 'Components/Tiles/TileGrid (Deprecated)', component: TileGrid, args: { children: ( <> Footer} /> Footer} /> Footer} /> ), }, } satisfies Meta export default meta type Story = StoryObj export const Playground: Story = { parameters: { docs: { canvas: { sourceState: 'shown', }, }, }, } export const FlipOneNotOthers: Story = { play: async ({ canvasElement, step }) => { const canvas = within(canvasElement) await step('initial render complete', async () => { await waitFor(() => { canvas.getByRole('button', { name: 'View more information: Title A', }) }) }) await step('Can focus to button', async () => { await waitFor(() => { const buttonWithInfoLabel = canvas.getByRole('button', { name: 'View more information: Title A', }) buttonWithInfoLabel.click() }) }) await step('Check other tiles', async () => { await waitFor(() => { expect(canvas.getByText('Side A - Back')).toBeInTheDocument() expect(canvas.getByText('Title B')).toBeInTheDocument() expect(canvas.getByText('Title C')).toBeInTheDocument() }) }) }, } export const OneTile: Story = { args: { children: ( Footer} /> ), }, play: async ({ canvasElement, step }) => { const canvas = within(canvasElement) await step('Tile renders as
  • ', async () => { await waitFor(() => { expect(canvas.getByRole('listitem')).toBeInTheDocument() }) }) }, } export const MultipleTiles: Story = { render: () => { return ( Footer} /> Footer} /> Footer} /> ) }, play: async ({ canvasElement, step }) => { const canvas = within(canvasElement) await step('All Tiles marked up as individual
  • elements', async () => { await waitFor(() => { const listOfTiles = canvas.getByRole('list') const { getAllByRole } = within(listOfTiles) const tiles = getAllByRole('listitem') expect(tiles.length).toBe(3) }) }) }, } export const Fragment: Story = { play: async ({ canvasElement, step }) => { const canvas = within(canvasElement) await step('All Tiles marked up as individual
  • elements', async () => { await waitFor(() => { const listOfTiles = canvas.getByRole('list') const { getAllByRole } = within(listOfTiles) const tiles = getAllByRole('listitem') expect(tiles.length).toBe(3) }) }) }, }