import type { Meta, StoryObj } from '@storybook/nextjs-vite' import { expect } from 'storybook/test' import OldDSLink from '.' const meta: Meta = { title: 'Components/OldDSLink', component: OldDSLink, argTypes: { size: { control: 'select', options: ['small', 'regular', 'tiny', 'none'], }, scroll: { table: { disable: true, }, }, prefetch: { table: { disable: true, }, }, partialMatch: { table: { disable: true, }, }, }, } export default meta type Story = StoryObj export const Default: Story = { args: { active: false, href: 'https://www.scandichotels.com/en', }, render: (args) => {args.href}, play: async ({ canvasElement }) => { const link = canvasElement.querySelector('a') if (!link) throw new Error('Link not found') expect(link).toBeInTheDocument() }, } export const Focused: Story = { args: { ...Default.args, }, render: Default.render, play: async ({ canvasElement }) => { const link = canvasElement.querySelector('a') if (!link) throw new Error('Link not found') expect(link).toBeInTheDocument() expect(link).not.toHaveFocus() let styles = getComputedStyle(link) expect(styles.outlineStyle).toBe('none') expect(parseFloat(styles.outlineWidth)).toBe(0) link?.focus() expect(link).toHaveFocus() styles = getComputedStyle(link) expect(styles.outlineStyle).not.toBe('none') expect(parseFloat(styles.outlineWidth)).toBeGreaterThan(0) }, }