diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/NonLevyPanelViewAttribute.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/NonLevyPanelViewAttribute.cs index df36a3fc24..ffc2fb4201 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/NonLevyPanelViewAttribute.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/NonLevyPanelViewAttribute.cs @@ -32,7 +32,7 @@ public class ArrangeNonLevyPanelViewCustomisation : ICustomization public void Customize(IFixture fixture) { fixture.Customize>(composer => composer - .With(panel => panel.ViewName, string.Empty)); + .With(panel => panel.ViewName, "Empty")); fixture.Customize(composer => composer .With(dash => dash.ApprenticeshipEmployerType, ApprenticeshipEmployerType.NonLevy) .With(dash => dash.PendingAgreements, new List())); diff --git a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingCallToActionViewName.cs b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingCallToActionViewName.cs index 399c603ea8..7a2b960ea0 100644 --- a/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingCallToActionViewName.cs +++ b/src/SFA.DAS.EmployerAccounts.Web.UnitTests/Orchestrators/EmployerTeamOrchestratorTests/WhenGettingCallToActionViewName.cs @@ -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 panelViewModel, @@ -26,7 +28,7 @@ public void WhenMultipleReservation_ThenShouldGetCheckFundingViewNameNotDisplayC sut.GetCallToActionViewName(panelViewModel); //Assert - panelViewModel.ViewName.Should().BeNullOrEmpty(); + panelViewModel.ViewName.Should().Be(EmptyViewName); } [Test, RecursiveMoqAutoData] @@ -43,7 +45,7 @@ public void WhenMultipleCohorts_ThenShouldGetCheckFundingViewNameNotDisplayCallT sut.GetCallToActionViewName(panelViewModel); //Assert - panelViewModel.ViewName.Should().BeNullOrEmpty(); + panelViewModel.ViewName.Should().Be(EmptyViewName); } [Test, RecursiveMoqAutoData] @@ -69,7 +71,7 @@ public void WhenMultipleApprenticeshipsWithinASingleCohort_ThenShouldGetCheckFun sut.GetCallToActionViewName(panelViewModel); //Assert - panelViewModel.ViewName.Should().BeNullOrEmpty(); + panelViewModel.ViewName.Should().Be(EmptyViewName); } [Test, RecursiveMoqAutoData] @@ -86,7 +88,7 @@ public void WhenMultipleVacancies_ThenShouldGetCheckFundingViewNameNotDisplayCal sut.GetCallToActionViewName(panelViewModel); //Assert - panelViewModel.ViewName.Should().BeNullOrEmpty(); + panelViewModel.ViewName.Should().Be(EmptyViewName); } [Test, RecursiveMoqAutoData] @@ -117,7 +119,7 @@ public void WhenNoData_ThenDoNotSetCallToActionViewName( sut.GetCallToActionViewName(panelViewModel); //Assert - panelViewModel.ViewName.Should().BeNullOrEmpty(); + panelViewModel.ViewName.Should().Be(EmptyViewName); } [Test, RecursiveMoqAutoData] @@ -132,7 +134,7 @@ public void WhenLevy_IgnoreCallToActionRules( sut.GetCallToActionViewName(panelViewModel); //Assert - panelViewModel.ViewName.Should().BeNullOrEmpty(); + panelViewModel.ViewName.Should().Be(EmptyViewName); } [Test, RecursiveMoqAutoData] @@ -247,6 +249,31 @@ public void WhenSingleReservationAndApprenticeship_ThenShouldGetSingleApprentice panelViewModel.ViewName.Should().Be("SingleApprenticeshipReadyForReview"); } + [Test, RecursiveMoqAutoData] + public void WhenNoReservationAndCohortWithMultipleDraftApprenticeships_ThenShouldNotSetViewName( + CohortViewModel singleCohort, + Reservation singleReservation, + List apprenticeships, + [NonLevyPanelView] PanelViewModel panelViewModel, + EmployerTeamOrchestrator sut) + { + // Arrange + singleCohort.Apprenticeships = new List(); + singleCohort.CohortStatus = CohortStatus.WithTrainingProvider; + apprenticeships.ForEach(app => app.ApprenticeshipStatus = ApprenticeshipStatus.Draft); + singleCohort.NumberOfDraftApprentices = 2; + panelViewModel.Data.CallToActionViewModel.Cohorts = new List { singleCohort }; + panelViewModel.Data.CallToActionViewModel.Apprenticeships = new List(); + panelViewModel.Data.CallToActionViewModel.Reservations = new List(); + panelViewModel.Data.CallToActionViewModel.VacanciesViewModel = new VacanciesViewModel(); + + // Act + sut.GetCallToActionViewName(panelViewModel); + + //Assert + panelViewModel.ViewName.Should().Be(EmptyViewName); + } + [Test, RecursiveMoqAutoData] public void WhenSingleReservationAndCohortWithNoApprenticeship_ThenShouldGetSingleApprenticeshipContinueWithProviderViewName( CohortViewModel singleCohort, diff --git a/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestrator.cs b/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestrator.cs index 132bc4b3fb..84cebd7022 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestrator.cs +++ b/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/EmployerTeamOrchestrator.cs @@ -845,10 +845,11 @@ private bool EvaluateSingleApprenticeshipsWithTrainingProviderStatusCallToAction private bool EvaluateContinueSetupForSingleApprenticeshipByProviderCallToActionRule(PanelViewModel 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";