-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add tests for
ToolbarLaunch
behavior
- Loading branch information
1 parent
6a32519
commit b854805
Showing
2 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
frontend/src/scenes/toolbar-launch/ToolbarLaunch.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { Meta, StoryFn } from '@storybook/react' | ||
import { useActions, useValues } from 'kea' | ||
import { router } from 'kea-router' | ||
import { useEffect } from 'react' | ||
import { teamLogic } from 'scenes/teamLogic' | ||
import { urls } from 'scenes/urls' | ||
|
||
import { mswDecorator, useStorybookMocks } from '~/mocks/browser' | ||
import { TeamPublicType } from '~/types' | ||
|
||
import { ToolbarLaunch } from './ToolbarLaunch' | ||
|
||
const meta: Meta = { | ||
title: 'Scenes-Other/ToolbarLaunch', | ||
parameters: { | ||
layout: 'fullscreen', | ||
testOptions: { | ||
includeNavigationInSnapshot: true, | ||
}, | ||
featureFlags: ['web-experiments', 'web-vitals', 'web-vitals-toolbar'], | ||
viewMode: 'story', | ||
mockDate: '2024-01-01', | ||
}, | ||
decorators: [ | ||
mswDecorator({ | ||
post: { | ||
'/api/environments/:environment_id/query/': () => [ | ||
200, | ||
{ | ||
results: [ | ||
['https://posthog.com', 150], | ||
['https://app.posthog.com', 100], | ||
['https://docs.posthog.com', 75], | ||
], | ||
}, | ||
], | ||
}, | ||
}), | ||
], | ||
} | ||
export default meta | ||
|
||
const Template: StoryFn = () => { | ||
useEffect(() => { | ||
router.actions.push(urls.dashboards()) | ||
}, []) | ||
|
||
return <ToolbarLaunch /> | ||
} | ||
|
||
export const Default = Template.bind({}) | ||
|
||
export const NoUrlsTemplate: StoryFn = () => { | ||
const { currentTeam } = useValues(teamLogic) | ||
const { loadCurrentTeamSuccess } = useActions(teamLogic) | ||
|
||
useEffect(() => { | ||
const team = { ...currentTeam, app_urls: [] } | ||
loadCurrentTeamSuccess(team as TeamPublicType) | ||
}, []) // eslint-disable-line react-hooks/exhaustive-deps | ||
|
||
return <Template /> | ||
} | ||
|
||
export const NoSuggestionsTemplate: StoryFn = () => { | ||
useStorybookMocks({ | ||
post: { '/api/environments/:environment_id/query/': () => [200, { results: [] }] }, | ||
}) | ||
|
||
return <Template /> | ||
} | ||
|
||
export const EmptyStateTemplate: StoryFn = () => { | ||
const { currentTeam } = useValues(teamLogic) | ||
const { loadCurrentTeamSuccess } = useActions(teamLogic) | ||
|
||
useEffect(() => { | ||
const team = { ...currentTeam, app_urls: [] } | ||
loadCurrentTeamSuccess(team as TeamPublicType) | ||
}, []) // eslint-disable-line react-hooks/exhaustive-deps | ||
|
||
useStorybookMocks({ | ||
post: { '/api/environments/:environment_id/query/': () => [200, { results: [] }] }, | ||
}) | ||
|
||
return <Template /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters