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.1 KB
Raw Blame
import { cleanup, render, screen } from '@testing-library/react'
import { Suspense } from 'react'

import { maxLogic } from 'scenes/max/maxLogic'

import { SIDE_PANEL_PANEL_ID } from '~/layout/ai/aiPanelIds'
import { initKeaTests } from '~/test/init'

import { SidePanelMax } from './SidePanelMax'

jest.mock('scenes/max/Max', () => ({
    MaxInstance: () => <div>side panel chat</div>,
}))

describe('SidePanelMax', () => {
    beforeEach(() => {
        initKeaTests()
    })

    afterEach(() => {
        cleanup()
    })

    it('keeps the side panel chat mounted after the panel closes', async () => {
        // Stands in for the mount the chat UI holds while the panel is open.
        const unmountPanelChat = maxLogic({ panelId: SIDE_PANEL_PANEL_ID }).mount()

        const { unmount } = render(
            <Suspense fallback={null}>
                <SidePanelMax />
            </Suspense>
        )
        await screen.findByText('side panel chat')

        unmount()
        unmountPanelChat()

        expect(maxLogic.findMounted({ panelId: SIDE_PANEL_PANEL_ID })).not.toBeNull()
    })
})