Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions app/navigation/verify/VerifyNavigator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package navigation.verify

import controllers.routes
import jakarta.inject.Singleton
import models.{CheckMode, Mode, NormalMode, UserAnswers}
import navigation.NavigatorForJourney
Expand Down Expand Up @@ -65,19 +64,15 @@ class VerifyNavigator @Inject() () extends NavigatorForJourney {

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 (Some(true), m) =>
controllers.verify.routes.EmailAddressController.onPageLoad(m)

case (Some(false), _) =>
controllers.verify.routes.VerificationDeclarationController.onPageLoad()

case _ =>
routes.IndexController.onPageLoad()
controllers.routes.JourneyRecoveryController.onPageLoad()
}

private def navigatorFromSelectSubcontractorPage(mode: Mode)(ua: UserAnswers): Call = {
Expand All @@ -87,20 +82,17 @@ class VerifyNavigator @Inject() () extends NavigatorForJourney {

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
controllers.routes.JourneyRecoveryController.onPageLoad()
controllers.verify.routes.VerificationDeclarationController.onPageLoad()

case (Some(DifferentEmail), _) =>
// TODO: navigate to SM-01b Enter alternate email once implemented
controllers.routes.JourneyRecoveryController.onPageLoad()
case (Some(DifferentEmail), m) =>
controllers.verify.routes.EmailAddressController.onPageLoad(m)

case (Some(DoNotSend), _) =>
// TODO: navigate to VF-06 Verify declaration once implemented
controllers.routes.JourneyRecoveryController.onPageLoad()
controllers.verify.routes.VerificationDeclarationController.onPageLoad()

case _ =>
controllers.routes.JourneyRecoveryController.onPageLoad()
}

}
57 changes: 33 additions & 24 deletions test/navigation/verify/VerifyNavigatorSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@ class VerifyNavigatorSpec extends SpecBase {
navigator.nextPage(UnknownPage, NormalMode, UserAnswers("id")) mustBe journeyRecovery
}

"must go from ContractorEmailConfirmationNotStoredPage to ContractorEmailConfirmationNotStoredController when answer is true" in {
"must go from ContractorEmailConfirmationNotStoredPage to EmailAddressController when answer is true" in {
val ua = emptyUserAnswers.setOrException(ContractorEmailConfirmationNotStoredPage, true)

navigator.nextPage(ContractorEmailConfirmationNotStoredPage, NormalMode, ua) mustBe
controllers.verify.routes.ContractorEmailConfirmationNotStoredController.onPageLoad(NormalMode)
controllers.verify.routes.EmailAddressController.onPageLoad(NormalMode)
}

"must go from ContractorEmailConfirmationNotStoredPage to ContractorEmailConfirmationNotStoredController when answer is false" in {
"must go from ContractorEmailConfirmationNotStoredPage to VerificationDeclarationController when answer is false" in {
val ua = emptyUserAnswers.setOrException(ContractorEmailConfirmationNotStoredPage, false)

navigator.nextPage(ContractorEmailConfirmationNotStoredPage, NormalMode, ua) mustBe
controllers.verify.routes.ContractorEmailConfirmationNotStoredController.onPageLoad(NormalMode)
controllers.verify.routes.VerificationDeclarationController.onPageLoad()
}

"must go from ContractorEmailConfirmationNotStoredPage to Index when answer is not present" in {
"must go from ContractorEmailConfirmationNotStoredPage to JourneyRecovery when answer is not present" in {
navigator.nextPage(
ContractorEmailConfirmationNotStoredPage,
NormalMode,
emptyUserAnswers
) mustBe routes.IndexController.onPageLoad()
) mustBe journeyRecovery
}

"must go from SelectSubcontractorPage to SelectSubcontractorController in NormalMode" in {
Expand All @@ -74,28 +74,34 @@ class VerifyNavigatorSpec extends SpecBase {
.url
}

"must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is CurrentEmail" in {
"must go from ContractorEmailConfirmationStoredPage to VerificationDeclarationController when answer is CurrentEmail" in {
val ua = emptyUserAnswers.setOrException(
ContractorEmailConfirmationStoredPage,
ContractorEmailConfirmationStored.CurrentEmail
)
navigator.nextPage(ContractorEmailConfirmationStoredPage, NormalMode, ua) mustBe journeyRecovery

navigator.nextPage(ContractorEmailConfirmationStoredPage, NormalMode, ua) mustBe
controllers.verify.routes.VerificationDeclarationController.onPageLoad()
}

"must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is DifferentEmail" in {
"must go from ContractorEmailConfirmationStoredPage to EmailAddressController when answer is DifferentEmail" in {
val ua = emptyUserAnswers.setOrException(
ContractorEmailConfirmationStoredPage,
ContractorEmailConfirmationStored.DifferentEmail
)
navigator.nextPage(ContractorEmailConfirmationStoredPage, NormalMode, ua) mustBe journeyRecovery

navigator.nextPage(ContractorEmailConfirmationStoredPage, NormalMode, ua) mustBe
controllers.verify.routes.EmailAddressController.onPageLoad(NormalMode)
}

"must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is DoNotSend" in {
"must go from ContractorEmailConfirmationStoredPage to VerificationDeclarationController when answer is DoNotSend" in {
val ua = emptyUserAnswers.setOrException(
ContractorEmailConfirmationStoredPage,
ContractorEmailConfirmationStored.DoNotSend
)
navigator.nextPage(ContractorEmailConfirmationStoredPage, NormalMode, ua) mustBe journeyRecovery

navigator.nextPage(ContractorEmailConfirmationStoredPage, NormalMode, ua) mustBe
controllers.verify.routes.VerificationDeclarationController.onPageLoad()
}

"must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is not present" in {
Expand All @@ -117,26 +123,26 @@ class VerifyNavigatorSpec extends SpecBase {
navigator.nextPage(UnknownPage, CheckMode, UserAnswers("id")) mustBe journeyRecovery
}

"must go from ContractorEmailConfirmationNotStoredPage to ContractorEmailConfirmationNotStoredController when answer is true" in {
"must go from ContractorEmailConfirmationNotStoredPage to EmailAddressController when answer is true" in {
val ua = emptyUserAnswers.setOrException(ContractorEmailConfirmationNotStoredPage, true)

navigator.nextPage(ContractorEmailConfirmationNotStoredPage, CheckMode, ua) mustBe
controllers.verify.routes.ContractorEmailConfirmationNotStoredController.onPageLoad(NormalMode)
controllers.verify.routes.EmailAddressController.onPageLoad(CheckMode)
}

"must go from ContractorEmailConfirmationNotStoredPage to Index when answer is false" in {
"must go from ContractorEmailConfirmationNotStoredPage to VerificationDeclarationController when answer is false" in {
val ua = emptyUserAnswers.setOrException(ContractorEmailConfirmationNotStoredPage, false)

navigator.nextPage(ContractorEmailConfirmationNotStoredPage, CheckMode, ua) mustBe
routes.IndexController.onPageLoad()
controllers.verify.routes.VerificationDeclarationController.onPageLoad()
}

"must go from ContractorEmailConfirmationNotStoredPage to Index when answer is not present" in {
"must go from ContractorEmailConfirmationNotStoredPage to JourneyRecovery when answer is not present" in {
navigator.nextPage(
ContractorEmailConfirmationNotStoredPage,
CheckMode,
emptyUserAnswers
) mustBe routes.IndexController.onPageLoad()
) mustBe journeyRecovery
}

"must go from SelectSubcontractorPage to SelectSubcontractorController in CheckMode" in {
Expand All @@ -151,28 +157,31 @@ class VerifyNavigatorSpec extends SpecBase {
.url
}

"must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is CurrentEmail" in {
"must go from ContractorEmailConfirmationStoredPage to VerificationDeclarationpage when answer is CurrentEmail" in {
val ua = emptyUserAnswers.setOrException(
ContractorEmailConfirmationStoredPage,
ContractorEmailConfirmationStored.CurrentEmail
)
navigator.nextPage(ContractorEmailConfirmationStoredPage, CheckMode, ua) mustBe journeyRecovery
navigator.nextPage(ContractorEmailConfirmationStoredPage, CheckMode, ua) mustBe
controllers.verify.routes.VerificationDeclarationController.onPageLoad()
}

"must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is DifferentEmail" in {
"must go from ContractorEmailConfirmationStoredPage to JEmailAddressPage when answer is DifferentEmail" in {
val ua = emptyUserAnswers.setOrException(
ContractorEmailConfirmationStoredPage,
ContractorEmailConfirmationStored.DifferentEmail
)
navigator.nextPage(ContractorEmailConfirmationStoredPage, CheckMode, ua) mustBe journeyRecovery
navigator.nextPage(ContractorEmailConfirmationStoredPage, CheckMode, ua) mustBe
controllers.verify.routes.EmailAddressController.onPageLoad(CheckMode)
}

"must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is DoNotSend" in {
"must go from ContractorEmailConfirmationStoredPage to VerificationDeclarationPage when answer is DoNotSend" in {
val ua = emptyUserAnswers.setOrException(
ContractorEmailConfirmationStoredPage,
ContractorEmailConfirmationStored.DoNotSend
)
navigator.nextPage(ContractorEmailConfirmationStoredPage, CheckMode, ua) mustBe journeyRecovery
navigator.nextPage(ContractorEmailConfirmationStoredPage, CheckMode, ua) mustBe
controllers.verify.routes.VerificationDeclarationController.onPageLoad()
}

"must go from ContractorEmailConfirmationStoredPage to JourneyRecovery when answer is not present" in {
Expand Down