Skip to content

Commit

Permalink
update to handle scenario where we would have NL account with multipl…
Browse files Browse the repository at this point in the history
…e levy reservations (transfers) and has 2 draft apprenticeships in a single draft cohort
  • Loading branch information
cofaulco committed Jul 6, 2022
1 parent e1fe95e commit acc0ab5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ArrangeNonLevyPanelViewCustomisation : ICustomization
public void Customize(IFixture fixture)
{
fixture.Customize<PanelViewModel<AccountDashboardViewModel>>(composer => composer
.With(panel => panel.ViewName, string.Empty));
.With(panel => panel.ViewName, "Empty"));
fixture.Customize<AccountDashboardViewModel>(composer => composer
.With(dash => dash.ApprenticeshipEmployerType, ApprenticeshipEmployerType.NonLevy)
.With(dash => dash.PendingAgreements, new List<PendingAgreementsViewModel>()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Orchestrators.EmployerTeamOrche
{
public class WhenGettingCallToActionViewName
{
const string EmptyViewName = "Empty";

[Test, RecursiveMoqAutoData]
public void WhenMultipleReservation_ThenShouldGetCheckFundingViewNameNotDisplayCallToAction(
[NonLevyPanelView] PanelViewModel<AccountDashboardViewModel> panelViewModel,
Expand All @@ -26,7 +28,7 @@ public void WhenMultipleReservation_ThenShouldGetCheckFundingViewNameNotDisplayC
sut.GetCallToActionViewName(panelViewModel);

//Assert
panelViewModel.ViewName.Should().BeNullOrEmpty();
panelViewModel.ViewName.Should().Be(EmptyViewName);
}

[Test, RecursiveMoqAutoData]
Expand All @@ -43,7 +45,7 @@ public void WhenMultipleCohorts_ThenShouldGetCheckFundingViewNameNotDisplayCallT
sut.GetCallToActionViewName(panelViewModel);

//Assert
panelViewModel.ViewName.Should().BeNullOrEmpty();
panelViewModel.ViewName.Should().Be(EmptyViewName);
}

[Test, RecursiveMoqAutoData]
Expand All @@ -69,7 +71,7 @@ public void WhenMultipleApprenticeshipsWithinASingleCohort_ThenShouldGetCheckFun
sut.GetCallToActionViewName(panelViewModel);

//Assert
panelViewModel.ViewName.Should().BeNullOrEmpty();
panelViewModel.ViewName.Should().Be(EmptyViewName);
}

[Test, RecursiveMoqAutoData]
Expand All @@ -86,7 +88,7 @@ public void WhenMultipleVacancies_ThenShouldGetCheckFundingViewNameNotDisplayCal
sut.GetCallToActionViewName(panelViewModel);

//Assert
panelViewModel.ViewName.Should().BeNullOrEmpty();
panelViewModel.ViewName.Should().Be(EmptyViewName);
}

[Test, RecursiveMoqAutoData]
Expand Down Expand Up @@ -117,7 +119,7 @@ public void WhenNoData_ThenDoNotSetCallToActionViewName(
sut.GetCallToActionViewName(panelViewModel);

//Assert
panelViewModel.ViewName.Should().BeNullOrEmpty();
panelViewModel.ViewName.Should().Be(EmptyViewName);
}

[Test, RecursiveMoqAutoData]
Expand All @@ -132,7 +134,7 @@ public void WhenLevy_IgnoreCallToActionRules(
sut.GetCallToActionViewName(panelViewModel);

//Assert
panelViewModel.ViewName.Should().BeNullOrEmpty();
panelViewModel.ViewName.Should().Be(EmptyViewName);
}

[Test, RecursiveMoqAutoData]
Expand Down Expand Up @@ -247,6 +249,31 @@ public void WhenSingleReservationAndApprenticeship_ThenShouldGetSingleApprentice
panelViewModel.ViewName.Should().Be("SingleApprenticeshipReadyForReview");
}

[Test, RecursiveMoqAutoData]
public void WhenNoReservationAndCohortWithMultipleDraftApprenticeships_ThenShouldNotSetViewName(
CohortViewModel singleCohort,
Reservation singleReservation,
List<ApprenticeshipViewModel> apprenticeships,
[NonLevyPanelView] PanelViewModel<AccountDashboardViewModel> panelViewModel,
EmployerTeamOrchestrator sut)
{
// Arrange
singleCohort.Apprenticeships = new List<ApprenticeshipViewModel>();
singleCohort.CohortStatus = CohortStatus.WithTrainingProvider;
apprenticeships.ForEach(app => app.ApprenticeshipStatus = ApprenticeshipStatus.Draft);
singleCohort.NumberOfDraftApprentices = 2;
panelViewModel.Data.CallToActionViewModel.Cohorts = new List<CohortViewModel> { singleCohort };
panelViewModel.Data.CallToActionViewModel.Apprenticeships = new List<ApprenticeshipViewModel>();
panelViewModel.Data.CallToActionViewModel.Reservations = new List<Reservation>();
panelViewModel.Data.CallToActionViewModel.VacanciesViewModel = new VacanciesViewModel();

// Act
sut.GetCallToActionViewName(panelViewModel);

//Assert
panelViewModel.ViewName.Should().Be(EmptyViewName);
}

[Test, RecursiveMoqAutoData]
public void WhenSingleReservationAndCohortWithNoApprenticeship_ThenShouldGetSingleApprenticeshipContinueWithProviderViewName(
CohortViewModel singleCohort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,11 @@ private bool EvaluateSingleApprenticeshipsWithTrainingProviderStatusCallToAction

private bool EvaluateContinueSetupForSingleApprenticeshipByProviderCallToActionRule(PanelViewModel<AccountDashboardViewModel> viewModel)
{
if (viewModel.Data.CallToActionViewModel.ReservationsCount < 2
if (viewModel.Data.CallToActionViewModel.ReservationsCount == 1
&& viewModel.Data.CallToActionViewModel.CohortsCount == 1
&& viewModel.Data.CallToActionViewModel.Cohorts.Single() != null
&& viewModel.Data.CallToActionViewModel.ApprenticeshipsCount == 0
&& viewModel.Data.CallToActionViewModel.ApprenticeshipsCount == 0
&& viewModel.Data.CallToActionViewModel.Cohorts.Single().NumberOfDraftApprentices == 1
&& viewModel.Data.CallToActionViewModel.Cohorts.Single().CohortStatus.Equals(CohortStatus.WithTrainingProvider))
{
viewModel.ViewName = "SingleApprenticeshipContinueWithProvider";
Expand Down

0 comments on commit acc0ab5

Please sign in to comment.