Skip to content

Commit f1f0ddb

Browse files
CCM-13415: Use error code and render bullet pointed list
1 parent 1c46d38 commit f1f0ddb

File tree

14 files changed

+63
-83
lines changed

14 files changed

+63
-83
lines changed

frontend/src/__tests__/components/forms/EmailTemplateForm/__snapshots__/EmailTemplateForm.test.tsx.snap

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -733,16 +733,6 @@ exports[`renders page one error 1`] = `
733733
Template name error
734734
</a>
735735
</li>
736-
<li>
737-
<a
738-
href="#emailTemplateSubjectLine"
739-
/>
740-
</li>
741-
<li>
742-
<a
743-
href="#emailTemplateMessage"
744-
/>
745-
</li>
746736
</ul>
747737
</div>
748738
<h1

frontend/src/__tests__/components/forms/EmailTemplateForm/server-action.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { EmailTemplate } from 'nhs-notify-web-template-management-utils';
44
import { redirect } from 'next/navigation';
55
import { processFormActions } from '@forms/EmailTemplateForm/server-action';
66
import { MAX_EMAIL_CHARACTER_LENGTH } from '@utils/constants';
7+
import { ErrorCodes } from '@utils/error-codes';
78

89
jest.mock('@utils/amplify-utils');
910
jest.mock('@utils/form-actions');
@@ -108,7 +109,7 @@ describe('CreateEmailTemplate server actions', () => {
108109
formErrors: [],
109110
fieldErrors: {
110111
emailTemplateMessage: [
111-
'You cannot use the following custom personalisation fields in your message: date, address_line_1, address_line_2, address_line_3, address_line_4, address_line_5, address_line_6, address_line_7',
112+
ErrorCodes.MESSAGE_CONTAINS_INVALID_PERSONALISATION_FIELD_NAME,
112113
],
113114
},
114115
},

frontend/src/__tests__/components/forms/LetterTemplateForm/__snapshots__/LetterTemplateForm.test.tsx.snap

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -960,31 +960,6 @@ exports[`renders page one error 1`] = `
960960
Template name error
961961
</a>
962962
</li>
963-
<li>
964-
<a
965-
href="#letterTemplateCampaignId"
966-
/>
967-
</li>
968-
<li>
969-
<a
970-
href="#letterTemplateLetterType"
971-
/>
972-
</li>
973-
<li>
974-
<a
975-
href="#letterTemplateLanguage"
976-
/>
977-
</li>
978-
<li>
979-
<a
980-
href="#letterTemplatePdf"
981-
/>
982-
</li>
983-
<li>
984-
<a
985-
href="#letterTemplateCsv"
986-
/>
987-
</li>
988963
</ul>
989964
</div>
990965
<form
@@ -1958,21 +1933,6 @@ exports[`renders page with multiple errors 1`] = `
19581933
CSV error
19591934
</a>
19601935
</li>
1961-
<li>
1962-
<a
1963-
href="#letterTemplateCampaignId"
1964-
/>
1965-
</li>
1966-
<li>
1967-
<a
1968-
href="#letterTemplateLetterType"
1969-
/>
1970-
</li>
1971-
<li>
1972-
<a
1973-
href="#letterTemplateLanguage"
1974-
/>
1975-
</li>
19761936
</ul>
19771937
</div>
19781938
<form

frontend/src/__tests__/components/forms/NhsAppTemplateForm/__snapshots__/NhsAppTemplateForm.test.tsx.snap

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,11 +1401,6 @@ exports[`renders page one error 1`] = `
14011401
Template name error
14021402
</a>
14031403
</li>
1404-
<li>
1405-
<a
1406-
href="#nhsAppTemplateMessage"
1407-
/>
1408-
</li>
14091404
</ul>
14101405
</div>
14111406
<h1

frontend/src/__tests__/components/forms/NhsAppTemplateForm/server-action.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
} from 'nhs-notify-web-template-management-utils';
77
import { redirect } from 'next/navigation';
88
import { processFormActions } from '@forms/NhsAppTemplateForm/server-action';
9+
import { ErrorCodes } from '@utils/error-codes';
910

1011
jest.mock('@utils/amplify-utils');
1112
jest.mock('@utils/form-actions');
@@ -110,7 +111,7 @@ describe('CreateNHSAppTemplate server actions', () => {
110111
formErrors: [],
111112
fieldErrors: {
112113
nhsAppTemplateMessage: [
113-
'You cannot use the following custom personalisation fields in your message: date, address_line_1, address_line_2, address_line_3, address_line_4, address_line_5, address_line_6, address_line_7',
114+
ErrorCodes.MESSAGE_CONTAINS_INVALID_PERSONALISATION_FIELD_NAME,
114115
],
115116
},
116117
},

frontend/src/__tests__/components/forms/SmsTemplateForm/__snapshots__/SmsTemplateForm.test.tsx.snap

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,6 @@ exports[`CreateSmsTemplate component renders page one error 1`] = `
495495
Template name error
496496
</a>
497497
</li>
498-
<li>
499-
<a
500-
href="#smsTemplateMessage"
501-
/>
502-
</li>
503498
</ul>
504499
</div>
505500
<h1

frontend/src/__tests__/components/forms/SmsTemplateForm/server-action.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { SMSTemplate } from 'nhs-notify-web-template-management-utils';
44
import { redirect } from 'next/navigation';
55
import { processFormActions } from '@forms/SmsTemplateForm/server-action';
66
import { TemplateDto } from 'nhs-notify-backend-client';
7+
import { ErrorCodes } from '@utils/error-codes';
78

89
jest.mock('@utils/amplify-utils');
910
jest.mock('@utils/form-actions');
@@ -104,7 +105,7 @@ describe('CreateSmsTemplate server actions', () => {
104105
formErrors: [],
105106
fieldErrors: {
106107
smsTemplateMessage: [
107-
'You cannot use the following custom personalisation fields in your message: date, address_line_1, address_line_2, address_line_3, address_line_4, address_line_5, address_line_6, address_line_7',
108+
ErrorCodes.MESSAGE_CONTAINS_INVALID_PERSONALISATION_FIELD_NAME,
108109
],
109110
},
110111
},

frontend/src/__tests__/components/molecules/__snapshots__/NhsNotifyErrorSummary.test.tsx.snap

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ exports[`Renders NhsNotifyErrorSummary correctly with errors 1`] = `
2222
<a
2323
href="#radios-id"
2424
>
25-
Radio error 1, Radio error 2
25+
Radio error 1
26+
</a>
27+
</li>
28+
<li>
29+
<a
30+
href="#radios-id"
31+
>
32+
Radio error 2
2633
</a>
2734
</li>
2835
<li>

frontend/src/components/forms/EmailTemplateForm/server-action.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
INVALID_PERSONALISATION_FIELDS,
1212
} from '@utils/constants';
1313
import content from '@content/content';
14+
import { ErrorCodes } from '@utils/error-codes';
1415

1516
const {
1617
components: {
@@ -40,7 +41,7 @@ export const $EmailTemplateFormSchema = z.object({
4041
templateMessage.includes(`((${personalisationFieldName}))`)
4142
),
4243
{
43-
message: `${form.emailTemplateMessage.error.invalidPersonalisation} ${INVALID_PERSONALISATION_FIELDS.join(', ')}`,
44+
message: ErrorCodes.MESSAGE_CONTAINS_INVALID_PERSONALISATION_FIELD_NAME,
4445
}
4546
),
4647
});

frontend/src/components/forms/NhsAppTemplateForm/server-action.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { saveTemplate, createTemplate } from '@utils/form-actions';
99
import { redirect, RedirectType } from 'next/navigation';
1010
import { INVALID_PERSONALISATION_FIELDS } from '@utils/constants';
1111
import content from '@content/content';
12+
import { ErrorCodes } from '@utils/error-codes';
1213

1314
const {
1415
components: {
@@ -57,7 +58,7 @@ export const $CreateNhsAppTemplateSchema = z.object({
5758
templateMessage.includes(`((${personalisationFieldName}))`)
5859
),
5960
{
60-
message: `${form.nhsAppTemplateMessage.error.invalidPersonalisation} ${INVALID_PERSONALISATION_FIELDS.join(', ')}`,
61+
message: ErrorCodes.MESSAGE_CONTAINS_INVALID_PERSONALISATION_FIELD_NAME,
6162
}
6263
),
6364
});

0 commit comments

Comments
 (0)