Skip to content

Commit

Permalink
Fix story
Browse files Browse the repository at this point in the history
  • Loading branch information
vietanhtran16 committed Dec 23, 2024
1 parent bc6f449 commit 9605a5b
Showing 1 changed file with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useId } from 'react'
import { type Meta, type StoryObj } from '@storybook/react'
import { expect, within } from '@storybook/test'
import { expect, within, userEvent } from '@storybook/test'

Check failure on line 3 in packages/components/src/Notification/ToastNotification/_docs/ToastNotification.stories.tsx

View workflow job for this annotation

GitHub Actions / eslint

`userEvent` import should occur before import of `within`
import { Button } from '~components/Button'
import { ToastNotification, useToastNotification } from '../index'

Expand Down Expand Up @@ -175,26 +175,27 @@ export const NoDuplicatesWithSameId: Story = {
render: () => {
const { addToastNotification } = useToastNotification()

useEffect(() => {
addToastNotification({
id: 'id--clear-example-1',
title: 'First',
type: 'positive',
message: 'There should only be one notification',
})
addToastNotification({
id: 'id--clear-example-1',
title: 'First',
type: 'positive',
message: 'There should only be one notification',
})
}, [addToastNotification])

return <div>Irrelevant content</div>
return (
<Button
label="Create notification"
onClick={() =>
addToastNotification({
id: 'id--clear-example-1',
title: 'First',
type: 'positive',
message: 'There should only be one notification',
})
}
/>
)
},
play: async (context) => {
const { canvasElement } = context
const { findAllByText } = within(canvasElement.parentElement!)
const { findAllByText, findByRole } = within(canvasElement.parentElement!)

const createNotificationButton = await findByRole('button', { name: 'Create notification' })
await userEvent.click(createNotificationButton)
await userEvent.click(createNotificationButton)

const notifications = await findAllByText('There should only be one notification')
expect(notifications).toHaveLength(1)
Expand Down

0 comments on commit 9605a5b

Please sign in to comment.