From d02c87b9a6e4f15331d7977824d67530dd4b9a62 Mon Sep 17 00:00:00 2001 From: GTVJ Date: Wed, 15 Nov 2023 18:17:09 +0000 Subject: [PATCH] CN-754: Fix issue with Contact Form back links --- .../contact-us/contact-us-controller.ts | 54 ++++++++- .../contact-us/index-public-contact-us.njk | 1 - .../tests/contact-us-controller.test.ts | 104 ++++++++++++++++++ ...-us-further-information-controller.test.ts | 7 +- .../contact-us-questions-controller.test.ts | 61 ++++++---- 5 files changed, 198 insertions(+), 29 deletions(-) diff --git a/src/components/contact-us/contact-us-controller.ts b/src/components/contact-us/contact-us-controller.ts index f8c783af15..a0587ed9fe 100644 --- a/src/components/contact-us/contact-us-controller.ts +++ b/src/components/contact-us/contact-us-controller.ts @@ -15,6 +15,7 @@ import { logger } from "../../utils/logger"; import { getClientNameThatDirectsAllContactFormSubmissionsToSmartAgent, getServiceDomain, + getSupportLinkUrl, } from "../../config"; import { contactUsServiceSmartAgent } from "./contact-us-service-smart-agent"; @@ -114,9 +115,12 @@ export function contactUsGet(req: Request, res: Response): void { } } + const supportLinkURL = getSupportLinkUrl(); + const options = { referer: referer, fromURL: fromURL, + hrefBack: prepareBackLink(req, supportLinkURL, serviceDomain), ...(getAppSessionId(req.query.appSessionId as string) && { appSessionId: getAppSessionId(req.query.appSessionId as string), }), @@ -125,6 +129,45 @@ export function contactUsGet(req: Request, res: Response): void { return res.render("contact-us/index-public-contact-us.njk", options); } +export function prepareBackLink( + req: Request, + supportLinkURL: string, + serviceDomain: string +): string { + let hrefBack: string; + + if (req.path.endsWith(PATH_NAMES.CONTACT_US)) { + hrefBack = supportLinkURL; + } else if (req.path.endsWith(PATH_NAMES.CONTACT_US_FURTHER_INFORMATION)) { + if (req.query.fromURL && req.query.theme === ZENDESK_THEMES.ID_CHECK_APP) { + hrefBack = supportLinkURL; + } else { + hrefBack = PATH_NAMES.CONTACT_US; + } + } else if (req.path.endsWith(PATH_NAMES.CONTACT_US_QUESTIONS)) { + hrefBack = PATH_NAMES.CONTACT_US_FURTHER_INFORMATION; + } else { + hrefBack = PATH_NAMES.CONTACT_US; + } + + const queryParams = new URLSearchParams(); + + if (validateReferer(req.query.fromURL as string, serviceDomain)) { + queryParams.append("fromURL", req.query.fromURL as string); + } + + if ( + req.query.theme && + Object.values(ZENDESK_THEMES).includes(req.query.theme as string) + ) { + queryParams.append("theme", req.query.theme as string); + } + + return queryParams.toString().length > 0 + ? hrefBack + "?" + queryParams.toString() + : hrefBack; +} + export function contactUsGetFromTriagePage(req: Request, res: Response): void { const queryParams = new URLSearchParams({ ...(validateAppId(req.query.appSessionId as string) && { @@ -261,13 +304,13 @@ export function contactUsFormPost(req: Request, res: Response): void { } export function furtherInformationGet(req: Request, res: Response): void { + const supportLinkURL = getSupportLinkUrl(); + const backLinkHref = prepareBackLink(req, supportLinkURL, serviceDomain); + if (!req.query.theme) { return res.redirect(PATH_NAMES.CONTACT_US); } - const backLinkHref = - validateReferer(req.get("referer"), serviceDomain) || PATH_NAMES.CONTACT_US; - if (isAppJourney(req.query.appSessionId as string)) { return res.render("contact-us/further-information/index.njk", { theme: req.query.theme, @@ -328,6 +371,9 @@ export function setContactFormSubmissionUrlBasedOnClientName( } export function contactUsQuestionsGet(req: Request, res: Response): void { + const supportLinkURL = getSupportLinkUrl(); + const backLinkHref = prepareBackLink(req, supportLinkURL, serviceDomain); + const formSubmissionUrl = setContactFormSubmissionUrlBasedOnClientName( req?.session?.client?.name, getClientNameThatDirectsAllContactFormSubmissionsToSmartAgent() @@ -349,7 +395,7 @@ export function contactUsQuestionsGet(req: Request, res: Response): void { formSubmissionUrl: formSubmissionUrl, theme: req.query.theme, subtheme: req.query.subtheme, - backurl: validateReferer(req.headers.referer, serviceDomain), + backurl: backLinkHref, referer: validateReferer(req.query.referer as string, serviceDomain), ...(validateReferer(req.query.fromURL as string, serviceDomain) && { fromURL: validateReferer(req.query.fromURL as string, serviceDomain), diff --git a/src/components/contact-us/index-public-contact-us.njk b/src/components/contact-us/index-public-contact-us.njk index 54ebcc2d95..b7c7887c12 100644 --- a/src/components/contact-us/index-public-contact-us.njk +++ b/src/components/contact-us/index-public-contact-us.njk @@ -6,7 +6,6 @@ {% from "govuk/components/warning-text/macro.njk" import govukWarningText %} {% set showBack = true %} -{% set hrefBack = referer %} {% set pageTitleName = 'pages.contactUsPublic.title' | translateEnOnly %} {% block content %} diff --git a/src/components/contact-us/tests/contact-us-controller.test.ts b/src/components/contact-us/tests/contact-us-controller.test.ts index a1d54b590d..bfffdcd9e2 100644 --- a/src/components/contact-us/tests/contact-us-controller.test.ts +++ b/src/components/contact-us/tests/contact-us-controller.test.ts @@ -16,6 +16,7 @@ import { contactUsGetFromTriagePage, setContactFormSubmissionUrlBasedOnClientName, validateReferer, + prepareBackLink, } from "../contact-us-controller"; import { PATH_NAMES, @@ -24,6 +25,7 @@ import { CONTACT_US_REFERER_ALLOWLIST, } from "../../../app.constants"; import { RequestGet, ResponseRedirect } from "../../../types"; +import { getServiceDomain, getSupportLinkUrl } from "../../../config"; describe("contact us controller", () => { let sandbox: sinon.SinonSandbox; @@ -35,6 +37,7 @@ describe("contact us controller", () => { sandbox = sinon.createSandbox(); req = { + path: PATH_NAMES.CONTACT_US, body: {}, query: {}, headers: {}, @@ -399,3 +402,104 @@ describe("appErrorCode and appSessionId query parameters", () => { }); }); }); + +describe("prepareBackLink", () => { + let sandbox: sinon.SinonSandbox; + let req: Partial; + let supportLinkURL: string; + let serviceDomain: string; + + beforeEach(() => { + sandbox = sinon.createSandbox(); + + serviceDomain = getServiceDomain(); + supportLinkURL = getSupportLinkUrl(); + + req = { + url: "", + path: "", + body: {}, + query: {}, + headers: {}, + get: sandbox.fake() as unknown as RequestGet, + }; + }); + + afterEach(() => { + sandbox.restore(); + }); + + it("should return the supportLinkURL when the req.path ends with the CONTACT_US path", () => { + req.path = PATH_NAMES.CONTACT_US; + expect( + prepareBackLink(req as Request, supportLinkURL, serviceDomain) + ).to.equal(supportLinkURL); + }); + + it("should return the CONTACT_US path when the req.path ends with the CONTACT_US_FURTHER_INFORMATION path", () => { + req.path = PATH_NAMES.CONTACT_US_FURTHER_INFORMATION; + expect( + prepareBackLink(req as Request, supportLinkURL, serviceDomain) + ).to.equal(PATH_NAMES.CONTACT_US); + }); + + it("should return the CONTACT_US_FURTHER_INFORMATION path when the req.path ends with the CONTACT_US_QUESTIONS path", () => { + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; + expect( + prepareBackLink(req as Request, supportLinkURL, serviceDomain) + ).to.equal(PATH_NAMES.CONTACT_US_FURTHER_INFORMATION); + }); + + it("should return the supportLinkURL with a fromURL parameter when one is included in the req.url", () => { + req.query.fromURL = `https://${getServiceDomain()}${PATH_NAMES.CONTACT_US}`; + const fromURL = + "?fromURL=" + + encodeURIComponent( + `https://${getServiceDomain()}${PATH_NAMES.CONTACT_US}` + ); + + expect( + prepareBackLink(req as Request, supportLinkURL, serviceDomain) + ).to.equal(supportLinkURL + fromURL); + }); + + it("should omit the fromURL from the backlink where the one included in req.url is not valid", () => { + req.url = `https://${getServiceDomain()}${ + PATH_NAMES.CONTACT_US + }?fromURL=${encodeURIComponent("https://www.example.com")}`; + + expect( + prepareBackLink(req as Request, supportLinkURL, serviceDomain) + ).to.equal(supportLinkURL); + }); + + it("should include the `theme` where the theme is valid", () => { + req.query.theme = ZENDESK_THEMES.ACCOUNT_CREATION; + req.url = `https://${getServiceDomain()}${PATH_NAMES.CONTACT_US}?theme=${ + ZENDESK_THEMES.ACCOUNT_CREATION + }`; + + const theme = `?theme=${ZENDESK_THEMES.ACCOUNT_CREATION}`; + + expect( + prepareBackLink(req as Request, supportLinkURL, serviceDomain) + ).to.equal(supportLinkURL + theme); + }); + + describe("dynamic back links on CONTACT_US_FURTHER_INFORMATION", () => { + it("should default to returning the CONTACT_US path", () => { + req.path = PATH_NAMES.CONTACT_US_FURTHER_INFORMATION; + expect( + prepareBackLink(req as Request, supportLinkURL, serviceDomain) + ).to.equal(PATH_NAMES.CONTACT_US); + }); + it("should return the `supportLinkURL` if there is a fromURL and the theme is ID_CHECK_APP", () => { + req.path = PATH_NAMES.CONTACT_US_FURTHER_INFORMATION; + req.query.fromURL = PATH_NAMES.DOC_CHECKING_APP; + req.query.theme = ZENDESK_THEMES.ID_CHECK_APP; + expect( + prepareBackLink(req as Request, supportLinkURL, serviceDomain) + ).to.equal(`${supportLinkURL}?theme=${ZENDESK_THEMES.ID_CHECK_APP}`); + }); + }); +}); diff --git a/src/components/contact-us/tests/contact-us-further-information-controller.test.ts b/src/components/contact-us/tests/contact-us-further-information-controller.test.ts index 25b362842c..bc301b2223 100644 --- a/src/components/contact-us/tests/contact-us-further-information-controller.test.ts +++ b/src/components/contact-us/tests/contact-us-further-information-controller.test.ts @@ -35,6 +35,7 @@ describe("contact us further information controller", () => { it("should render signing in further information if a problem signing in to your account radio option was chosen", () => { req.query.theme = ZENDESK_THEMES.SIGNING_IN; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_FURTHER_INFORMATION; furtherInformationGet(req as Request, res as Response); expect(res.render).to.have.calledWith( @@ -42,12 +43,13 @@ describe("contact us further information controller", () => { { theme: "signing_in", referer: REFERER, - hrefBack: PATH_NAMES.CONTACT_US, + hrefBack: `${PATH_NAMES.CONTACT_US}?theme=${ZENDESK_THEMES.SIGNING_IN}`, } ); }); it("should render account creation further information if a creating an account radio option was chosen", () => { + req.path = PATH_NAMES.CONTACT_US_FURTHER_INFORMATION; req.query.theme = ZENDESK_THEMES.ACCOUNT_CREATION; req.query.referer = REFERER; furtherInformationGet(req as Request, res as Response); @@ -57,12 +59,13 @@ describe("contact us further information controller", () => { { theme: "account_creation", referer: REFERER, - hrefBack: PATH_NAMES.CONTACT_US, + hrefBack: `${PATH_NAMES.CONTACT_US}?theme=${ZENDESK_THEMES.ACCOUNT_CREATION}`, } ); }); it("should redirect to contact-us when no theme is present in request", () => { + req.path = PATH_NAMES.CONTACT_US_FURTHER_INFORMATION; furtherInformationGet(req as Request, res as Response); expect(res.redirect).to.have.calledWith("/contact-us"); diff --git a/src/components/contact-us/tests/contact-us-questions-controller.test.ts b/src/components/contact-us/tests/contact-us-questions-controller.test.ts index 8226e0f61a..a34473084c 100644 --- a/src/components/contact-us/tests/contact-us-questions-controller.test.ts +++ b/src/components/contact-us/tests/contact-us-questions-controller.test.ts @@ -22,7 +22,6 @@ describe("contact us questions controller", () => { let res: Partial; const REFERER = "http://localhost:3000/enter-email"; const REFERER_HEADER = "http://localhost/contact-us-further-information"; - const BACKURL = "http://localhost:3000/contact-us"; beforeEach(() => { sandbox = sinon.createSandbox(); @@ -48,15 +47,16 @@ describe("contact us questions controller", () => { describe("contactUsQuestionsGetFromContactUsPage", () => { it("should render contact-us-questions if a 'another problem using your account' radio option was chosen", () => { req.query.theme = ZENDESK_THEMES.SOMETHING_ELSE; - req.headers.referer = BACKURL; + req.headers.referer = REFERER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "something_else", subtheme: undefined, - backurl: BACKURL, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.SOMETHING_ELSE}`, pageTitleHeading: "pages.contactUsQuestions.anotherProblem.title", referer: REFERER, zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -68,15 +68,16 @@ describe("contact us questions controller", () => { }); it("should render contact-us-questions if a 'GOV.UK email subscriptions' radio option was chosen", () => { req.query.theme = ZENDESK_THEMES.EMAIL_SUBSCRIPTIONS; - req.headers.referer = BACKURL; + req.headers.referer = REFERER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "email_subscriptions", subtheme: undefined, - backurl: BACKURL, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.EMAIL_SUBSCRIPTIONS}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.emailSubscriptions.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -88,15 +89,16 @@ describe("contact us questions controller", () => { }); it("should render contact-us-questions if a 'A suggestion or feedback' radio option was chosen", () => { req.query.theme = ZENDESK_THEMES.SUGGESTIONS_FEEDBACK; - req.headers.referer = BACKURL; + req.headers.referer = REFERER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "suggestions_feedback", subtheme: undefined, - backurl: BACKURL, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.SUGGESTIONS_FEEDBACK}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.suggestionOrFeedback.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -109,15 +111,16 @@ describe("contact us questions controller", () => { it("should render contact-us-questions if a 'A problem proving your identity' radio option was chosen", () => { req.query.theme = ZENDESK_THEMES.PROVING_IDENTITY; - req.headers.referer = BACKURL; + req.headers.referer = REFERER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "proving_identity", subtheme: undefined, - backurl: BACKURL, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.PROVING_IDENTITY}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.provingIdentity.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -129,6 +132,7 @@ describe("contact us questions controller", () => { }); it("should redirect to contact-us when no theme is present in request", () => { + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.redirect).to.have.calledWith("/contact-us"); @@ -141,13 +145,14 @@ describe("contact us questions controller", () => { req.query.subtheme = ZENDESK_THEMES.NO_SECURITY_CODE; req.headers.referer = REFERER_HEADER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "signing_in", subtheme: "no_security_code", - backurl: REFERER_HEADER, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.SIGNING_IN}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.noSecurityCode.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -162,13 +167,14 @@ describe("contact us questions controller", () => { req.query.subtheme = ZENDESK_THEMES.INVALID_SECURITY_CODE; req.headers.referer = REFERER_HEADER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "signing_in", subtheme: "invalid_security_code", - backurl: REFERER_HEADER, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.SIGNING_IN}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.invalidSecurityCode.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -183,13 +189,14 @@ describe("contact us questions controller", () => { req.query.subtheme = ZENDESK_THEMES.NO_PHONE_NUMBER_ACCESS; req.headers.referer = REFERER_HEADER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "signing_in", subtheme: "no_phone_number_access", - backurl: REFERER_HEADER, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.SIGNING_IN}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.noPhoneNumberAccess.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -204,13 +211,14 @@ describe("contact us questions controller", () => { req.query.subtheme = ZENDESK_THEMES.FORGOTTEN_PASSWORD; req.headers.referer = REFERER_HEADER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "signing_in", subtheme: "forgotten_password", - backurl: REFERER_HEADER, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.SIGNING_IN}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.forgottenPassword.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -225,13 +233,14 @@ describe("contact us questions controller", () => { req.query.subtheme = ZENDESK_THEMES.ACCOUNT_NOT_FOUND; req.headers.referer = REFERER_HEADER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "signing_in", subtheme: "account_not_found", - backurl: REFERER_HEADER, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.SIGNING_IN}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.accountNotFound.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -246,13 +255,14 @@ describe("contact us questions controller", () => { req.query.subtheme = ZENDESK_THEMES.TECHNICAL_ERROR; req.headers.referer = REFERER_HEADER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "signing_in", subtheme: "technical_error", - backurl: REFERER_HEADER, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.SIGNING_IN}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.technicalError.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -267,13 +277,14 @@ describe("contact us questions controller", () => { req.query.subtheme = ZENDESK_THEMES.SOMETHING_ELSE; req.headers.referer = REFERER_HEADER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "signing_in", subtheme: "something_else", - backurl: REFERER_HEADER, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.SIGNING_IN}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.anotherProblem.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -291,13 +302,14 @@ describe("contact us questions controller", () => { req.query.subtheme = ZENDESK_THEMES.NO_SECURITY_CODE; req.headers.referer = REFERER_HEADER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "account_creation", subtheme: "no_security_code", - backurl: REFERER_HEADER, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.ACCOUNT_CREATION}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.noSecurityCode.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -312,13 +324,14 @@ describe("contact us questions controller", () => { req.query.subtheme = ZENDESK_THEMES.INVALID_SECURITY_CODE; req.headers.referer = REFERER_HEADER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "account_creation", subtheme: "invalid_security_code", - backurl: REFERER_HEADER, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.ACCOUNT_CREATION}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.invalidSecurityCode.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -333,13 +346,14 @@ describe("contact us questions controller", () => { req.query.subtheme = ZENDESK_THEMES.SIGN_IN_PHONE_NUMBER_ISSUE; req.headers.referer = REFERER_HEADER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "account_creation", subtheme: "sign_in_phone_number_issue", - backurl: REFERER_HEADER, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.ACCOUNT_CREATION}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.signInPhoneNumberIssue.title", @@ -355,13 +369,14 @@ describe("contact us questions controller", () => { req.query.subtheme = ZENDESK_THEMES.TECHNICAL_ERROR; req.headers.referer = REFERER_HEADER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "account_creation", subtheme: "technical_error", - backurl: REFERER_HEADER, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.ACCOUNT_CREATION}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.technicalError.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -376,13 +391,14 @@ describe("contact us questions controller", () => { req.query.subtheme = ZENDESK_THEMES.SOMETHING_ELSE; req.headers.referer = REFERER_HEADER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "account_creation", subtheme: "something_else", - backurl: REFERER_HEADER, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.ACCOUNT_CREATION}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.accountCreation.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH, @@ -397,13 +413,14 @@ describe("contact us questions controller", () => { req.query.subtheme = ZENDESK_THEMES.AUTHENTICATOR_APP_PROBLEM; req.headers.referer = REFERER_HEADER; req.query.referer = REFERER; + req.path = PATH_NAMES.CONTACT_US_QUESTIONS; contactUsQuestionsGet(req as Request, res as Response); expect(res.render).to.have.calledWith("contact-us/questions/index.njk", { formSubmissionUrl: PATH_NAMES.CONTACT_US_QUESTIONS, theme: "account_creation", subtheme: "authenticator_app_problem", - backurl: REFERER_HEADER, + backurl: `/contact-us-further-information?theme=${ZENDESK_THEMES.ACCOUNT_CREATION}`, referer: REFERER, pageTitleHeading: "pages.contactUsQuestions.authenticatorApp.title", zendeskFieldMaxLength: ZENDESK_FIELD_MAX_LENGTH,