Skip to content

Commit

Permalink
PSR-1510_Check-Status | Implement Check Status
Browse files Browse the repository at this point in the history
  • Loading branch information
ccatosdevelopment committed Dec 11, 2024
1 parent b0564a6 commit 86f15e3
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 23 deletions.
13 changes: 8 additions & 5 deletions app/utils/nonsipp/TaskListStatusUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,14 @@ object TaskListStatusUtils {
.url
)

(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)
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)
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/utils/nonsipp/TaskListUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,9 @@ object TaskListUtils {
val numSectionsUnableToStart = items.count(_.status == UnableToStart)
val numSectionsNotStarted = items.count(_.status == NotStarted)
val numSectionsInProgress = items.count(_.status == InProgress)
val numSectionsCheck = items.count(_.status == Check)
val numSectionsReadyForSubmission =
numSectionsTotal - (numSectionsUnableToStart + numSectionsNotStarted + numSectionsInProgress)
numSectionsTotal - (numSectionsUnableToStart + numSectionsNotStarted + numSectionsInProgress + numSectionsCheck)

(numSectionsReadyForSubmission, numSectionsTotal)
}
Expand Down
11 changes: 11 additions & 0 deletions app/views/components/TaskListItems.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@
</strong>
</span>
</li>
} else if(item.status == Check) {
<li class="govuk-task-list__item govuk-task-list__item--with-link">
<span class="govuk-task-list__name-and-hint">
@renderMessage(item.link.withAttr("aria-describedby", id).withAttr("class", "govuk-task-list__link"))
</span>
<span class="govuk-task-list__status" id="@id">
<strong class="govuk-tag govuk-tag--yellow">
@renderMessage(item.status.description)
</strong>
</span>
</li>
} else {
<li class="govuk-task-list__item govuk-task-list__item--with-link">
<span class="govuk-task-list__name-and-hint">
Expand Down
1 change: 1 addition & 0 deletions conf/messages.en
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ tasklist.recorded = Recorded
tasklist.check = Check
tasklist.noneRecorded = None recorded
tasklist.numItems = {0} {1}
tasklist.check = Check

members.singular = member
members.plural = members
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ class LandOrPropertyListControllerSpec extends ControllerBaseSpec {
.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)
private lazy val onSubmit = routes.LandOrPropertyListController.onSubmit(srn, page = 1, NormalMode)
private lazy val onLandOrPropertyHeldPageLoad = routes.LandOrPropertyHeldController.onPageLoad(srn, NormalMode)
Expand Down Expand Up @@ -155,12 +159,26 @@ class LandOrPropertyListControllerSpec extends ControllerBaseSpec {
)
}.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"))

act.like(
redirectToPage(
onPageLoad,
controllers.nonsipp.landorproperty.routes.LandOrPropertyHeldController.onPageLoad(srn, NormalMode),
completedUserAnswers.remove(LandOrPropertyCompleted(srn, indexOne)).get
).withName("Incomplete Journey")
inProgressUserAnswers
).withName("In Progress Journey")
)

act.like(
Expand Down
37 changes: 22 additions & 15 deletions test/utils/nonsipp/TaskListStatusUtilsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -360,16 +360,6 @@ 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" - {
Expand All @@ -382,6 +372,15 @@ 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)
result mustBe (Recorded(1, "landOrProperties"), listPageUrl)
}
}

"should be Check" - {
"when landOrPropertyHeldPage true and only first page is present" in {
val customUserAnswers = defaultUserAnswers
.unsafeSet(LandOrPropertyHeldPage(srn), true)
.unsafeSet(LandPropertyInUKPage(srn, refineMV(1)), true)
Expand All @@ -391,7 +390,7 @@ class TaskListStatusUtilsSpec extends AnyFreeSpec with Matchers with OptionValue

val result =
TaskListStatusUtils.getLandOrPropertyTaskListStatusAndLink(customUserAnswers, srn, isPrePop = false)
result mustBe (Recorded(2, "landOrProperties"), listPageUrl)
result mustBe (Check, listPageUrl)
}

"when landOrPropertyHeldPage true and more first pages than last pages is present - index 2 is missing" in {
Expand All @@ -403,20 +402,28 @@ class TaskListStatusUtilsSpec extends AnyFreeSpec with Matchers with OptionValue

val result =
TaskListStatusUtils.getLandOrPropertyTaskListStatusAndLink(customUserAnswers, srn, isPrePop = false)
result mustBe (Recorded(1, "landOrProperties"), listPageUrl)
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, refineMV(1)), true)
.unsafeSet(LandPropertyInUKPage(srn, index1of5000), true)
// missing here
.unsafeSet(LandPropertyInUKPage(srn, refineMV(2)), true)
.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)

val result =
TaskListStatusUtils.getLandOrPropertyTaskListStatusAndLink(customUserAnswers, srn, isPrePop = false)
result mustBe (Recorded(1, "landOrProperties"), listPageUrl)
result mustBe (Check, listPageUrl)
}
}
}
Expand Down

0 comments on commit 86f15e3

Please sign in to comment.