-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify KaizenProvider #5426
Simplify KaizenProvider #5426
Changes from 4 commits
a9eb40a
bc6f449
9605a5b
032f7d8
a131c0a
f7bea24
dba3278
bff6276
8afcee7
893ae1e
ff94155
ce636f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@kaizen/components': patch | ||
--- | ||
|
||
Simplify KaizenProvider |
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, userEvent, within } from '@storybook/test' | ||
import { Button } from '~components/Button' | ||
import { ToastNotification, useToastNotification } from '../index' | ||
|
||
|
@@ -175,26 +175,27 @@ export const NoDuplicatesWithSameId: Story = { | |
render: () => { | ||
const { addToastNotification } = useToastNotification() | ||
|
||
useEffect(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this story was failing before I made this change due to the toast was not visible. Not sure why that was the case but I think using useEffect here might have cause some issue as I suspect addToastNotification is not being wrapped inside a |
||
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 ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main issue I'd have with you changing this test is that I think some teams actually use I suggest you make a canary and test against There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let me test it out. I reckon all these There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually I will need to test a canary from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. read through your comment here about what the That is weird though as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't need to be a dependency, nothing inside useEffect is referring to it