diff --git a/app/presenters/return-requirements/no-returns-required.presenter.js b/app/presenters/return-requirements/no-returns-required.presenter.js index bbd681f0a0..3f978963e7 100644 --- a/app/presenters/return-requirements/no-returns-required.presenter.js +++ b/app/presenters/return-requirements/no-returns-required.presenter.js @@ -7,6 +7,7 @@ function go (session) { const data = { + selectedOption: session.data.reason || null, id: session.id, licenceRef: session.data.licence.licenceRef } diff --git a/app/presenters/return-requirements/start-date.presenter.js b/app/presenters/return-requirements/start-date.presenter.js index f90724e432..f4bd98603f 100644 --- a/app/presenters/return-requirements/start-date.presenter.js +++ b/app/presenters/return-requirements/start-date.presenter.js @@ -49,8 +49,7 @@ function _transformSession (sessionData) { anotherStartDateDay: null, anotherStartDateMonth: null, anotherStartDateYear: null, - anotherStartDateSelected: false, - licenceStartDateSelected: false + selectedOption: null } } @@ -58,8 +57,7 @@ function _transformSession (sessionData) { anotherStartDateDay: sessionData.startDateDay, anotherStartDateMonth: sessionData.startDateMonth, anotherStartDateYear: sessionData.startDateYear, - anotherStartDateSelected: selectedOption === 'anotherStartDate', - licenceStartDateSelected: selectedOption === 'licenceStartDate' + selectedOption } } diff --git a/app/services/return-requirements/submit-no-returns-required.service.js b/app/services/return-requirements/submit-no-returns-required.service.js index 2b452ed158..86c7edf612 100644 --- a/app/services/return-requirements/submit-no-returns-required.service.js +++ b/app/services/return-requirements/submit-no-returns-required.service.js @@ -43,6 +43,7 @@ async function go (sessionId, payload) { checkYourAnswersVisited: session.data.checkYourAnswersVisited, error: validationResult, pageTitle: 'Why are no returns required?', + selectedOption: null, ...formattedData } } diff --git a/app/views/return-requirements/no-returns-required.njk b/app/views/return-requirements/no-returns-required.njk index 7593428b51..2107b8fb6e 100644 --- a/app/views/return-requirements/no-returns-required.njk +++ b/app/views/return-requirements/no-returns-required.njk @@ -47,17 +47,17 @@ { text: 'Abstraction amount below 100 cubic metres per day', value: 'abstraction-below-100-cubic-metres-per-day', - checked: false + checked: selectedOption == 'abstraction-below-100-cubic-metres-per-day' }, { text: 'Returns exception', value: 'returns-exception', - checked: false + checked: selectedOption == 'returns-exception' }, { text: 'Transfer licence', value: 'transfer-licence', - checked: false + checked: selectedOption == 'transfer-licence' } ] }) }} diff --git a/app/views/return-requirements/start-date.njk b/app/views/return-requirements/start-date.njk index 1e35bad67d..aa7d9b6409 100644 --- a/app/views/return-requirements/start-date.njk +++ b/app/views/return-requirements/start-date.njk @@ -93,7 +93,7 @@ hint: { text: licenceVersionStartDate }, - checked: licenceStartDateSelected + checked: selectedOption == 'licenceStartDate' }, { id: 'another-start-date', @@ -102,7 +102,7 @@ hint: { text: 'For example, 27 3 2007' }, - checked: anotherStartDateSelected, + checked: selectedOption == 'anotherStartDate', conditional: { html: dateInputHTML } diff --git a/test/presenters/return-requirements/no-returns-required.presenter.test.js b/test/presenters/return-requirements/no-returns-required.presenter.test.js index 1ec2501336..eb43532572 100644 --- a/test/presenters/return-requirements/no-returns-required.presenter.test.js +++ b/test/presenters/return-requirements/no-returns-required.presenter.test.js @@ -21,7 +21,8 @@ describe('No Returns Required presenter', () => { id: 'ea53bfc6-740d-46c5-9558-fc8cabfc6c1f', licenceRef: '01/123', licenceHolder: 'Jane Doe' - } + }, + reason: 'transfer-licence' } } }) @@ -32,7 +33,9 @@ describe('No Returns Required presenter', () => { expect(result).to.equal({ id: 'f1288f6c-8503-4dc1-b114-75c408a14bd0', - licenceRef: '01/123' + licenceRef: '01/123', + selectedOption: 'transfer-licence' + }) }) }) diff --git a/test/presenters/return-requirements/start-date.presenter.test.js b/test/presenters/return-requirements/start-date.presenter.test.js index c5135eb702..00c221c3d2 100644 --- a/test/presenters/return-requirements/start-date.presenter.test.js +++ b/test/presenters/return-requirements/start-date.presenter.test.js @@ -25,7 +25,8 @@ describe('Start Date presenter', () => { licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', startDate: '2023-11-126T00:00:00.000Z' - } + }, + selectedOption: null } } }) @@ -41,8 +42,7 @@ describe('Start Date presenter', () => { anotherStartDateDay: null, anotherStartDateMonth: null, anotherStartDateYear: null, - anotherStartDateSelected: false, - licenceStartDateSelected: false + selectedOption: null }, { skip: ['id'] }) }) }) @@ -64,8 +64,8 @@ describe('Start Date presenter', () => { }, startDateDay: '26', startDateMonth: '11', - startDateOptions: 'anotherStartDate', - startDateYear: '2023' + startDateYear: '2023', + startDateOptions: 'anotherStartDate' } } }) @@ -81,8 +81,7 @@ describe('Start Date presenter', () => { anotherStartDateDay: '26', anotherStartDateMonth: '11', anotherStartDateYear: '2023', - anotherStartDateSelected: true, - licenceStartDateSelected: false + selectedOption: 'anotherStartDate' }, { skip: ['id'] }) }) }) diff --git a/test/services/return-requirements/no-returns-required.service.test.js b/test/services/return-requirements/no-returns-required.service.test.js index ecaa460876..157ab6ec3a 100644 --- a/test/services/return-requirements/no-returns-required.service.test.js +++ b/test/services/return-requirements/no-returns-required.service.test.js @@ -50,7 +50,8 @@ describe('No Returns Required service', () => { activeNavBar: 'search', checkYourAnswersVisited: false, pageTitle: 'Why are no returns required?', - licenceRef: '01/ABC' + licenceRef: '01/ABC', + selectedOption: null }, { skip: ['id'] }) }) }) diff --git a/test/services/return-requirements/start-date.service.test.js b/test/services/return-requirements/start-date.service.test.js index d0305daab3..d16edf7b2f 100644 --- a/test/services/return-requirements/start-date.service.test.js +++ b/test/services/return-requirements/start-date.service.test.js @@ -23,6 +23,7 @@ const sessionData = { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', + selectedOption: null, startDate: '2022-04-01T00:00:00.000Z' } } @@ -56,8 +57,7 @@ describe('Start Date service', () => { anotherStartDateDay: null, anotherStartDateMonth: null, anotherStartDateYear: null, - anotherStartDateSelected: false, - licenceStartDateSelected: false + selectedOption: null }, { skip: ['id'] }) }) }) diff --git a/test/services/return-requirements/submit-no-returns-required.service.test.js b/test/services/return-requirements/submit-no-returns-required.service.test.js index cb2e7248c6..7482eebab4 100644 --- a/test/services/return-requirements/submit-no-returns-required.service.test.js +++ b/test/services/return-requirements/submit-no-returns-required.service.test.js @@ -24,7 +24,9 @@ const sessionData = { licenceHolder: 'Turbo Kid', startDate: '2022-04-01T00:00:00.000Z' }, - journey: 'no-returns-required' + journey: 'no-returns-required', + selectedOption: null + } } @@ -78,7 +80,8 @@ describe('Submit No Returns Required service', () => { activeNavBar: 'search', checkYourAnswersVisited: false, pageTitle: 'Why are no returns required?', - licenceRef: '01/ABC' + licenceRef: '01/ABC', + selectedOption: null }, { skip: ['id', 'error'] }) }) diff --git a/test/services/return-requirements/submit-start-date.service.test.js b/test/services/return-requirements/submit-start-date.service.test.js index c9200ff648..b0b90728b8 100644 --- a/test/services/return-requirements/submit-start-date.service.test.js +++ b/test/services/return-requirements/submit-start-date.service.test.js @@ -24,7 +24,8 @@ const sessionData = { licenceHolder: 'Turbo Kid', startDate: '2022-04-01T00:00:00.000Z' }, - journey: 'no-returns-required' + journey: 'no-returns-required', + selectedOption: null } } @@ -134,14 +135,13 @@ describe('Submit Start Date service', () => { checkYourAnswersVisited: false, anotherStartDateDay: null, anotherStartDateMonth: null, - anotherStartDateSelected: false, anotherStartDateYear: null, journey: 'no-returns-required', licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', licenceRef: '01/ABC', - licenceStartDateSelected: false, licenceVersionStartDate: '1 January 2023', - pageTitle: 'Select the start date for the requirements for returns' + pageTitle: 'Select the start date for the requirements for returns', + selectedOption: null }, { skip: ['id', 'error'] }) }) @@ -187,8 +187,7 @@ describe('Submit Start Date service', () => { anotherStartDateDay: 'a', anotherStartDateMonth: 'b', anotherStartDateYear: 'c', - anotherStartDateSelected: true, - licenceStartDateSelected: false + selectedOption: 'anotherStartDate' }, { skip: ['id', 'error'] }) })