Skip to content

Commit

Permalink
psp-8690 Ensure that selected locations (#4146)
Browse files Browse the repository at this point in the history
1) enforce 15 max limit correctly
2) function correctly with no pid/pin
3) function correctly when plan number is shared.

Co-authored-by: Alejandro Sanchez <emailforasr@gmail.com>
  • Loading branch information
devinleighsmith and asanchezr authored Jul 2, 2024
1 parent ccf1938 commit 4db14b9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ describe('MapSelectorContainer component', () => {
await fillInput(container, 'pid', '123-456-789');
const searchButton = getByTitle('search');
await act(async () => userEvent.click(searchButton));
const checkbox = await findByTestId('selectrow-PID-009-727-493');
const checkbox = await findByTestId(
'selectrow-PID-009-727-493-48.76613749999999--123.46163749999998',
);
await act(async () => userEvent.click(checkbox));
const addButton = getByText('Add to selection');
await act(async () => userEvent.click(addButton));
Expand Down Expand Up @@ -201,54 +203,9 @@ describe('MapSelectorContainer component', () => {
},
selectingComponentId: null,
pimsFeature: {
geometry: null,
properties: {
ADDRESS_ID: null,
COUNTRY_CODE: null,
COUNTRY_NAME: null,
DESCRIPTION: null,
DISTRICT_CODE: 5,
ENCUMBRANCE_REASON: null,
HAS_ACTIVE_ACQUISITION_FILE: null,
HAS_ACTIVE_RESEARCH_FILE: null,
HISTORICAL_FILE_NUMBER_STR: null,
IS_ACTIVE_PAYABLE_LEASE: null,
IS_ACTIVE_RECEIVABLE_LEASE: null,
IS_DISPOSED: null,
IS_OTHER_INTEREST: null,
IS_OWNED: null,
IS_PAYABLE_LEASE: null,
IS_RECEIVABLE_LEASE: null,
IS_RETIRED: undefined,
IS_SENSITIVE: null,
IS_VISIBLE_TO_OTHER_AGENCIES: null,
LAND_AREA: undefined,
LAND_LEGAL_DESCRIPTION: 'Test Legal Description',
MUNICIPALITY_NAME: undefined,
NAME: undefined,
PID: 123456789,
PID_PADDED: '123-456-789',
PIN: null,
POSTAL_CODE: undefined,
PROPERTY_AREA_UNIT_TYPE_CODE: undefined,
PROPERTY_CLASSIFICATION_TYPE_CODE: null,
PROPERTY_DATA_SOURCE_EFFECTIVE_DATE: null,
PROPERTY_DATA_SOURCE_TYPE_CODE: null,
PROPERTY_ID: 123,
PROPERTY_STATUS_TYPE_CODE: null,
PROPERTY_TENURE_TYPE_CODE: null,
PROPERTY_TYPE_CODE: null,
PROVINCE_NAME: null,
PROVINCE_STATE_CODE: null,
REGION_CODE: 1,
STREET_ADDRESS_1: 'Test address 123',
STREET_ADDRESS_2: undefined,
STREET_ADDRESS_3: undefined,
SURVEY_PLAN_NUMBER: 'SPS22411',
ZONING: null,
ZONING_POTENTIAL: null,
STREET_ADDRESS_1: '1234 Fake St',
},
type: 'Feature',
},
location: {
lat: 48.76613749999999,
Expand All @@ -257,7 +214,7 @@ describe('MapSelectorContainer component', () => {
regionFeature: {},
districtFeature: {},
municipalityFeature: null,
id: 'PID-009-727-493',
id: 'PID-009-727-493-48.76613749999999--123.46163749999998',
},
]);
});
Expand All @@ -279,7 +236,9 @@ describe('MapSelectorContainer component', () => {

await act(async () => userEvent.click(searchButton));

const checkbox = await findByTestId('selectrow-PID-009-727-493');
const checkbox = await findByTestId(
'selectrow-PID-009-727-493-48.76613749999999--123.46163749999998',
);
await act(async () => userEvent.click(checkbox));
const addButton = getByText('Add to selection');
await act(async () => userEvent.click(addButton));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export const MapSelectorContainer: FunctionComponent<IMapSelectorContainerProps>
}
const pid = pidFromFeatureSet(property);
const pin = pinFromFeatureSet(property);
if (!pid || !pin) {
return property;
}
const pimsProperty = await loadProperties({ PID: pid, PIN: pin });
if (pimsProperty.features.length > 0) {
property.pimsFeature = pimsProperty.features[0];
Expand Down Expand Up @@ -138,7 +141,14 @@ const addProperties = (
const isSameProperty = (lhs: LocationFeatureDataset, rhs: LocationFeatureDataset) => {
const lhsName = getPropertyName(featuresetToMapProperty(lhs));
const rhsName = getPropertyName(featuresetToMapProperty(rhs));
if (lhsName.label === rhsName.label && lhsName.label !== NameSourceType.NONE) {
if (
(lhsName.label === rhsName.label &&
lhsName.label !== NameSourceType.NONE &&
lhsName.label !== NameSourceType.PLAN) ||
(lhsName.label === NameSourceType.PLAN &&
lhs.location.lat === rhs.location.lat &&
lhs.location.lng === rhs.location.lng)
) {
return lhsName.value === rhsName.value;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,15 @@ describe('PropertySearchSelectorFormView component', () => {
featureToLocationFeatureDataset(f as any),
),
});
const checkbox = await findByTestId('selectrow-PID-006-772-331');
const checkbox = await findByTestId(
'selectrow-PID-006-772-331-55.706230240625004--121.60834946062499',
);
await act(async () => userEvent.click(checkbox));
expect(checkbox).toBeChecked();
expect(onSelectedProperties).toHaveBeenCalledWith([
{
districtFeature: null,
id: 'PID-006-772-331',
id: 'PID-006-772-331-55.706230240625004--121.60834946062499',
location: {
lat: 55.706230240625004,
lng: -121.60834946062499,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const PropertySearchSelectorFormView: React.FunctionComponent<

function generatePropertyId(mapProperty: IMapProperty): string {
const propertyName = getPropertyName(mapProperty);
return `${propertyName.label}-${propertyName.value}`;
return `${propertyName.label}-${propertyName.value}-${mapProperty.latitude}-${mapProperty.longitude}`;
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ export const PropertySelectorSearchContainer: React.FC<IPropertySelectorSearchCo
}) as LocationFeatureDataset[];
setSearchResults(locations);
} else {
setSearchResults([]);
const locations = result?.features?.map(p => featureToLocationFeatureDataset(p));
setSearchResults(locations ?? []);
}
};
searchFunc();
Expand Down

0 comments on commit 4db14b9

Please sign in to comment.