diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/DatasetDetailsPage/DatasetDetailsPage.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/DatasetDetailsPage/DatasetDetailsPage.test.tsx
index 4f5cd0c0585..35f2e9fe1a9 100644
--- a/openmetadata-ui/src/main/resources/ui/src/pages/DatasetDetailsPage/DatasetDetailsPage.test.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/pages/DatasetDetailsPage/DatasetDetailsPage.test.tsx
@@ -20,8 +20,25 @@ import {
} from '@testing-library/react';
import React from 'react';
import { MemoryRouter } from 'react-router';
+import {
+ getAllFeeds,
+ getFeedCount,
+ postFeedById,
+ postThread,
+} from '../../axiosAPIs/feedsAPI';
import { getLineageByFQN } from '../../axiosAPIs/lineageAPI';
-import { getTableDetailsByFQN } from '../../axiosAPIs/tableAPI';
+import { addLineage, deleteLineageEdge } from '../../axiosAPIs/miscAPI';
+import {
+ addColumnTestCase,
+ addFollower,
+ addTableTestCase,
+ deleteColumnTestCase,
+ deleteTableTestCase,
+ getTableDetailsByFQN,
+ patchTableDetails,
+ removeFollower,
+} from '../../axiosAPIs/tableAPI';
+import { deletePost, getUpdatedThread } from '../../utils/FeedUtils';
import DatasetDetailsPage from './DatasetDetailsPage.component';
import {
createPostRes,
@@ -78,6 +95,7 @@ jest.mock('../../components/DatasetDetails/DatasetDetails.component', () => {
handleRemoveTableTest,
handleRemoveColumnTest,
deletePostHandler,
+ entityLineageHandler,
}) => (
)
);
@@ -184,11 +207,15 @@ jest.mock('fast-json-patch', () => ({
}));
jest.mock('../../axiosAPIs/tableAPI', () => ({
- addColumnTestCase: jest.fn().mockImplementation(() => Promise.resolve()),
+ addColumnTestCase: jest
+ .fn()
+ .mockImplementation(() => Promise.resolve({ data: updateTagRes })),
addFollower: jest
.fn()
.mockImplementation(() => Promise.resolve({ data: mockFollowRes })),
- addTableTestCase: jest.fn().mockImplementation(() => Promise.resolve()),
+ addTableTestCase: jest
+ .fn()
+ .mockImplementation(() => Promise.resolve({ data: updateTagRes })),
deleteColumnTestCase: jest.fn().mockImplementation(() => Promise.resolve()),
deleteTableTestCase: jest.fn().mockImplementation(() => Promise.resolve()),
getTableDetailsByFQN: jest.fn().mockImplementation(() =>
@@ -206,7 +233,9 @@ jest.mock('../../axiosAPIs/tableAPI', () => ({
jest.mock('../../utils/FeedUtils', () => ({
deletePost: jest.fn().mockImplementation(() => Promise.resolve()),
- getUpdatedThread: jest.fn().mockImplementation(() => Promise.resolve()),
+ getUpdatedThread: jest
+ .fn()
+ .mockImplementation(() => Promise.resolve({ id: 'test', posts: [] })),
}));
jest.mock('../../axiosAPIs/feedsAPI', () => ({
@@ -310,6 +339,10 @@ describe('Test DatasetDetails page', () => {
container,
'handleRemoveColumnTest'
);
+ const entityLineageHandler = await findByTestId(
+ container,
+ 'entityLineageHandler'
+ );
expect(followButton).toBeInTheDocument();
expect(unfollowButton).toBeInTheDocument();
@@ -332,6 +365,7 @@ describe('Test DatasetDetails page', () => {
expect(deletePostHandler).toBeInTheDocument();
expect(handleRemoveTableTest).toBeInTheDocument();
expect(handleRemoveColumnTest).toBeInTheDocument();
+ expect(entityLineageHandler).toBeInTheDocument();
fireEvent.click(followButton);
fireEvent.click(unfollowButton);
@@ -354,6 +388,7 @@ describe('Test DatasetDetails page', () => {
fireEvent.click(deletePostHandler);
fireEvent.click(handleRemoveTableTest);
fireEvent.click(handleRemoveColumnTest);
+ fireEvent.click(entityLineageHandler);
});
});
@@ -460,9 +495,24 @@ describe('Test DatasetDetails page', () => {
expect(ContainerText).toBeInTheDocument();
});
- it('Show error message on fail of getLineageByFQN api', async () => {
- (getLineageByFQN as jest.Mock).mockImplementationOnce(() =>
- Promise.reject({ response: { data: { message: 'Error!' } } })
+ it('show error if getTableDetailsByFQN resolves with empty response data', async () => {
+ (getTableDetailsByFQN as jest.Mock).mockImplementationOnce(() =>
+ Promise.resolve({ data: '' })
+ );
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const errorPlaceholder = await findByText(
+ container,
+ /ErrorPlaceHolder.component/i
+ );
+
+ expect(errorPlaceholder).toBeInTheDocument();
+ });
+
+ it('show error if getTableDetailsByFQN resolves with empty response', async () => {
+ (getTableDetailsByFQN as jest.Mock).mockImplementationOnce(() =>
+ Promise.resolve()
);
const { container } = render(, {
wrapper: MemoryRouter,
@@ -474,5 +524,967 @@ describe('Test DatasetDetails page', () => {
expect(ContainerText).toBeInTheDocument();
});
+
+ // getLineageByFQN test
+ it('Show error message on fail of getLineageByFQN api with error message', async () => {
+ (getLineageByFQN as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+ mockUseParams.tab = 'lineage';
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const loadNodeHandler = await findByTestId(container, 'loadNodeHandler');
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(loadNodeHandler).toBeInTheDocument();
+
+ fireEvent.click(loadNodeHandler);
+ });
+
+ it('Show error message on fail of getLineageByFQN api with empty response', async () => {
+ (getLineageByFQN as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: {} })
+ );
+ mockUseParams.tab = 'lineage';
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const loadNodeHandler = await findByTestId(container, 'loadNodeHandler');
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(loadNodeHandler).toBeInTheDocument();
+
+ fireEvent.click(loadNodeHandler);
+ });
+
+ it('Show error message on resolve of getLineageByFQN api without response', async () => {
+ (getLineageByFQN as jest.Mock).mockImplementation(() =>
+ Promise.resolve()
+ );
+ mockUseParams.tab = 'lineage';
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const loadNodeHandler = await findByTestId(container, 'loadNodeHandler');
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(loadNodeHandler).toBeInTheDocument();
+
+ fireEvent.click(loadNodeHandler);
+ });
+
+ it('Show error message on resolve of getLineageByFQN api without response data', async () => {
+ (getLineageByFQN as jest.Mock).mockImplementation(() =>
+ Promise.resolve({ data: '' })
+ );
+ mockUseParams.tab = 'lineage';
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const loadNodeHandler = await findByTestId(container, 'loadNodeHandler');
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(loadNodeHandler).toBeInTheDocument();
+
+ fireEvent.click(loadNodeHandler);
+ });
+
+ // getAllFeeds api test
+
+ it('Show error message on fail of getAllFeeds api with error message', async () => {
+ (getAllFeeds as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+ mockUseParams.tab = 'activity_feed';
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ });
+
+ it('Show error message on fail of getAllFeeds api with empty response', async () => {
+ (getAllFeeds as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject({ response: {} })
+ );
+ mockUseParams.tab = 'activity_feed';
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ });
+
+ it('Show error message on resolve of getAllFeeds api without response', async () => {
+ (getAllFeeds as jest.Mock).mockImplementationOnce(() =>
+ Promise.resolve()
+ );
+ mockUseParams.tab = 'activity_feed';
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ });
+
+ it('Show error message on resolve of getAllFeeds api without response data', async () => {
+ (getAllFeeds as jest.Mock).mockImplementationOnce(() =>
+ Promise.resolve({ data: '' })
+ );
+ mockUseParams.tab = 'activity_feed';
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ });
+
+ // getFeedCount api test
+
+ it('Show error message on fail of getFeedCount api with error message', async () => {
+ (getFeedCount as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+ mockUseParams.tab = 'schema';
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ });
+
+ it('Show error message on fail of getFeedCount api with empty response', async () => {
+ (getFeedCount as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject({ response: {} })
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ });
+
+ it('Show error message on resolve of getFeedCount api without response', async () => {
+ (getFeedCount as jest.Mock).mockImplementationOnce(() =>
+ Promise.resolve()
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ });
+
+ it('Show error message on resolve of getFeedCount api without response data', async () => {
+ (getFeedCount as jest.Mock).mockImplementationOnce(() =>
+ Promise.resolve({ data: '' })
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ });
+
+ // CTA actions test
+
+ it('Show error message on fail of CTA api with error message', async () => {
+ (patchTableDetails as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+ (addFollower as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+ (removeFollower as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+ (deleteLineageEdge as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+ (postFeedById as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+ (postThread as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+ (deleteTableTestCase as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+ (deleteColumnTestCase as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+
+ mockUseParams.tab = 'schema';
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const postFeedHandler = await findByTestId(container, 'postFeedHandler');
+ const followButton = await findByTestId(container, 'follow-button');
+ const unfollowButton = await findByTestId(container, 'unfollow-button');
+ const tag = await findByTestId(container, 'tag');
+ const description = await findByTestId(container, 'description');
+ const columnUpdate = await findByTestId(container, 'columnUpdate');
+ const addLineageHandler = await findByTestId(
+ container,
+ 'addLineageHandler'
+ );
+ const removeLineageHandler = await findByTestId(
+ container,
+ 'removeLineageHandler'
+ );
+ const createThread = await findByTestId(container, 'createThread');
+ const handleRemoveTableTest = await findByTestId(
+ container,
+ 'handleRemoveTableTest'
+ );
+ const handleRemoveColumnTest = await findByTestId(
+ container,
+ 'handleRemoveColumnTest'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(postFeedHandler).toBeInTheDocument();
+ expect(addLineageHandler).toBeInTheDocument();
+ expect(removeLineageHandler).toBeInTheDocument();
+ expect(followButton).toBeInTheDocument();
+ expect(unfollowButton).toBeInTheDocument();
+ expect(description).toBeInTheDocument();
+ expect(tag).toBeInTheDocument();
+ expect(columnUpdate).toBeInTheDocument();
+ expect(createThread).toBeInTheDocument();
+ expect(handleRemoveTableTest).toBeInTheDocument();
+ expect(handleRemoveColumnTest).toBeInTheDocument();
+
+ fireEvent.click(followButton);
+ fireEvent.click(postFeedHandler);
+ fireEvent.click(unfollowButton);
+ fireEvent.click(tag);
+ fireEvent.click(columnUpdate);
+ fireEvent.click(description);
+ fireEvent.click(addLineageHandler);
+ fireEvent.click(removeLineageHandler);
+ fireEvent.click(createThread);
+ fireEvent.click(handleRemoveTableTest);
+ fireEvent.click(handleRemoveColumnTest);
+ });
+
+ it('Show error message on fail of CTA api with empty response', async () => {
+ (patchTableDetails as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: {} })
+ );
+ (addFollower as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: {} })
+ );
+ (removeFollower as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: {} })
+ );
+ (deleteLineageEdge as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: {} })
+ );
+ (postFeedById as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: {} })
+ );
+ (postThread as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: {} })
+ );
+ (deleteTableTestCase as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: {} })
+ );
+ (deleteColumnTestCase as jest.Mock).mockImplementation(() =>
+ Promise.reject({ response: {} })
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const postFeedHandler = await findByTestId(container, 'postFeedHandler');
+ const followButton = await findByTestId(container, 'follow-button');
+ const unfollowButton = await findByTestId(container, 'unfollow-button');
+ const tag = await findByTestId(container, 'tag');
+ const description = await findByTestId(container, 'description');
+ const columnUpdate = await findByTestId(container, 'columnUpdate');
+ const addLineageHandler = await findByTestId(
+ container,
+ 'addLineageHandler'
+ );
+ const removeLineageHandler = await findByTestId(
+ container,
+ 'removeLineageHandler'
+ );
+ const createThread = await findByTestId(container, 'createThread');
+ const handleRemoveTableTest = await findByTestId(
+ container,
+ 'handleRemoveTableTest'
+ );
+ const handleRemoveColumnTest = await findByTestId(
+ container,
+ 'handleRemoveColumnTest'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(postFeedHandler).toBeInTheDocument();
+ expect(addLineageHandler).toBeInTheDocument();
+ expect(removeLineageHandler).toBeInTheDocument();
+ expect(followButton).toBeInTheDocument();
+ expect(unfollowButton).toBeInTheDocument();
+ expect(description).toBeInTheDocument();
+ expect(tag).toBeInTheDocument();
+ expect(columnUpdate).toBeInTheDocument();
+ expect(createThread).toBeInTheDocument();
+ expect(handleRemoveTableTest).toBeInTheDocument();
+ expect(handleRemoveColumnTest).toBeInTheDocument();
+
+ fireEvent.click(followButton);
+ fireEvent.click(unfollowButton);
+ fireEvent.click(tag);
+ fireEvent.click(columnUpdate);
+ fireEvent.click(description);
+ fireEvent.click(addLineageHandler);
+ fireEvent.click(postFeedHandler);
+ fireEvent.click(removeLineageHandler);
+ fireEvent.click(createThread);
+ fireEvent.click(handleRemoveTableTest);
+ fireEvent.click(handleRemoveColumnTest);
+ });
+
+ it('Show error message on fail of CTA api with empty object', async () => {
+ (patchTableDetails as jest.Mock).mockImplementation(() =>
+ Promise.reject({})
+ );
+ (addFollower as jest.Mock).mockImplementation(() => Promise.reject({}));
+ (removeFollower as jest.Mock).mockImplementation(() =>
+ Promise.reject({})
+ );
+ (deleteLineageEdge as jest.Mock).mockImplementation(() =>
+ Promise.reject({})
+ );
+ (postFeedById as jest.Mock).mockImplementation(() => Promise.reject({}));
+ (postThread as jest.Mock).mockImplementation(() => Promise.reject({}));
+ (deleteTableTestCase as jest.Mock).mockImplementation(() =>
+ Promise.reject({})
+ );
+ (deleteColumnTestCase as jest.Mock).mockImplementation(() =>
+ Promise.reject({})
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const postFeedHandler = await findByTestId(container, 'postFeedHandler');
+ const followButton = await findByTestId(container, 'follow-button');
+ const unfollowButton = await findByTestId(container, 'unfollow-button');
+ const tag = await findByTestId(container, 'tag');
+ const description = await findByTestId(container, 'description');
+ const columnUpdate = await findByTestId(container, 'columnUpdate');
+ const addLineageHandler = await findByTestId(
+ container,
+ 'addLineageHandler'
+ );
+ const removeLineageHandler = await findByTestId(
+ container,
+ 'removeLineageHandler'
+ );
+ const createThread = await findByTestId(container, 'createThread');
+ const handleRemoveTableTest = await findByTestId(
+ container,
+ 'handleRemoveTableTest'
+ );
+ const handleRemoveColumnTest = await findByTestId(
+ container,
+ 'handleRemoveColumnTest'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(postFeedHandler).toBeInTheDocument();
+ expect(addLineageHandler).toBeInTheDocument();
+ expect(removeLineageHandler).toBeInTheDocument();
+ expect(followButton).toBeInTheDocument();
+ expect(unfollowButton).toBeInTheDocument();
+ expect(description).toBeInTheDocument();
+ expect(tag).toBeInTheDocument();
+ expect(columnUpdate).toBeInTheDocument();
+ expect(createThread).toBeInTheDocument();
+ expect(handleRemoveTableTest).toBeInTheDocument();
+ expect(handleRemoveColumnTest).toBeInTheDocument();
+
+ fireEvent.click(followButton);
+ fireEvent.click(unfollowButton);
+ fireEvent.click(tag);
+ fireEvent.click(columnUpdate);
+ fireEvent.click(description);
+ fireEvent.click(addLineageHandler);
+ fireEvent.click(postFeedHandler);
+ fireEvent.click(removeLineageHandler);
+ fireEvent.click(createThread);
+ fireEvent.click(handleRemoveTableTest);
+ fireEvent.click(handleRemoveColumnTest);
+ });
+
+ it('Show error message on resolve of CTA api without response', async () => {
+ (patchTableDetails as jest.Mock).mockImplementation(() =>
+ Promise.resolve()
+ );
+ (addFollower as jest.Mock).mockImplementation(() => Promise.resolve());
+ (removeFollower as jest.Mock).mockImplementation(() => Promise.resolve());
+ (addLineage as jest.Mock).mockImplementation(() => Promise.resolve());
+ (deleteLineageEdge as jest.Mock).mockImplementation(() =>
+ Promise.resolve()
+ );
+ (postFeedById as jest.Mock).mockImplementation(() => Promise.resolve());
+ (postThread as jest.Mock).mockImplementation(() => Promise.resolve());
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const followButton = await findByTestId(container, 'follow-button');
+ const unfollowButton = await findByTestId(container, 'unfollow-button');
+ const tag = await findByTestId(container, 'tag');
+ const description = await findByTestId(container, 'description');
+ const columnUpdate = await findByTestId(container, 'columnUpdate');
+ const addLineageHandler = await findByTestId(
+ container,
+ 'addLineageHandler'
+ );
+ const removeLineageHandler = await findByTestId(
+ container,
+ 'removeLineageHandler'
+ );
+ const postFeedHandler = await findByTestId(container, 'postFeedHandler');
+ const createThread = await findByTestId(container, 'createThread');
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(addLineageHandler).toBeInTheDocument();
+ expect(removeLineageHandler).toBeInTheDocument();
+ expect(followButton).toBeInTheDocument();
+ expect(unfollowButton).toBeInTheDocument();
+ expect(description).toBeInTheDocument();
+ expect(tag).toBeInTheDocument();
+ expect(columnUpdate).toBeInTheDocument();
+ expect(postFeedHandler).toBeInTheDocument();
+ expect(createThread).toBeInTheDocument();
+
+ fireEvent.click(followButton);
+ fireEvent.click(unfollowButton);
+ fireEvent.click(tag);
+ fireEvent.click(columnUpdate);
+ fireEvent.click(description);
+ fireEvent.click(addLineageHandler);
+ fireEvent.click(postFeedHandler);
+ fireEvent.click(removeLineageHandler);
+ fireEvent.click(createThread);
+ });
+
+ it('Show error message on resolve of CTA api without response data', async () => {
+ (patchTableDetails as jest.Mock).mockImplementation(() =>
+ Promise.resolve({ data: '' })
+ );
+ (addFollower as jest.Mock).mockImplementation(() =>
+ Promise.resolve({ data: '' })
+ );
+ (removeFollower as jest.Mock).mockImplementation(() =>
+ Promise.resolve({ data: '' })
+ );
+ (addLineage as jest.Mock).mockImplementation(() =>
+ Promise.resolve({ data: '' })
+ );
+ (deleteLineageEdge as jest.Mock).mockImplementation(() =>
+ Promise.resolve({ data: '' })
+ );
+ (postFeedById as jest.Mock).mockImplementation(() =>
+ Promise.resolve({ data: '' })
+ );
+ (postThread as jest.Mock).mockImplementation(() =>
+ Promise.resolve({ data: '' })
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const followButton = await findByTestId(container, 'follow-button');
+ const unfollowButton = await findByTestId(container, 'unfollow-button');
+ const tag = await findByTestId(container, 'tag');
+ const description = await findByTestId(container, 'description');
+ const columnUpdate = await findByTestId(container, 'columnUpdate');
+ const addLineageHandler = await findByTestId(
+ container,
+ 'addLineageHandler'
+ );
+ const removeLineageHandler = await findByTestId(
+ container,
+ 'removeLineageHandler'
+ );
+ const postFeedHandler = await findByTestId(container, 'postFeedHandler');
+ const createThread = await findByTestId(container, 'createThread');
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(addLineageHandler).toBeInTheDocument();
+ expect(removeLineageHandler).toBeInTheDocument();
+ expect(followButton).toBeInTheDocument();
+ expect(unfollowButton).toBeInTheDocument();
+ expect(description).toBeInTheDocument();
+ expect(tag).toBeInTheDocument();
+ expect(columnUpdate).toBeInTheDocument();
+ expect(postFeedHandler).toBeInTheDocument();
+ expect(createThread).toBeInTheDocument();
+
+ fireEvent.click(followButton);
+ fireEvent.click(unfollowButton);
+ fireEvent.click(tag);
+ fireEvent.click(columnUpdate);
+ fireEvent.click(description);
+ fireEvent.click(addLineageHandler);
+ fireEvent.click(removeLineageHandler);
+ fireEvent.click(postFeedHandler);
+ fireEvent.click(createThread);
+ });
+
+ // deletePost api test
+
+ it('Show error message on fail of deletePost api with error message', async () => {
+ (deletePost as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const deletePostHandler = await findByTestId(
+ container,
+ 'deletePostHandler'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(deletePostHandler).toBeInTheDocument();
+
+ fireEvent.click(deletePostHandler);
+ });
+
+ it('Show error message on fail of deletePost api with empty response', async () => {
+ (deletePost as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject({ response: {} })
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const deletePostHandler = await findByTestId(
+ container,
+ 'deletePostHandler'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(deletePostHandler).toBeInTheDocument();
+
+ fireEvent.click(deletePostHandler);
+ });
+
+ it('Show error message on fail of deletePost api with empty object', async () => {
+ (deletePost as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject({})
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const deletePostHandler = await findByTestId(
+ container,
+ 'deletePostHandler'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(deletePostHandler).toBeInTheDocument();
+
+ fireEvent.click(deletePostHandler);
+ });
+
+ it('Show error message on fail of deletePost api with no response', async () => {
+ (deletePost as jest.Mock).mockImplementationOnce(() => Promise.reject());
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const deletePostHandler = await findByTestId(
+ container,
+ 'deletePostHandler'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(deletePostHandler).toBeInTheDocument();
+
+ fireEvent.click(deletePostHandler);
+ });
+
+ // getUpdatedThread api test
+
+ it('Show error message on fail of getUpdatedThread api with error message', async () => {
+ (deletePost as jest.Mock).mockImplementationOnce(() => Promise.resolve());
+ (getUpdatedThread as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const deletePostHandler = await findByTestId(
+ container,
+ 'deletePostHandler'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(deletePostHandler).toBeInTheDocument();
+
+ fireEvent.click(deletePostHandler);
+ });
+
+ it('Show error message on fail of getUpdatedThread api with empty response', async () => {
+ (getUpdatedThread as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject({ response: {} })
+ );
+ (deletePost as jest.Mock).mockImplementationOnce(() => Promise.resolve());
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const deletePostHandler = await findByTestId(
+ container,
+ 'deletePostHandler'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(deletePostHandler).toBeInTheDocument();
+
+ fireEvent.click(deletePostHandler);
+ });
+
+ it('Show error message on fail of getUpdatedThread api with empty object', async () => {
+ (getUpdatedThread as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject({})
+ );
+ (deletePost as jest.Mock).mockImplementationOnce(() => Promise.resolve());
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const deletePostHandler = await findByTestId(
+ container,
+ 'deletePostHandler'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(deletePostHandler).toBeInTheDocument();
+
+ fireEvent.click(deletePostHandler);
+ });
+
+ it('Show error message on fail of getUpdatedThread api with no response', async () => {
+ (getUpdatedThread as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject()
+ );
+ (deletePost as jest.Mock).mockImplementationOnce(() => Promise.resolve());
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const deletePostHandler = await findByTestId(
+ container,
+ 'deletePostHandler'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(deletePostHandler).toBeInTheDocument();
+
+ fireEvent.click(deletePostHandler);
+ });
+
+ it('Show error message on resolve of getUpdatedThread api without response data', async () => {
+ (getUpdatedThread as jest.Mock).mockImplementationOnce(() =>
+ Promise.resolve()
+ );
+ (deletePost as jest.Mock).mockImplementationOnce(() => Promise.resolve());
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const deletePostHandler = await findByTestId(
+ container,
+ 'deletePostHandler'
+ );
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(deletePostHandler).toBeInTheDocument();
+
+ fireEvent.click(deletePostHandler);
+ });
+
+ // addTableTestCase api test
+
+ it('Show error message on fail of addTableTestCase api with error message', async () => {
+ (addTableTestCase as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const addTableTest = await findByTestId(container, 'add-table-test');
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(addTableTest).toBeInTheDocument();
+
+ fireEvent.click(addTableTest);
+ });
+
+ it('Show error message on fail of addTableTestCase api with empty response', async () => {
+ (addTableTestCase as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject({ response: {} })
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const addTableTest = await findByTestId(container, 'add-table-test');
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(addTableTest).toBeInTheDocument();
+
+ fireEvent.click(addTableTest);
+ });
+
+ it('Show error message on resolve of addTableTestCase api without response', async () => {
+ (addTableTestCase as jest.Mock).mockImplementationOnce(() =>
+ Promise.resolve()
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const addTableTest = await findByTestId(container, 'add-table-test');
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(addTableTest).toBeInTheDocument();
+
+ fireEvent.click(addTableTest);
+ });
+
+ it('Show error message on resolve of addTableTestCase api without response data', async () => {
+ (addTableTestCase as jest.Mock).mockImplementationOnce(() =>
+ Promise.resolve({ data: '' })
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const addTableTest = await findByTestId(container, 'add-table-test');
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(addTableTest).toBeInTheDocument();
+
+ fireEvent.click(addTableTest);
+ });
+
+ // addColumnTestCase api test
+
+ it('Show error message on fail of addColumnTestCase api with error message', async () => {
+ (addColumnTestCase as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject({ response: { data: { message: 'Error!' } } })
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const addColumnTest = await findByTestId(container, 'add-column-test');
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(addColumnTest).toBeInTheDocument();
+
+ fireEvent.click(addColumnTest);
+ });
+
+ it('Show error message on fail of addColumnTestCase api with empty response', async () => {
+ (addColumnTestCase as jest.Mock).mockImplementationOnce(() =>
+ Promise.reject({ response: {} })
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const addColumnTest = await findByTestId(container, 'add-column-test');
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(addColumnTest).toBeInTheDocument();
+
+ fireEvent.click(addColumnTest);
+ });
+
+ it('Show error message on resolve of addColumnTestCase api without response', async () => {
+ (addColumnTestCase as jest.Mock).mockImplementationOnce(() =>
+ Promise.resolve()
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const addColumnTest = await findByTestId(container, 'add-column-test');
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(addColumnTest).toBeInTheDocument();
+
+ fireEvent.click(addColumnTest);
+ });
+
+ it('Show error message on resolve of addColumnTestCase api without response data', async () => {
+ (addColumnTestCase as jest.Mock).mockImplementationOnce(() =>
+ Promise.resolve({ data: '' })
+ );
+
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+ const ContainerText = await findByTestId(
+ container,
+ 'datasetdetails-component'
+ );
+ const addColumnTest = await findByTestId(container, 'add-column-test');
+
+ expect(ContainerText).toBeInTheDocument();
+ expect(addColumnTest).toBeInTheDocument();
+
+ fireEvent.click(addColumnTest);
+ });
});
});