: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 { MOCK_DEFAULT_USER } from 'lib/api.mock'
import { userLogic } from 'scenes/userLogic'
import { initKeaTests } from '~/test/init'
import { settingsLogic } from './settingsLogic'
jest.mock('posthog-js/dist/surveys-preview', () => ({
renderFeedbackWidgetPreview: jest.fn(),
renderSurveysPreview: jest.fn(),
}))
describe('staffOnly settings', () => {
it.each([
[true, true],
[false, false],
])('is_staff=%s shows AI gateway developer mode: %s', (isStaff, visible) => {
initKeaTests()
userLogic.mount()
userLogic.actions.loadUserSuccess({ ...MOCK_DEFAULT_USER, is_staff: isStaff })
const logic = settingsLogic({ logicKey: 'staff-only-test', sectionId: 'user-ai-gateway-dev-mode' })
logic.mount()
expect(logic.values.sections.some((section) => section.id === 'user-ai-gateway-dev-mode')).toBe(visible)
expect(logic.values.settings.some((setting) => setting.id === 'ai-gateway-dev-mode')).toBe(visible)
expect(
logic.values.globalSearchIndex
.search('developer mode')
.some(({ item }) => item.settingId === 'ai-gateway-dev-mode')
).toBe(visible)
})
})