: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import '@testing-library/jest-dom'
import { act, cleanup, render, screen } from '@testing-library/react'
import { userLogic } from 'scenes/userLogic'
import { initKeaTests } from '~/test/init'
import { ImpersonationNoticeSlot } from './ImpersonationNoticeSlot'
jest.mock('./ImpersonationNotice', () => ({
ImpersonationNotice: () => <div>impersonation notice</div>,
}))
describe('ImpersonationNoticeSlot', () => {
beforeEach(() => {
initKeaTests()
userLogic.mount()
})
afterEach(cleanup)
it('keeps the notice mounted after impersonation ends', async () => {
act(() => userLogic.actions.loadUserSuccess({ is_impersonated: false } as any))
render(<ImpersonationNoticeSlot />)
expect(screen.queryByText('impersonation notice')).not.toBeInTheDocument()
act(() => userLogic.actions.loadUserSuccess({ is_impersonated: true } as any))
expect(await screen.findByText('impersonation notice')).toBeInTheDocument()
act(() => userLogic.actions.loadUserSuccess({ is_impersonated: false } as any))
expect(screen.getByText('impersonation notice')).toBeInTheDocument()
})
})