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.5 KB
Raw Blame
import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'

import '@testing-library/jest-dom'

import { cleanup, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { expectLogic } from 'kea-test-utils'

import { OrganizationMembershipLevel } from 'lib/constants'
import { preflightLogic } from 'lib/logic/preflightLogic'
import { teamLogic } from 'scenes/teamLogic'

import { initKeaTests } from '~/test/init'

import { TimezoneConfig } from './TimezoneConfig'

describe('<TimezoneConfig />', () => {
    beforeEach(async () => {
        initKeaTests()
        teamLogic.mount()
        preflightLogic.mount()
        teamLogic.actions.loadCurrentTeamSuccess({
            ...MOCK_DEFAULT_TEAM,
            timezone: 'Europe/Madrid',
            effective_membership_level: OrganizationMembershipLevel.Admin,
        })
        await expectLogic(preflightLogic).toFinishAllListeners()
    })

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

    it('keeps the current time zone when the selection is cleared with backspace', async () => {
        const { container } = render(<TimezoneConfig />)
        const input = container.querySelector('input[type="text"]') as HTMLInputElement

        await userEvent.click(input)
        await userEvent.keyboard('{Backspace}')

        expect(screen.getByText('Europe / Madrid (UTC+1:00)')).toBeInTheDocument()
        await expectLogic(teamLogic).toNotHaveDispatchedActions(['updateCurrentTeam'])
    })
})