Skip to content

Commit

Permalink
Reset the referer flag in case if the user restarts the WP journey be…
Browse files Browse the repository at this point in the history
…fore report submission (#228)
  • Loading branch information
sujithvg authored Nov 29, 2024
1 parent ed13887 commit d547220
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions server/routes/__tests__/water-pollution.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
})
4 changes: 3 additions & 1 deletion server/routes/water-pollution.js
Original file line number Diff line number Diff line change
@@ -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
})
Expand Down
1 change: 1 addition & 0 deletions server/views/water-pollution/pollution-substance.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
{
value: question.answers.unknown.answerId,
text: question.answers.unknown.text,
behaviour: "exclusive",
checked: getAnswer(answers, question.answers.unknown.answerId)
}
]
Expand Down

0 comments on commit d547220

Please sign in to comment.