Skip to content

Commit

Permalink
psp-6856 correct display of address country - other field.
Browse files Browse the repository at this point in the history
  • Loading branch information
devinleighsmith committed Sep 11, 2023
1 parent 00082be commit 34d6f90
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export class OwnerAddressFormModel {
model.postal = apiAddress.postal;
model.provinceId = apiAddress.provinceStateId;
model.countryId = apiAddress.countryId;
model.countryOther = apiAddress.countryOther;

return model;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ describe('UpdateAcquisitionOwnersSubForm component', () => {
utils.container.querySelector(
`input[name="owners[${index}].contactPhoneNumber"]`,
) as HTMLInputElement,
getCountryNameTextbox: (index = 0) =>
utils.container.querySelector(
`input[name="owners[${index}].address.countryOther"]`,
) as HTMLInputElement,
};
};

Expand Down Expand Up @@ -107,6 +111,31 @@ describe('UpdateAcquisitionOwnersSubForm component', () => {
expect(getByTestId('owners[0]-remove-button')).toBeVisible();
});

it(`renders 'country name' text`, async () => {
const { getCountryNameTextbox } = setup({
initialForm: {
...testForm,
owners: [
{
isPrimaryContact: '',
isOrganization: '',
lastNameAndCorpName: '',
otherName: '',
givenName: '',
incorporationNumber: '',
registrationNumber: '',
contactEmailAddress: '',
contactPhoneNumber: '',
isEmpty: noop as any,
toApi: noop as any,
address: { countryId: 4, countryOther: 'fake country' },
},
],
},
});
expect(getCountryNameTextbox()).toHaveDisplayValue('fake country');
});

it(`renders owner row fields when 'Add owner' link is clicked`, async () => {
const { getByTestId, getGivenNameTextbox, getIsPrimaryContactRadioButtonValue } = setup({
initialForm: testForm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,15 @@ const getFormattedAddress = (address?: Api_Address | null): string => {
}

if (address?.country?.description) {
let countryDisplay = address?.country?.description?.trim() || '';
addressDisplay = addressDisplay.concat(countryDisplay);
if (address?.country?.code === 'OTHER') {
let countryDisplay =
`${address?.country?.description?.trim()} - ${address?.countryOther?.trim()}` || '';
addressDisplay = addressDisplay.concat(countryDisplay);
} else {
let countryDisplay = address?.country?.description?.trim() || '';
addressDisplay = addressDisplay.concat(countryDisplay);
}
}

return addressDisplay;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,19 @@ describe('Acquisition File Owners View component', () => {
),
).toBeVisible();
});

it('renders owner address other country information', () => {
const ownerTest = {
...ownerCorporate,
incorporationNumber: null,
address: {
country: { code: 'OTHER', description: 'Other' },
countryOther: 'test name',
},
} as Api_AcquisitionFileOwner;
const { getByText } = setup({
props: { ownersList: [ownerTest], isLoading: false },
});
expect(getByText('Other - test name')).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const AcquisitionOwnersSummaryView: React.FC<IAcquisitionOwnersSummaryViewProps>
isLoading,
ownersList,
}) => {
const onwerDetailList = ownersList?.map(o => DetailAcquisitionFileOwner.fromApi(o));
const ownerDetailList = ownersList?.map(o => DetailAcquisitionFileOwner.fromApi(o));

if (isLoading) {
return <LoadingBackdrop show={true} parentScreen={true}></LoadingBackdrop>;
Expand All @@ -23,7 +23,7 @@ const AcquisitionOwnersSummaryView: React.FC<IAcquisitionOwnersSummaryViewProps>
<StyledSectionParagraph>
Each property in this file should be owned by the owner(s) in this section
</StyledSectionParagraph>
{onwerDetailList?.map((owner, index) => {
{ownerDetailList?.map((owner, index) => {
return (
<span key={`owner-${index}-${owner.ownerName}`} data-testid={`owner[${index}]`}>
<SectionField label={null}>
Expand All @@ -49,7 +49,7 @@ const AcquisitionOwnersSummaryView: React.FC<IAcquisitionOwnersSummaryViewProps>
</SectionField>
<SectionField label="Email">{owner.ownerContactEmail}</SectionField>
<SectionField label="Phone">{owner.ownerContactPhone}</SectionField>
{index < onwerDetailList.length - 1 && <hr></hr>}
{index < ownerDetailList.length - 1 && <hr></hr>}
</span>
);
})}
Expand Down

0 comments on commit 34d6f90

Please sign in to comment.