@@ -303,7 +324,7 @@ const DatabaseDetails: FunctionComponent = () => {
'tableBody-row',
!isEven(index + 1) ? 'odd-row' : null
)}
- data-testid="column"
+ data-testid="tabale-column"
key={index}>
|
({
@@ -36,7 +36,13 @@ jest.mock('../../utils/FilterUtils', () => ({
}));
jest.mock('../../components/searched-data/SearchedData', () => {
- return jest.fn().mockReturnValue( SearchedData );
+ return jest
+ .fn()
+ .mockImplementation(({ children }: { children: React.ReactNode }) => (
+
+ ));
});
jest.mock('../../hooks/useToastContext', () => {
@@ -44,19 +50,16 @@ jest.mock('../../hooks/useToastContext', () => {
});
describe('Test Explore page', () => {
- it('Should Call Search API', async () => {
- await act(async () => {
- render();
+ it('Component should render', async () => {
+ const { container } = render(, {
+ wrapper: MemoryRouter,
});
+ const searchData = await findByTestId(container, 'search-data');
+ const wrappedContent = await findByTestId(container, 'wrapped-content');
+ const tabs = await findAllByTestId(container, 'tab');
- expect(await screen.findByText('SearchedData')).toBeInTheDocument();
- });
-
- it('getFilterString should return filter as string', async () => {
- await act(async () => {
- render();
- });
-
- expect(getFilterString).toEqual(getFilterString);
+ expect(searchData).toBeInTheDocument();
+ expect(wrappedContent).toBeInTheDocument();
+ expect(tabs.length).toBe(3);
});
});
diff --git a/catalog-rest-service/src/main/resources/ui/src/pages/explore/index.tsx b/catalog-rest-service/src/main/resources/ui/src/pages/explore/index.tsx
index f1e338ad872..0f205e5ded5 100644
--- a/catalog-rest-service/src/main/resources/ui/src/pages/explore/index.tsx
+++ b/catalog-rest-service/src/main/resources/ui/src/pages/explore/index.tsx
@@ -504,6 +504,7 @@ const ExplorePage: React.FC = (): React.ReactElement => {
className={`tw-pb-2 tw-px-4 tw-gh-tabs ${getActiveTabClass(
tab.tab
)}`}
+ data-testid="tab"
key={index}
onClick={() => {
onTabChange(tab.tab);
diff --git a/catalog-rest-service/src/main/resources/ui/src/pages/my-data/index.test.tsx b/catalog-rest-service/src/main/resources/ui/src/pages/my-data/index.test.tsx
index db6ecd5dde7..11539d0c020 100644
--- a/catalog-rest-service/src/main/resources/ui/src/pages/my-data/index.test.tsx
+++ b/catalog-rest-service/src/main/resources/ui/src/pages/my-data/index.test.tsx
@@ -17,7 +17,12 @@
/* eslint-disable @typescript-eslint/camelcase */
-import { findByTestId, render } from '@testing-library/react';
+import {
+ findAllByTestId,
+ findByTestId,
+ findByText,
+ render,
+} from '@testing-library/react';
import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import MyDataPage from './index';
@@ -189,13 +194,21 @@ jest.mock('../../axiosAPIs/miscAPI', () => ({
jest.mock('../../components/searched-data/SearchedData', () => {
return jest
.fn()
- .mockReturnValue(SearchedData );
+ .mockImplementation(({ children }: { children: React.ReactNode }) => (
+
+ ));
});
jest.mock('../../components/recently-viewed/RecentlyViewed', () => {
return jest.fn().mockReturnValue(RecentlyViewed );
});
+jest.mock('../../components/my-data/MyDataHeader', () => {
+ return jest.fn().mockReturnValue(MyDataHeader );
+});
+
jest.mock('../../utils/ServiceUtils', () => ({
getAllServices: jest
.fn()
@@ -211,7 +224,13 @@ describe('Test MyData page', () => {
wrapper: MemoryRouter,
});
const searchData = await findByTestId(container, 'search-data');
+ const wrappedContent = await findByTestId(container, 'wrapped-content');
+ const tabs = await findAllByTestId(container, 'tab');
+ const myDataHeader = await findByText(container, /MyDataHeader/i);
expect(searchData).toBeInTheDocument();
+ expect(wrappedContent).toBeInTheDocument();
+ expect(myDataHeader).toBeInTheDocument();
+ expect(tabs.length).toBe(3);
});
});
diff --git a/catalog-rest-service/src/main/resources/ui/src/pages/service/index.test.tsx b/catalog-rest-service/src/main/resources/ui/src/pages/service/index.test.tsx
index 551c4583168..995e764ed69 100644
--- a/catalog-rest-service/src/main/resources/ui/src/pages/service/index.test.tsx
+++ b/catalog-rest-service/src/main/resources/ui/src/pages/service/index.test.tsx
@@ -1,6 +1,8 @@
import {
findAllByTestId,
findByTestId,
+ findByText,
+ fireEvent,
queryByText,
render,
} from '@testing-library/react';
@@ -77,14 +79,41 @@ jest.mock('../../utils/ServiceUtils', () => ({
serviceTypeLogo: jest.fn().mockReturnValue('img/path'),
}));
+jest.mock(
+ '../../components/common/title-breadcrumb/title-breadcrumb.component',
+ () => {
+ return jest.fn().mockReturnValue(TitleBreadcrumb );
+ }
+);
+
+jest.mock(
+ '../../components/Modals/ModalWithMarkdownEditor/ModalWithMarkdownEditor',
+ () => ({
+ ModalWithMarkdownEditor: jest
+ .fn()
+ .mockReturnValue(ModalWithMarkdownEditor ),
+ })
+);
+
describe('Test ServicePage Component', () => {
it('Component should render', async () => {
const { container } = render(, {
wrapper: MemoryRouter,
});
const servicePage = await findByTestId(container, 'service-page');
+ const titleBreadcrumb = await findByText(container, /TitleBreadcrumb/i);
+ const descriptionContainer = await findByTestId(
+ container,
+ 'description-container'
+ );
+ const descriptionData = await findByTestId(container, 'description-data');
+ const descriptionEdit = await findByTestId(container, 'description-edit');
expect(servicePage).toBeInTheDocument();
+ expect(titleBreadcrumb).toBeInTheDocument();
+ expect(descriptionContainer).toBeInTheDocument();
+ expect(descriptionData).toBeInTheDocument();
+ expect(descriptionEdit).toBeInTheDocument();
});
it('Table should be visible if data is available', async () => {
@@ -107,4 +136,18 @@ describe('Test ServicePage Component', () => {
expect(column.length).toBe(1);
});
+
+ it('on click of edit description icon ModalWithMarkdownEditor should open', async () => {
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+
+ const editIcon = await findByTestId(container, 'description-edit');
+
+ fireEvent.click(editIcon);
+
+ expect(
+ await findByText(container, /ModalWithMarkdownEditor/i)
+ ).toBeInTheDocument();
+ });
});
diff --git a/catalog-rest-service/src/main/resources/ui/src/pages/service/index.tsx b/catalog-rest-service/src/main/resources/ui/src/pages/service/index.tsx
index f1648c19227..d2ae87ef33e 100644
--- a/catalog-rest-service/src/main/resources/ui/src/pages/service/index.tsx
+++ b/catalog-rest-service/src/main/resources/ui/src/pages/service/index.tsx
@@ -567,7 +567,9 @@ const ServicePage: FunctionComponent = () => {
-
+
Description
@@ -575,6 +577,7 @@ const ServicePage: FunctionComponent = () => {
-
+
{description ? (
) : (
|