: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 type { UserBasicApi } from 'products/signals/frontend/generated/api.schemas'
import { scoutOwnerBubbles, scoutOwnersLabel, showsScoutOwnership } from './scoutOwners'
function owner(overrides: Partial<UserBasicApi> & Pick<UserBasicApi, 'email'>): UserBasicApi {
return {
id: 1,
uuid: '00000000-0000-0000-0000-000000000000',
first_name: '',
last_name: '',
hedgehog_config: null,
...overrides,
}
}
describe('scoutOwners', () => {
it.each([
['custom', true],
['canonical', false],
] as const)('shows ownership for a %s scout: %s', (scout_origin, expected) => {
expect(showsScoutOwnership({ scout_origin })).toBe(expected)
})
it('labels a single owner by name and several by count', () => {
const ada = owner({ email: '[email protected]', first_name: 'Ada', last_name: 'Ellis' })
expect(scoutOwnersLabel([ada])).toBe('Ada Ellis')
expect(scoutOwnersLabel([ada, owner({ email: '[email protected]' })])).toBe('2 owners')
})
it('falls back to the email for an owner who never set a name', () => {
// Invited-but-unnamed members are common, and an avatar with a blank label names nobody.
const nameless = owner({ email: '[email protected]' })
expect(scoutOwnersLabel([nameless])).toBe('[email protected]')
expect(scoutOwnerBubbles([nameless])).toEqual([
{ email: '[email protected]', name: '[email protected]', title: '[email protected]' },
])
})
it('puts the email in the hover title next to a name', () => {
expect(scoutOwnerBubbles([owner({ email: '[email protected]', first_name: 'Ada', last_name: 'Ellis' })])).toEqual(
[{ email: '[email protected]', name: 'Ada Ellis', title: 'Ada Ellis ([email protected])' }]
)
})
})