diff --git a/src/server/plugins/engine/models/SummaryViewModel.test.ts b/src/server/plugins/engine/models/SummaryViewModel.test.ts index 696edcd3d..2fef463da 100644 --- a/src/server/plugins/engine/models/SummaryViewModel.test.ts +++ b/src/server/plugins/engine/models/SummaryViewModel.test.ts @@ -67,9 +67,9 @@ describe('SummaryViewModel', () => { } satisfies FormState, keys: [ 'How would you like to receive your pizza?', - 'Pizzas', + 'Pizza', 'How you would like to receive your pizza', - 'Pizzas', + 'Pizza', 'Pizza' ], values: ['Collection', 'Not provided'], @@ -91,13 +91,13 @@ describe('SummaryViewModel', () => { } satisfies FormState, keys: [ 'How would you like to receive your pizza?', - 'Pizza added', + 'Pizza', 'How you would like to receive your pizza', - 'Pizzas', + 'Pizza', 'Pizza' ], - values: ['Delivery', 'You added 1 Pizza'], - answers: ['Delivery', 'You added 1 Pizza'], + values: ['Delivery', 'You have added 1 answer'], + answers: ['Delivery', 'You have added 1 answer'], names: ['orderType', 'pizza'] }, { @@ -120,13 +120,13 @@ describe('SummaryViewModel', () => { } satisfies FormState, keys: [ 'How would you like to receive your pizza?', - 'Pizzas added', + 'Pizza', 'How you would like to receive your pizza', - 'Pizzas', + 'Pizza', 'Pizza' ], - values: ['Delivery', 'You added 2 Pizzas'], - answers: ['Delivery', 'You added 2 Pizzas'], + values: ['Delivery', 'You have added 2 answers'], + answers: ['Delivery', 'You have added 2 answers'], names: ['orderType', 'pizza'] } ])( @@ -326,7 +326,7 @@ describe('SummaryViewModel', () => { expect(details1.items[0]).toMatchObject({ name: 'pizza', value: '', - title: 'Pizzas', + title: 'Pizza', label: 'Pizza' }) diff --git a/src/server/plugins/engine/models/SummaryViewModel.ts b/src/server/plugins/engine/models/SummaryViewModel.ts index f41fc0d98..52ec20f4e 100644 --- a/src/server/plugins/engine/models/SummaryViewModel.ts +++ b/src/server/plugins/engine/models/SummaryViewModel.ts @@ -186,13 +186,13 @@ function ItemRepeat( const { name, title } = repeat.options const values = page.getListFromState(state) - const unit = values.length === 1 ? title : `${title}s` + const unit = values.length === 1 ? 'answer' : 'answers' return { name, label: title, - title: values.length ? `${unit} added` : unit, - value: values.length ? `You added ${values.length} ${unit}` : '', + title, + value: values.length ? `You have added ${values.length} ${unit}` : '', href: getPageHref(page, options.path, { returnUrl: getPageHref(page, page.getSummaryPath()) }), diff --git a/src/server/plugins/engine/models/__snapshots__/SummaryViewModel.test.ts.snap b/src/server/plugins/engine/models/__snapshots__/SummaryViewModel.test.ts.snap index fc118e040..e911051b7 100644 --- a/src/server/plugins/engine/models/__snapshots__/SummaryViewModel.test.ts.snap +++ b/src/server/plugins/engine/models/__snapshots__/SummaryViewModel.test.ts.snap @@ -5,7 +5,7 @@ exports[`SummaryViewModel Check answers (0 items) should use correct summary lab { "label": "Pizza", "name": "pizza", - "title": "Pizzas", + "title": "Pizza", "value": "", }, { @@ -22,8 +22,8 @@ exports[`SummaryViewModel Check answers (1 item) should use correct summary labe { "label": "Pizza", "name": "pizza", - "title": "Pizza added", - "value": "You added 1 Pizza", + "title": "Pizza", + "value": "You have added 1 answer", }, { "label": "How would you like to receive your pizza?", @@ -39,8 +39,8 @@ exports[`SummaryViewModel Check answers (2 items) should use correct summary lab { "label": "Pizza", "name": "pizza", - "title": "Pizzas added", - "value": "You added 2 Pizzas", + "title": "Pizza", + "value": "You have added 2 answers", }, { "label": "How would you like to receive your pizza?", diff --git a/src/server/plugins/engine/pageControllers/RepeatPageController.test.ts b/src/server/plugins/engine/pageControllers/RepeatPageController.test.ts index 775a896ee..b66f91e5f 100644 --- a/src/server/plugins/engine/pageControllers/RepeatPageController.test.ts +++ b/src/server/plugins/engine/pageControllers/RepeatPageController.test.ts @@ -149,7 +149,7 @@ describe('RepeatPageController', () => { description: 'No items', list: [] satisfies RepeatListState, viewModel: { - pageTitle: 'You have added 0 Pizzas', + pageTitle: 'You have added 0 answers', showTitle: true, sectionTitle: 'Food' } @@ -164,7 +164,7 @@ describe('RepeatPageController', () => { } ] satisfies RepeatListState, viewModel: { - pageTitle: 'You have added 1 Pizza', + pageTitle: 'You have added 1 answer', showTitle: true, sectionTitle: 'Food' } @@ -184,7 +184,7 @@ describe('RepeatPageController', () => { } ] satisfies RepeatListState, viewModel: { - pageTitle: 'You have added 2 Pizzas', + pageTitle: 'You have added 2 answers', showTitle: true, sectionTitle: 'Food' } diff --git a/src/server/plugins/engine/pageControllers/RepeatPageController.ts b/src/server/plugins/engine/pageControllers/RepeatPageController.ts index 3c6296c4b..e9656249c 100644 --- a/src/server/plugins/engine/pageControllers/RepeatPageController.ts +++ b/src/server/plugins/engine/pageControllers/RepeatPageController.ts @@ -207,7 +207,7 @@ export class RepeatPageController extends QuestionPageController { ) => { const { path, repeat } = this const { query } = request - const { schema, options } = repeat + const { schema } = repeat const { state } = context const list = this.getListFromState(state) @@ -232,7 +232,7 @@ export class RepeatPageController extends QuestionPageController { // Show error if repeat limits apply if (hasErrorMin || hasErrorMax) { const count = hasErrorMax ? schema.max : schema.min - const itemTitle = `${options.title}${count === 1 ? '' : 's'}` + const itemTitle = `answer${count === 1 ? '' : 's'}` context.errors = [ { @@ -295,9 +295,9 @@ export class RepeatPageController extends QuestionPageController { ...viewModel, context, backLink: this.getBackLink(request, context), - pageTitle: `Are you sure you want to remove this ${title}?`, + pageTitle: 'Are you sure you want to remove this answer?', itemTitle: `${title} ${list.indexOf(item) + 1}`, - buttonConfirm: { text: `Remove ${title}` }, + buttonConfirm: { text: 'Remove' }, buttonCancel: { text: 'Cancel' } } satisfies ItemDeletePageViewModel) } @@ -431,11 +431,13 @@ export class RepeatPageController extends QuestionPageController { }) } + const unit = count === 1 ? 'answer' : 'answers' + return { ...this.viewModel, backLink: this.getBackLink(request, context), repeatTitle: title, - pageTitle: `You have added ${count} ${title}${count === 1 ? '' : 's'}`, + pageTitle: `You have added ${count} ${unit}`, showTitle: true, context, errors, diff --git a/src/server/plugins/engine/views/repeat-list-summary.html b/src/server/plugins/engine/views/repeat-list-summary.html index b9edf5dce..1befdaea7 100644 --- a/src/server/plugins/engine/views/repeat-list-summary.html +++ b/src/server/plugins/engine/views/repeat-list-summary.html @@ -36,7 +36,7 @@ }) }} {{ govukButton({ - text: "Add another " + repeatTitle, + text: "Add another", name: "action", value: "add-another", classes: "govuk-button--secondary", diff --git a/test/form/repeat.test.js b/test/form/repeat.test.js index 48f4b85b4..77602d37f 100644 --- a/test/form/repeat.test.js +++ b/test/form/repeat.test.js @@ -522,7 +522,7 @@ describe('Repeat POST tests', () => { }) expect($heading).toBeInTheDocument() - expect($errorItems[0]).toHaveTextContent('You can only add up to 3 Pizzas') + expect($errorItems[0]).toHaveTextContent('You can only add up to 3 answers') }) test('POST /pizza-order/summary CONTINUE with 1 item returns 200 with errors under schema.min', async () => { @@ -548,7 +548,7 @@ describe('Repeat POST tests', () => { }) expect($heading).toBeInTheDocument() - expect($errorItems[0]).toHaveTextContent('You must add at least 2 Pizzas') + expect($errorItems[0]).toHaveTextContent('You must add at least 2 answers') }) test('POST /pizza-order/summary with 2 items CONTINUE returns 303 to /summary', async () => { @@ -581,7 +581,7 @@ describe('Repeat POST tests', () => { classList.contains('govuk-summary-list__value') ) - expect($values[0]).toHaveTextContent('You added 2 Pizzas') + expect($values[0]).toHaveTextContent('You have added 2 answers') // POST the summary page await server.inject({