: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 { expectLogic } from 'kea-test-utils'
import { initKeaTests } from '~/test/init'
import { columnConfiguratorLogic } from './columnConfiguratorLogic'
describe('columnConfiguratorLogic', () => {
let logic: ReturnType<typeof columnConfiguratorLogic.build>
const startingColumns = ['a', 'b', 'ant', 'aardvark']
beforeEach(() => {
initKeaTests()
logic = columnConfiguratorLogic({ key: 'uniqueKey', columns: startingColumns, setColumns: () => {} })
logic.mount()
})
it('starts with expected defaults', async () => {
await expectLogic(logic).toMatchValues({
modalVisible: false,
columns: startingColumns,
})
})
it('can show modal', async () => {
await expectLogic(logic, () => logic.actions.showModal()).toMatchValues({
modalVisible: true,
})
})
it('can hide the modal', async () => {
await expectLogic(logic, () => logic.actions.hideModal()).toMatchValues({
modalVisible: false,
})
})
it('sets modal to hidden when user has selected and saved columns', async () => {
await expectLogic(logic, () => {
logic.actions.showModal()
logic.actions.setColumns(['a'])
logic.actions.save()
}).toMatchValues({
modalVisible: false,
})
})
it('cannot duplicate columns', async () => {
await expectLogic(logic, () => {
logic.actions.selectColumn('added')
logic.actions.selectColumn('added')
}).toMatchValues({
columns: ['a', 'b', 'ant', 'aardvark', 'added'],
})
})
})