: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 { prefetchTeamsStep } from '~/ingestion/common/steps/prefetch-teams-step'
import { PipelineResultType } from '~/ingestion/framework/results'
type TestInput = { headers: { token?: string } }
function createInput(token?: string): TestInput {
return { headers: { token } }
}
describe('prefetchTeamsStep', () => {
it('warms the team cache by header token, skipping events without one', async () => {
const teamManager = { getTeamsByTokens: jest.fn().mockResolvedValue({}) }
const step = prefetchTeamsStep<TestInput>(teamManager, true)
const results = await step([createInput('token-a'), createInput('token-b'), createInput()])
expect(results.map((result) => result.type)).toEqual(Array(3).fill(PipelineResultType.OK))
expect(teamManager.getTeamsByTokens).toHaveBeenCalledWith(['token-a', 'token-b'], { flush: true })
})
})