diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/FailedTestCaseSampleData/FailedTestCaseSampleData.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/FailedTestCaseSampleData/FailedTestCaseSampleData.test.tsx index 7fa84ccee747..f540e015eb96 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/FailedTestCaseSampleData/FailedTestCaseSampleData.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/FailedTestCaseSampleData/FailedTestCaseSampleData.test.tsx @@ -11,13 +11,83 @@ * limitations under the License. */ -import { act, render, screen } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; +import React, { Fragment } from 'react'; import { TestCase } from '../../../../generated/tests/testCase'; import { TestCasePageTabs } from '../../../../pages/IncidentManager/IncidentManager.interface'; import { getTestCaseFailedSampleData } from '../../../../rest/testAPI'; import observabilityRouterClassBase from '../../../../utils/ObservabilityRouterClassBase'; import FailedTestCaseSampleData from './FailedTestCaseSampleData.component'; +jest.mock('@openmetadata/ui-core-components', () => { + type Col = { id: string; label?: React.ReactNode }; + type Row = Record & { __rowKey: number | string }; + + const TableMock = Object.assign( + ({ children, ...rest }: React.PropsWithChildren) => ( + {children}
+ ), + { + Header: ({ + columns, + children, + }: { + columns?: Col[]; + children: (col: Col) => React.ReactNode; + }) => ( + + + {columns?.map((col) => ( + {children(col)} + ))} + + + ), + Head: ({ label, id }: { label?: React.ReactNode; id?: string }) => ( + {label} + ), + Body: ({ + items, + children, + }: { + items?: Row[]; + children: (item: Row) => React.ReactNode; + }) => ( + + {items?.map((item) => ( + {children(item)} + ))} + + ), + Row: ({ + columns, + children, + id, + }: { + columns?: Col[]; + children: (col: Col) => React.ReactNode; + id?: React.Key; + }) => ( + + {columns?.map((col) => ( + {children(col)} + ))} + + ), + Cell: ({ children }: React.PropsWithChildren) => ( + {children} + ), + } + ); + + return { + Table: TableMock, + Typography: ({ children }: React.PropsWithChildren) => ( + {children} + ), + }; +}); + jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom'), Link: jest.fn().mockImplementation(({ children, to, ...rest }) => ( @@ -109,15 +179,13 @@ describe('FailedTestCaseSampleData - observabilityRouterClassBase migration', () '../../../../utils/RouterUtils' ); - await act(async () => { - render(); - }); + render(); const exploreBtn = await screen.findByTestId('explore-with-query'); const link = exploreBtn.closest('a'); expect(link).not.toBeNull(); - expect(link?.getAttribute('data-to')).toBe( + expect(link?.dataset.to).toBe( observabilityRouterClassBase.getTestCaseDetailPagePath( FQN, TestCasePageTabs.SQL_QUERY