diff --git a/source/frontend/src/components/maps/leaflet/LayerPopup/LayerPopupView.test.tsx b/source/frontend/src/components/maps/leaflet/LayerPopup/LayerPopupView.test.tsx index d5de3554c9..e6d2ba1560 100644 --- a/source/frontend/src/components/maps/leaflet/LayerPopup/LayerPopupView.test.tsx +++ b/source/frontend/src/components/maps/leaflet/LayerPopup/LayerPopupView.test.tsx @@ -1,19 +1,14 @@ import { createMemoryHistory } from 'history'; -import { useMap } from 'react-leaflet'; -import { useMapStateMachine } from '@/components/common/mapFSM/MapStateMachineContext'; import Claims from '@/constants/claims'; import { mockLookups } from '@/mocks/lookups.mock'; -import { mapMachineBaseMock } from '@/mocks/mapFSM.mock'; import { emptyPmbcParcel } from '@/models/layers/parcelMapBC'; import { EmptyPropertyLocation } from '@/models/layers/pimsPropertyLocationView'; import { lookupCodesSlice } from '@/store/slices/lookupCodes'; -import { pidParser } from '@/utils/propertyUtils'; +import { pidParser, pinParser } from '@/utils/propertyUtils'; import { act, render, RenderOptions, userEvent } from '@/utils/test-utils'; import { ILayerPopupViewProps, LayerPopupView } from './LayerPopupView'; -import { emptyPimsBoundaryFeatureCollection } from '@/components/common/mapFSM/models'; -import { useKeycloak } from '@react-keycloak/web'; vi.mock('react-leaflet'); @@ -54,6 +49,7 @@ describe('LayerPopupView component', () => { }); expect(asFragment()).toMatchSnapshot(); }); + describe('fly out behaviour', () => { it('fly out is hidden by default', async () => { const { queryByText } = setup({ @@ -122,7 +118,7 @@ describe('LayerPopupView component', () => { expect(history.location.pathname).toBe(`/mapview/sidebar/property/${propertyId}`); }); - it('handles view property action for non-inventory properties', async () => { + it('handles view property action for non-inventory properties - with PID', async () => { const pid = '123456789'; const parsedPid = pidParser(pid); const { getByTestId, getByText } = setup({ @@ -162,7 +158,51 @@ describe('LayerPopupView component', () => { const link = getByText('View Property Info'); await act(async () => userEvent.click(link)); expect(history.location.pathname).toBe( - `/mapview/sidebar/non-inventory-property/${parsedPid}`, + `/mapview/sidebar/non-inventory-property/pid/${parsedPid}`, + ); + }); + + it('handles view property action for non-inventory properties - with PIN', async () => { + const pin = '123456789'; + const parsedPin = pinParser(pin); + const { getByTestId, getByText } = setup({ + layerPopup: { + layers: [ + { + data: { PIN: pin }, + title: '', + config: {}, + }, + ], + latlng: undefined, + }, + featureDataset: { + parcelFeature: { + type: 'Feature', + properties: { ...emptyPmbcParcel, PIN: parsedPin }, + geometry: { type: 'Point', coordinates: [] }, + }, + location: { lat: 0, lng: 0 }, + fileLocation: null, + pimsFeature: null, + regionFeature: null, + districtFeature: null, + municipalityFeature: null, + highwayFeature: null, + selectingComponentId: null, + crownLandLeasesFeature: null, + crownLandLicensesFeature: null, + crownLandTenuresFeature: null, + crownLandInventoryFeature: null, + crownLandInclusionsFeature: null, + }, + }); + const ellipsis = getByTestId('fly-out-ellipsis'); + await act(async () => userEvent.click(ellipsis)); + const link = getByText('View Property Info'); + await act(async () => userEvent.click(link)); + expect(history.location.pathname).toBe( + `/mapview/sidebar/non-inventory-property/pin/${parsedPin}`, ); }); @@ -440,5 +480,39 @@ describe('LayerPopupView component', () => { await act(async () => userEvent.click(link)); expect(history.location.pathname).toBe('/mapview/sidebar/consolidation/new'); }); + + it('handles create lease and licence file action', async () => { + const { getByTestId, getByText } = setup({ + layerPopup: { + latlng: undefined, + layers: [], + }, + featureDataset: null, + + claims: [Claims.LEASE_ADD], + }); + const ellipsis = getByTestId('fly-out-ellipsis'); + await act(async () => userEvent.click(ellipsis)); + const link = getByText('Lease/Licence File'); + await act(async () => userEvent.click(link)); + expect(history.location.pathname).toBe('/mapview/sidebar/lease/new'); + }); + + it('handles create disposition file action', async () => { + const { getByTestId, getByText } = setup({ + layerPopup: { + latlng: undefined, + layers: [], + }, + featureDataset: null, + + claims: [Claims.DISPOSITION_ADD], + }); + const ellipsis = getByTestId('fly-out-ellipsis'); + await act(async () => userEvent.click(ellipsis)); + const link = getByText('Disposition File'); + await act(async () => userEvent.click(link)); + expect(history.location.pathname).toBe('/mapview/sidebar/disposition/new'); + }); }); }); diff --git a/source/frontend/src/components/maps/leaflet/LayerPopup/LayerPopupView.tsx b/source/frontend/src/components/maps/leaflet/LayerPopup/LayerPopupView.tsx index b809996170..5dc9ff8101 100644 --- a/source/frontend/src/components/maps/leaflet/LayerPopup/LayerPopupView.tsx +++ b/source/frontend/src/components/maps/leaflet/LayerPopup/LayerPopupView.tsx @@ -57,7 +57,7 @@ export const LayerPopupView: React.FC { }); it('hides the property information tab for non-inventory properties', async () => { - history.push('/mapview/sidebar/non-inventory-property/9212434'); + history.push('/mapview/sidebar/non-inventory-property/pid/9212434'); // non-inventory properties will not attempt to contact the backend. const error = { isAxiosError: true,