Skip to content

Commit 3c0be18

Browse files
committed
LP-924 Update error construction and tests for language
1 parent 7c4e7d2 commit 3c0be18

20 files changed

+114
-43
lines changed

locales/cy/errors.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
"noComma": "WELSH - Value must not include a comma",
99
"atLeastOneType": "WELSH - Select at least one type of contribution",
1010
"currencyRequired": "WELSH - Select the currency of the capital contribution"
11+
},
12+
13+
"address": {
14+
"confirm": {
15+
"countryMissing": "WELSH - We cannot identify the country for this address. Select Change, then select the country."
16+
}
1117
}
1218
}
1319
}

locales/cy/translations.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@
146146
"limitedPartnerPrincipalOfficeAddress": {
147147
"title": "WELSH - Confirm the limited partner's principal office address",
148148
"publicRegisterLine1": "WELSH - We'll show the limited partner's principal office address on the public register."
149-
},
150-
"countryMissing": "WELSH - We cannot identify the country for this address. Select Change, then select the country."
151-
149+
}
152150
},
153151

154152
"enterAddress": {

locales/en/errors.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
"noComma": "Value must not include a comma",
99
"atLeastOneType": "Select at least one type of contribution",
1010
"currencyRequired": "Select the currency of the capital contribution"
11+
},
12+
13+
"address": {
14+
"confirm": {
15+
"countryMissing": "We cannot identify the country for this address. Select Change, then select the country."
16+
}
1117
}
1218
}
1319
}

locales/en/translations.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@
148148
"limitedPartnerPrincipalOfficeAddress": {
149149
"title": "Confirm the limited partner's principal office address",
150150
"publicRegisterLine1": "We'll show the limited partner's principal office address on the public register."
151-
},
152-
"errorMessages": {
153-
"countryMissing": "We cannot identify the country for this address. Select Change, then select the country."
154151
}
155152
},
156153

src/application/service/AddressService.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ class AddressService {
170170
hasCountry(address: Address, uiErrors?: UIErrors | undefined): UIErrors | undefined {
171171
if (!address.country) {
172172
uiErrors ??= new UIErrors();
173-
174-
this.setFieldError(uiErrors, "change", this.i18n?.address.confirm.errorMessages.countryMissing);
173+
uiErrors.setWebError("change", this.i18n?.errorMessages?.address?.confirm?.countryMissing);
175174
}
176175

177176
return uiErrors;

src/presentation/test/integration/postTransition/generalPartner/address/confirm-general-partner-correspondence-address.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import request from "supertest";
33
import app from "../../../app";
44
import enTranslationText from "../../../../../../../locales/en/translations.json";
55
import cyTranslationText from "../../../../../../../locales/cy/translations.json";
6+
import enErrorMessages from "../../../../../../../locales/en/errors.json";
67

78
import { getUrl, setLocalesEnabled, testTranslations } from "../../../../utils";
89
import {
@@ -133,7 +134,7 @@ describe("Confirm General Partner Correspondence Address Page", () => {
133134
});
134135

135136
expect(res.status).toBe(200);
136-
expect(res.text).toContain(enTranslationText.address.confirm.errorMessages.countryMissing);
137+
expect(res.text).toContain(enErrorMessages.errorMessages.address.confirm.countryMissing);
137138
});
138139
});
139140
});

src/presentation/test/integration/postTransition/generalPartner/address/confirm-general-partner-principal-office-address.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import request from "supertest";
22

33
import enTranslationText from "../../../../../../../locales/en/translations.json";
44
import cyTranslationText from "../../../../../../../locales/cy/translations.json";
5+
import enErrorMessages from "../../../../../../../locales/en/errors.json";
56

67
import app from "../../../app";
78
import { getUrl, setLocalesEnabled, testTranslations } from "../../../../utils";
@@ -134,7 +135,7 @@ describe("Confirm General Partner Principal Office Address Page", () => {
134135
});
135136

136137
expect(res.status).toBe(200);
137-
expect(res.text).toContain(enTranslationText.address.confirm.errorMessages.countryMissing);
138+
expect(res.text).toContain(enErrorMessages.errorMessages.address.confirm.countryMissing);
138139
});
139140
});
140141
});

src/presentation/test/integration/postTransition/generalPartner/address/confirm-general-partner-usual-residential-address.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import request from "supertest";
33
import app from "../../../app";
44
import enTranslationText from "../../../../../../../locales/en/translations.json";
55
import cyTranslationText from "../../../../../../../locales/cy/translations.json";
6+
import enErrorMessages from "../../../../../../../locales/en/errors.json";
67

78
import { getUrl, setLocalesEnabled, testTranslations } from "../../../../utils";
89
import {
@@ -141,7 +142,7 @@ describe("Confirm General Partner Usual Residential Address Page", () => {
141142
});
142143

143144
expect(res.status).toBe(200);
144-
expect(res.text).toContain(enTranslationText.address.confirm.errorMessages.countryMissing);
145+
expect(res.text).toContain(enErrorMessages.errorMessages.address.confirm.countryMissing);
145146
});
146147

147148
it("should redirect to the confirm correspondance address if already saved", async () => {

src/presentation/test/integration/postTransition/limitedPartner/address/confirm-limited-partner-principal-office-address.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import request from "supertest";
22

33
import enTranslationText from "../../../../../../../locales/en/translations.json";
44
import cyTranslationText from "../../../../../../../locales/cy/translations.json";
5+
import enErrorMessages from "../../../../../../../locales/en/errors.json";
56

67
import app from "../../../app";
78
import { getUrl, setLocalesEnabled, testTranslations } from "../../../../utils";
@@ -134,7 +135,7 @@ describe("Confirm Limited Partner Principal Office Address Page", () => {
134135
});
135136

136137
expect(res.status).toBe(200);
137-
expect(res.text).toContain(enTranslationText.address.confirm.errorMessages.countryMissing);
138+
expect(res.text).toContain(enErrorMessages.errorMessages.address.confirm.countryMissing);
138139
});
139140
});
140141
});

src/presentation/test/integration/postTransition/limitedPartner/address/confirm-limited-partner-usual-residential-address.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import request from "supertest";
33
import app from "../../../app";
44
import enTranslationText from "../../../../../../../locales/en/translations.json";
55
import cyTranslationText from "../../../../../../../locales/cy/translations.json";
6+
import enErrorMessages from "../../../../../../../locales/en/errors.json";
67

78
import { getUrl, setLocalesEnabled, testTranslations } from "../../../../utils";
89
import {
@@ -140,7 +141,7 @@ describe("Confirm Limited Partner Usual Residential Address Page", () => {
140141
});
141142

142143
expect(res.status).toBe(200);
143-
expect(res.text).toContain(enTranslationText.address.confirm.errorMessages.countryMissing);
144+
expect(res.text).toContain(enErrorMessages.errorMessages.address.confirm.countryMissing);
144145
});
145146
});
146147
});

0 commit comments

Comments
 (0)