-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from SkillsFundingAgency/CON-2502-CoP-inform-…
…page CON-2502 Change of provider inform page
- Loading branch information
Showing
12 changed files
with
261 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...ommitmentsV2.Web.UnitTests/Mappers/Apprentice/ChangeProviderInformViewModelMapperTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using AutoFixture; | ||
using Moq; | ||
using NUnit.Framework; | ||
using SFA.DAS.CommitmentsV2.Api.Client; | ||
using SFA.DAS.CommitmentsV2.Api.Types.Responses; | ||
using SFA.DAS.CommitmentsV2.Types; | ||
using SFA.DAS.EmployerCommitmentsV2.Web.Mappers.Apprentice; | ||
using SFA.DAS.EmployerCommitmentsV2.Web.Models.Apprentice; | ||
using SFA.DAS.Encoding; | ||
using SFA.DAS.Testing.AutoFixture; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Mappers.Apprentice | ||
{ | ||
public class ChangeProviderInformViewModelMapperTests | ||
{ | ||
private Mock<ICommitmentsApiClient> _mockCommitmentsApiClient; | ||
private Mock<IEncodingService> _mockEncodingService; | ||
private GetApprenticeshipResponse _apprenticeshipResponse; | ||
|
||
private ChangeProviderInformViewModelMapper _mapper; | ||
|
||
private const long ApprenticeshipId = 10000000; | ||
|
||
[SetUp] | ||
public void Arrange() | ||
{ | ||
var autoFixture = new Fixture(); | ||
|
||
_apprenticeshipResponse = autoFixture.Build<GetApprenticeshipResponse>() | ||
.With(a => a.Status, ApprenticeshipStatus.Stopped) | ||
.Create(); | ||
|
||
|
||
_mockCommitmentsApiClient = new Mock<ICommitmentsApiClient>(); | ||
_mockCommitmentsApiClient.Setup(a => a.GetApprenticeship(It.IsAny<long>(), It.IsAny<CancellationToken>())) | ||
.ReturnsAsync(_apprenticeshipResponse); | ||
|
||
_mockEncodingService = new Mock<IEncodingService>(); | ||
_mockEncodingService.Setup(d => d.Decode(It.IsAny<string>(), EncodingType.ApprenticeshipId)) | ||
.Returns(ApprenticeshipId); | ||
|
||
|
||
_mapper = new ChangeProviderInformViewModelMapper(_mockCommitmentsApiClient.Object, _mockEncodingService.Object); | ||
} | ||
|
||
[Test, MoqAutoData] | ||
public async Task ApprenticeshipHashedId_IsMapped(ChangeProviderInformRequest request) | ||
{ | ||
var result = await _mapper.Map(request); | ||
|
||
Assert.AreEqual(request.ApprenticeshipHashedId, result.ApprenticeshipHashedId); | ||
} | ||
|
||
[Test, MoqAutoData] | ||
public async Task AccountHashedId_IsMapped(ChangeProviderInformRequest request) | ||
{ | ||
var result = await _mapper.Map(request); | ||
|
||
Assert.AreEqual(request.AccountHashedId, result.AccountHashedId); | ||
} | ||
|
||
[Test, MoqAutoData] | ||
public async Task ApprenticeshipStatus_IsMapped(ChangeProviderInformRequest request) | ||
{ | ||
var result = await _mapper.Map(request); | ||
|
||
Assert.AreEqual(ApprenticeshipStatus.Stopped, result.ApprenticeshipStatus); | ||
} | ||
|
||
[Test, MoqAutoData] | ||
public async Task WhenRequestingChangeProviderInformPage_ThenHashedApprenticeshipIdIsDecoded(ChangeProviderInformRequest request) | ||
{ | ||
var result = await _mapper.Map(request); | ||
|
||
_mockEncodingService.Verify(a => a.Decode(request.ApprenticeshipHashedId, EncodingType.ApprenticeshipId), Times.Once); | ||
} | ||
|
||
[Test, MoqAutoData] | ||
public async Task WhenRequestingChangeProviderInformPage_ThenGetApprenticeshipIsCalled(ChangeProviderInformRequest request) | ||
{ | ||
var result = await _mapper.Map(request); | ||
|
||
_mockCommitmentsApiClient.Verify(a => a.GetApprenticeship(ApprenticeshipId, It.IsAny<CancellationToken>()), Times.Once); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...A.DAS.EmployerCommitmentsV2.Web/Mappers/Apprentice/ChangeProviderInformViewModelMapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using SFA.DAS.CommitmentsV2.Api.Client; | ||
using SFA.DAS.CommitmentsV2.Shared.Interfaces; | ||
using SFA.DAS.EmployerCommitmentsV2.Web.Models.Apprentice; | ||
using SFA.DAS.Encoding; | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Web.Mappers.Apprentice | ||
{ | ||
public class ChangeProviderInformViewModelMapper : IMapper<ChangeProviderInformRequest, ChangeProviderInformViewModel> | ||
{ | ||
private readonly ICommitmentsApiClient _commitmentsApiClient; | ||
private readonly IEncodingService _encodingService; | ||
|
||
public ChangeProviderInformViewModelMapper(ICommitmentsApiClient commitmentsApiClient, IEncodingService encodingService) | ||
{ | ||
_commitmentsApiClient = commitmentsApiClient; | ||
_encodingService = encodingService; | ||
} | ||
|
||
public async Task<ChangeProviderInformViewModel> Map(ChangeProviderInformRequest source) | ||
{ | ||
var apprenticeshipId = _encodingService.Decode(source.ApprenticeshipHashedId, EncodingType.ApprenticeshipId); | ||
|
||
var apprenticeship = await _commitmentsApiClient.GetApprenticeship(apprenticeshipId, CancellationToken.None); | ||
|
||
var result = new ChangeProviderInformViewModel | ||
{ | ||
AccountHashedId = source.AccountHashedId, | ||
ApprenticeshipHashedId = source.ApprenticeshipHashedId, | ||
ApprenticeshipStatus = apprenticeship.Status | ||
}; | ||
|
||
return result; | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/SFA.DAS.EmployerCommitmentsV2.Web/Models/Apprentice/ChangeProviderInformRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Web.Models.Apprentice | ||
{ | ||
public class ChangeProviderInformRequest | ||
{ | ||
[FromRoute] | ||
public string AccountHashedId { get; set; } | ||
|
||
[FromRoute] | ||
public string ApprenticeshipHashedId { get; set; } | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/SFA.DAS.EmployerCommitmentsV2.Web/Models/Apprentice/ChangeProviderInformViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
| ||
using SFA.DAS.CommitmentsV2.Types; | ||
|
||
namespace SFA.DAS.EmployerCommitmentsV2.Web.Models.Apprentice | ||
{ | ||
public class ChangeProviderInformViewModel | ||
{ | ||
public string AccountHashedId { get; set; } | ||
public string ApprenticeshipHashedId { get; set; } | ||
public ApprenticeshipStatus ApprenticeshipStatus { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/SFA.DAS.EmployerCommitmentsV2.Web/Views/Apprentice/ApprenticeNotStoppedError.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
@* | ||
Placeholder for CON-2516 | ||
*@ | ||
|
||
<h1> You need to wait until {apprentice} has stopped training </h1> |
64 changes: 64 additions & 0 deletions
64
src/SFA.DAS.EmployerCommitmentsV2.Web/Views/Apprentice/ChangeProviderInform.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
@inject ILinkGenerator LinkGenerator; | ||
@using SFA.DAS.EmployerCommitmentsV2.Web.Extensions | ||
@using SFA.DAS.CommitmentsV2.Types | ||
@using SFA.DAS.EmployerCommitmentsV2.Web.RouteValues | ||
@model SFA.DAS.EmployerCommitmentsV2.Web.Models.Apprentice.ChangeProviderInformViewModel; | ||
|
||
@{ | ||
ViewData["Title"] = "Changing training provider - Apprenticeship service - GOV.UK"; | ||
} | ||
|
||
<div class="das-panel das-panel--featured das-!-text-align-left"> | ||
<h1 class="das-panel__heading govuk-!-margin-top-0"> | ||
Changing training provider | ||
</h1> | ||
<div class="govuk-!-width-two-thirds das-panel__body"> | ||
|
||
@if (Model.ApprenticeshipStatus != ApprenticeshipStatus.Stopped) | ||
{ | ||
<div class="govuk-warning-text"> | ||
<span class="govuk-warning-text__icon das-warning-text__icon--blue das-warning-text__icon--valign-middle" aria-hidden="true">!</span> | ||
<strong class="govuk-warning-text__text das-!-colour-inherit"> | ||
<span class="govuk-warning-text__assistive">Warning</span> | ||
When you change an apprentice's training provider, their apprenticeship record with the current training provider will be stopped. | ||
</strong> | ||
</div> | ||
} | ||
|
||
<p class="govuk-body das-!-colour-inherit"> | ||
Before you request this change, you must contact the new training provider to agree the new training dates and price. | ||
</p> | ||
<p class="govuk-body das-!-colour-inherit"> | ||
You should only change your apprentice's training provider if: | ||
</p> | ||
<ul class="govuk-list govuk-list--bullet das-!-colour-inherit"> | ||
<li> | ||
you're not happy with their performance | ||
</li> | ||
<li> | ||
they've stopped delivering the apprentice's training course | ||
</li> | ||
<li> | ||
they're shutting down or have already shut down | ||
</li> | ||
</ul> | ||
</div> | ||
|
||
@if (Model.ApprenticeshipStatus != ApprenticeshipStatus.Stopped) | ||
{ | ||
<a class="govuk-button das-button--inverted govuk-!-font-weight-bold govuk-!-margin-top-2" asp-route="@RouteNames.ApprenticeNotStoppedError"> Continue </a> | ||
} | ||
else | ||
{ | ||
<a class="govuk-button das-button--inverted govuk-!-font-weight-bold govuk-!-margin-top-2" asp-route="@RouteNames.EnterNewTrainingProvider"> Continue </a> | ||
} | ||
|
||
<p class="govuk-body-s govuk-!-margin-top-0 govuk-!-margin-bottom-0"> | ||
<a class="das-panel__link" href="@LinkGenerator.EmployerHome(Model.AccountHashedId)">Cancel and return to account home</a> | ||
</p> | ||
</div> | ||
|
||
@section Back | ||
{ | ||
<div class="das-js-back-link"></div> | ||
} |
6 changes: 6 additions & 0 deletions
6
src/SFA.DAS.EmployerCommitmentsV2.Web/Views/Apprentice/EnterNewTrainingProvider.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
@* | ||
Placeholder for CON-2505 | ||
*@ | ||
|
||
<h1> Enter a new training provider </h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters