From ae16ce7ad7f8b1cb4ad55527c885a93d7c5060b6 Mon Sep 17 00:00:00 2001 From: Sachin Chaurasiya Date: Fri, 15 Sep 2023 14:43:01 +0530 Subject: [PATCH] fix(#13204): after changing the team type action buttons are not disappearing (#13205) --- .../EntitySummaryDetails.test.tsx | 34 +++++++++++++++++-- .../EntitySummaryDetails.tsx | 7 +++- .../TeamTypeSelect.component.tsx | 18 ++++++++-- 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/EntitySummaryDetails/EntitySummaryDetails.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/EntitySummaryDetails/EntitySummaryDetails.test.tsx index 62592badda0..553af0fdfac 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/EntitySummaryDetails/EntitySummaryDetails.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/EntitySummaryDetails/EntitySummaryDetails.test.tsx @@ -11,9 +11,9 @@ * limitations under the License. */ -import { findByTestId, render } from '@testing-library/react'; +import { act, findByTestId, render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import React from 'react'; -import { act } from 'react-test-renderer'; import EntitySummaryDetails from './EntitySummaryDetails'; const mockData = { @@ -69,4 +69,34 @@ describe('EntitySummaryDetails Component', () => { expect(EntitySummary).toBeInTheDocument(); }); }); + + it('Edit team type should render the appropriate component', async () => { + render( + + ); + + const editTeamTypeBtn = screen.getByTestId('edit-TeamType-icon'); + + await act(async () => { + userEvent.click(editTeamTypeBtn); + }); + + // should show the team type select box and action buttons + expect(screen.getByTestId('team-type-select')).toBeInTheDocument(); + + const cancelBtn = screen.getByTestId('cancel-btn'); + const saveBtn = screen.getByTestId('save-btn'); + + expect(cancelBtn).toBeInTheDocument(); + expect(saveBtn).toBeInTheDocument(); + + // should hide the team type select box and action buttons after save + await act(async () => { + userEvent.click(saveBtn); + }); + + expect(screen.queryByTestId('team-type-select')).toBeNull(); + expect(screen.queryByTestId('cancel-btn')).toBeNull(); + expect(screen.queryByTestId('save-btn')).toBeNull(); + }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/EntitySummaryDetails/EntitySummaryDetails.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/EntitySummaryDetails/EntitySummaryDetails.tsx index 4025e10678f..35f0d0438e1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/EntitySummaryDetails/EntitySummaryDetails.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/EntitySummaryDetails/EntitySummaryDetails.tsx @@ -83,6 +83,11 @@ const EntitySummaryDetails = ({ setShowTypeSelector(value); }, []); + const handleUpdateTeamType = (type: TeamType) => { + updateTeamType?.(type); + handleShowTypeSelector(false); + }; + const ownerDropdown = allowTeamOwner ? ( ) : ( <> diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/TeamTypeSelect/TeamTypeSelect.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/TeamTypeSelect/TeamTypeSelect.component.tsx index f0d3f7749cb..b36d8fde876 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/TeamTypeSelect/TeamTypeSelect.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/TeamTypeSelect/TeamTypeSelect.component.tsx @@ -42,7 +42,11 @@ function TeamTypeSelect({ const options = useMemo(() => getTeamTypeOptions(showGroupOption), []); return ( - +