From d5472202fab15e759202946bda6435c76cd78e54 Mon Sep 17 00:00:00 2001 From: sujithvg Date: Fri, 29 Nov 2024 10:21:52 +0000 Subject: [PATCH] Reset the referer flag in case if the user restarts the WP journey before report submission (#228) --- server/routes/__tests__/water-pollution.spec.js | 7 +++++++ server/routes/water-pollution.js | 4 +++- server/views/water-pollution/pollution-substance.html | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/server/routes/__tests__/water-pollution.spec.js b/server/routes/__tests__/water-pollution.spec.js index b6140917..aaf19d5f 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 873ee60e..037a7743 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 a89a1d8e..eb67443f 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) } ]