Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cut-provider-notification-cycle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@toptal/picasso-provider': patch
---

- cut the `@toptal/picasso-provider` → `@toptal/picasso-notification` source-import cycle that PF-2031 publish forensics flagged. The `NotificationsProvider` integration test (which exercised `maxNotifications` by going through `useNotifications`) moved to `cypress/component/NotificationsProvider.spec.tsx`, and the `PicassoLight with notifications and favicon` storybook example was dropped (the equivalent demonstration already lives in `@toptal/picasso-notification`'s `use-notification/story/MaxNotifications.example.tsx`). No public API change.
49 changes: 49 additions & 0 deletions cypress/component/NotificationsProvider.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react'
import { Button } from '@toptal/picasso-button'
import { useNotifications } from '@toptal/picasso-notification'
import { NotificationsProvider } from '@toptal/picasso-provider'
import type { NotificationsProviderProps } from '@toptal/picasso-provider'

const TRIGGER_TEST_ID = 'trigger'
const NOTIFICATION_TEST_ID = 'notification-item'
const NOTIFICATIONS_TO_FIRE = 6

const Trigger = () => {
const { showInfo } = useNotifications()

const handleClick = () => {
for (let index = 0; index < NOTIFICATIONS_TO_FIRE; index++) {
showInfo(<span data-testid={NOTIFICATION_TEST_ID}>Notification</span>)
}
}

return (
<Button data-testid={TRIGGER_TEST_ID} onClick={handleClick}>
Open notifications
</Button>
)
}

const Example = (props: Omit<NotificationsProviderProps, 'children'>) => (
<NotificationsProvider {...props}>
<Trigger />
</NotificationsProvider>
)

describe('NotificationsProvider', () => {
it('caps at the default maxNotifications when no prop is set', () => {
cy.mount(<Example />)

cy.getByTestId(TRIGGER_TEST_ID).click()

cy.get(`[data-testid=${NOTIFICATION_TEST_ID}]`).should('have.length', 5)
})

it('caps at the configured maxNotifications', () => {
cy.mount(<Example maxNotifications={2} />)

cy.getByTestId(TRIGGER_TEST_ID).click()

cy.get(`[data-testid=${NOTIFICATION_TEST_ID}]`).should('have.length', 2)
})
})

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions packages/picasso-provider/src/Picasso/story/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,3 @@ page
title: 'PicassoLight with FixViewport and FontsLoader',
takeScreenshot: false,
})
.addExample('Picasso/story/LightWithNotificationsAndFavicon.example.tsx', {
title: 'PicassoLight with notifications and favicon',
takeScreenshot: false,
})
Loading