diff --git a/app/utils/nonsipp/TaskListStatusUtils.scala b/app/utils/nonsipp/TaskListStatusUtils.scala index 596c9e125..0a9e5f6f1 100644 --- a/app/utils/nonsipp/TaskListStatusUtils.scala +++ b/app/utils/nonsipp/TaskListStatusUtils.scala @@ -468,14 +468,11 @@ object TaskListStatusUtils { .url ) - val ifNeedsChecking = answersMissingLandOrPropertySection(userAnswers, srn) - - (wereLandOrPropertiesHeld, numRecorded, ifNeedsChecking) match { - case (_, _, true) => (Check, listPageUrl) // TODO: navigate to new list page - case (None, _, false) => (NotStarted, firstQuestionPageUrl) - case (Some(false), _, false) => (Recorded(0, ""), firstQuestionPageUrl) - case (Some(true), 0, false) => (InProgress, inProgressCalculatedUrl) - case (Some(true), _, false) => (Recorded(numRecorded, "landOrProperties"), listPageUrl) + (wereLandOrPropertiesHeld, numRecorded) match { + case (None, _) => (NotStarted, firstQuestionPageUrl) + case (Some(false), _) => (Recorded(0, ""), firstQuestionPageUrl) + case (Some(true), 0) => (InProgress, inProgressCalculatedUrl) + case (Some(true), _) => (Recorded(numRecorded, "landOrProperties"), listPageUrl) } } diff --git a/test/controllers/nonsipp/landorproperty/LandOrPropertyListControllerSpec.scala b/test/controllers/nonsipp/landorproperty/LandOrPropertyListControllerSpec.scala index cb7c2153d..9f08801c7 100644 --- a/test/controllers/nonsipp/landorproperty/LandOrPropertyListControllerSpec.scala +++ b/test/controllers/nonsipp/landorproperty/LandOrPropertyListControllerSpec.scala @@ -26,8 +26,6 @@ import eu.timepit.refined.refineMV import pages.nonsipp.{CompilationOrSubmissionDatePage, FbVersionPage} import forms.YesNoPageFormProvider import models._ -import pages.nonsipp.common.{IdentityTypePage, OtherRecipientDetailsPage} -import models.IdentitySubject.LandOrPropertySeller import viewmodels.models.SectionCompleted import eu.timepit.refined.api.Refined import org.mockito.ArgumentMatchers.any @@ -54,6 +52,8 @@ class LandOrPropertyListControllerSpec extends ControllerBaseSpec { ) private val completedUserAnswers = defaultUserAnswers + .unsafeSet(LandOrPropertyHeldPage(srn), true) + // LOP 1 - Completed .unsafeSet(LandPropertyInUKPage(srn, indexOne), true) .unsafeSet(LandOrPropertyChosenAddressPage(srn, indexOne), address1) .unsafeSet(LandRegistryTitleNumberPage(srn, indexOne), ConditionalYesNo.yes[String, String]("some-number")) @@ -61,11 +61,11 @@ class LandOrPropertyListControllerSpec extends ControllerBaseSpec { .unsafeSet(LandOrPropertyTotalCostPage(srn, indexOne), money) .unsafeSet(IsLandOrPropertyResidentialPage(srn, indexOne), true) .unsafeSet(IsLandPropertyLeasedPage(srn, indexOne), true) - .unsafeSet(LandOrPropertySellerConnectedPartyPage(srn, indexOne), true) .unsafeSet(LandOrPropertyLeaseDetailsPage(srn, indexOne), (leaseName, money, localDate)) .unsafeSet(IsLesseeConnectedPartyPage(srn, indexOne), true) .unsafeSet(LandOrPropertyTotalIncomePage(srn, indexOne), money) .unsafeSet(LandOrPropertyCompleted(srn, indexOne), SectionCompleted) + // LOP 2 - Completed then Removed .unsafeSet(LandPropertyInUKPage(srn, indexTwo), true) .unsafeSet(LandOrPropertyChosenAddressPage(srn, indexTwo), address2) .unsafeSet(LandRegistryTitleNumberPage(srn, indexTwo), ConditionalYesNo.yes[String, String]("some-number")) @@ -73,12 +73,11 @@ class LandOrPropertyListControllerSpec extends ControllerBaseSpec { .unsafeSet(LandOrPropertyTotalCostPage(srn, indexTwo), money) .unsafeSet(IsLandOrPropertyResidentialPage(srn, indexTwo), true) .unsafeSet(IsLandPropertyLeasedPage(srn, indexTwo), true) - .unsafeSet(LandOrPropertySellerConnectedPartyPage(srn, indexTwo), true) .unsafeSet(LandOrPropertyLeaseDetailsPage(srn, indexTwo), (leaseName, money, localDate)) .unsafeSet(IsLesseeConnectedPartyPage(srn, indexTwo), true) .unsafeSet(LandOrPropertyTotalIncomePage(srn, indexTwo), money) + .unsafeSet(LandOrPropertyCompleted(srn, indexTwo), SectionCompleted) .unsafeSet(RemovePropertyPage(srn, indexTwo), true) - .unsafeSet(LandOrPropertyHeldPage(srn), true) private val completedUserAnswersToCheck = completedUserAnswers .unsafeSet(LandPropertyInUKPage(srn, indexThree), true) @@ -86,16 +85,12 @@ class LandOrPropertyListControllerSpec extends ControllerBaseSpec { .unsafeSet(LandRegistryTitleNumberPage(srn, indexThree), ConditionalYesNo.yes[String, String]("some-number")) .unsafeSet(WhyDoesSchemeHoldLandPropertyPage(srn, indexThree), SchemeHoldLandProperty.Transfer) .unsafeSet(LandOrPropertyTotalCostPage(srn, indexThree), money) - .unsafeSet(IdentityTypePage(srn, indexThree, LandOrPropertySeller), IdentityType.Other) - .unsafeSet(OtherRecipientDetailsPage(srn, indexThree, LandOrPropertySeller), otherRecipientDetails) private val noUserAnswers = defaultUserAnswers .unsafeSet(LandOrPropertyHeldPage(srn), false) .unsafeSet(FbVersionPage(srn), "002") .unsafeSet(CompilationOrSubmissionDatePage(srn), submissionDateTwo) - private val checkUserAnswers = completedUserAnswers.unsafeRemove(LandOrPropertyCompleted(srn, indexOne)) - private val inProgressUserAnswers = defaultUserAnswers.unsafeSet(LandOrPropertyHeldPage(srn), true) private lazy val onPageLoad = routes.LandOrPropertyListController.onPageLoad(srn, page = 1, NormalMode) @@ -141,7 +136,7 @@ class LandOrPropertyListControllerSpec extends ControllerBaseSpec { isPrePop = false ) ) - }.withName("Completed Journey")) + }.withName("Completed Journey - 1 added record")) act.like(renderViewWithPrePopSession(onPageLoad, completedUserAnswersToCheck) { implicit app => implicit request => injected[ListView].apply( @@ -157,28 +152,14 @@ class LandOrPropertyListControllerSpec extends ControllerBaseSpec { isPrePop = true ) ) - }.withName("Completed PrePop Journey")) - - act.like(renderView(onPageLoad, checkUserAnswers) { implicit app => implicit request => - injected[ListView].apply( - form(new YesNoPageFormProvider()), - viewModel( - srn, - 1, - NormalMode, - addresses, - schemeName, - showBackLink = true - ) - ) - }.withName("Check Journey")) + }.withName("PrePop Journey - 1 added record, 1 PrePop record to Check")) act.like( redirectToPage( onPageLoad, controllers.nonsipp.landorproperty.routes.LandOrPropertyHeldController.onPageLoad(srn, NormalMode), inProgressUserAnswers - ).withName("In Progress Journey") + ).withName("In Progress Journey - 0 added records") ) act.like( diff --git a/test/utils/nonsipp/TaskListStatusUtilsSpec.scala b/test/utils/nonsipp/TaskListStatusUtilsSpec.scala index f15eaa0a1..41fa930e7 100644 --- a/test/utils/nonsipp/TaskListStatusUtilsSpec.scala +++ b/test/utils/nonsipp/TaskListStatusUtilsSpec.scala @@ -360,6 +360,16 @@ class TaskListStatusUtilsSpec extends AnyFreeSpec with Matchers with OptionValue TaskListStatusUtils.getLandOrPropertyTaskListStatusAndLink(customUserAnswers, srn, isPrePop = false) result mustBe (InProgress, firstQuestionPageUrl) } + + "when landOrPropertyHeldPage true and only first page is present" in { + val customUserAnswers = defaultUserAnswers + .unsafeSet(LandOrPropertyHeldPage(srn), true) + .unsafeSet(LandPropertyInUKPages(srn), Map("0" -> true)) + + val result = + TaskListStatusUtils.getLandOrPropertyTaskListStatusAndLink(customUserAnswers, srn, isPrePop = false) + result mustBe (InProgress, secondQuestionPageUrl(index1of5000)) + } } "should be Recorded" - { @@ -374,55 +384,22 @@ class TaskListStatusUtilsSpec extends AnyFreeSpec with Matchers with OptionValue "when landOrPropertyHeldPage true and equal number of first pages and last pages are present" in { val customUserAnswers = currentUA - val result = TaskListStatusUtils.getLandOrPropertyTaskListStatusAndLink(customUserAnswers, srn) + val result = + TaskListStatusUtils.getLandOrPropertyTaskListStatusAndLink(customUserAnswers, srn, isPrePop = false) result mustBe (Recorded(1, "landOrProperties"), listPageUrl) } } "should be Check" - { - "when landOrPropertyHeldPage true and only first page is present" in { + "when at least 1 record requires checking and isPrePop" in { val customUserAnswers = defaultUserAnswers - .unsafeSet(LandOrPropertyHeldPage(srn), true) - .unsafeSet(LandPropertyInUKPage(srn, refineMV(1)), true) - .unsafeSet(LandOrPropertyCompleted(srn, index1of5000), SectionCompleted) - .unsafeSet(LandPropertyInUKPage(srn, refineMV(2)), true) - .unsafeSet(LandOrPropertyCompleted(srn, index2of5000), SectionCompleted) - - val result = - TaskListStatusUtils.getLandOrPropertyTaskListStatusAndLink(customUserAnswers, srn, isPrePop = false) - result mustBe (Check, listPageUrl) - } - - "when landOrPropertyHeldPage true and more first pages than last pages is present - index 2 is missing" in { - val customUserAnswers = defaultUserAnswers - .unsafeSet(LandOrPropertyHeldPage(srn), true) - .unsafeSet(LandPropertyInUKPage(srn, refineMV(1)), true) - .unsafeSet(LandOrPropertyCompleted(srn, index1of5000), SectionCompleted) - .unsafeSet(LandPropertyInUKPage(srn, refineMV(2)), true) - - val result = - TaskListStatusUtils.getLandOrPropertyTaskListStatusAndLink(customUserAnswers, srn, isPrePop = false) - result mustBe (Check, listPageUrl) - } - - "when landOrPropertyHeldPage true and more first pages than last pages is present - index 1 is missing" in { - val customUserAnswers = defaultUserAnswers - .unsafeSet(LandOrPropertyHeldPage(srn), true) .unsafeSet(LandPropertyInUKPage(srn, index1of5000), true) - // missing here - .unsafeSet(LandPropertyInUKPage(srn, index2of5000), true) - .unsafeSet(LandOrPropertyChosenAddressPage(srn, index2of5000), address) - .unsafeSet(LandRegistryTitleNumberPage(srn, index2of5000), ConditionalYesNo.no[String, String](reason)) - .unsafeSet(WhyDoesSchemeHoldLandPropertyPage(srn, index2of5000), SchemeHoldLandProperty.Transfer) - .unsafeSet(LandOrPropertyTotalCostPage(srn, index2of5000), money) - .unsafeSet(IsLandOrPropertyResidentialPage(srn, index2of5000), false) - .unsafeSet(IsLandPropertyLeasedPage(srn, index2of5000), false) - .unsafeSet(LandOrPropertyTotalIncomePage(srn, index2of5000), money) - .unsafeSet(LandOrPropertyCompleted(srn, index2of5000), SectionCompleted) - .unsafeSet(LandPropertyIndependentValuationPage(srn, index2of5000), false) + .unsafeSet(LandOrPropertyChosenAddressPage(srn, index1of5000), address) + .unsafeSet(LandRegistryTitleNumberPage(srn, index1of5000), ConditionalYesNo.no[String, String](reason)) + .unsafeSet(WhyDoesSchemeHoldLandPropertyPage(srn, index1of5000), SchemeHoldLandProperty.Transfer) + .unsafeSet(LandOrPropertyTotalCostPage(srn, index1of5000), money) - val result = - TaskListStatusUtils.getLandOrPropertyTaskListStatusAndLink(customUserAnswers, srn, isPrePop = false) + val result = TaskListStatusUtils.getLandOrPropertyTaskListStatusAndLink(customUserAnswers, srn, isPrePop = true) result mustBe (Check, listPageUrl) } }