Skip to content
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

test(3000): Fix Sidebar story #18251

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions .storybook/decorators/withFeatureFlags.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { setFeatureFlags } from '~/mocks/browser'
import type { Decorator } from '@storybook/react'

declare module '@storybook/types' {
interface Parameters {
featureFlags?: string[]
}
}

/** Global story decorator that allows setting feature flags.
*
* ```ts
Expand Down
6 changes: 6 additions & 0 deletions .storybook/decorators/withMockDate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import type { Decorator } from '@storybook/react'
import MockDate from 'mockdate'

declare module '@storybook/types' {
interface Parameters {
mockDate?: string | number | Date
}
}

/** Global story decorator that allows mocking of dates.
*
* ```ts
Expand Down
1 change: 0 additions & 1 deletion .storybook/test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ declare module '@storybook/types' {
/** If taking a component snapshot, you can narrow it down by specifying the selector. */
snapshotTargetSelector?: string
}
mockDate?: string | number | Date
msw?: {
mocks?: Mocks
}
Expand Down
Binary file modified frontend/__snapshots__/posthog-3000-sidebar--dashboards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions frontend/src/layout/navigation-3000/Navigation.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { router } from 'kea-router'
import { urls } from 'scenes/urls'
import { App } from 'scenes/App'
import { EMPTY_PAGINATED_RESPONSE } from '~/mocks/handlers'
import { FEATURE_FLAGS } from 'lib/constants'

const meta: Meta = {
title: 'PostHog 3000/Navigation',
Expand All @@ -23,12 +24,12 @@ const meta: Meta = {
layout: 'fullscreen',
viewMode: 'story',
mockDate: '2023-02-01',
featureFlags: [FEATURE_FLAGS.POSTHOG_3000],
},
}
export default meta

export function NavigationBase(): JSX.Element {
setFeatureFlags(['posthog-3000'])
useEffect(() => {
router.actions.push(urls.projectHomepage())
}, [])
Expand All @@ -37,7 +38,7 @@ export function NavigationBase(): JSX.Element {
}

export function Navigation3000(): JSX.Element {
setFeatureFlags(['posthog-3000', 'posthog-3000-nav'])
setFeatureFlags([FEATURE_FLAGS.POSTHOG_3000, FEATURE_FLAGS.POSTHOG_3000_NAV])
useEffect(() => {
router.actions.push(urls.projectHomepage())
}, [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import { Sidebar } from './Sidebar'
import featureFlagsJson from '../../../scenes/feature-flags/__mocks__/feature_flags.json'
import dashboardsJson from '../../../scenes/dashboard/__mocks__/dashboards.json'
import { SidebarNavbarItem } from '../types'
import { setFeatureFlags } from '~/mocks/browser'
import { FEATURE_FLAGS } from 'lib/constants'

const meta: Meta = {
title: 'PostHog 3000/Sidebar',
parameters: {
mockDate: '2023-02-01',
layout: 'fullscreen',
viewMode: 'story',
featureFlags: [FEATURE_FLAGS.POSTHOG_3000, FEATURE_FLAGS.POSTHOG_3000_NAV],
},
}
export default meta
Expand All @@ -32,7 +33,6 @@ const multipliedFeatureFlagsJson = {
}

export function Dashboards(): JSX.Element {
setFeatureFlags(['posthog-3000', 'posthog-3000-nav'])
useStorybookMocks({
get: {
'/api/projects/:team_id/dashboards/': dashboardsJson,
Expand All @@ -52,7 +52,6 @@ export function Dashboards(): JSX.Element {
}

export function FeatureFlags(): JSX.Element {
setFeatureFlags(['posthog-3000', 'posthog-3000-nav'])
useStorybookMocks({
get: {
'/api/projects/:team_id/feature_flags/': multipliedFeatureFlagsJson,
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading