Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSR-1510 | Check Status Tag on Task List #932

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
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 @@ -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
Expand All @@ -54,46 +52,47 @@ 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"))
.unsafeSet(WhyDoesSchemeHoldLandPropertyPage(srn, indexOne), SchemeHoldLandProperty.Transfer)
.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"))
.unsafeSet(WhyDoesSchemeHoldLandPropertyPage(srn, indexTwo), SchemeHoldLandProperty.Transfer)
.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)
.unsafeSet(LandOrPropertyChosenAddressPage(srn, indexThree), address3)
.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 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 @@ -137,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(
Expand All @@ -153,14 +152,14 @@ class LandOrPropertyListControllerSpec extends ControllerBaseSpec {
isPrePop = true
)
)
}.withName("Completed PrePop Journey"))
}.withName("PrePop Journey - 1 added record, 1 PrePop record to Check"))

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 - 0 added records")
)

act.like(
Expand Down
40 changes: 12 additions & 28 deletions test/utils/nonsipp/TaskListStatusUtilsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -382,41 +382,25 @@ 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 = 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 (Recorded(2, "landOrProperties"), 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 customUserAnswers = currentUA

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

"when landOrPropertyHeldPage true and more first pages than last pages is present - index 1 is missing" in {
"should be Check" - {
"when at least 1 record requires checking and isPrePop" in {
val customUserAnswers = defaultUserAnswers
.unsafeSet(LandOrPropertyHeldPage(srn), true)
.unsafeSet(LandPropertyInUKPage(srn, refineMV(1)), true)
// missing here
.unsafeSet(LandPropertyInUKPage(srn, refineMV(2)), true)
.unsafeSet(LandOrPropertyCompleted(srn, index2of5000), SectionCompleted)

val result =
TaskListStatusUtils.getLandOrPropertyTaskListStatusAndLink(customUserAnswers, srn, isPrePop = false)
result mustBe (Recorded(1, "landOrProperties"), listPageUrl)
.unsafeSet(LandPropertyInUKPage(srn, index1of5000), true)
.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 = true)
result mustBe (Check, listPageUrl)
}
}
}
Expand Down