From df197178071d070836f29b5d6b65acb09b0b9d25 Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez Date: Mon, 4 Mar 2024 18:19:49 -0800 Subject: [PATCH] Test updates --- .../property/MotiInventoryHeader.test.tsx | 18 +++++++++- .../detail/PropertyDetailsTabView.test.tsx | 34 ++++++++++++++++--- .../PropertyDetailsTabView.test.tsx.snap | 23 +------------ 3 files changed, 48 insertions(+), 27 deletions(-) diff --git a/source/frontend/src/features/mapSideBar/property/MotiInventoryHeader.test.tsx b/source/frontend/src/features/mapSideBar/property/MotiInventoryHeader.test.tsx index eae7189414..36e63cb3a8 100644 --- a/source/frontend/src/features/mapSideBar/property/MotiInventoryHeader.test.tsx +++ b/source/frontend/src/features/mapSideBar/property/MotiInventoryHeader.test.tsx @@ -85,10 +85,26 @@ describe('MotiInventoryHeader component', () => { }, isLoading: false, }); - // PID is shown + // land parcel type is shown expect(result.getByText(testProperty?.propertyType?.description as string)).toBeVisible(); }); + it(`shows "retired" indicator for retired properties`, async () => { + const testProperty: ApiGen_Concepts_Property = { + ...getEmptyProperty(), + isRetired: true, + }; + const result = setup({ + composedProperty: { + ...defaultComposedProperty, + pimsProperty: testProperty, + }, + isLoading: false, + }); + // "retire" indicator is shown + expect(result.getByText(/expired/i)).toBeVisible(); + }); + it('allows the active property to be zoomed in', async () => { const testProperty: ApiGen_Concepts_Property = {} as any; diff --git a/source/frontend/src/features/mapSideBar/property/tabs/propertyDetails/detail/PropertyDetailsTabView.test.tsx b/source/frontend/src/features/mapSideBar/property/tabs/propertyDetails/detail/PropertyDetailsTabView.test.tsx index af782011a8..6102062768 100644 --- a/source/frontend/src/features/mapSideBar/property/tabs/propertyDetails/detail/PropertyDetailsTabView.test.tsx +++ b/source/frontend/src/features/mapSideBar/property/tabs/propertyDetails/detail/PropertyDetailsTabView.test.tsx @@ -7,12 +7,12 @@ import { ApiGen_Concepts_Property } from '@/models/api/generated/ApiGen_Concepts import { getEmptyBaseAudit, getEmptyProperty } from '@/models/defaultInitializers'; import { lookupCodesSlice } from '@/store/slices/lookupCodes'; import { toTypeCodeNullable } from '@/utils/formUtils'; -import { render, RenderOptions } from '@/utils/test-utils'; +import { RenderOptions, render } from '@/utils/test-utils'; +import { useApiProperties } from '@/hooks/pims-api/useApiProperties'; +import { useApiPropertyOperation } from '@/hooks/pims-api/useApiPropertyOperation'; import { PropertyDetailsTabView } from './PropertyDetailsTabView'; import { toFormValues } from './PropertyDetailsTabView.helpers'; -import { useApiPropertyOperation } from '@/hooks/pims-api/useApiPropertyOperation'; -import { useApiProperties } from '@/hooks/pims-api/useApiProperties'; const history = createMemoryHistory(); const storeState = { @@ -41,7 +41,7 @@ describe('PropertyDetailsTabView component', () => { const component = render(, { ...rest, store: storeState, - claims: [Claims.PROPERTY_EDIT], + claims: renderOptions?.claims ?? [], history, }); @@ -168,6 +168,32 @@ describe('PropertyDetailsTabView component', () => { const { getByText } = setup({ property }); expect(getByText(/Property address not available/i)).toBeVisible(); }); + + it('should display the Edit button if the user has permissions', async () => { + const property: ApiGen_Concepts_Property = { + ...mockPropertyInfo, + }; + const { getByTitle } = setup({ property, claims: [Claims.PROPERTY_EDIT] }); + expect(getByTitle(/Edit property details/)).toBeVisible(); + }); + + it('should not display the Edit button if the user does not have permissions', async () => { + const property: ApiGen_Concepts_Property = { + ...mockPropertyInfo, + }; + const { queryByTitle } = await setup({ property, claims: [] }); + expect(queryByTitle(/Edit property details/)).toBeNull(); + }); + + it('should replace the Edit button with a tooltip for retired properties', async () => { + const property: ApiGen_Concepts_Property = { + ...mockPropertyInfo, + isRetired: true, + }; + const { queryByTitle, getByTestId } = await setup({ property, claims: [Claims.PROPERTY_EDIT] }); + expect(queryByTitle(/Edit property details/)).toBeNull(); + expect(getByTestId('tooltip-icon-1-summary-cannot-edit-tooltip')).toBeInTheDocument(); + }); }); export const mockPropertyInfo: ApiGen_Concepts_Property = { diff --git a/source/frontend/src/features/mapSideBar/property/tabs/propertyDetails/detail/__snapshots__/PropertyDetailsTabView.test.tsx.snap b/source/frontend/src/features/mapSideBar/property/tabs/propertyDetails/detail/__snapshots__/PropertyDetailsTabView.test.tsx.snap index 668c6b8094..6f71d7152a 100644 --- a/source/frontend/src/features/mapSideBar/property/tabs/propertyDetails/detail/__snapshots__/PropertyDetailsTabView.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/property/tabs/propertyDetails/detail/__snapshots__/PropertyDetailsTabView.test.tsx.snap @@ -80,28 +80,7 @@ exports[`PropertyDetailsTabView component renders as expected when provided vali >
- -
+ />