: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 { FeatureFlagGroupType, PropertyFilterType, PropertyOperator } from '~/types'
import { defaultReleaseConditionsLogic } from './defaultReleaseConditionsLogic'
describe('defaultReleaseConditionsLogic', () => {
let logic: ReturnType<typeof defaultReleaseConditionsLogic.build>
const groupWithBigIntId = (value: bigint): FeatureFlagGroupType => ({
properties: [{ key: 'id', value, type: PropertyFilterType.Person, operator: PropertyOperator.Exact }],
rollout_percentage: 100,
variant: null,
})
beforeEach(async () => {
initKeaTests()
logic = defaultReleaseConditionsLogic()
logic.mount()
await expectLogic(logic).toDispatchActions(['loadDefaultReleaseConditionsSuccess'])
})
afterEach(() => {
logic.unmount()
})
describe('hasChanges', () => {
// hasChanges used to compare groups via raw JSON.stringify, which throws on bigint
// property values (PropertyFilterBaseValue allows bigint).
it.each([
{ candidateValue: BigInt('9007199254740993'), expected: false },
{ candidateValue: BigInt('9007199254740994'), expected: true },
])(
'does not throw and reports hasChanges=$expected for a bigint property value',
({ candidateValue, expected }) => {
logic.actions.loadDefaultReleaseConditionsSuccess({
enabled: true,
default_groups: [groupWithBigIntId(BigInt('9007199254740993'))],
})
expect(() => {
logic.actions.setLocalGroups([groupWithBigIntId(candidateValue)])
}).not.toThrow()
expectLogic(logic).toMatchValues({ hasChanges: expected })
}
)
})
})