Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.4 KB
Raw Blame
import type { ProductEmptyStateConfig, SceneProductEmptyState } from 'lib/components/ProductEmptyState/types'
import { Scene } from 'scenes/sceneTypes'

import { ProductKey } from '~/queries/schema/schema-general'

import { pickWelcomeEmptyState } from './welcomeEmptyState'

function emptyStateWith(
    emptyState: Partial<SceneProductEmptyState> & { productKey: ProductKey }
): SceneProductEmptyState {
    const { productKey, ...rest } = emptyState
    return {
        config: { productKey } as ProductEmptyStateConfig,
        statusLogic: {} as SceneProductEmptyState['statusLogic'],
        ...rest,
    }
}

describe('pickWelcomeEmptyState', () => {
    test.each([
        {
            name: "the scene's own product",
            emptyState: emptyStateWith({ productKey: ProductKey.SESSION_REPLAY }),
            expected: true,
        },
        {
            name: 'an empty state for another product',
            emptyState: emptyStateWith({ productKey: ProductKey.ERROR_TRACKING }),
            expected: false,
        },
        {
            name: 'an empty state scoped to another scene',
            emptyState: emptyStateWith({ productKey: ProductKey.SESSION_REPLAY, scenes: [Scene.Heatmaps] }),
            expected: false,
        },
    ])('$name', ({ emptyState, expected }) => {
        const picked = pickWelcomeEmptyState(emptyState, ProductKey.SESSION_REPLAY, Scene.Replay, {})
        expect(picked !== null).toBe(expected)
    })
})