Skip to content

Commit

Permalink
Merge branch 'master' into CON-1635-hide-task-bar-with-call-to-action
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephek committed Apr 20, 2020
2 parents 2d3ac35 + 5f9f93f commit 938d172
Show file tree
Hide file tree
Showing 22 changed files with 185 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void Arrange()
_hashingService = new Mock<IHashingService>();
_hashingService.Setup(x => x.DecodeValue(hashedAccountId)).Returns(_accountId);

RequestHandler = new GetSingleCohortRequestHandler(RequestValidator.Object, _commitmentV2Service.Object, _hashingService.Object);
RequestHandler = new GetSingleCohortRequestHandler(RequestValidator.Object, _commitmentV2Service.Object, _hashingService.Object, Mock.Of<ILog>());

Query = new GetSingleCohortRequest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,5 +404,34 @@ public async Task ThenShouldGetCohortResponse()
//Assert
Assert.AreEqual(1, result.Data.CallToActionViewModel.CohortsCount);
}

[Test]
[TestCase(false, false, false, false, false, Description = "All calls successful")]
[TestCase(true, false, false, false, true, Description = "Vacancy call failed")]
[TestCase(false, true, false, false, true, Description = "Vacancy call failed")]
[TestCase(false, false, true, false, true, Description = "Cohort call failed")]
public async Task ThenShouldSetUnableToDetermineCallToAction(
bool vacancyCallFailed,
bool reservationsCallFailed,
bool cohortCallFailed,
bool apprenticeshipCallFailed,
bool unableToDetermineCallToActionExpected)
{
//Arrange
_mediator.Setup(x => x.SendAsync(It.IsAny<GetVacanciesRequest>())).ReturnsAsync(new GetVacanciesResponse { Vacancies = new List<Vacancy>(), HasFailed = vacancyCallFailed });

_mediator.Setup(x => x.SendAsync(It.IsAny<GetReservationsRequest>())).ReturnsAsync(new GetReservationsResponse { Reservations = new List<Reservation>(), HasFailed = reservationsCallFailed });

_mediator.Setup(x => x.SendAsync(It.IsAny<GetApprenticeshipsRequest>())).ReturnsAsync(new GetApprenticeshipsResponse{ Apprenticeships = new List<Apprenticeship>(), HasFailed = apprenticeshipCallFailed });

var cohort = new Cohort() { Id = 1, NumberOfDraftApprentices = 1, Apprenticeships = new List<Apprenticeship> { new Apprenticeship { FirstName = "FirstName" } } };
_mediator.Setup(x => x.SendAsync(It.IsAny<GetSingleCohortRequest>())).ReturnsAsync(new GetSingleCohortResponse { Cohort = cohort, HasFailed = cohortCallFailed });

//Act
var result = await _orchestrator.GetAccount(HashedAccountId, UserId);

//Assert
Assert.AreEqual(unableToDetermineCallToActionExpected, result.Data.CallToActionViewModel.UnableToDetermineCallToAction);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public static string GetZenDeskSnippetSectionId(this HtmlHelper html)
var configuration = DependencyResolver.Current.GetService<EmployerAccountsConfiguration>();
return configuration.ZenDeskSectionId;
}
public static string GetZenDeskCobrowsingSnippetKey(this HtmlHelper html)
{
var configuration = DependencyResolver.Current.GetService<EmployerAccountsConfiguration>();
return configuration.ZenDeskCobrowsingSnippetKey;
}

public static IHeaderViewModel GetHeaderViewModel(this HtmlHelper html, bool useLegacyStyles = false)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public virtual async Task<OrchestratorResponse<AccountDashboardViewModel>> GetAc
{
_mapper.Map<Cohort, CohortViewModel>(accountCohort.Cohort)
},
UnableToDetermineCallToAction = vacanciesResponse.HasFailed || reservationsResponse.HasFailed
UnableToDetermineCallToAction = vacanciesResponse.HasFailed || reservationsResponse.HasFailed || accountCohort.HasFailed || apprenticeshipsResponse.HasFailed
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<Version>1.0.16</Version>
</PackageReference>
<PackageReference Include="SFA.DAS.MA.Shared.UI">
<Version>1.1.34</Version>
<Version>1.1.42</Version>
</PackageReference>
<PackageReference Include="SFA.DAS.NLog.Logger" Version="1.2.1" />
<PackageReference Include="SFA.DAS.NLog.Targets.Redis" Version="1.2.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
{
<div class="das-notification">
<p class="das-notification__heading govuk-!-margin-bottom-0">
Coronavirus (COVID-19): <a href="https://www.gov.uk/government/publications/coronavirus-covid-19-apprenticeship-programme-response/coronavirus-covid-19-guidance-for-apprentices-employers-training-providers-end-point-assessment-organisations-and-external-quality-assurance-pro" target="_blank" class="govuk-link">read our guidance</a> on the changes we're making to apprenticeships and <a href="https://help.apprenticeships.education.gov.uk/hc/en-gb/articles/360009509360-Pause-or-stop-an-apprenticeship" target="_blank" class="govuk-link">find out how you can pause your apprenticeships</a>.
Coronavirus (COVID-19): <a href="https://www.gov.uk/government/publications/coronavirus-covid-19-apprenticeship-programme-response/coronavirus-covid-19-guidance-for-apprentices-employers-training-providers-end-point-assessment-organisations-and-external-quality-assurance-pro" target="_blank" class="govuk-link">read our guidance</a> on the changes we're making to help your apprentices continue learning or <a href="https://help.apprenticeships.education.gov.uk/hc/en-gb/articles/360009509360-Pause-or-stop-an-apprenticeship" target="_blank" class="govuk-link">find out how you can pause your apprenticeships</a>.
</p>
</div>
}
else
{
<div class="info-summary">
<h2 class="heading-medium">
Coronavirus (COVID-19): <a href="https://www.gov.uk/government/publications/coronavirus-covid-19-apprenticeship-programme-response/coronavirus-covid-19-guidance-for-apprentices-employers-training-providers-end-point-assessment-organisations-and-external-quality-assurance-pro" target="_blank">read our guidance</a> on the changes we're making to apprenticeships and <a href="https://help.apprenticeships.education.gov.uk/hc/en-gb/articles/360009509360-Pause-or-stop-an-apprenticeship" target="_blank">find out how you can pause your apprenticeships</a>.
Coronavirus (COVID-19): <a href="https://www.gov.uk/government/publications/coronavirus-covid-19-apprenticeship-programme-response/coronavirus-covid-19-guidance-for-apprentices-employers-training-providers-end-point-assessment-organisations-and-external-quality-assurance-pro" target="_blank">read our guidance</a> on the changes we're making to help your apprentices continue learning or <a href="https://help.apprenticeships.education.gov.uk/hc/en-gb/articles/360009509360-Pause-or-stop-an-apprenticeship" target="_blank">find out how you can pause your apprenticeships</a>.
</h2>
</div>
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
};
</script>
<script id="ze-snippet" src="https://static.zdassets.com/ekr/[email protected]()"></script>
<script id="co-snippet" src="https://embed-euw1.rcrsv.io/@Html.GetZenDeskCobrowsingSnippetKey()?zwwi=1"></script>
@Html.SetZenDeskLabels(new string[] { ViewBag.ZenDeskLabel })


2 changes: 1 addition & 1 deletion src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie6.css
Original file line number Diff line number Diff line change
Expand Up @@ -4691,7 +4691,7 @@ hr.dashboard-heading-separator {
margin-top: 30px; }

.das-panel--action {
background: #dee0e2;
background: #f3f2f1;
color: #000;
margin-top: 20px; }
.das-panel--action > p:last-child {
Expand Down
2 changes: 1 addition & 1 deletion src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie7.css
Original file line number Diff line number Diff line change
Expand Up @@ -4683,7 +4683,7 @@ hr.dashboard-heading-separator {
margin-top: 30px; }

.das-panel--action {
background: #dee0e2;
background: #f3f2f1;
color: #000;
margin-top: 20px; }
.das-panel--action > p:last-child {
Expand Down
2 changes: 1 addition & 1 deletion src/SFA.DAS.EmployerAccounts.Web/dist/css/screen-ie8.css
Original file line number Diff line number Diff line change
Expand Up @@ -4647,7 +4647,7 @@ hr.dashboard-heading-separator {
margin-top: 30px; }

.das-panel--action {
background: #dee0e2;
background: #f3f2f1;
color: #000;
margin-top: 20px; }
.das-panel--action > p:last-child {
Expand Down
2 changes: 1 addition & 1 deletion src/SFA.DAS.EmployerAccounts.Web/dist/css/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -4956,7 +4956,7 @@ hr.dashboard-heading-separator {
margin-top: 30px; }

.das-panel--action {
background: #dee0e2;
background: #f3f2f1;
color: #000;
margin-top: 20px; }
.das-panel--action > p:last-child {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class EmployerAccountsConfiguration : ITopicMessagePublisherConfiguration
public string AdfsMetadata { get; set; }
public string ZenDeskSnippetKey { get; set; }
public string ZenDeskSectionId { get; set; }
public string ZenDeskCobrowsingSnippetKey { get; set; }
public CommitmentsApiV2ClientConfiguration CommitmentsApi { get; set; }
public RecruitClientApiConfiguration RecruitApi { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using SFA.DAS.Validation;
using SFA.DAS.EmployerAccounts.Interfaces;
using SFA.DAS.HashingService;
using System;

namespace SFA.DAS.EmployerAccounts.Queries.GetApprenticeship
{
Expand Down Expand Up @@ -37,10 +38,21 @@ public async Task<GetApprenticeshipsResponse> Handle(GetApprenticeshipsRequest m

long accountId = _hashingService.DecodeValue(message.HashedAccountId);

return new GetApprenticeshipsResponse
try
{
Apprenticeships = await _commitmentV2Service.GetApprenticeships(accountId)
};
return new GetApprenticeshipsResponse
{
Apprenticeships = await _commitmentV2Service.GetApprenticeships(accountId)
};
}
catch(Exception ex)
{
_logger.Error(ex, $"Failed to get Cohorts for {message.HashedAccountId}");
return new GetApprenticeshipsResponse
{
HasFailed = true
};
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ namespace SFA.DAS.EmployerAccounts.Queries.GetApprenticeship
public class GetApprenticeshipsResponse
{
public IEnumerable<Apprenticeship> Apprenticeships { get; set; }
public bool HasFailed { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using SFA.DAS.EmployerAccounts.Interfaces;
using System.Linq;
using SFA.DAS.HashingService;
using System;
using SFA.DAS.NLog.Logger;

namespace SFA.DAS.EmployerAccounts.Queries.GetSingleCohort
{
Expand All @@ -12,15 +14,18 @@ public class GetSingleCohortRequestHandler : IAsyncRequestHandler<GetSingleCohor
private readonly IValidator<GetSingleCohortRequest> _validator;
private readonly ICommitmentV2Service _commitmentV2Service;
private readonly IHashingService _hashingService;
private readonly ILog _logger;

public GetSingleCohortRequestHandler(
IValidator<GetSingleCohortRequest> validator,
ICommitmentV2Service commitmentV2Service,
IHashingService hashingService)
IHashingService hashingService,
ILog logger)
{
_validator = validator;
_commitmentV2Service = commitmentV2Service;
_hashingService = hashingService;
_logger = logger;
}

public async Task<GetSingleCohortResponse> Handle(GetSingleCohortRequest message)
Expand All @@ -32,22 +37,33 @@ public async Task<GetSingleCohortResponse> Handle(GetSingleCohortRequest message
throw new InvalidRequestException(validationResult.ValidationDictionary);
}

long accountId = _hashingService.DecodeValue(message.HashedAccountId);
long accountId = _hashingService.DecodeValue(message.HashedAccountId);

var cohortsResponse = await _commitmentV2Service.GetCohorts(accountId);
if (cohortsResponse.Count() != 1) return new GetSingleCohortResponse();
try
{
var cohortsResponse = await _commitmentV2Service.GetCohorts(accountId);
if (cohortsResponse.Count() != 1) return new GetSingleCohortResponse();

var singleCohort = cohortsResponse.Single();
var singleCohort = cohortsResponse.Single();

if (singleCohort.NumberOfDraftApprentices > 0)
{
singleCohort.Apprenticeships = await _commitmentV2Service.GetDraftApprenticeships(singleCohort);
}
if (singleCohort.NumberOfDraftApprentices > 0)
{
singleCohort.Apprenticeships = await _commitmentV2Service.GetDraftApprenticeships(singleCohort);
}

return new GetSingleCohortResponse
return new GetSingleCohortResponse
{
Cohort = singleCohort
};
}
catch(Exception ex)
{
Cohort = singleCohort
};
_logger.Error(ex, $"Failed to get Cohorts for {message.HashedAccountId}");
return new GetSingleCohortResponse
{
HasFailed = true
};
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ namespace SFA.DAS.EmployerAccounts.Queries.GetSingleCohort
public class GetSingleCohortResponse
{
public Cohort Cohort { get; set; }
public bool HasFailed { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,85 @@ public async Task ThenIShouldGetCorrectFrameworkPathwayName()
Assert.AreEqual(_framework.PathwayName, details.First().PathwayName);
}

[Test]
public async Task ThenShouldNotAttemptToGetStandardWithNullStandardCode()
{
// Arrange
_mapper.Setup(x => x.Map<PaymentDetails>(It.IsAny<Provider.Events.Api.Types.Payment>()))
.Returns(() => _frameworkPayment);

// Act
var details = await _paymentService.GetAccountPayments(PeriodEnd, AccountId);

// Assert
_apprenticeshipInfoService.Verify(x => x.GetStandardsAsync(false), Times.Never);
}

[Test]
public async Task ThenShouldNotAttemptToGetStandardWithZeroStandardCode()
{
// Arrange
_frameworkPayment.StandardCode = 0;
_mapper.Setup(x => x.Map<PaymentDetails>(It.IsAny<Provider.Events.Api.Types.Payment>()))
.Returns(() => _frameworkPayment);

// Act
var details = await _paymentService.GetAccountPayments(PeriodEnd, AccountId);

// Assert
_apprenticeshipInfoService.Verify(x => x.GetStandardsAsync(false), Times.Never);
}

[Test]
public async Task ThenShouldNotAttemptToGetFrameworkWithNullFrameworkCode()
{
// Arrange
_frameworkPayment.FrameworkCode = null;
_mapper.Setup(x => x.Map<PaymentDetails>(It.IsAny<Provider.Events.Api.Types.Payment>()))
.Returns(() => _frameworkPayment);

// Act
var details = await _paymentService.GetAccountPayments(PeriodEnd, AccountId);

// Assert
_apprenticeshipInfoService.Verify(x => x.GetFrameworksAsync(false), Times.Never);
}

[Test]
public async Task ThenShouldNotAttemptToGetFrameworkWithZeroFrameworkCode()
{
// Arrange
_frameworkPayment.FrameworkCode = 0;
_mapper.Setup(x => x.Map<PaymentDetails>(It.IsAny<Provider.Events.Api.Types.Payment>()))
.Returns(() => _frameworkPayment);

// Act
var details = await _paymentService.GetAccountPayments(PeriodEnd, AccountId);

// Assert
_apprenticeshipInfoService.Verify(x => x.GetFrameworksAsync(false), Times.Never);
}

[Test]
[TestCase(0, 0)]
[TestCase(0, null)]
[TestCase(null, 0)]
[TestCase(null, null)]
public async Task ThenShouldLogWarningIfBothStandardCodeAndFramworkCodeNotSet(int? invalidFrameworkCode, int? invalidStandardCode)
{
// Arrange
_frameworkPayment.FrameworkCode = invalidFrameworkCode;
_frameworkPayment.StandardCode = invalidStandardCode;
_mapper.Setup(x => x.Map<PaymentDetails>(It.IsAny<Provider.Events.Api.Types.Payment>()))
.Returns(() => _frameworkPayment);

// Act
var details = await _paymentService.GetAccountPayments(PeriodEnd, AccountId);

// Assert
_logger.Verify(x => x.Warn(It.IsAny<string>()), Times.Once);
}

[Test]
public async Task ThenIShouldGetCorrectApprenticeDetails()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,11 @@ public static string GetZenDeskSnippetSectionId(this HtmlHelper html)
var configuration = DependencyResolver.Current.GetService<EmployerFinanceConfiguration>();
return configuration.ZenDeskSectionId;
}

public static string GetZenDeskCobrowsingSnippetKey(this HtmlHelper html)
{
var configuration = DependencyResolver.Current.GetService<EmployerFinanceConfiguration>();
return configuration.ZenDeskCobrowsingSnippetKey;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="info-summary">
<h2 class="heading-medium">
Coronavirus (COVID-19): <a href="https://www.gov.uk/government/publications/coronavirus-covid-19-apprenticeship-programme-response/coronavirus-covid-19-guidance-for-apprentices-employers-training-providers-end-point-assessment-organisations-and-external-quality-assurance-pro" target="_blank">read our guidance</a> on the changes we're making to apprenticeships and <a href="https://help.apprenticeships.education.gov.uk/hc/en-gb/articles/360009509360-Pause-or-stop-an-apprenticeship" target="_blank">find out how you can pause your apprenticeships</a>.
Coronavirus (COVID-19): <a href="https://www.gov.uk/government/publications/coronavirus-covid-19-apprenticeship-programme-response/coronavirus-covid-19-guidance-for-apprentices-employers-training-providers-end-point-assessment-organisations-and-external-quality-assurance-pro" target="_blank">read our guidance</a> on the changes we're making to help your apprentices continue learning or <a href="https://help.apprenticeships.education.gov.uk/hc/en-gb/articles/360009509360-Pause-or-stop-an-apprenticeship" target="_blank">find out how you can pause your apprenticeships</a>.
</h2>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
};
</script>
<script id="ze-snippet" src="https://static.zdassets.com/ekr/[email protected]()"></script>
<script id="co-snippet" src="https://embed-euw1.rcrsv.io/@Html.GetZenDeskCobrowsingSnippetKey()?zwwi=1"></script>
@Html.SetZenDeskLabels(new string[] { ViewBag.ZenDeskLabel })
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ public class EmployerFinanceConfiguration : ITopicMessagePublisherConfiguration
public string ZenDeskHelpCentreUrl { get; set; }
public string ZenDeskSnippetKey { get; set; }
public string ZenDeskSectionId { get; set; }
public string ZenDeskCobrowsingSnippetKey { get; set; }
}
}
Loading

0 comments on commit 938d172

Please sign in to comment.