Skip to content

Commit

Permalink
Merge pull request #537 from companieshouse/IDVA5-1373-International-…
Browse files Browse the repository at this point in the history
…Correspondence-Address

Fixed country name and premise not being retained on error
  • Loading branch information
ttingle-ch authored Nov 21, 2024
2 parents 44eaee7 + 420b8e1 commit f8c9ba8
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 9 deletions.
1 change: 1 addition & 0 deletions locales/cy/address-look-up.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"correspondenceLookUpAddressPostCodeInput": "Cod post y DU",
"correspondenceLookUpAddressInputHint1": "Enw neu rif eiddo",
"correspondenceLookUpAddressInputHint2": "Bydd angen i chi cofnodi'r cyfeiriad â llaw os nad yw yn y Deyrnas Unedig",
"businessLookUpAddressPostcodeHint": "Er enghraifft, 'Y Felin', '116' neu 'Fflat 37a'",
"correspondenceLookUpAddressFindAddressBtn": "Dod o hyd i gyfeiriad",
"correspondenceLookUpAddressManuallyBtn": "Cofnodwch y cyfeiriad â llaw",
"correspondenceLookUpAddressListTitle": "Dewiswch y cyfeiriad gohebiaeth",
Expand Down
1 change: 1 addition & 0 deletions locales/en/address-look-up.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"correspondenceLookUpAddressPostCodeInput": "UK postcode",
"correspondenceLookUpAddressInputHint1": "Property name or number",
"correspondenceLookUpAddressInputHint2": "You'll need to enter the address manually if it's not in the UK",
"businessLookUpAddressPostcodeHint": "For example, The Mill', '116' or 'Flat 37a'",
"correspondenceLookUpAddressFindAddressBtn": "Find address",
"correspondenceLookUpAddressManuallyBtn": "Enter address manually",
"correspondenceLookUpAddressListTitle": "Select the correspondence address",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class CorrespondenceAddressManualService {
addressLine2: req.body.addressLine2,
locality: req.body.addressTown,
region: req.body.addressCounty,
country: req.body.addressCountry,
country: req.body.countryInput,
postalCode: req.body.addressPostcode
};
const applicantDetails = acspData.applicantDetails || {};
Expand All @@ -20,12 +20,12 @@ export class CorrespondenceAddressManualService {

public getCorrespondenceManualAddress (acspData: AcspData) {
return {
propertyDetails: acspData?.applicantDetails?.correspondenceAddress?.premises,
addressPropertyDetails: acspData?.applicantDetails?.correspondenceAddress?.premises,
addressLine1: acspData?.applicantDetails?.correspondenceAddress?.addressLine1,
addressLine2: acspData?.applicantDetails?.correspondenceAddress?.addressLine2,
addressTown: acspData?.applicantDetails?.correspondenceAddress?.locality,
addressCounty: acspData?.applicantDetails?.correspondenceAddress?.region,
addressCountry:
countryInput:
acspData?.applicantDetails?.correspondenceAddress?.country,
addressPostcode:
acspData?.applicantDetails?.correspondenceAddress?.postalCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
id: "addressPropertyDetails",
name: "addressPropertyDetails",
value: payload["propertyDetails"],
value: payload["addressPropertyDetails"],
errorMessage: {
text: errors["addressPropertyDetails"].text
} if errors.addressPropertyDetails
Expand Down Expand Up @@ -85,6 +85,9 @@
<div id="typeahead-form-group" class="govuk-form-group">
<label for="countryInput" class="govuk-label">{{ i18n.addressCountry }}</label>
{% set dropdownDefaultText = i18n.whereDoYouLiveDefaultDropdownText %}
{% if payload.countryInput | length %}
{% set dropdownValue = payload.countryInput %}
{% endif %}
<p class="govuk-hint" id="typeahead-hint">{{ i18n.whereDoYouLiveHint }}</p>
<div id="my-autocomplete-container" class="autocomplete-wrapper govuk-!-width-two-thirds"></div>
{% set errorMessage = errors %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
autocomplete: "street-address",
value: payload.premise,
hint: {
text: i18n.correspondenceLookUpAddressInputHint2,
text: i18n.businessLookUpAddressPostcodeHint,
classes: "govuk-hint"
}
}) }}
Expand Down
2 changes: 1 addition & 1 deletion src/views/partials/country-typeahead-input.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<script type="text/javascript">
const countryList = "{{countryList}}"
const error = "{{errors.countryInput.text}}"
const countryDefaultValue = "{{countryInput}}"
const countryDefaultValue = "{{payload.countryInput}}"
var autocompleteConfig = {
element: document.querySelector('#my-autocomplete-container'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("CorrespondenceAddressManualService", () => {
addressLine2: "Suite 300",
addressTown: "Example",
addressCounty: "Example",
addressCountry: "Example",
countryInput: "Example",
addressPostcode: "EX1 1EX"
};

Expand Down Expand Up @@ -70,12 +70,12 @@ describe("CorrespondenceAddressManualService", () => {
const retrievedAddress = service.getCorrespondenceManualAddress(acspData);

expect(retrievedAddress).toEqual({
propertyDetails: "Suite 100",
addressPropertyDetails: "Suite 100",
addressLine1: "123 Test St",
addressLine2: "Apt 4",
addressTown: "Test",
addressCounty: "Test",
addressCountry: "Test",
countryInput: "Test",
addressPostcode: "TE5 5TL"
});
});
Expand Down Expand Up @@ -111,4 +111,20 @@ describe("CorrespondenceAddressManualService", () => {
addressPostcode: undefined
});
});

test("getCorrespondenceManualAddress handles undefined acspData", () => {
const acspDataUndefined = undefined;

const retrievedAddress = service.getCorrespondenceManualAddress(acspDataUndefined!);

expect(retrievedAddress).toEqual({
propertyDetails: undefined,
addressLine1: undefined,
addressLine2: undefined,
addressTown: undefined,
addressCounty: undefined,
addressCountry: undefined,
addressPostcode: undefined
});
});
});

0 comments on commit f8c9ba8

Please sign in to comment.