Skip to content

Commit

Permalink
Hotfixes (#3597)
Browse files Browse the repository at this point in the history
* release 4.1 hotfixes.

* test correction.

---------

Co-authored-by: Smith <[email protected]>
  • Loading branch information
devinleighsmith and Smith committed Nov 20, 2023
1 parent 5aa646f commit 12aa4ea
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 21 deletions.
6 changes: 3 additions & 3 deletions source/backend/api/Pims.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<UserSecretsId>0ef6255f-9ea0-49ec-8c65-c172304b4926</UserSecretsId>
<Version>4.0.0-67.14</Version>
<Version>4.0.0-67.14</Version>
<AssemblyVersion>4.0.0.67</AssemblyVersion>
<Version>4.1.1-67.43</Version>
<Version>4.1.1-67.43</Version>
<AssemblyVersion>4.1.1.67</AssemblyVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProjectGuid>16BC0468-78F6-4C91-87DA-7403C919E646</ProjectGuid>
</PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion source/frontend/src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ export const Table = <T extends IIdentifiedObject, TFilter extends object = {}>(
} = props;
const manualSortBy = !!externalSort || props.manualSortBy;
const totalItems = externalTotalItems ?? data?.length;
const pageCount = externalPageCount ?? Math.ceil(totalItems / internalPageSize);
const pageCount =
externalPageCount ?? internalPageSize > 0 ? Math.ceil(totalItems / internalPageSize) : 0;
const selectedRowsRef = React.useRef<T[]>(externalSelectedRows ?? []); // used as a global var for providing up to date list of selected rows to code within the table (that is arrow function scoped).

// manually update the contents of the global ref of selected rows if the list of external selected rows changes.
Expand Down
3 changes: 0 additions & 3 deletions source/frontend/src/components/maps/MapSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ const MapSearch: React.FC<React.PropsWithChildren<MapSearchProps>> = () => {
setPropertySearchFilter(filter);
};

const searchButtonClicked = () => {};

return (
<StyledFilterContainer fluid className="px-0">
<PropertyFilter
Expand All @@ -41,7 +39,6 @@ const MapSearch: React.FC<React.PropsWithChildren<MapSearchProps>> = () => {
...defaultPropertyFilter,
}}
onChange={handleMapFilterChange}
searchButtonClicked={searchButtonClicked}
/>
</StyledFilterContainer>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,29 @@ describe('AddLeaseTenantContainer component', () => {
});
});

it('onSubmit calls api with expected data when a person with organization is populated', async () => {
await setup({});
viewProps.onSubmit({
...new LeaseFormModel(),
tenants: [{ personId: 1, organizationId: 2 }],
id: 1,
});
await waitFor(async () => {
expect(updateTenants).toHaveBeenCalledTimes(1);
expect(onEdit).toHaveBeenCalledWith(false);
expect(updateTenants.mock.calls[0][1][0]).toStrictEqual({
personId: 1,
organizationId: undefined,
lessorType: undefined,
tenantTypeCode: undefined,
primaryContactId: undefined,
note: undefined,
rowVersion: undefined,
leaseId: 0,
});
});
});

it('onCancel removes the callback', async () => {
await setup({});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ export class FormTenant {
public static toApi(model: FormTenant): Api_LeaseTenant {
return {
personId: model.personId,
organizationId: model.organizationId,
organizationId: !model.personId ? model.organizationId : undefined,
lessorType: model.lessorTypeCode,
tenantTypeCode: toTypeCode(model.tenantType),
primaryContactId: model.primaryContactId,
primaryContactId: !model.personId ? model.primaryContactId : undefined,
note: model.note,
rowVersion: model.rowVersion,
leaseId: model.leaseId ?? 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,30 @@ describe('useGenerateAgreement functions', () => {
await act(async () => {
await generate(mockAgreementsResponse()[1]);
expect(generateFn).toHaveBeenCalled();
expect(getPersonConceptFn).toHaveBeenCalled();
expect(getPersonConceptFn).toHaveBeenCalledWith(1);
expect(getAcquisitionFileProperties).toHaveBeenCalled();
});
});

it('makes requests to expected api endpoints if a team member is a negotiating agent with person', async () => {
const responseWithTeam: Api_AcquisitionFile = {
...mockAcquisitionFileResponse(),
acquisitionTeam: [
{
id: 1,
acquisitionFileId: 1,
personId: 1,
teamProfileTypeCode: 'NEGOTAGENT',
rowVersion: 2,
},
],
};
const generate = setup({ acquisitionResponse: responseWithTeam });

await act(async () => {
await generate(mockAgreementsResponse()[1]);
expect(generateFn).toHaveBeenCalled();
expect(getPersonConceptFn).toHaveBeenCalledWith(1);
expect(getAcquisitionFileProperties).toHaveBeenCalled();
});
});
Expand All @@ -111,7 +134,30 @@ describe('useGenerateAgreement functions', () => {
await act(async () => {
await generate(mockAgreementsResponse()[1]);
expect(generateFn).toHaveBeenCalled();
expect(getOrganizationConceptFn).toHaveBeenCalled();
expect(getOrganizationConceptFn).toHaveBeenCalledWith(1);
expect(getAcquisitionFileProperties).toHaveBeenCalled();
});
});

it('makes requests to expected api endpoints if a team member is a negotiating agent with organization', async () => {
const responseWithTeam: Api_AcquisitionFile = {
...mockAcquisitionFileResponse(),
acquisitionTeam: [
{
id: 1,
acquisitionFileId: 1,
organizationId: 1,
teamProfileTypeCode: 'NEGOTAGENT',
rowVersion: 2,
},
],
};
const generate = setup({ acquisitionResponse: responseWithTeam });

await act(async () => {
await generate(mockAgreementsResponse()[1]);
expect(generateFn).toHaveBeenCalled();
expect(getOrganizationConceptFn).toHaveBeenCalledWith(1);
expect(getAcquisitionFileProperties).toHaveBeenCalled();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ export const useGenerateAgreement = () => {

const coordinatorPromise = coordinator?.personId
? getPersonConcept(coordinator?.personId).then(p => (coordinator.person = p?.data))
: provincialSolicitor?.organizationId
? getOrganizationConcept(provincialSolicitor?.organizationId).then(o =>
: coordinator?.organizationId
? getOrganizationConcept(coordinator?.organizationId).then(o =>
!!coordinator ? (coordinator.organization = o?.data) : null,
)
: Promise.resolve();
const negotiatingAgentPromise = negotiatingAgent?.personId
? getPersonConcept(negotiatingAgent?.personId).then(p => (negotiatingAgent.person = p?.data))
: provincialSolicitor?.organizationId
? getOrganizationConcept(provincialSolicitor?.organizationId).then(o =>
: negotiatingAgent?.organizationId
? getOrganizationConcept(negotiatingAgent?.organizationId).then(o =>
!!negotiatingAgent ? (negotiatingAgent.organization = o?.data) : null,
)
: Promise.resolve();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ export interface IPropertyFilterProps {
sort?: TableSort<any>;
/** Event fire when sorting changes. */
onSorting?: (sort: TableSort<any>) => void;
/** Override to trigger filterchanged in the parent */
searchButtonClicked?: () => void;
/** Which toggle view is currently active */
toggle?: SearchToggleOption;
/** Which toggle view is currently active */
Expand All @@ -44,7 +42,6 @@ export const PropertyFilter: React.FC<React.PropsWithChildren<IPropertyFilterPro
onChange,
sort,
onSorting,
searchButtonClicked,
toggle = SearchToggleOption.Map,
useGeocoder,
}) => {
Expand Down Expand Up @@ -117,6 +114,7 @@ export const PropertyFilter: React.FC<React.PropsWithChildren<IPropertyFilterPro
setFieldValue('latitude', null);
setFieldValue('longitude', null);
setFieldValue('pinOrPid', null);
setFieldValue('planNumber', null);

Check warning on line 117 in source/frontend/src/features/properties/filter/PropertyFilter.tsx

View check run for this annotation

Codecov / codecov/patch

source/frontend/src/features/properties/filter/PropertyFilter.tsx#L117

Added line #L117 was not covered by tests
}}
/>
</NoRightPaddingColumn>
Expand Down Expand Up @@ -155,8 +153,10 @@ export const PropertyFilter: React.FC<React.PropsWithChildren<IPropertyFilterPro
</StyledCol>
<Col xs="auto">
<SearchButton
disabled={isSubmitting || !(values.pinOrPid || values.latitude || values.longitude)}
onClick={() => searchButtonClicked && searchButtonClicked()}
disabled={
isSubmitting ||
!(values.pinOrPid || values.latitude || values.longitude || values.planNumber)
}
/>
</Col>
<Col xs="auto">
Expand Down
4 changes: 3 additions & 1 deletion source/frontend/src/utils/YupSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ export const UserUpdateSchema = Yup.object().shape({
});

export const FilterBarSchema = Yup.object().shape({
pinOrPid: Yup.string().matches(/^\d{0,3}-\d{3}-\d{3}$|^\d{0,9}$/, 'Invalid PIN or PID'),
pinOrPid: Yup.string()
.nullable()
.matches(/^\d{0,3}-\d{3}-\d{3}$|^\d{0,9}$/, 'Invalid PIN or PID'),
});

0 comments on commit 12aa4ea

Please sign in to comment.