: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
feat(data-quality): add overview check creation (#92013)
Thiago Salvatore78d6855b38a4
diff --git a/products/data_quality/frontend/CheckEditorModal.tsx b/products/data_quality/frontend/CheckEditorModal.tsxindex fb88b5f4b5ba..c43e58067283 100644--- a/products/data_quality/frontend/CheckEditorModal.tsx+++ b/products/data_quality/frontend/CheckEditorModal.tsx@@ -9,15 +9,18 @@ import {LemonSegmentedButton,LemonSelect,LemonTextArea,+ Link,Spinner,} from '@posthog/lemon-ui'import { LemonField } from 'lib/lemon-ui/LemonField'import { CodeEditorResizeable } from 'lib/monaco/CodeEditorResizable'+import { urls } from 'scenes/urls'+import type { DataQualitySubjectRef } from './checksApi'import { checkTypeLabel } from './checksConstants'import { dataQualityCheckEditorLogic } from './dataQualityCheckEditorLogic'-import { CheckTypeEnumApi, DataQualityCheckSeverityEnumApi } from './generated/api.schemas'+import { CheckTypeEnumApi, DataQualityCheckSeverityEnumApi, SubjectTypeEnumApi } from './generated/api.schemas'export function CheckEditorModal(): JSX.Element {const {@@ -25,17 +28,25 @@ export function CheckEditorModal(): JSX.Element {editingCheck,checkForm,checkTypes,+ checkTypesError,checkTypesLoading,requiresColumn,availableColumns,databaseLoading,+ databaseLoadError,+ openedWithoutSubject,+ relationshipSubjects,+ subject,isCheckFormSubmitting,serverError,} = useValues(dataQualityCheckEditorLogic)// Which fields the form has depends on the check-type catalog, so showing the form before it// arrives means fields appearing under the user's cursor a moment later.const formShapeLoading = checkTypesLoading && !checkTypes.length- const { requestClose, submitCheckForm, setCheckFormValues } = useActions(dataQualityCheckEditorLogic)+ const awaitingSubject = openedWithoutSubject && !subject+ const checkTypesFailedEmpty = checkTypesError && !checkTypesLoading && !checkTypes.length+ const { loadCheckTypes, loadDatabase, requestClose, setCheckFormValues, setSubject, submitCheckForm } =+ useActions(dataQualityCheckEditorLogic)return (<LemonModal@@ -55,11 +66,15 @@ export function CheckEditorModal(): JSX.Element {onClick={submitCheckForm}loading={isCheckFormSubmitting}disabledReason={- isCheckFormSubmitting- ? 'Saving'- : formShapeLoading- ? 'Loading the check types'- : undefined+ awaitingSubject+ ? 'Pick a table or view first'+ : isCheckFormSubmitting+ ? 'Saving'+ : formShapeLoading+ ? 'Loading the check types'+ : checkTypesFailedEmpty+ ? 'Load the check types to continue'+ : undefined}data-attr="data-quality-check-save">@@ -75,10 +90,62 @@ export function CheckEditorModal(): JSX.Element {<span>Loading check types...</span></div>)}+ {openedWithoutSubject && (+ <div className="flex flex-col gap-2 mb-3">+ <LemonField.Pure label="Table or view">+ <LemonInputSelect+ mode="single"+ value={subject ? [subject.subjectId] : []}+ options={relationshipSubjects.map((candidate) => ({+ key: candidate.id,+ label: candidate.name,+ }))}+ onChange={(selectedIds) => {+ const selected = relationshipSubjects.find(+ (candidate) => candidate.id === selectedIds[0]+ )+ if (!selected) {+ return+ }+ const selectedSubject: DataQualitySubjectRef = {+ subjectId: selected.id,+ subjectType: selected.type === SubjectTypeEnumApi.View ? 'view' : 'table',+ }+ setSubject(selectedSubject)+ }}+ loading={databaseLoading}+ placeholder="Search tables and views"+ data-attr="data-quality-check-subject"+ />+ </LemonField.Pure>+ {databaseLoadError && !databaseLoading ? (+ <div className="flex items-center gap-2 text-secondary text-sm">+ <span>Couldn't load your tables and views.</span>+ <LemonButton size="small" type="secondary" onClick={() => loadDatabase()}>+ Retry+ </LemonButton>+ </div>+ ) : !databaseLoading && relationshipSubjects.length === 0 ? (+ <p className="mb-0 text-secondary text-sm">+ Connect a source or <Link to={urls.database()}>browse tables and views</Link>.+ </p>+ ) : null}+ </div>+ )}+ {checkTypesFailedEmpty && (+ <div className="flex items-center gap-2 py-8 justify-center text-secondary">+ <span>Couldn't load check types.</span>+ <LemonButton size="small" type="secondary" onClick={loadCheckTypes}>+ Retry+ </LemonButton>+ </div>+ )}<Formlogic={dataQualityCheckEditorLogic}formKey="checkForm"- className={formShapeLoading ? 'hidden' : 'flex flex-col gap-3'}+ className={+ formShapeLoading || awaitingSubject || checkTypesFailedEmpty ? 'hidden' : 'flex flex-col gap-3'+ }><LemonField name="checkType" label="Check type"><LemonSelect@@ -218,16 +285,22 @@ function RelationshipFields(): JSX.Element {return (<><LemonField name="toSubjectUuid" label="References table or view">- <LemonSelect+ <LemonInputSelect+ mode="single"loading={databaseLoading}- options={relationshipSubjects.map((subject) => ({ value: subject.id, label: subject.name }))}- onChange={(toSubjectUuid) =>+ value={checkForm.toSubjectUuid ? [checkForm.toSubjectUuid] : []}+ options={relationshipSubjects.map((subject) => ({ key: subject.id, label: subject.name }))}+ onChange={(selectedIds) => {+ const toSubjectUuid = selectedIds[0]+ if (!toSubjectUuid) {+ return+ }setCheckFormValues({toSubjectUuid,toSubjectType: relationshipSubjects.find((subject) => subject.id === toSubjectUuid)?.type,toColumn: '',})- }+ }}/></LemonField><LemonField name="toColumn" label="References column">diff --git a/products/data_quality/frontend/dataQualityCheckEditorLogic.test.ts b/products/data_quality/frontend/dataQualityCheckEditorLogic.test.tsindex 16b20b279e6f..300589eb00f9 100644--- a/products/data_quality/frontend/dataQualityCheckEditorLogic.test.ts+++ b/products/data_quality/frontend/dataQualityCheckEditorLogic.test.ts@@ -12,6 +12,7 @@ import {warehouseSavedQueriesChecksCheckTypesList,warehouseSavedQueriesChecksCreate,warehouseSavedQueriesChecksPartialUpdate,+ warehouseTablesChecksCheckTypesList,warehouseTablesChecksCreate,} from './generated/api'import type { DataQualityCheckApi } from './generated/api.schemas'@@ -61,11 +62,12 @@ jest.mock('scenes/data-management/database/databaseTableListLogic', () => {path(['scenes', 'data-management', 'database', 'databaseTableListLogic']),actions({ loadDatabase: true }),reducers({- views: [[]],+ views: [[{ id: 'view-7', name: 'orders_view', fields: { order_id: {} } }]],dataWarehouseTables: [[{ id: 'table-9', name: 'stripe_charges', fields: { customer_id: {}, amount: {} } }],],databaseLoading: [false],+ databaseLoadError: [null],loadCount: [0, { loadDatabase: (state: number) => state + 1 }],}),]),@@ -147,6 +149,7 @@ describe('dataQualityCheckEditorLogic', () => {jest.clearAllMocks()silenceKeaLoadersErrors();(warehouseSavedQueriesChecksCheckTypesList as jest.Mock).mockResolvedValue(CHECK_TYPE_CATALOG)+ ;(warehouseTablesChecksCheckTypesList as jest.Mock).mockResolvedValue(CHECK_TYPE_CATALOG)})afterEach(() => {@@ -377,6 +380,107 @@ describe('dataQualityCheckEditorLogic', () => {expect(warehouseSavedQueriesChecksCreate).not.toHaveBeenCalled()})+ it.each<[string, DataQualitySubjectRef, string, string, jest.Mock]>([+ [+ 'a table',+ { subjectType: 'table', subjectId: 'table-9' },+ 'customer_id',+ 'table-9',+ warehouseTablesChecksCreate as jest.Mock,+ ],+ [+ 'a view',+ { subjectType: 'view', subjectId: 'view-7' },+ 'order_id',+ 'view-7',+ warehouseSavedQueriesChecksCreate as jest.Mock,+ ],+ ])(+ 'opens without a subject and creates against %s after it is picked',+ async (_case, subject, column, id, create) => {+ create.mockResolvedValue(buildCheck({ id: 'check-new' }))+ await mountLogic({ surface: 'overview' })++ logic.actions.openEditor(null, null)+ await expectLogic(logic).toFinishAllListeners()++ expect(warehouseSavedQueriesChecksCheckTypesList).not.toHaveBeenCalled()+ expect(warehouseTablesChecksCheckTypesList).not.toHaveBeenCalled()+ expect((databaseTableListLogic.values as unknown as { loadCount: number }).loadCount).toEqual(1)++ logic.actions.setSubject(subject)+ await expectLogic(logic).toFinishAllListeners()+ logic.actions.setCheckFormValues({ checkType: 'not_null', columnName: column })++ logic.actions.submitCheckForm()+ await expectLogic(logic).toFinishAllListeners()++ expect(create).toHaveBeenCalledWith('1', id, expect.objectContaining({ column_name: column }))+ }+ )++ it('clears subject-specific errors and columns when the picked subject changes', async () => {+ await mountLogic({ surface: 'overview' })+ logic.actions.openEditor(null, null)+ await expectLogic(logic).toFinishAllListeners()+ logic.actions.setSubject({ subjectType: 'table', subjectId: 'table-9' })+ await expectLogic(logic).toFinishAllListeners()+ logic.actions.setCheckFormValues({ columnName: 'customer_id', toColumn: 'id' })+ logic.actions.setCheckFormManualErrors({ columnName: 'Pick a column.' })+ logic.actions.setServerError('Could not save the check.')++ logic.actions.setSubject({ subjectType: 'view', subjectId: 'view-7' })+ await expectLogic(logic).toFinishAllListeners()++ expect(logic.values.checkForm.columnName).toEqual('')+ expect(logic.values.checkForm.toColumn).toEqual('id')+ expect(logic.values.checkFormManualErrors).toEqual({})+ expect(logic.values.serverError).toBeNull()+ })++ it('reloads check types when the picked subject changes', async () => {+ await mountLogic({ surface: 'overview' })+ logic.actions.openEditor(null, null)+ await expectLogic(logic).toFinishAllListeners()++ logic.actions.setSubject({ subjectType: 'table', subjectId: 'table-9' })+ await expectLogic(logic).toFinishAllListeners()+ logic.actions.setSubject({ subjectType: 'view', subjectId: 'view-7' })+ await expectLogic(logic).toFinishAllListeners()++ expect(warehouseTablesChecksCheckTypesList).toHaveBeenCalledWith('1', 'table-9')+ expect(warehouseSavedQueriesChecksCheckTypesList).toHaveBeenCalledWith('1', 'view-7')+ })++ it('does not create a check until a subject is picked', async () => {+ await mountLogic({ surface: 'overview' })+ logic.actions.openEditor(null, null)+ await expectLogic(logic).toFinishAllListeners()++ logic.actions.submitCheckForm()+ await expectLogic(logic).toFinishAllListeners()++ expect(warehouseSavedQueriesChecksCreate).not.toHaveBeenCalled()+ expect(warehouseTablesChecksCreate).not.toHaveBeenCalled()+ })++ it('clears the check type error when a failed catalog request is retried', async () => {+ ;(warehouseSavedQueriesChecksCheckTypesList as jest.Mock)+ .mockRejectedValueOnce(new Error('down'))+ .mockResolvedValueOnce(CHECK_TYPE_CATALOG)+ await mountLogic()+ logic.actions.openEditor(null, VIEW_SUBJECT, COLUMNS)+ await expectLogic(logic).toFinishAllListeners()++ expect(logic.values.checkTypesError).toBe(true)++ logic.actions.loadCheckTypes()+ await expectLogic(logic).toFinishAllListeners()++ expect(logic.values.checkTypesError).toBe(false)+ expect(logic.values.checkTypes).toEqual(CHECK_TYPE_CATALOG)+ })+it('closes an untouched draft without asking', async () => {await mountLogic()await openWith(buildCheck())@@ -438,4 +542,16 @@ describe('dataQualityCheckEditorLogic', () => {expect((databaseTableListLogic.values as unknown as { loadCount: number }).loadCount).toEqual(1)})++ it('keeps the warehouse catalog loaded when reopening an unscoped draft', async () => {+ await mountLogic({ surface: 'overview' })+ logic.actions.openEditor(null, null)+ await expectLogic(logic).toFinishAllListeners()+ logic.actions.closeEditor()+ await expectLogic(logic).toFinishAllListeners()+ logic.actions.openEditor(null, null)+ await expectLogic(logic).toFinishAllListeners()++ expect((databaseTableListLogic.values as unknown as { loadCount: number }).loadCount).toEqual(1)+ })})diff --git a/products/data_quality/frontend/dataQualityCheckEditorLogic.ts b/products/data_quality/frontend/dataQualityCheckEditorLogic.tsindex 9b8af5690d87..7962cb73be75 100644--- a/products/data_quality/frontend/dataQualityCheckEditorLogic.ts+++ b/products/data_quality/frontend/dataQualityCheckEditorLogic.ts@@ -214,6 +214,7 @@ function generalErrorMessage(error: unknown): string {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface dataQualityCheckEditorLogicValues {dataWarehouseTables: DatabaseSchemaDataWarehouseTable[] // databaseTableListLogic+ databaseLoadError: string | null // databaseTableListLogicdatabaseLoading: boolean // databaseTableListLogicviews: DatabaseSchemaViewTable[] // databaseTableListLogicavailableColumns: string[]@@ -230,12 +231,14 @@ export interface dataQualityCheckEditorLogicValues {[k: string]: DataQualityCheckTypeApi}checkTypes: DataQualityCheckTypeApi[]+ checkTypesError: booleancheckTypesLoading: booleaneditingCheck: DataQualityCheckApi | nullisCheckFormSubmitting: booleanisCheckFormValid: booleanisOpen: booleanneedsWarehouseCatalog: boolean+ openedWithoutSubject: booleanrelationshipSubjects: RelationshipSubject[]requiresColumn: booleanserverError: string | null@@ -281,12 +284,12 @@ export interface dataQualityCheckEditorLogicActions {}openEditor: (check: DataQualityCheckApi | null,- subject: DataQualitySubjectRef,+ subject: DataQualitySubjectRef | null,columns?: string[]) => {check: DataQualityCheckApi | nullcolumns: string[]- subject: DataQualitySubjectRef+ subject: DataQualitySubjectRef | null}requestClose: () => {value: true@@ -310,6 +313,9 @@ export interface dataQualityCheckEditorLogicActions {setServerError: (serverError: string | null) => {serverError: string | null}+ setSubject: (subject: DataQualitySubjectRef) => {+ subject: DataQualitySubjectRef+ }submitCheckForm: () => {value: boolean}@@ -356,7 +362,8 @@ export interface dataQualityCheckEditorLogicMeta {needsWarehouseCatalog: (checkForm: CheckFormValues,requiresColumn: boolean,- subjectColumns: string[]+ subjectColumns: string[],+ subject: DataQualitySubjectRef | null) => boolean}}@@ -381,14 +388,19 @@ export const dataQualityCheckEditorLogic = kea<dataQualityCheckEditorLogicType>(path((key) => ['products', 'data_quality', 'frontend', 'dataQualityCheckEditorLogic', key]),connect(() => ({actions: [databaseTableListLogic, ['loadDatabase']],- values: [databaseTableListLogic, ['views', 'dataWarehouseTables', 'databaseLoading']],+ values: [databaseTableListLogic, ['views', 'dataWarehouseTables', 'databaseLoading', 'databaseLoadError']],})),actions({- openEditor: (check: DataQualityCheckApi | null, subject: DataQualitySubjectRef, columns: string[] = []) => ({+ openEditor: (+ check: DataQualityCheckApi | null,+ subject: DataQualitySubjectRef | null,+ columns: string[] = []+ ) => ({check,subject,columns,}),+ setSubject: (subject: DataQualitySubjectRef) => ({ subject }),requestClose: true,closeEditor: true,setServerError: (serverError: string | null) => ({ serverError }),@@ -422,6 +434,13 @@ export const dataQualityCheckEditorLogic = kea<dataQualityCheckEditorLogicType>(null as DataQualitySubjectRef | null,{openEditor: (_, { subject }) => subject,+ setSubject: (_, { subject }) => subject,+ },+ ],+ openedWithoutSubject: [+ false,+ {+ openEditor: (_, { subject }) => subject === null,},],subjectColumns: [@@ -430,13 +449,19 @@ export const dataQualityCheckEditorLogic = kea<dataQualityCheckEditorLogicType>(openEditor: (_, { columns }) => columns,},],- // One request per editor instance: a type switch back to relationships must not refetch.+ // Keep the full catalog available across modal opens, while avoiding refetches on type switches.warehouseCatalogRequested: [false,{loadWarehouseCatalog: () => true,},],+ checkTypes: [+ [] as DataQualityCheckTypeApi[],+ {+ setSubject: () => [],+ },+ ],serverError: [null as string | null,{@@ -445,6 +470,16 @@ export const dataQualityCheckEditorLogic = kea<dataQualityCheckEditorLogicType>(closeEditor: () => null,},],+ checkTypesError: [+ false,+ {+ loadCheckTypes: () => false,+ loadCheckTypesSuccess: () => false,+ loadCheckTypesFailure: () => true,+ openEditor: () => false,+ setSubject: () => false,+ },+ ],}),selectors({checkTypeByName: [@@ -578,11 +613,18 @@ export const dataQualityCheckEditorLogic = kea<dataQualityCheckEditorLogicType>(!!checkTypeByName[checkForm.checkType]?.requires_column,],needsWarehouseCatalog: [- (s) => [s.checkForm, s.requiresColumn, s.subjectColumns],- (checkForm: CheckFormValues, requiresColumn: boolean, subjectColumns: string[]) =>+ (s) => [s.checkForm, s.requiresColumn, s.subjectColumns, s.subject],+ (+ checkForm: CheckFormValues,+ requiresColumn: boolean,+ subjectColumns: string[],+ subject: DataQualitySubjectRef | null+ ) =>// Relationships needs every subject to point at; anything else only needs the// catalog when the surface that opened the editor could not supply the columns.- checkForm.checkType === CheckTypeEnumApi.Relationships || (requiresColumn && !subjectColumns.length),+ subject === null ||+ checkForm.checkType === CheckTypeEnumApi.Relationships ||+ (requiresColumn && !subjectColumns.length),],}),listeners(({ props, values, actions }) => {@@ -601,6 +643,14 @@ export const dataQualityCheckEditorLogic = kea<dataQualityCheckEditorLogicType>(}ensureWarehouseCatalog()},+ setSubject: () => {+ actions.loadCheckTypes()+ if (values.checkForm.columnName) {+ actions.setCheckFormValues({ columnName: '' })+ }+ actions.setServerError(null)+ actions.setCheckFormManualErrors({})+ },setCheckFormValues: () => {if (values.isOpen) {ensureWarehouseCatalog()diff --git a/products/data_quality/frontend/overview/DataQualityOverview.test.tsx b/products/data_quality/frontend/overview/DataQualityOverview.test.tsxindex d0ed926724b4..809f8d3031ab 100644--- a/products/data_quality/frontend/overview/DataQualityOverview.test.tsx+++ b/products/data_quality/frontend/overview/DataQualityOverview.test.tsx@@ -1,5 +1,8 @@import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'+import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'++import { resumeKeaLoadersErrors, silenceKeaLoadersErrors } from '~/initKea'import { initKeaTests } from '~/test/init'import {@@ -7,6 +10,7 @@ import {dataQualityChecksList,dataQualityRunsCreate,dataQualityRunsRetrieve,+ warehouseSavedQueriesChecksCheckTypesList,warehouseSavedQueriesChecksRunsList,} from 'products/data_quality/frontend/generated/api'import type { DataQualityOverviewCheckApi } from 'products/data_quality/frontend/generated/api.schemas'@@ -14,6 +18,25 @@ import type { DataQualityOverviewCheckApi } from 'products/data_quality/frontendimport { DataQualityOverview } from './DataQualityOverview'import { subjectDisclosureId } from './dataQualityOverviewLogic'+jest.mock('scenes/data-management/database/databaseTableListLogic', () => {+ const { actions, kea, path, reducers } = jest.requireActual('kea')+ return {+ databaseTableListLogic: kea([+ path(['scenes', 'data-management', 'database', 'databaseTableListLogic']),+ actions({ loadDatabase: true, setDatabaseLoadError: (error: string | null) => ({ error }) }),+ reducers({+ views: [[]],+ dataWarehouseTables: [[]],+ databaseLoading: [false],+ databaseLoadError: [+ null,+ { setDatabaseLoadError: (_: string | null, { error }: { error: string | null }) => error },+ ],+ }),+ ]),+ }+})+jest.mock('lib/api', () => ({__esModule: true,default: {},@@ -25,6 +48,8 @@ jest.mock('lib/lemon-ui/LemonToast/LemonToast', () => ({lemonToast: { success: jest.fn(), error: jest.fn(), info: jest.fn(), warning: jest.fn() },}))+jest.mock('./DataQualityGateToggle', () => ({ DataQualityGateToggle: () => null }))+jest.mock('products/data_quality/frontend/generated/api', () => ({dataQualityChecksList: jest.fn(),dataQualityChecksHealthList: jest.fn(),@@ -91,6 +116,7 @@ describe('DataQualityOverview', () => {beforeEach(() => {jest.clearAllMocks()initKeaTests()+ silenceKeaLoadersErrors();(dataQualityChecksList as jest.Mock).mockResolvedValue({results: [buildCheck('check-1', 'orders'), buildCheck('check-2', 'customers')],})@@ -121,9 +147,13 @@ describe('DataQualityOverview', () => {started_at: null,},])+ ;(warehouseSavedQueriesChecksCheckTypesList as jest.Mock).mockResolvedValue([+ { check_type: 'not_null', description: '', requires_column: true, config_schema: {} },+ ])})afterEach(() => {+ resumeKeaLoadersErrors()cleanup()})@@ -182,13 +212,55 @@ describe('DataQualityOverview', () => {expect(screen.getAllByText('orders').length).toBeGreaterThan(0)})- it('shows the first-use state when the project has no checks', async () => {+ it('opens the subject picker from the first-use state', async () => {;(dataQualityChecksList as jest.Mock).mockResolvedValue({ results: [] });(dataQualityChecksHealthList as jest.Mock).mockResolvedValue([])render(<DataQualityOverview />)expect(await screen.findByText('No checks yet')).toBeTruthy()expect(screen.queryByText('No checks match these filters.')).toBeNull()+ expect(document.querySelector('[data-attr="data-quality-overview-new-check"]')).not.toBeNull()++ fireEvent.click(document.querySelector('[data-attr="data-quality-overview-first-check"]')!)++ expect(await screen.findByText('Table or view')).toBeTruthy()+ expect(document.querySelector('.ReactModal__Content')?.textContent).toContain('Connect a source or')+ })++ it('keeps the existing subject-scoped editor free of a subject picker', async () => {+ await renderOverview()++ fireEvent.click(queryAll('[data-attr="data-quality-overview-check-actions"]')[0])+ fireEvent.click(await screen.findByText('Edit'))++ expect(await screen.findByText('Check type')).toBeTruthy()+ expect(screen.queryByText('Table or view')).toBeNull()+ })++ it('shows a retry when the subject picker catalog cannot load', async () => {+ ;(dataQualityChecksList as jest.Mock).mockResolvedValue({ results: [] })+ ;(dataQualityChecksHealthList as jest.Mock).mockResolvedValue([])+ render(<DataQualityOverview />)+ await screen.findByText('No checks yet')+ fireEvent.click(document.querySelector('[data-attr="data-quality-overview-first-check"]')!)++ ;(+ databaseTableListLogic.actions as unknown as { setDatabaseLoadError: (error: string) => void }+ ).setDatabaseLoadError('down')++ expect(await screen.findByText("Couldn't load your tables and views.")).toBeTruthy()+ expect(screen.getByText('Retry')).toBeTruthy()+ })++ it('shows a retry when the check type catalog cannot load', async () => {+ ;(warehouseSavedQueriesChecksCheckTypesList as jest.Mock).mockRejectedValueOnce(new Error('down'))+ await renderOverview()++ fireEvent.click(queryAll('[data-attr="data-quality-overview-check-actions"]')[0])+ fireEvent.click(await screen.findByText('Edit'))++ expect(await screen.findByText("Couldn't load check types.")).toBeTruthy()+ expect(screen.getByText('Retry')).toBeTruthy()})it('shows a retry rather than an empty page when the first load fails', async () => {diff --git a/products/data_quality/frontend/overview/DataQualityOverview.tsx b/products/data_quality/frontend/overview/DataQualityOverview.tsxindex 7868220f4106..8cb4bc0c32c0 100644--- a/products/data_quality/frontend/overview/DataQualityOverview.tsx+++ b/products/data_quality/frontend/overview/DataQualityOverview.tsx@@ -41,6 +41,8 @@ const STATUS_FILTERS: { value: OverviewStatusFilter; label: string }[] = [{ value: 'never_run', label: 'Not run yet' },]+const NEW_CHECK_ACTION_ID = 'data-quality-overview-new-check'+function focusFirstAvailable(elementIds: string[]): void {// Runs after the removed row has left the DOM, so the first id that still resolves wins.window.requestAnimationFrame(() => {@@ -71,7 +73,7 @@ export function DataQualityOverview(): JSX.Element {overviewSummary,lastActionCheckId,} = useValues(dataQualityOverviewLogic)- const { setFilters, runChecks, loadOverview } = useActions(dataQualityOverviewLogic)+ const { setFilters, runChecks, loadOverview, setLastActionCheck } = useActions(dataQualityOverviewLogic)const editorProps: DataQualityCheckEditorLogicProps = {surface: 'data-quality-overview',@@ -83,9 +85,17 @@ export function DataQualityOverview(): JSX.Element {onClosed: () => {if (lastActionCheckId) {focusFirstAvailable([rowActionsId(lastActionCheckId)])+ } else {+ focusFirstAvailable([NEW_CHECK_ACTION_ID])}},}+ const { openEditor } = useActions(dataQualityCheckEditorLogic(editorProps))++ const addCheck = (): void => {+ setLastActionCheck(null)+ openEditor(null, null)+ }const runningAll = (startingRun || isRunning) && runTarget?.kind === 'all'const anyRunActive = startingRun || isRunning@@ -125,7 +135,7 @@ export function DataQualityOverview(): JSX.Element {<div className="flex flex-wrap items-center gap-2"><DataQualityGateToggle /><LemonButton- type="primary"+ type="secondary"onClick={() => runChecks({ kind: 'all' })}loading={runningAll}disabledReason={@@ -139,6 +149,14 @@ export function DataQualityOverview(): JSX.Element {>Run all checks</LemonButton>+ <LemonButton+ id={NEW_CHECK_ACTION_ID}+ type="primary"+ onClick={addCheck}+ data-attr="data-quality-overview-new-check"+ >+ New check+ </LemonButton></div></div>@@ -166,7 +184,7 @@ export function DataQualityOverview(): JSX.Element {)}{checks.length === 0 ? (- <NoChecksYet />+ <NoChecksYet onAddCheck={addCheck} />) : subjectGroups.length === 0 ? (<div className="flex items-center gap-2"><span className="text-secondary">No checks match these filters.</span>@@ -189,14 +207,17 @@ export function DataQualityOverview(): JSX.Element {)}-function NoChecksYet(): JSX.Element {+function NoChecksYet({ onAddCheck }: { onAddCheck: () => void }): JSX.Element {return (<div className="border rounded p-4 flex flex-col items-start gap-2"><h4 className="mb-0">No checks yet</h4>- <p className="mb-0 text-secondary">Add a check from a table or view to monitor data quality here.</p>+ <p className="mb-0 text-secondary">Add a check here, or browse tables and views first.</p>+ <LemonButton type="primary" size="small" onClick={onAddCheck} data-attr="data-quality-overview-first-check">+ Add your first check+ </LemonButton><LemonButtonid={BROWSE_ACTION_ID}- type="primary"+ type="secondary"size="small"to={urls.database()}data-attr="data-quality-overview-browse"