diff --git a/server/routes/__tests__/water-pollution.spec.js b/server/routes/__tests__/water-pollution.spec.js index b614091..aaf19d5 100644 --- a/server/routes/__tests__/water-pollution.spec.js +++ b/server/routes/__tests__/water-pollution.spec.js @@ -9,5 +9,12 @@ describe(url, () => { it(`Should return success response and correct view for ${url}`, async () => { await submitGetRequest({ url }, header) }) + it(`Happy: Reset the CYA journey if user restarts the WP journey before report submission ${url}`, async () => { + const sessionData = { + referer: '/water-pollution/check-your-answers' + } + const response = await submitGetRequest({ url }, header, constants.statusCodes.OK, sessionData) + expect(response.request.yar.get(constants.redisKeys.REFERER)).toEqual(null) + }) }) }) diff --git a/server/routes/water-pollution.js b/server/routes/water-pollution.js index 873ee60..037a774 100644 --- a/server/routes/water-pollution.js +++ b/server/routes/water-pollution.js @@ -1,8 +1,10 @@ import constants from '../utils/constants.js' const handlers = { - get: async (_request, h) => { + get: async (request, h) => { const context = _getContext() + // Clear referer key in case if user restarts the journey before report submission + request.yar.clear(constants.redisKeys.REFERER) return h.view(constants.views.WATER_POLUTION, { ...context }) diff --git a/server/views/water-pollution/pollution-substance.html b/server/views/water-pollution/pollution-substance.html index a89a1d8..eb67443 100644 --- a/server/views/water-pollution/pollution-substance.html +++ b/server/views/water-pollution/pollution-substance.html @@ -66,6 +66,7 @@ { value: question.answers.unknown.answerId, text: question.answers.unknown.text, + behaviour: "exclusive", checked: getAnswer(answers, question.answers.unknown.answerId) } ]