diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DashboardDetails/DashboardDetails.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DashboardDetails/DashboardDetails.test.tsx index c1421ad255a..9ed20268bb7 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/DashboardDetails/DashboardDetails.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/DashboardDetails/DashboardDetails.test.tsx @@ -11,7 +11,7 @@ * limitations under the License. */ -import { getAllByTestId, getByTestId, render } from '@testing-library/react'; +import { findByText, render } from '@testing-library/react'; import { LeafNodes, LoadingNodeState, TableDetail } from 'Models'; import React from 'react'; import { MemoryRouter } from 'react-router-dom'; @@ -77,7 +77,7 @@ jest.mock('../ManageTab/ManageTab.component', () => { return jest.fn().mockReturnValue(

ManageTab

); }); -jest.mock('../../components/common/description/Description', () => { +jest.mock('../common/description/Description', () => { return jest.fn().mockReturnValue(

Description

); }); jest.mock('../common/rich-text-editor/RichTextEditorPreviewer', () => { @@ -92,6 +92,18 @@ jest.mock('../tags/tags', () => { return jest.fn().mockReturnValue(

Tags

); }); +jest.mock('../EntityLineage/EntityLineage.component', () => { + return jest.fn().mockReturnValue(

EntityLineage

); +}); + +jest.mock('../common/TabsPane/TabsPane', () => { + return jest.fn().mockReturnValue(

TabsPane

); +}); + +jest.mock('../common/entityPageInfo/EntityPageInfo', () => { + return jest.fn().mockReturnValue(

EntityPageInfo

); +}); + jest.mock('../../utils/CommonUtils', () => ({ addToRecentViewed: jest.fn(), getCurrentUserId: jest.fn().mockReturnValue('CurrentUserId'), @@ -101,17 +113,17 @@ jest.mock('../../utils/CommonUtils', () => ({ })); describe('Test DashboardDetails component', () => { - it('Checks if the DashboardDetails component has all the proper components rendered', () => { + it('Checks if the DashboardDetails component has all the proper components rendered', async () => { const { container } = render( , { wrapper: MemoryRouter, } ); - const followButton = getByTestId(container, 'follow-button'); - const tabs = getAllByTestId(container, 'tab'); + const EntityPageInfo = await findByText(container, /EntityPageInfo/i); + const TabsPane = await findByText(container, /TabsPane/i); - expect(followButton).toBeInTheDocument(); - expect(tabs.length).toBe(2); + expect(EntityPageInfo).toBeInTheDocument(); + expect(TabsPane).toBeInTheDocument(); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Explore/Explore.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Explore/Explore.test.tsx index 17fab4e2d8a..7bcd72b527c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Explore/Explore.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Explore/Explore.test.tsx @@ -19,11 +19,14 @@ import { mockResponse } from './exlore.mock'; import Explore from './Explore.component'; jest.mock('react-router-dom', () => ({ useHistory: jest.fn(), - useLocation: jest.fn().mockImplementation(() => ({ search: '' })), + useLocation: jest + .fn() + .mockImplementation(() => ({ search: '', pathname: '/explore' })), })); jest.mock('../../utils/FilterUtils', () => ({ getFilterString: jest.fn().mockImplementation(() => 'user.address'), + getFilterCount: jest.fn().mockImplementation(() => 10), })); jest.mock('../../components/searched-data/SearchedData', () => { @@ -36,6 +39,27 @@ jest.mock('../../components/searched-data/SearchedData', () => { )); }); +jest.mock( + '../containers/PageLayout', + () => + ({ + children, + leftPanel, + rightPanel, + }: { + children: React.ReactNode; + rightPanel: React.ReactNode; + leftPanel: React.ReactNode; + }) => + ( +
+
{leftPanel}
+
{rightPanel}
+ {children} +
+ ) +); + const mockFunction = jest.fn(); const mockSearchResult = { @@ -79,7 +103,7 @@ describe('Test Explore component', () => { wrapper: MemoryRouter, } ); - const pageContainer = await findByTestId(container, 'fluid-container'); + const pageContainer = await findByTestId(container, 'PageLayout'); const searchData = await findByTestId(container, 'search-data'); const wrappedContent = await findByTestId(container, 'wrapped-content'); const tabs = await findAllByTestId(container, 'tab'); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/IngestionModal/IngestionModal.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/IngestionModal/IngestionModal.component.tsx index ef542604ecf..541453d3475 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/IngestionModal/IngestionModal.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/IngestionModal/IngestionModal.component.tsx @@ -295,7 +295,7 @@ const IngestionModal: React.FC = ({ = ({ { addIngestion={mockFunction} header="Add Ingestion" ingestionList={[]} - ingestionTypes={[]} - serviceList={mockServiceList} + ingestionTypes={['metadata', 'queryUsage'] as PipelineType[]} + service="bigquery_gcp" + serviceList={[]} onCancel={mockFunction} />, { @@ -90,108 +92,67 @@ describe('Test Ingestion modal component', () => { const nextButton = await findByTestId(container, 'next-button'); const previousButton = await findByTestId(container, 'previous-button'); - fireEvent.click(nextButton); - - expect( - await findByText(container, /Ingestion Name is required/i) - ).toBeInTheDocument(); - const name = await findByTestId(container, 'name'); - fireEvent.change(name, { - target: { value: 'mockName' }, - }); expect(name).toBeInTheDocument(); - expect(name).toHaveValue('mockName'); - - const service = await findByTestId(container, 'select-service'); - fireEvent.change(service, { - target: { value: 'Redshift$$aws_redshift' }, - }); - - expect(service).toBeInTheDocument(); - expect(service).toHaveValue('Redshift$$aws_redshift'); + expect(name).toHaveValue('bigquery_gcp_metadata'); // service name + 1st value of ingestionType const ingestionType = await findByTestId(container, 'ingestion-type'); - fireEvent.change(ingestionType, { - target: { value: 'redshift' }, - }); expect(ingestionType).toBeInTheDocument(); - expect(ingestionType).toHaveValue('redshift'); + expect(ingestionType).toHaveValue('metadata'); // 1st value of ingestionType - fireEvent.click(nextButton); - - // Step 2 - fireEvent.click(nextButton); - - expect( - await findByText(container, /Username is required/i) - ).toBeInTheDocument(); - expect( - await findByText(container, /Password is required/i) - ).toBeInTheDocument(); - expect( - await findByText(container, /Host is required/i) - ).toBeInTheDocument(); - expect( - await findByText(container, /Database is required/i) - ).toBeInTheDocument(); - expect(previousButton).not.toHaveClass('tw-invisible'); - - const userName = await findByTestId(container, 'user-name'); - fireEvent.change(userName, { - target: { value: 'test' }, - }); - - expect(userName).toBeInTheDocument(); - expect(userName).toHaveValue('test'); - - const password = await findByTestId(container, 'password'); - fireEvent.change(password, { - target: { value: 'password' }, - }); - - expect(password).toBeInTheDocument(); - expect(password).toHaveValue('password'); - - const host = await findByTestId(container, 'host'); - fireEvent.change(host, { - target: { value: 'host' }, - }); - - expect(host).toBeInTheDocument(); - expect(host).toHaveValue('host'); - - const database = await findByTestId(container, 'database'); - fireEvent.change(database, { - target: { value: 'database' }, - }); - - expect(database).toBeInTheDocument(); - expect(database).toHaveValue('database'); - - const includeFilterPattern = await findByTestId( + const tableIncludeFilterPattern = await findByTestId( container, - 'include-filter-pattern' + 'table-include-filter-pattern' ); - fireEvent.change(includeFilterPattern, { - target: { value: 'include_pattern' }, + fireEvent.change(tableIncludeFilterPattern, { + target: { value: 'table-include-filter-pattern' }, }); - expect(includeFilterPattern).toBeInTheDocument(); - expect(includeFilterPattern).toHaveValue('include_pattern'); + expect(tableIncludeFilterPattern).toBeInTheDocument(); + expect(tableIncludeFilterPattern).toHaveValue( + 'table-include-filter-pattern' + ); - const excludeFilterPattern = await findByTestId( + const tableExcludeFilterPattern = await findByTestId( container, - 'exclude-filter-pattern' + 'table-exclude-filter-pattern' ); - fireEvent.change(excludeFilterPattern, { - target: { value: 'exclude_pattern' }, + fireEvent.change(tableExcludeFilterPattern, { + target: { value: 'table-exclude-filter-pattern' }, }); - expect(excludeFilterPattern).toBeInTheDocument(); - expect(excludeFilterPattern).toHaveValue('exclude_pattern'); + expect(tableExcludeFilterPattern).toBeInTheDocument(); + expect(tableExcludeFilterPattern).toHaveValue( + 'table-exclude-filter-pattern' + ); + + const schemaIncludeFilterPattern = await findByTestId( + container, + 'schema-include-filter-pattern' + ); + fireEvent.change(schemaIncludeFilterPattern, { + target: { value: 'schema-include-filter-pattern' }, + }); + + expect(schemaIncludeFilterPattern).toBeInTheDocument(); + expect(schemaIncludeFilterPattern).toHaveValue( + 'schema-include-filter-pattern' + ); + + const schemaExcludeFilterPattern = await findByTestId( + container, + 'schema-exclude-filter-pattern' + ); + fireEvent.change(schemaExcludeFilterPattern, { + target: { value: 'schema-exclude-filter-pattern' }, + }); + + expect(schemaExcludeFilterPattern).toBeInTheDocument(); + expect(schemaExcludeFilterPattern).toHaveValue( + 'schema-exclude-filter-pattern' + ); const includeViews = await findByTestId(container, 'include-views'); fireEvent.click(includeViews); @@ -205,9 +166,20 @@ describe('Test Ingestion modal component', () => { expect(dataProfiler).toBeInTheDocument(); expect(dataProfiler).toHaveClass('open'); + const ingestSampleData = await findByTestId( + container, + 'ingest-sample-data' + ); + fireEvent.click(ingestSampleData); + + expect(ingestSampleData).toBeInTheDocument(); + expect(ingestSampleData).not.toHaveClass('open'); + fireEvent.click(nextButton); - // Step 3 + // Step 2 + expect(previousButton).toBeInTheDocument(); + const scheduleInterval = await findByTestId(container, 'schedule-interval'); expect(scheduleInterval).toBeInTheDocument(); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/facetfilter/FilterContainer.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/facetfilter/FilterContainer.test.tsx index 01b16ae27fa..d84b14139c6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/facetfilter/FilterContainer.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/facetfilter/FilterContainer.test.tsx @@ -30,7 +30,7 @@ describe('Test FilterContainer Component', () => { /> ); - expect(getByTestId(container, 'filter-container')).toBeInTheDocument(); + expect(getByTestId(container, 'filter-container-test')).toBeInTheDocument(); }); it('onClick of checkbox callback function should call', () => { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/non-admin-action/NonAdminAction.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/non-admin-action/NonAdminAction.test.tsx index 466cfd63997..8d9afdcbcf1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/non-admin-action/NonAdminAction.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/non-admin-action/NonAdminAction.test.tsx @@ -18,6 +18,9 @@ import NonAdminAction from './NonAdminAction'; const mockAuth = { isAdminUser: true, isAuthDisabled: true, + userPermissions: { + UpdateOwner: true, + }, }; jest.mock('../../../hooks/authHooks', () => ({ @@ -48,6 +51,7 @@ describe('Test AddUsersModal component', () => { it('Should restrict user if criteria does not match', async () => { mockAuth.isAdminUser = false; mockAuth.isAuthDisabled = false; + mockAuth.userPermissions.UpdateOwner = false; const { container } = render( diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/popover/PopOver.test.js b/openmetadata-ui/src/main/resources/ui/src/components/common/popover/PopOver.test.js index 0264ce8a744..f23c726ee8c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/popover/PopOver.test.js +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/popover/PopOver.test.js @@ -45,7 +45,7 @@ describe('Test Popover Component', () => { expect(popover).toBeInTheDocument(); }); - it('Onclick popover should display title', () => { + it('Onclick popover should display title', async () => { const { container } = render( Hello World @@ -60,11 +60,11 @@ describe('Test Popover Component', () => { }) ); - expect(screen.getByText(/test popover/i)).toBeInTheDocument(); + expect(await screen.findByText(/test popover/i)).toBeInTheDocument(); }); - it('Onclick popover should display html', () => { - const html =

test popover

; + it('Onclick popover should display html', async () => { + const html = test popover; const { container } = render( Hello World @@ -79,6 +79,6 @@ describe('Test Popover Component', () => { }) ); - expect(screen.getByText(/test popover/i)).toBeInTheDocument(); + expect(await screen.findByText(/test popover/i)).toBeInTheDocument(); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/table-data-card/TableDataCard.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/table-data-card/TableDataCard.test.tsx index 2d635a0505c..e7e19d5ffe7 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/table-data-card/TableDataCard.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/table-data-card/TableDataCard.test.tsx @@ -43,6 +43,7 @@ describe('Test TableDataCard Component', () => { fullyQualifiedName="testFQN" indexType="testIndex" name="test card" + tags={[]} />, { wrapper: MemoryRouter } ); @@ -51,17 +52,19 @@ describe('Test TableDataCard Component', () => { expect(tableDataCard).toBeInTheDocument(); }); - it('Link should have proper path', () => { + it('Component should render for deleted', () => { const { getByTestId } = render( , { wrapper: MemoryRouter } ); - const link = getByTestId('table-link'); + const deleted = getByTestId('deleted'); - expect(link).toHaveAttribute('href', `/EntityLink`); + expect(deleted).toBeInTheDocument(); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/table-data-card/TableDataCard.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/table-data-card/TableDataCard.tsx index d02e3859b77..82fe005695c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/table-data-card/TableDataCard.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/table-data-card/TableDataCard.tsx @@ -131,7 +131,9 @@ const TableDataCard: FunctionComponent = ({ {deleted && ( <> -
+
Deleted
diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/services/index.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/services/index.test.tsx index 65fea2769b9..8fee000a542 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/services/index.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/services/index.test.tsx @@ -80,6 +80,7 @@ const mockDatabaseService = { }, }, ], + paging: { total: 2 }, }, }; @@ -96,6 +97,7 @@ const mockMessagingService = { serviceType: 'Kafka', }, ], + paging: { total: 1 }, }, }; @@ -113,6 +115,7 @@ const mockDashboardService = { username: 'admin', }, ], + paging: { total: 1 }, }, }; @@ -129,6 +132,7 @@ const mockPipelineService = { href: 'http://localhost:8585/api/v1/services/pipelineServices/7576944e-2921-4c15-9edc-b9bada93338a', }, ], + paging: { total: 1 }, }, }; @@ -167,7 +171,7 @@ jest.mock('../../components/common/non-admin-action/NonAdminAction', () => { return jest .fn() .mockImplementation(({ children }: { children: ReactNode }) => ( -
{children}
+ {children} )); }); @@ -189,10 +193,6 @@ describe('Test Service page', () => { expect(services).toBeInTheDocument(); expect(tabs.length).toBe(mockServiceDetails.data.length); expect(dataContainer).toBeInTheDocument(); - - expect(dataContainer.childElementCount).toBe( - mockDatabaseService.data.data.length - ); }); it('On page load database service should be active tab with corresponding data', async () => { @@ -200,11 +200,13 @@ describe('Test Service page', () => { wrapper: MemoryRouter, }); const tabs = await findAllByTestId(container, 'tab'); - const serviceNames = await findAllByTestId(container, 'service-name'); + const serviceNames = await findByTestId(container, 'service-name'); + const dataContainer = await findByTestId(container, 'data-container'); - expect(tabs[0]).toHaveClass('active'); - expect(serviceNames.map((s) => s.textContent)).toEqual( - mockDatabaseService.data.data.map((d) => d.name) + expect(tabs[0]).toHaveClass('activeCategory'); + expect(serviceNames).toBeInTheDocument(); + expect(dataContainer.childElementCount).toBe( + mockDatabaseService.data.data.length ); }); @@ -214,15 +216,15 @@ describe('Test Service page', () => { }); let tabs = await findAllByTestId(container, 'tab'); - expect(tabs[0]).toHaveClass('active'); + expect(tabs[0]).toHaveClass('activeCategory'); fireEvent.click(tabs[1]); tabs = await findAllByTestId(container, 'tab'); - const serviceNames = await findAllByTestId(container, 'service-name'); + const dataContainer = await findByTestId(container, 'data-container'); - expect(tabs[1]).toHaveClass('active'); - expect(serviceNames.map((s) => s.textContent)).toEqual( - mockMessagingService.data.data.map((d) => d.name) + expect(tabs[1]).toHaveClass('activeCategory'); + expect(dataContainer.childElementCount).toBe( + mockMessagingService.data.data.length ); }); @@ -238,45 +240,30 @@ describe('Test Service page', () => { ).toBeInTheDocument(); }); - it('OnClick of edit service, AddServiceModal should open', async () => { - const { container } = render(, { - wrapper: MemoryRouter, - }); - const editService = await findAllByTestId(container, 'edit-service'); - fireEvent.click(editService[0]); - - expect( - await findByTestId(container, 'add-service-modal') - ).toBeInTheDocument(); - }); - it('Card details should be display properly', async () => { const { container } = render(, { wrapper: MemoryRouter, }); - const serviceName = await findAllByTestId(container, 'service-name'); + const serviceName = await findByTestId(container, 'service-name'); + const tabs = await findAllByTestId(container, 'tab'); + const serviceDescription = await findAllByTestId( container, 'service-description' ); - const additionalField = await findAllByTestId( - container, - 'additional-field' - ); - const ingestion = await findAllByTestId(container, 'service-ingestion'); const type = await findAllByTestId(container, 'service-type'); - const edit = await findAllByTestId(container, 'edit-service'); - const deleteIcon = await findAllByTestId(container, 'delete-service'); + const deleteIcon = await findAllByTestId( + container, + 'delete-icon-container' + ); const icon = await findAllByTestId(container, 'service-icon'); - expect(serviceName.length).toBe(mockDatabaseService.data.data.length); + expect(tabs[0]).toHaveClass('activeCategory'); + expect(tabs[0].innerText).toBe(serviceName.innerText); expect(serviceDescription.length).toBe( mockDatabaseService.data.data.length ); - expect(additionalField.length).toBe(mockDatabaseService.data.data.length); - expect(ingestion.length).toBe(mockDatabaseService.data.data.length); expect(type.length).toBe(mockDatabaseService.data.data.length); - expect(edit.length).toBe(mockDatabaseService.data.data.length); expect(deleteIcon.length).toBe(mockDatabaseService.data.data.length); expect(icon.length).toBe(mockDatabaseService.data.data.length); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/services/index.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/services/index.tsx index d079380fc4e..44b7df0a8ef 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/services/index.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/services/index.tsx @@ -569,7 +569,9 @@ const ServicesPage = () => {
-
+