diff --git a/app/controllers/verify/VerifyCheckYourAnswersController.scala b/app/controllers/verify/VerifyCheckYourAnswersController.scala new file mode 100644 index 00000000..3ff5631e --- /dev/null +++ b/app/controllers/verify/VerifyCheckYourAnswersController.scala @@ -0,0 +1,56 @@ +/* + * Copyright 2026 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package controllers.verify + +import controllers.actions.* +import play.api.i18n.{I18nSupport, MessagesApi} +import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} +import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController +import viewmodels.checkAnswers.verify.* +import viewmodels.govuk.summarylist.* +import views.html.verify.VerifyCheckYourAnswersView + +import javax.inject.Inject + +class VerifyCheckYourAnswersController @Inject() ( + override val messagesApi: MessagesApi, + identify: IdentifierAction, + getData: DataRetrievalAction, + requireData: DataRequiredAction, + val controllerComponents: MessagesControllerComponents, + view: VerifyCheckYourAnswersView +) extends FrontendBaseController + with I18nSupport { + + def onPageLoad(): Action[AnyContent] = (identify andThen getData andThen requireData) { implicit request => + val ua = request.userAnswers + val list = SummaryListViewModel( + rows = Seq( + SelectSubcontractorSummary.row(ua), + ReverifyExistingSubcontractorsYesNoSummary.row(ua), + ContractorEmailConfirmationStoredSummary.row(ua), + ContractorEmailConfirmationNotStoredSummary.row(ua), + EmailAddressSummary.row(ua) + ).flatten + ) + Ok(view(list)) + } + + def onSubmit(): Action[AnyContent] = (identify andThen getData andThen requireData) { implicit request => + Redirect(controllers.verify.routes.SubmissionSendingController.onPageLoad()) + } +} diff --git a/app/navigation/verify/VerifyNavigator.scala b/app/navigation/verify/VerifyNavigator.scala index d8e0fc12..f7526e77 100644 --- a/app/navigation/verify/VerifyNavigator.scala +++ b/app/navigation/verify/VerifyNavigator.scala @@ -43,12 +43,14 @@ class VerifyNavigator @Inject() () extends NavigatorForJourney { userAnswers => navigatorFromContractorEmailConfirmationNotStoredPage(NormalMode)(userAnswers) case SelectSubcontractorPage => userAnswers => navigatorFromSelectSubcontractorPage(NormalMode)(userAnswers) + case ReverifyExistingSubcontractorsYesNoPage => + userAnswers => navigatorFromReverifyExistingSubcontractorsYesNoPage(NormalMode)(userAnswers) case ContractorEmailConfirmationStoredPage => userAnswers => navigatorFromContractorEmailConfirmationStoredPage(NormalMode)(userAnswers) case SelectSubcontractorsToReverifyPage => _ => controllers.verify.routes.ContractorEmailConfirmationStoredController.onPageLoad(NormalMode) case EmailAddressPage => - _ => controllers.verify.routes.EmailAddressController.onPageLoad(NormalMode) + _ => controllers.verify.routes.VerifyCheckYourAnswersController.onPageLoad() case _ => _ => controllers.routes.JourneyRecoveryController.onPageLoad() } @@ -57,54 +59,57 @@ class VerifyNavigator @Inject() () extends NavigatorForJourney { userAnswers => navigatorFromContractorEmailConfirmationNotStoredPage(CheckMode)(userAnswers) case SelectSubcontractorPage => userAnswers => navigatorFromSelectSubcontractorPage(CheckMode)(userAnswers) + case ReverifyExistingSubcontractorsYesNoPage => + userAnswers => navigatorFromReverifyExistingSubcontractorsYesNoPage(CheckMode)(userAnswers) case ContractorEmailConfirmationStoredPage => userAnswers => navigatorFromContractorEmailConfirmationStoredPage(CheckMode)(userAnswers) case SelectSubcontractorsToReverifyPage => _ => controllers.verify.routes.ContractorEmailConfirmationStoredController.onPageLoad(CheckMode) case EmailAddressPage => - _ => controllers.verify.routes.EmailAddressController.onPageLoad(CheckMode) + _ => controllers.verify.routes.VerifyCheckYourAnswersController.onPageLoad() case _ => _ => controllers.routes.JourneyRecoveryController.onPageLoad() - } private def navigatorFromContractorEmailConfirmationNotStoredPage(mode: Mode)(ua: UserAnswers): Call = (ua.get(ContractorEmailConfirmationNotStoredPage), mode) match { - case (Some(true), _) => - // ToDo: navigate to next page after the page is implemented - controllers.verify.routes.ContractorEmailConfirmationNotStoredController.onPageLoad(NormalMode) - - case (Some(false), NormalMode) => - // ToDo: navigate to next page after the page is implemented - controllers.verify.routes.ContractorEmailConfirmationNotStoredController.onPageLoad(NormalMode) - case (Some(false), CheckMode) => - // ToDo: navigate CYA page after the page is implemented and implement the logic to handle dependent pages - routes.IndexController.onPageLoad() - - case _ => - routes.IndexController.onPageLoad() + case (Some(true), _) => controllers.verify.routes.EmailAddressController.onPageLoad(NormalMode) + case (Some(false), _) => controllers.verify.routes.VerifyCheckYourAnswersController.onPageLoad() + case _ => controllers.routes.JourneyRecoveryController.onPageLoad() } private def navigatorFromSelectSubcontractorPage(mode: Mode)(ua: UserAnswers): Call = { val _ = ua - controllers.verify.routes.SelectSubcontractorController.onPageLoad(mode) + mode match { + case NormalMode => controllers.verify.routes.ReverifyExistingSubcontractorsYesNoController.onPageLoad(NormalMode) + case CheckMode => controllers.verify.routes.VerifyCheckYourAnswersController.onPageLoad() + } } - private def navigatorFromContractorEmailConfirmationStoredPage(mode: Mode)(ua: UserAnswers): Call = - (ua.get(ContractorEmailConfirmationStoredPage), mode) match { - case (Some(CurrentEmail), _) => - // TODO: navigate to VF-06 Verify declaration once implemented + private def navigatorFromReverifyExistingSubcontractorsYesNoPage(mode: Mode)(ua: UserAnswers): Call = + (ua.get(ReverifyExistingSubcontractorsYesNoPage), mode) match { + case (Some(true), _) => + // TODO: navigate to VF-03c Subcontractors to reverify once implemented controllers.routes.JourneyRecoveryController.onPageLoad() - - case (Some(DifferentEmail), _) => - // TODO: navigate to SM-01b Enter alternate email once implemented - controllers.routes.JourneyRecoveryController.onPageLoad() - - case (Some(DoNotSend), _) => - // TODO: navigate to VF-06 Verify declaration once implemented + case (Some(false), NormalMode) => + val hasStoredEmail = ua + .get(NewestVerificationBatchResponsePage) + .flatMap(_.scheme.headOption) + .flatMap(_.emailAddress) + .isDefined + if (hasStoredEmail) controllers.verify.routes.ContractorEmailConfirmationStoredController.onPageLoad(NormalMode) + else controllers.verify.routes.ContractorEmailConfirmationNotStoredController.onPageLoad(NormalMode) + case (Some(false), CheckMode) => + controllers.verify.routes.VerifyCheckYourAnswersController.onPageLoad() + case _ => controllers.routes.JourneyRecoveryController.onPageLoad() + } - case _ => - controllers.routes.JourneyRecoveryController.onPageLoad() + private def navigatorFromContractorEmailConfirmationStoredPage(mode: Mode)(ua: UserAnswers): Call = + (ua.get(ContractorEmailConfirmationStoredPage), mode) match { + case (Some(CurrentEmail), _) => controllers.verify.routes.VerifyCheckYourAnswersController.onPageLoad() + case (Some(DifferentEmail), _) => controllers.verify.routes.EmailAddressController.onPageLoad(NormalMode) + case (Some(DoNotSend), _) => controllers.verify.routes.VerifyCheckYourAnswersController.onPageLoad() + case _ => controllers.routes.JourneyRecoveryController.onPageLoad() } } diff --git a/app/views/verify/VerifyCheckYourAnswersView.scala.html b/app/views/verify/VerifyCheckYourAnswersView.scala.html new file mode 100644 index 00000000..37744d25 --- /dev/null +++ b/app/views/verify/VerifyCheckYourAnswersView.scala.html @@ -0,0 +1,41 @@ +@* + * Copyright 2026 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *@ + +@import views.html.components._ + +@this( + layout: templates.Layout, + govukSummaryList: GovukSummaryList, + h1: H1, + h2: H2, + govukButton: GovukButton, + formHelper: FormWithCSRF +) + +@(list: SummaryList)(implicit request: Request[_], messages: Messages) + +@layout(pageTitle = titleNoForm(messages("verify.verifyCheckYourAnswers.title"))) { + + @formHelper(action = controllers.verify.routes.VerifyCheckYourAnswersController.onSubmit(), Symbol("autoComplete") -> "off") { + + @h1("verify.verifyCheckYourAnswers.heading") + @h2("verify.verifyCheckYourAnswers.subHeading") + + @govukSummaryList(list) + + @govukButton(ButtonViewModel(messages("verify.verifyCheckYourAnswers.confirm"))) + } +} diff --git a/conf/app.routes b/conf/app.routes index 277d23e8..ffe4c33a 100644 --- a/conf/app.routes +++ b/conf/app.routes @@ -350,51 +350,53 @@ POST /add/trust/check-your-answers controllers.add.trust.TrustCh GET /add/trust/subcontractor-added controllers.add.SubcontractorAddedController.trustSubcontractorAdded() # Verify -GET /verify/confirmation-email-not-stored controllers.verify.ContractorEmailConfirmationNotStoredController.onPageLoad(mode: Mode = NormalMode) -POST /verify/confirmation-email-not-stored controllers.verify.ContractorEmailConfirmationNotStoredController.onSubmit(mode: Mode = NormalMode) -GET /verify/change-confirmation-email-not-stored controllers.verify.ContractorEmailConfirmationNotStoredController.onPageLoad(mode: Mode = CheckMode) -POST /verify/change-confirmation-email-not-stored controllers.verify.ContractorEmailConfirmationNotStoredController.onSubmit(mode: Mode = CheckMode) +GET /verify/confirmation-email-not-stored controllers.verify.ContractorEmailConfirmationNotStoredController.onPageLoad(mode: Mode = NormalMode) +POST /verify/confirmation-email-not-stored controllers.verify.ContractorEmailConfirmationNotStoredController.onSubmit(mode: Mode = NormalMode) +GET /verify/change-confirmation-email-not-stored controllers.verify.ContractorEmailConfirmationNotStoredController.onPageLoad(mode: Mode = CheckMode) +POST /verify/change-confirmation-email-not-stored controllers.verify.ContractorEmailConfirmationNotStoredController.onSubmit(mode: Mode = CheckMode) -GET /verify/verification-declaration controllers.verify.VerificationDeclarationController.onPageLoad(mode: Mode = NormalMode) -POST /verify/verification-declaration controllers.verify.VerificationDeclarationController.onSubmit(mode: Mode = NormalMode) +GET /verify/verification-declaration controllers.verify.VerificationDeclarationController.onPageLoad(mode: Mode = NormalMode) +POST /verify/verification-declaration controllers.verify.VerificationDeclarationController.onSubmit(mode: Mode = NormalMode) -GET /verify/submitting-verification-request controllers.verify.SubmissionSendingController.onPageLoad() +GET /verify/submitting-verification-request controllers.verify.SubmissionSendingController.onPageLoad() -GET /verify/no-subcontractors-added controllers.verify.NoSubcontractorsAddedController.onPageLoad() +GET /verify/no-subcontractors-added controllers.verify.NoSubcontractorsAddedController.onPageLoad() -GET /verify/newest controllers.verify.NewestVerificationBatchController.onPageLoad() +GET /verify/newest controllers.verify.NewestVerificationBatchController.onPageLoad() -GET /verify/current controllers.verify.CurrentVerificationBatchController.onPageLoad() +GET /verify/current controllers.verify.CurrentVerificationBatchController.onPageLoad() -GET /verify/verification-request-in-progress controllers.verify.VerificationRequestInProgressController.onPageLoad() +GET /verify/verification-request-in-progress controllers.verify.VerificationRequestInProgressController.onPageLoad() -GET /verify/confirmation-email-stored controllers.verify.ContractorEmailConfirmationStoredController.onPageLoad(mode: Mode = NormalMode) -POST /verify/confirmation-email-stored controllers.verify.ContractorEmailConfirmationStoredController.onSubmit(mode: Mode = NormalMode) -GET /verify/change-confirmation-email-stored controllers.verify.ContractorEmailConfirmationStoredController.onPageLoad(mode: Mode = CheckMode) -POST /verify/change-confirmation-email-stored controllers.verify.ContractorEmailConfirmationStoredController.onSubmit(mode: Mode = CheckMode) +GET /verify/confirmation-email-stored controllers.verify.ContractorEmailConfirmationStoredController.onPageLoad(mode: Mode = NormalMode) +POST /verify/confirmation-email-stored controllers.verify.ContractorEmailConfirmationStoredController.onSubmit(mode: Mode = NormalMode) +GET /verify/change-confirmation-email-stored controllers.verify.ContractorEmailConfirmationStoredController.onPageLoad(mode: Mode = CheckMode) +POST /verify/change-confirmation-email-stored controllers.verify.ContractorEmailConfirmationStoredController.onSubmit(mode: Mode = CheckMode) +GET /verify/select-subcontractors-to-reverify controllers.verify.SelectSubcontractorsToReverifyController.onPageLoad(mode: Mode = NormalMode, page: Int ?= 1) +POST /verify/select-subcontractors-to-reverify controllers.verify.SelectSubcontractorsToReverifyController.onSubmit(mode: Mode = NormalMode, page: Int ?= 1) +GET /verify/change-select-subcontractors-to-reverify controllers.verify.SelectSubcontractorsToReverifyController.onPageLoad(mode: Mode = CheckMode, page: Int ?= 1) +POST /verify/change-select-subcontractors-to-reverify controllers.verify.SelectSubcontractorsToReverifyController.onSubmit(mode: Mode = CheckMode, page: Int ?= 1) -GET /verify/select-subcontractors-to-reverify controllers.verify.SelectSubcontractorsToReverifyController.onPageLoad(mode: Mode = NormalMode, page: Int ?= 1) -POST /verify/select-subcontractors-to-reverify controllers.verify.SelectSubcontractorsToReverifyController.onSubmit(mode: Mode = NormalMode, page: Int ?= 1) -GET /verify/change-select-subcontractors-to-reverify controllers.verify.SelectSubcontractorsToReverifyController.onPageLoad(mode: Mode = CheckMode, page: Int ?= 1) -POST /verify/change-select-subcontractors-to-reverify controllers.verify.SelectSubcontractorsToReverifyController.onSubmit(mode: Mode = CheckMode, page: Int ?= 1) +GET /verify/select-subcontractors-to-verify controllers.verify.SelectSubcontractorController.onPageLoad(mode: Mode = NormalMode, page: Int ?= 1) +POST /verify/select-subcontractors-to-verify controllers.verify.SelectSubcontractorController.onSubmit(mode: Mode = NormalMode, page: Int ?= 1) +GET /verify/change-select-subcontractors-to-verify controllers.verify.SelectSubcontractorController.onPageLoad(mode: Mode = CheckMode, page: Int ?= 1) +POST /verify/change-select-subcontractors-to-verify controllers.verify.SelectSubcontractorController.onSubmit(mode: Mode = CheckMode, page: Int ?= 1) -GET /verify/select-subcontractors-to-verify controllers.verify.SelectSubcontractorController.onPageLoad(mode: Mode = NormalMode, page: Int ?= 1) -POST /verify/select-subcontractors-to-verify controllers.verify.SelectSubcontractorController.onSubmit(mode: Mode = NormalMode, page: Int ?= 1) -GET /verify/change-select-subcontractors-to-verify controllers.verify.SelectSubcontractorController.onPageLoad(mode: Mode = CheckMode, page: Int ?= 1) -POST /verify/change-select-subcontractors-to-verify controllers.verify.SelectSubcontractorController.onSubmit(mode: Mode = CheckMode, page: Int ?= 1) - -GET /verify/enter-confirmation-email controllers.verify.EmailAddressController.onPageLoad(mode: Mode = NormalMode) -POST /verify/enter-confirmation-email controllers.verify.EmailAddressController.onSubmit(mode: Mode = NormalMode) -GET /verify/change-enter-confirmation-email controllers.verify.EmailAddressController.onPageLoad(mode: Mode = CheckMode) -POST /verify/change-enter-confirmation-email controllers.verify.EmailAddressController.onSubmit(mode: Mode = CheckMode) +GET /verify/enter-confirmation-email controllers.verify.EmailAddressController.onPageLoad(mode: Mode = NormalMode) +POST /verify/enter-confirmation-email controllers.verify.EmailAddressController.onSubmit(mode: Mode = NormalMode) +GET /verify/change-enter-confirmation-email controllers.verify.EmailAddressController.onPageLoad(mode: Mode = CheckMode) +POST /verify/change-enter-confirmation-email controllers.verify.EmailAddressController.onSubmit(mode: Mode = CheckMode) GET /verify/reverify-existing-subcontractors controllers.verify.ReverifyExistingSubcontractorsYesNoController.onPageLoad(mode: Mode = NormalMode) POST /verify/reverify-existing-subcontractors controllers.verify.ReverifyExistingSubcontractorsYesNoController.onSubmit(mode: Mode = NormalMode) GET /verify/change-reverify-existing-subcontractors controllers.verify.ReverifyExistingSubcontractorsYesNoController.onPageLoad(mode: Mode = CheckMode) POST /verify/change-reverify-existing-subcontractors controllers.verify.ReverifyExistingSubcontractorsYesNoController.onSubmit(mode: Mode = CheckMode) -GET /verify/no-new-subcontractors-to-verify controllers.verify.VerifyYourSubcontractorsYesNoController.onPageLoad -POST /verify/no-new-subcontractors-to-verify controllers.verify.VerifyYourSubcontractorsYesNoController.onSubmit +GET /verify/no-new-subcontractors-to-verify controllers.verify.VerifyYourSubcontractorsYesNoController.onPageLoad +POST /verify/no-new-subcontractors-to-verify controllers.verify.VerifyYourSubcontractorsYesNoController.onSubmit + +GET /verify/problem-with-verification-warning controllers.verify.VerifyDepartmentalErrorController.onPageLoad() -GET /verify/problem-with-verification-warning controllers.verify.VerifyDepartmentalErrorController.onPageLoad() +GET /verify/check-your-answers controllers.verify.VerifyCheckYourAnswersController.onPageLoad() +POST /verify/check-your-answers controllers.verify.VerifyCheckYourAnswersController.onSubmit() diff --git a/conf/messages.en b/conf/messages.en index a06ce4cc..ceb72b8e 100644 --- a/conf/messages.en +++ b/conf/messages.en @@ -833,26 +833,20 @@ verify.verificationRequestInProgress.p3 = if you hav verify.verificationRequestInProgress.p4 = Back to verify.verificationRequestInProgress.p4.link = Manage your subcontractors -verify.selectSubcontractorsToReverify.title = Which subcontractors do you want to reverify? -verify.selectSubcontractorsToReverify.heading = Which subcontractors do you want to reverify? -verify.selectSubcontractorsToReverify.hint = Select the existing subcontractors you want to include in this verification request -verify.selectSubcontractorsToReverify.checkYourAnswersLabel = Which subcontractors do you want to reverify? -verify.selectSubcontractorsToReverify.error.required = Select at least one subcontractor to verify -verify.selectSubcontractorsToReverify.change.hidden = select subcontractors to reverify +verify.selectSubcontractorsToReverify.title = Which subcontractors do you want to reverify? +verify.selectSubcontractorsToReverify.heading = Which subcontractors do you want to reverify? +verify.selectSubcontractorsToReverify.hint = Select the existing subcontractors you want to include in this verification request +verify.selectSubcontractorsToReverify.checkYourAnswersLabel = Which subcontractors do you want to reverify? +verify.selectSubcontractorsToReverify.error.required = Select at least one subcontractor to verify +verify.selectSubcontractorsToReverify.change.hidden = select subcontractors to reverify verify.selectSubcontractorsToReverify.showingResults = Showing {0} to {1} of {2} results - - -verify.selectSubcontractorsToReverify.include = Include -verify.selectSubcontractorsToReverify.name = Name -verify.selectSubcontractorsToReverify.utr = UTR -verify.selectSubcontractorsToReverify.verified = Verified -verify.selectSubcontractorsToReverify.verificationNumber = Verification number -verify.selectSubcontractorsToReverify.taxTreatment = Tax treatment -verify.selectSubcontractorsToReverify.dateAdded = Date added - -site.pagination.previous = Previous -site.pagination.next = Next -site.pagination.landmark = Pagination +verify.selectSubcontractorsToReverify.include = Include +verify.selectSubcontractorsToReverify.name = Name +verify.selectSubcontractorsToReverify.utr = UTR +verify.selectSubcontractorsToReverify.verified = Verified +verify.selectSubcontractorsToReverify.verificationNumber = Verification number +verify.selectSubcontractorsToReverify.taxTreatment = Tax treatment +verify.selectSubcontractorsToReverify.dateAdded = Date added verify.selectSubcontractor.title = Which subcontractors do you want to verify? verify.selectSubcontractor.heading = Which subcontractors do you want to verify? @@ -891,3 +885,8 @@ verify.verifyDepartmentalError.contactHMRC.p1 = for more h verify.verifyDepartmentalError.contactHMRC.p1.link = Contact HMRC by phone verify.verifyDepartmentalError.manageSubcontractors.p1 = Back to verify.verifyDepartmentalError.manageSubcontractors.p1.link = Manage your subcontractors + +verify.verifyCheckYourAnswers.title = Check your answers before submitting your verification request +verify.verifyCheckYourAnswers.heading = Check your answers before submitting your verification request +verify.verifyCheckYourAnswers.subHeading = Subcontractors to verify +verify.verifyCheckYourAnswers.confirm = Confirm and submit diff --git a/test/controllers/verify/VerifyCheckYourAnswersControllerSpec.scala b/test/controllers/verify/VerifyCheckYourAnswersControllerSpec.scala new file mode 100644 index 00000000..f87110b0 --- /dev/null +++ b/test/controllers/verify/VerifyCheckYourAnswersControllerSpec.scala @@ -0,0 +1,75 @@ +/* + * Copyright 2026 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package controllers.verify + +import base.SpecBase +import play.api.test.FakeRequest +import play.api.test.Helpers.* +import views.html.verify.VerifyCheckYourAnswersView + +class VerifyCheckYourAnswersControllerSpec extends SpecBase { + + private lazy val onPageLoadRoute = controllers.verify.routes.VerifyCheckYourAnswersController.onPageLoad().url + private lazy val onSubmitRoute = controllers.verify.routes.VerifyCheckYourAnswersController.onSubmit().url + + "VerifyCheckYourAnswersController" - { + + "onPageLoad" - { + + "must return OK and render the view" in { + val application = applicationBuilder(userAnswers = Some(emptyUserAnswers)).build() + running(application) { + val request = FakeRequest(GET, onPageLoadRoute) + val result = route(application, request).value + val view = application.injector.instanceOf[VerifyCheckYourAnswersView] + + status(result) mustEqual OK + contentAsString(result) mustEqual view( + viewmodels.govuk.summarylist.SummaryListViewModel(rows = Seq.empty) + )(request, messages(application)).toString + } + } + + "must redirect to Journey Recovery when there is no session data" in { + val application = applicationBuilder(userAnswers = None).build() + running(application) { + val request = FakeRequest(GET, onPageLoadRoute) + val result = route(application, request).value + + status(result) mustEqual SEE_OTHER + redirectLocation(result).value mustEqual controllers.routes.JourneyRecoveryController.onPageLoad().url + } + } + } + + "onSubmit" - { + + "must redirect to Submission Sending" in { + val application = applicationBuilder(userAnswers = Some(emptyUserAnswers)).build() + running(application) { + val request = FakeRequest(POST, onSubmitRoute) + val result = route(application, request).value + + status(result) mustEqual SEE_OTHER + redirectLocation(result).value mustEqual controllers.verify.routes.SubmissionSendingController + .onPageLoad() + .url + } + } + } + } +} diff --git a/test/navigation/verify/VerifyNavigatorSpec.scala b/test/navigation/verify/VerifyNavigatorSpec.scala index 98ced657..2edae004 100644 --- a/test/navigation/verify/VerifyNavigatorSpec.scala +++ b/test/navigation/verify/VerifyNavigatorSpec.scala @@ -18,10 +18,10 @@ package navigation.verify import base.SpecBase import controllers.routes -import models.{CheckMode, NormalMode, UserAnswers} -import org.scalactic.Prettifier.default -import pages.Page +import models.{CheckMode, ContractorScheme, NormalMode, UserAnswers} +import models.response.GetNewestVerificationBatchResponse import models.verify.ContractorEmailConfirmationStored +import pages.Page import pages.verify.* class VerifyNavigatorSpec extends SpecBase { @@ -29,6 +29,27 @@ class VerifyNavigatorSpec extends SpecBase { private val navigator = new VerifyNavigator() private lazy val journeyRecovery = routes.JourneyRecoveryController.onPageLoad() + private lazy val cya = controllers.verify.routes.VerifyCheckYourAnswersController.onPageLoad() + + private def batchResponseWithEmail(email: String): GetNewestVerificationBatchResponse = + GetNewestVerificationBatchResponse( + scheme = Some(ContractorScheme(accountsOfficeReference = None, emailAddress = Some(email))), + subcontractors = Seq.empty, + verificationBatch = None, + verifications = Seq.empty, + submission = None, + monthlyReturn = None + ) + + private val batchResponseNoEmail: GetNewestVerificationBatchResponse = + GetNewestVerificationBatchResponse( + scheme = Some(ContractorScheme(accountsOfficeReference = None, emailAddress = None)), + subcontractors = Seq.empty, + verificationBatch = None, + verifications = Seq.empty, + submission = None, + monthlyReturn = None + ) "VerifyNavigator" - { @@ -40,79 +61,108 @@ class VerifyNavigatorSpec extends SpecBase { navigator.nextPage(UnknownPage, NormalMode, UserAnswers("id")) mustBe journeyRecovery } - "must go from ContractorEmailConfirmationNotStoredPage to ContractorEmailConfirmationNotStoredController when answer is true" in { - val ua = emptyUserAnswers.setOrException(ContractorEmailConfirmationNotStoredPage, true) - - navigator.nextPage(ContractorEmailConfirmationNotStoredPage, NormalMode, ua) mustBe - controllers.verify.routes.ContractorEmailConfirmationNotStoredController.onPageLoad(NormalMode) + "ContractorEmailConfirmationNotStoredPage" - { + + "must go to EmailAddressController when answer is true" in { + val ua = emptyUserAnswers.setOrException(ContractorEmailConfirmationNotStoredPage, true) + navigator.nextPage(ContractorEmailConfirmationNotStoredPage, NormalMode, ua) mustBe + controllers.verify.routes.EmailAddressController.onPageLoad(NormalMode) + } + + "must go to VerifyCheckYourAnswers when answer is false" in { + val ua = emptyUserAnswers.setOrException(ContractorEmailConfirmationNotStoredPage, false) + navigator.nextPage(ContractorEmailConfirmationNotStoredPage, NormalMode, ua) mustBe cya + } + + "must go to JourneyRecovery when answer is not present" in { + navigator.nextPage( + ContractorEmailConfirmationNotStoredPage, + NormalMode, + emptyUserAnswers + ) mustBe journeyRecovery + } } - "must go from ContractorEmailConfirmationNotStoredPage to ContractorEmailConfirmationNotStoredController when answer is false" in { - val ua = emptyUserAnswers.setOrException(ContractorEmailConfirmationNotStoredPage, false) - - navigator.nextPage(ContractorEmailConfirmationNotStoredPage, NormalMode, ua) mustBe - controllers.verify.routes.ContractorEmailConfirmationNotStoredController.onPageLoad(NormalMode) - } + "SelectSubcontractorPage" - { - "must go from ContractorEmailConfirmationNotStoredPage to Index when answer is not present" in { - navigator.nextPage( - ContractorEmailConfirmationNotStoredPage, - NormalMode, - emptyUserAnswers - ) mustBe routes.IndexController.onPageLoad() + "must go to ReverifyExistingSubcontractorsYesNoController in NormalMode" in { + navigator.nextPage(SelectSubcontractorPage, NormalMode, emptyUserAnswers) mustBe + controllers.verify.routes.ReverifyExistingSubcontractorsYesNoController.onPageLoad(NormalMode) + } } - "must go from SelectSubcontractorPage to SelectSubcontractorController in NormalMode" in { - val ua = UserAnswers("id") - - val result = - navigator.nextPage(SelectSubcontractorPage, NormalMode, ua) - - result.url mustBe - controllers.verify.routes.SelectSubcontractorController - .onPageLoad(NormalMode) - .url + "ReverifyExistingSubcontractorsYesNoPage" - { + + "must go to JourneyRecovery when answer is true (VF-03c not yet implemented)" in { + val ua = emptyUserAnswers.setOrException(ReverifyExistingSubcontractorsYesNoPage, true) + navigator.nextPage(ReverifyExistingSubcontractorsYesNoPage, NormalMode, ua) mustBe journeyRecovery + } + + "must go to ContractorEmailConfirmationStoredController when answer is false and email is stored" in { + val ua = emptyUserAnswers + .setOrException(ReverifyExistingSubcontractorsYesNoPage, false) + .setOrException(NewestVerificationBatchResponsePage, batchResponseWithEmail("test@example.com")) + navigator.nextPage(ReverifyExistingSubcontractorsYesNoPage, NormalMode, ua) mustBe + controllers.verify.routes.ContractorEmailConfirmationStoredController.onPageLoad(NormalMode) + } + + "must go to ContractorEmailConfirmationNotStoredController when answer is false and no email is stored" in { + val ua = emptyUserAnswers + .setOrException(ReverifyExistingSubcontractorsYesNoPage, false) + .setOrException(NewestVerificationBatchResponsePage, batchResponseNoEmail) + navigator.nextPage(ReverifyExistingSubcontractorsYesNoPage, NormalMode, ua) mustBe + controllers.verify.routes.ContractorEmailConfirmationNotStoredController.onPageLoad(NormalMode) + } + + "must go to JourneyRecovery when answer is not present" in { + navigator.nextPage( + ReverifyExistingSubcontractorsYesNoPage, + NormalMode, + emptyUserAnswers + ) mustBe journeyRecovery + } } - "must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is CurrentEmail" in { - val ua = emptyUserAnswers.setOrException( - ContractorEmailConfirmationStoredPage, - ContractorEmailConfirmationStored.CurrentEmail - ) - navigator.nextPage(ContractorEmailConfirmationStoredPage, NormalMode, ua) mustBe journeyRecovery - } - - "must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is DifferentEmail" in { - val ua = emptyUserAnswers.setOrException( - ContractorEmailConfirmationStoredPage, - ContractorEmailConfirmationStored.DifferentEmail - ) - navigator.nextPage(ContractorEmailConfirmationStoredPage, NormalMode, ua) mustBe journeyRecovery - } - - "must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is DoNotSend" in { - val ua = emptyUserAnswers.setOrException( - ContractorEmailConfirmationStoredPage, - ContractorEmailConfirmationStored.DoNotSend - ) - navigator.nextPage(ContractorEmailConfirmationStoredPage, NormalMode, ua) mustBe journeyRecovery - } - - "must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is not present" in { - navigator.nextPage(ContractorEmailConfirmationStoredPage, NormalMode, emptyUserAnswers) mustBe journeyRecovery + "ContractorEmailConfirmationStoredPage" - { + + "must go to VerifyCheckYourAnswers when answer is CurrentEmail" in { + val ua = emptyUserAnswers.setOrException( + ContractorEmailConfirmationStoredPage, + ContractorEmailConfirmationStored.CurrentEmail + ) + navigator.nextPage(ContractorEmailConfirmationStoredPage, NormalMode, ua) mustBe cya + } + + "must go to EmailAddressController when answer is DifferentEmail" in { + val ua = emptyUserAnswers.setOrException( + ContractorEmailConfirmationStoredPage, + ContractorEmailConfirmationStored.DifferentEmail + ) + navigator.nextPage(ContractorEmailConfirmationStoredPage, NormalMode, ua) mustBe + controllers.verify.routes.EmailAddressController.onPageLoad(NormalMode) + } + + "must go to VerifyCheckYourAnswers when answer is DoNotSend" in { + val ua = emptyUserAnswers.setOrException( + ContractorEmailConfirmationStoredPage, + ContractorEmailConfirmationStored.DoNotSend + ) + navigator.nextPage(ContractorEmailConfirmationStoredPage, NormalMode, ua) mustBe cya + } + + "must go to JourneyRecovery when answer is not present" in { + navigator.nextPage(ContractorEmailConfirmationStoredPage, NormalMode, emptyUserAnswers) mustBe journeyRecovery + } } "must go from SelectSubcontractorsToReverifyPage to ContractorEmailConfirmationStoredController in NormalMode" in { - val result = navigator.nextPage(SelectSubcontractorsToReverifyPage, NormalMode, emptyUserAnswers) - result mustBe controllers.verify.routes.ContractorEmailConfirmationStoredController.onPageLoad(NormalMode) } - "must go from EmailAddressPage to next page" in { - val ua = emptyUserAnswers.set(EmailAddressPage, "test@test.com").success.value - navigator.nextPage(EmailAddressPage, NormalMode, ua) mustBe - controllers.verify.routes.EmailAddressController.onPageLoad(NormalMode) + "must go to VerifyCheckYourAnswers from EmailAddressPage in NormalMode" in { + val ua = emptyUserAnswers.setOrException(EmailAddressPage, "test@test.com") + navigator.nextPage(EmailAddressPage, NormalMode, ua) mustBe cya } } @@ -124,80 +174,96 @@ class VerifyNavigatorSpec extends SpecBase { navigator.nextPage(UnknownPage, CheckMode, UserAnswers("id")) mustBe journeyRecovery } - "must go from ContractorEmailConfirmationNotStoredPage to ContractorEmailConfirmationNotStoredController when answer is true" in { - val ua = emptyUserAnswers.setOrException(ContractorEmailConfirmationNotStoredPage, true) - - navigator.nextPage(ContractorEmailConfirmationNotStoredPage, CheckMode, ua) mustBe - controllers.verify.routes.ContractorEmailConfirmationNotStoredController.onPageLoad(NormalMode) - } - - "must go from ContractorEmailConfirmationNotStoredPage to Index when answer is false" in { - val ua = emptyUserAnswers.setOrException(ContractorEmailConfirmationNotStoredPage, false) - - navigator.nextPage(ContractorEmailConfirmationNotStoredPage, CheckMode, ua) mustBe - routes.IndexController.onPageLoad() - } - - "must go from ContractorEmailConfirmationNotStoredPage to Index when answer is not present" in { - navigator.nextPage( - ContractorEmailConfirmationNotStoredPage, - CheckMode, - emptyUserAnswers - ) mustBe routes.IndexController.onPageLoad() - } - - "must go from SelectSubcontractorPage to SelectSubcontractorController in CheckMode" in { - val ua = UserAnswers("id") - - val result = - navigator.nextPage(SelectSubcontractorPage, CheckMode, ua) - - result.url mustBe - controllers.verify.routes.SelectSubcontractorController - .onPageLoad(CheckMode) - .url + "ContractorEmailConfirmationNotStoredPage" - { + + "must go to EmailAddressController when answer is true" in { + val ua = emptyUserAnswers.setOrException(ContractorEmailConfirmationNotStoredPage, true) + navigator.nextPage(ContractorEmailConfirmationNotStoredPage, CheckMode, ua) mustBe + controllers.verify.routes.EmailAddressController.onPageLoad(NormalMode) + } + + "must go to VerifyCheckYourAnswers when answer is false" in { + val ua = emptyUserAnswers.setOrException(ContractorEmailConfirmationNotStoredPage, false) + navigator.nextPage(ContractorEmailConfirmationNotStoredPage, CheckMode, ua) mustBe cya + } + + "must go to JourneyRecovery when answer is not present" in { + navigator.nextPage( + ContractorEmailConfirmationNotStoredPage, + CheckMode, + emptyUserAnswers + ) mustBe journeyRecovery + } } - "must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is CurrentEmail" in { - val ua = emptyUserAnswers.setOrException( - ContractorEmailConfirmationStoredPage, - ContractorEmailConfirmationStored.CurrentEmail - ) - navigator.nextPage(ContractorEmailConfirmationStoredPage, CheckMode, ua) mustBe journeyRecovery - } + "SelectSubcontractorPage" - { - "must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is DifferentEmail" in { - val ua = emptyUserAnswers.setOrException( - ContractorEmailConfirmationStoredPage, - ContractorEmailConfirmationStored.DifferentEmail - ) - navigator.nextPage(ContractorEmailConfirmationStoredPage, CheckMode, ua) mustBe journeyRecovery + "must go to VerifyCheckYourAnswers in CheckMode" in { + navigator.nextPage(SelectSubcontractorPage, CheckMode, emptyUserAnswers) mustBe cya + } } - "must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is DoNotSend" in { - val ua = emptyUserAnswers.setOrException( - ContractorEmailConfirmationStoredPage, - ContractorEmailConfirmationStored.DoNotSend - ) - navigator.nextPage(ContractorEmailConfirmationStoredPage, CheckMode, ua) mustBe journeyRecovery + "ReverifyExistingSubcontractorsYesNoPage" - { + + "must go to JourneyRecovery when answer is true (VF-03c not yet implemented)" in { + val ua = emptyUserAnswers.setOrException(ReverifyExistingSubcontractorsYesNoPage, true) + navigator.nextPage(ReverifyExistingSubcontractorsYesNoPage, CheckMode, ua) mustBe journeyRecovery + } + + "must go to VerifyCheckYourAnswers when answer is false" in { + val ua = emptyUserAnswers.setOrException(ReverifyExistingSubcontractorsYesNoPage, false) + navigator.nextPage(ReverifyExistingSubcontractorsYesNoPage, CheckMode, ua) mustBe cya + } + + "must go to JourneyRecovery when answer is not present" in { + navigator.nextPage( + ReverifyExistingSubcontractorsYesNoPage, + CheckMode, + emptyUserAnswers + ) mustBe journeyRecovery + } } - "must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is not present" in { - navigator.nextPage(ContractorEmailConfirmationStoredPage, CheckMode, emptyUserAnswers) mustBe journeyRecovery + "ContractorEmailConfirmationStoredPage" - { + + "must go to VerifyCheckYourAnswers when answer is CurrentEmail" in { + val ua = emptyUserAnswers.setOrException( + ContractorEmailConfirmationStoredPage, + ContractorEmailConfirmationStored.CurrentEmail + ) + navigator.nextPage(ContractorEmailConfirmationStoredPage, CheckMode, ua) mustBe cya + } + + "must go to EmailAddressController when answer is DifferentEmail" in { + val ua = emptyUserAnswers.setOrException( + ContractorEmailConfirmationStoredPage, + ContractorEmailConfirmationStored.DifferentEmail + ) + navigator.nextPage(ContractorEmailConfirmationStoredPage, CheckMode, ua) mustBe + controllers.verify.routes.EmailAddressController.onPageLoad(NormalMode) + } + + "must go to VerifyCheckYourAnswers when answer is DoNotSend" in { + val ua = emptyUserAnswers.setOrException( + ContractorEmailConfirmationStoredPage, + ContractorEmailConfirmationStored.DoNotSend + ) + navigator.nextPage(ContractorEmailConfirmationStoredPage, CheckMode, ua) mustBe cya + } + + "must go to JourneyRecovery when answer is not present" in { + navigator.nextPage(ContractorEmailConfirmationStoredPage, CheckMode, emptyUserAnswers) mustBe journeyRecovery + } } "must go from SelectSubcontractorsToReverifyPage to ContractorEmailConfirmationStoredController in CheckMode" in { - val result = navigator.nextPage(SelectSubcontractorsToReverifyPage, CheckMode, emptyUserAnswers) - result mustBe controllers.verify.routes.ContractorEmailConfirmationStoredController.onPageLoad(CheckMode) } - "must go from EmailAddressPage to EmailAddressPage in CheckMode" in { - val ua = emptyUserAnswers.set(EmailAddressPage, "test@test.com").success.value - - navigator.nextPage(EmailAddressPage, CheckMode, ua) mustBe controllers.verify.routes.EmailAddressController - .onPageLoad(CheckMode) + "must go to VerifyCheckYourAnswers from EmailAddressPage in CheckMode" in { + val ua = emptyUserAnswers.setOrException(EmailAddressPage, "test@test.com") + navigator.nextPage(EmailAddressPage, CheckMode, ua) mustBe cya } } }