diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedEditor/ActivityFeedEditor.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedEditor/ActivityFeedEditor.test.tsx index 646e3e59bc2..2795370ffc6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedEditor/ActivityFeedEditor.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedEditor/ActivityFeedEditor.test.tsx @@ -12,7 +12,7 @@ */ import { findByTestId, render } from '@testing-library/react'; -import React from 'react'; +import React, { forwardRef } from 'react'; import { MemoryRouter } from 'react-router-dom'; import ActivityFeedEditor from './ActivityFeedEditor'; @@ -28,16 +28,20 @@ jest.mock('../../../utils/FeedUtils', () => ({ })); jest.mock('../../FeedEditor/FeedEditor', () => ({ - FeedEditor: jest.fn().mockImplementation(({ onChangeHandler, onSave }) => { - return ( -
- FeedEditor -
- ); - }), + __esModule: true, + FeedEditor: forwardRef( + jest.fn().mockImplementation(({ onChangeHandler, onSave }, ref) => { + return ( +
+ FeedEditor +
+ ); + }) + ), })); jest.mock('./SendButton', () => ({ 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 468886f7e3a..d30fe34dfd5 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 @@ -12,6 +12,7 @@ */ import { + act, findByTestId, findByText, fireEvent, @@ -427,29 +428,31 @@ describe('Test DashboardDetails component', () => { }); it('Check that tags and glossary terms are not present', async () => { - (getTagCategories as jest.Mock).mockImplementationOnce(() => - Promise.reject() - ); - (fetchGlossaryTerms as jest.Mock).mockImplementationOnce(() => - Promise.reject() - ); - const { getByTestId, queryByText } = render( - , - { - wrapper: MemoryRouter, - } - ); + await act(async () => { + (getTagCategories as jest.Mock).mockImplementationOnce(() => + Promise.reject() + ); + (fetchGlossaryTerms as jest.Mock).mockImplementationOnce(() => + Promise.reject() + ); + const { getByTestId, queryByText } = render( + , + { + wrapper: MemoryRouter, + } + ); - const tagWrapper = getByTestId('tags-wrapper'); - fireEvent.click( - tagWrapper, - new MouseEvent('click', { bubbles: true, cancelable: true }) - ); + const tagWrapper = getByTestId('tags-wrapper'); + fireEvent.click( + tagWrapper, + new MouseEvent('click', { bubbles: true, cancelable: true }) + ); - const tag1 = queryByText('TagCat1.Tag1'); - const glossaryTerm1 = queryByText('Glossary.Tag1'); + const tag1 = queryByText('TagCat1.Tag1'); + const glossaryTerm1 = queryByText('Glossary.Tag1'); - expect(tag1).not.toBeInTheDocument(); - expect(glossaryTerm1).not.toBeInTheDocument(); + expect(tag1).not.toBeInTheDocument(); + expect(glossaryTerm1).not.toBeInTheDocument(); + }); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/entityPageInfo/EntityPageInfo.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/entityPageInfo/EntityPageInfo.test.tsx index 60ae87bcbb6..38818cef96d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/entityPageInfo/EntityPageInfo.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/entityPageInfo/EntityPageInfo.test.tsx @@ -12,11 +12,13 @@ */ import { + act, findByTestId, findByText, fireEvent, queryByTestId, render, + screen, } from '@testing-library/react'; import { flatten } from 'lodash'; import { FormattedGlossaryTermData, TagOption } from 'Models'; @@ -613,29 +615,29 @@ describe('Test EntityPageInfo component', () => { }); it('Check that tags and glossary terms are not present', async () => { - (getTagCategories as jest.Mock).mockImplementationOnce(() => - Promise.reject() - ); - (fetchGlossaryTerms as jest.Mock).mockImplementationOnce(() => - Promise.reject() - ); - const { getByTestId, queryByText } = render( - , - { + await act(async () => { + (getTagCategories as jest.Mock).mockImplementationOnce(() => + Promise.reject() + ); + (fetchGlossaryTerms as jest.Mock).mockImplementationOnce(() => + Promise.reject() + ); + + render(, { wrapper: MemoryRouter, - } - ); + }); + const tagWrapper = screen.getByTestId('tags-wrapper'); - const tagWrapper = getByTestId('tags-wrapper'); - fireEvent.click( - tagWrapper, - new MouseEvent('click', { bubbles: true, cancelable: true }) - ); + fireEvent.click( + tagWrapper, + new MouseEvent('click', { bubbles: true, cancelable: true }) + ); - const tag1 = queryByText('TagCat1.Tag1'); - const glossaryTerm1 = queryByText('Glossary.Tag1'); + const tag1 = screen.queryByText('TagCat1.Tag1'); + const glossaryTerm1 = screen.queryByText('Glossary.Tag1'); - expect(tag1).not.toBeInTheDocument(); - expect(glossaryTerm1).not.toBeInTheDocument(); + expect(tag1).not.toBeInTheDocument(); + expect(glossaryTerm1).not.toBeInTheDocument(); + }); }); }); 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 179202897a6..11a72de6262 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 @@ -1104,71 +1104,76 @@ describe('Test DatasetDetails page', () => { }); 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: '' }) - ); + await act(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 { 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); }); - 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); }); it('Show error message on resolve of getUpdatedThread api without response data', async () => { diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryPage/GlossaryPage.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryPage/GlossaryPage.test.tsx index 44502185d3a..0e6f1f64939 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryPage/GlossaryPage.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryPage/GlossaryPage.test.tsx @@ -213,40 +213,44 @@ describe('Test GlossaryComponent page', () => { }); it('All Function call should work properly - part 2', async () => { - render(); + await act(async () => { + render(); - const glossaryComponent = await screen.findByText(/Glossary.component/i); - const handleAddGlossaryClick = await screen.findByTestId( - 'handleAddGlossaryClick' - ); - const handleAddGlossaryTermClick = await screen.findByTestId( - 'handleAddGlossaryTermClick' - ); - const handleChildLoading = await screen.findByTestId('handleChildLoading'); - const handleExpandedKey = await screen.findByTestId('handleExpandedKey'); - const handleGlossaryDelete = await screen.findByTestId( - 'handleGlossaryDelete' - ); - const handleGlossaryTermUpdate = await screen.findByTestId( - 'handleGlossaryTermUpdate' - ); - const handleGlossaryTermDelete = await screen.findByTestId( - 'handleGlossaryTermDelete' - ); - const handleSearchText = await screen.findByTestId('handleSearchText'); + const glossaryComponent = await screen.findByText(/Glossary.component/i); + const handleAddGlossaryClick = await screen.findByTestId( + 'handleAddGlossaryClick' + ); + const handleAddGlossaryTermClick = await screen.findByTestId( + 'handleAddGlossaryTermClick' + ); + const handleChildLoading = await screen.findByTestId( + 'handleChildLoading' + ); + const handleExpandedKey = await screen.findByTestId('handleExpandedKey'); + const handleGlossaryDelete = await screen.findByTestId( + 'handleGlossaryDelete' + ); + const handleGlossaryTermUpdate = await screen.findByTestId( + 'handleGlossaryTermUpdate' + ); + const handleGlossaryTermDelete = await screen.findByTestId( + 'handleGlossaryTermDelete' + ); + const handleSearchText = await screen.findByTestId('handleSearchText'); - expect(glossaryComponent).toBeInTheDocument(); + expect(glossaryComponent).toBeInTheDocument(); - fireEvent.click(handleAddGlossaryClick); - fireEvent.click(handleAddGlossaryTermClick); - fireEvent.click(handleChildLoading); - fireEvent.click(handleExpandedKey); - fireEvent.click(handleGlossaryDelete); + fireEvent.click(handleAddGlossaryClick); + fireEvent.click(handleAddGlossaryTermClick); + fireEvent.click(handleChildLoading); + fireEvent.click(handleExpandedKey); + fireEvent.click(handleGlossaryDelete); - fireEvent.click(handleGlossaryTermUpdate); - fireEvent.click(handleGlossaryTermDelete); + fireEvent.click(handleGlossaryTermUpdate); + fireEvent.click(handleGlossaryTermDelete); - fireEvent.click(handleSearchText); + fireEvent.click(handleSearchText); + }); }); describe('Render Sad Paths', () => { @@ -261,7 +265,9 @@ describe('Test GlossaryComponent page', () => { expect(handleGlossaryTermDelete).toBeInTheDocument(); - fireEvent.click(handleGlossaryTermDelete); + await act(async () => { + fireEvent.click(handleGlossaryTermDelete); + }); }); it('show error if deleteGlossary API fails', async () => { @@ -275,7 +281,9 @@ describe('Test GlossaryComponent page', () => { expect(handleGlossaryDelete).toBeInTheDocument(); - fireEvent.click(handleGlossaryDelete); + await act(async () => { + fireEvent.click(handleGlossaryDelete); + }); }); it('show error if patchGlossaryTerm API resolves without data', async () => { @@ -289,7 +297,9 @@ describe('Test GlossaryComponent page', () => { expect(handleGlossaryTermUpdate).toBeInTheDocument(); - fireEvent.click(handleGlossaryTermUpdate); + await act(async () => { + fireEvent.click(handleGlossaryTermUpdate); + }); }); }); });