: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 '@testing-library/jest-dom'
import { cleanup, render, screen } from '@testing-library/react'
import { initKeaTests } from '~/test/init'
import { CheckRunsTable } from './CheckRunsTable'
import type { DataQualityCheckRunApi } from './generated/api.schemas'
const PASSING_METRIC_RUN: DataQualityCheckRunApi = {
id: 'pass',
quality_check: 'check-1',
check_name: 'Signups stay positive',
suite_run: 'suite-1',
subject_type: 'metric',
subject_uuid: '018f2a1c-0000-7000-8000-000000000001',
subject_name: 'signups',
check_type: 'custom_sql',
column_name: '',
check_config: null,
check_severity: 'error',
status: 'passed',
failed_row_count: 0,
observed_value: 0,
compiled_query: 'SELECT count() FROM signups',
audited_staged_refresh: false,
error: '',
duration_ms: 20,
started_at: null,
finished_at: null,
created_at: '2026-09-01T00:00:00Z',
}
function metricRun(overrides: Partial<DataQualityCheckRunApi>): DataQualityCheckRunApi {
return { ...PASSING_METRIC_RUN, ...overrides }
}
describe('CheckRunsTable', () => {
afterEach(cleanup)
it('describes each run in the terms of its check type', () => {
initKeaTests()
render(
<CheckRunsTable
runs={[
PASSING_METRIC_RUN,
metricRun({
id: 'fail',
status: 'failed',
failed_row_count: 7,
observed_value: 7,
duration_ms: 30,
}),
metricRun({
id: 'error',
status: 'errored',
failed_row_count: null,
observed_value: null,
duration_ms: 40,
error: 'Unknown column signups',
}),
]}
/>
)
expect(screen.getByText('passed')).toBeInTheDocument()
expect(screen.getByText('failed')).toBeInTheDocument()
expect(screen.getByText('errored')).toBeInTheDocument()
expect(screen.getByText('7 rows returned')).toBeInTheDocument()
expect(screen.getByText('Unknown column signups')).toBeInTheDocument()
expect(screen.queryByText('Failed rows')).not.toBeInTheDocument()
expect(screen.queryByText('Unpublished refresh')).not.toBeInTheDocument()
})
it('marks a run that checked a refresh before it was published', () => {
initKeaTests()
render(<CheckRunsTable runs={[metricRun({ status: 'failed', audited_staged_refresh: true })]} />)
expect(screen.getByText('Unpublished refresh')).toBeInTheDocument()
})
it('shows a freshness run as how old its newest row is', () => {
initKeaTests()
render(
<CheckRunsTable
runs={[
metricRun({
subject_type: 'table',
check_type: 'freshness',
column_name: 'last_updated_time',
check_config: { max_age_minutes: 2160 },
status: 'failed',
failed_row_count: 1,
observed_value: 147117,
}),
]}
/>
)
expect(screen.getByText('1d 16h old')).toBeInTheDocument()
})
})