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.

991 B
Raw Blame
import { patchConversationsWidgetFilterFields } from './conversationsWidgetConfigValidation'

describe('conversationsWidgetConfigValidation', () => {
    it('sets and clears a saved view without dropping other config', () => {
        const config = { limit: 15, status: 'open' as const, priorities: ['high' as const] }
        const withSavedView = patchConversationsWidgetFilterFields(config, { savedViewId: 'view-1' })

        expect(withSavedView).toMatchObject({
            limit: 15,
            status: 'open',
            priorities: ['high'],
            savedViewId: 'view-1',
        })

        const cleared = patchConversationsWidgetFilterFields(withSavedView, { savedViewId: null })
        expect(cleared.savedViewId).toBeNull()
        expect(cleared.limit).toBe(15)
    })

    it('rejects saved view IDs longer than the backend short ID limit', () => {
        expect(() => patchConversationsWidgetFilterFields({}, { savedViewId: '1234567890123' })).toThrow()
    })
})