-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/183558 Added page for providing extra information about proje…
…ct status change when status is cancelled or withdrawn (#989) * Project status reason backend * Frontend reasons page WIP * Edit status reason and display in project overview * Added API test * Updated cypress tests, fixed referrer functionality * Fixed bug with selecting cancelled/withdrawn reason * Added section break
- Loading branch information
1 parent
b7a2663
commit 8356c6f
Showing
28 changed files
with
14,344 additions
and
382 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
66 changes: 66 additions & 0 deletions
66
...eSchoolProjects/Dfe.ManageFreeSchoolProjects.API.Contracts/Project/ProjectStatusReason.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,66 @@ | ||
using System.ComponentModel; | ||
|
||
namespace Dfe.ManageFreeSchoolProjects.API.Contracts.Project | ||
{ | ||
public enum ProjectCancelledReason | ||
{ | ||
NotSet, | ||
|
||
[Description("Educational")] | ||
Educational, | ||
|
||
[Description("Governance")] | ||
Governance, | ||
|
||
[Description("Planning")] | ||
Planning, | ||
|
||
[Description("Procurement / Construction")] | ||
ProcurementConstruction, | ||
|
||
[Description("Property")] | ||
Property, | ||
|
||
[Description("Pupil numbers / viability")] | ||
PupilNumbersViability, | ||
|
||
[Description("Trust not content with site option")] | ||
TrustNotContentWithSiteOption, | ||
|
||
[Description("Trust not willing to open in temporary accommodation")] | ||
TrustNotWillingToOpenInTemporaryAccommodation | ||
|
||
|
||
} | ||
|
||
public enum ProjectWithdrawnReason | ||
{ | ||
NotSet, | ||
|
||
[Description("Educational")] | ||
Educational, | ||
|
||
[Description("Governance")] | ||
Governance, | ||
|
||
[Description("Planning")] | ||
Planning, | ||
|
||
[Description("Procurement / Construction")] | ||
ProcurementConstruction, | ||
|
||
[Description("Property")] | ||
Property, | ||
|
||
[Description("Pupil numbers / viability")] | ||
PupilNumbersViability, | ||
|
||
[Description("Trust not content with site option")] | ||
TrustNotContentWithSiteOption, | ||
|
||
[Description("Trust not willing to open in temporary accommodation")] | ||
TrustNotWillingToOpenInTemporaryAccommodation | ||
|
||
|
||
} | ||
} |
20 changes: 17 additions & 3 deletions
20
...Projects/Dfe.ManageFreeSchoolProjects.API.Contracts/Project/UpdateProjectStatusRequest.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 |
---|---|---|
@@ -1,12 +1,26 @@ | ||
using Dfe.ManageFreeSchoolProjects.API.Contracts.Common; | ||
|
||
namespace Dfe.ManageFreeSchoolProjects.API.Contracts.Project; | ||
|
||
public class UpdateProjectStatusRequest | ||
{ | ||
public ProjectStatus ProjectStatus { get; set; } | ||
|
||
|
||
public ProjectCancelledReason ProjectCancelledReason { get; set; } | ||
|
||
public ProjectWithdrawnReason ProjectWithdrawnReason { get; set; } | ||
|
||
public DateTime? CancelledDate { get; set; } | ||
|
||
public DateTime? ClosedDate { get; set; } | ||
|
||
public DateTime? WithdrawnDate { get; set; } | ||
|
||
public YesNo? ProjectCancelledDueToNationalReviewOfPipelineProjects { get; set; } | ||
|
||
public YesNo? ProjectWithdrawnDueToNationalReviewOfPipelineProjects { get; set; } | ||
|
||
public string CommentaryForCancellation { get; set; } | ||
public string CommentaryForWithdrawal { 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
135 changes: 135 additions & 0 deletions
135
...choolProjects/Dfe.ManageFreeSchoolProjects.API.Tests/Integration/ProjectStatusApiTests.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,135 @@ | ||
using Azure.Core; | ||
using Dfe.ManageFreeSchoolProjects.API.Contracts.Common; | ||
using Dfe.ManageFreeSchoolProjects.API.Contracts.Project; | ||
using Dfe.ManageFreeSchoolProjects.API.Contracts.ResponseModels; | ||
using Dfe.ManageFreeSchoolProjects.API.Tests.Fixtures; | ||
using Dfe.ManageFreeSchoolProjects.API.Tests.Helpers; | ||
using Dfe.ManageFreeSchoolProjects.API.UseCases.Project; | ||
using Dfe.ManageFreeSchoolProjects.API.UseCases.ProjectOverview; | ||
using System; | ||
using System.Net; | ||
using System.Net.Http.Json; | ||
using System.Threading.Tasks; | ||
|
||
namespace Dfe.ManageFreeSchoolProjects.API.Tests.Integration | ||
{ | ||
[Collection(ApiTestCollection.ApiTestCollectionName)] | ||
public class ProjectStatusApiTests : ApiTestsBase | ||
{ | ||
public ProjectStatusApiTests(ApiTestFixture apiTestFixture) : base(apiTestFixture) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task When_Post_ProjectDoesNotExist_Returns_404() | ||
{ | ||
var projectId = Guid.NewGuid().ToString(); | ||
var updateStatusRequest = _autoFixture.Create<UpdateProjectStatusRequest>(); | ||
|
||
var updateStatusResponse = await _client.PostAsync($"/api/v1/client/updateprojectstatus?projectId={projectId}", updateStatusRequest.ConvertToJson()); | ||
updateStatusResponse.StatusCode.Should().Be(HttpStatusCode.NotFound); | ||
} | ||
|
||
[Fact] | ||
public async Task When_Post_StatusValid_Returns_200() | ||
{ | ||
var project = DatabaseModelBuilder.BuildProject(); | ||
var projectId = project.ProjectStatusProjectId; | ||
var updateStatusRequest = new UpdateProjectStatusRequest() | ||
{ | ||
ProjectStatus = ProjectStatus.Open, | ||
ProjectCancelledReason = ProjectCancelledReason.NotSet, | ||
ProjectWithdrawnReason = ProjectWithdrawnReason.NotSet, | ||
CancelledDate = null, | ||
ClosedDate = null, | ||
WithdrawnDate = null, | ||
ProjectCancelledDueToNationalReviewOfPipelineProjects = null, | ||
ProjectWithdrawnDueToNationalReviewOfPipelineProjects = null, | ||
CommentaryForCancellation = null, | ||
CommentaryForWithdrawal = null | ||
|
||
}; | ||
|
||
|
||
using var context = _testFixture.GetContext(); | ||
context.Kpi.Add(project); | ||
await context.SaveChangesAsync(); | ||
|
||
var updateStatusResponse = await _client.PostAsync($"/api/v1/client/updateprojectstatus?projectId={projectId}", updateStatusRequest.ConvertToJson()); | ||
updateStatusResponse.StatusCode.Should().Be(HttpStatusCode.OK); | ||
|
||
var overviewResponse = await _client.GetAsync($"/api/v1/client/projects/{project.ProjectStatusProjectId}/overview"); | ||
overviewResponse.StatusCode.Should().Be(HttpStatusCode.OK); | ||
|
||
var result = await overviewResponse.Content.ReadFromJsonAsync<ApiSingleResponseV2<ProjectOverviewResponse>>(); | ||
|
||
// Project status | ||
var projectStatus = result.Data.ProjectStatus; | ||
projectStatus.ProjectStatus.Should().Be(ProjectStatus.Open); | ||
projectStatus.ProjectCancelledReason.Should().Be(ProjectCancelledReason.NotSet); | ||
projectStatus.ProjectWithdrawnReason.Should().Be(ProjectWithdrawnReason.NotSet); | ||
projectStatus.ProjectCancelledDate.Should().BeNull(); | ||
projectStatus.ProjectClosedDate.Should().BeNull(); | ||
projectStatus.ProjectWithdrawnDate.Should().BeNull(); | ||
projectStatus.ProjectCancelledDueToNationalReviewOfPipelineProjects.Should().BeNull(); | ||
projectStatus.ProjectWithdrawnDueToNationalReviewOfPipelineProjects.Should().BeNull(); | ||
projectStatus.CommentaryForCancellation.Should().BeNull(); | ||
projectStatus.CommentaryForWithdrawal.Should().BeNull(); | ||
|
||
|
||
} | ||
|
||
[Fact] | ||
public async Task When_Post_StatusCancelledValid_Returns_200() | ||
{ | ||
var project = DatabaseModelBuilder.BuildProject(); | ||
var projectId = project.ProjectStatusProjectId; | ||
|
||
var cancelledDate = DateTime.UtcNow.Date; | ||
var commentaryForCancellation = "Cancelled due to issues with planning"; | ||
var updateStatusRequest = new UpdateProjectStatusRequest() | ||
{ | ||
ProjectStatus = ProjectStatus.Cancelled, | ||
ProjectCancelledReason = ProjectCancelledReason.Planning, | ||
ProjectWithdrawnReason = ProjectWithdrawnReason.NotSet, | ||
CancelledDate = cancelledDate, | ||
ClosedDate = null, | ||
WithdrawnDate = null, | ||
ProjectCancelledDueToNationalReviewOfPipelineProjects = YesNo.No, | ||
ProjectWithdrawnDueToNationalReviewOfPipelineProjects = null, | ||
CommentaryForCancellation = commentaryForCancellation, | ||
CommentaryForWithdrawal = null | ||
|
||
}; | ||
|
||
|
||
using var context = _testFixture.GetContext(); | ||
context.Kpi.Add(project); | ||
await context.SaveChangesAsync(); | ||
|
||
var updateStatusResponse = await _client.PostAsync($"/api/v1/client/updateprojectstatus?projectId={projectId}", updateStatusRequest.ConvertToJson()); | ||
updateStatusResponse.StatusCode.Should().Be(HttpStatusCode.OK); | ||
|
||
var overviewResponse = await _client.GetAsync($"/api/v1/client/projects/{project.ProjectStatusProjectId}/overview"); | ||
overviewResponse.StatusCode.Should().Be(HttpStatusCode.OK); | ||
|
||
var result = await overviewResponse.Content.ReadFromJsonAsync<ApiSingleResponseV2<ProjectOverviewResponse>>(); | ||
|
||
// Project status | ||
var projectStatus = result.Data.ProjectStatus; | ||
projectStatus.ProjectStatus.Should().Be(ProjectStatus.Cancelled); | ||
projectStatus.ProjectCancelledReason.Should().Be(ProjectCancelledReason.Planning); | ||
projectStatus.ProjectWithdrawnReason.Should().Be(ProjectWithdrawnReason.NotSet); | ||
projectStatus.ProjectCancelledDate.Should().Be(cancelledDate); | ||
projectStatus.ProjectClosedDate.Should().BeNull(); | ||
projectStatus.ProjectWithdrawnDate.Should().BeNull(); | ||
projectStatus.ProjectCancelledDueToNationalReviewOfPipelineProjects.Should().Be(YesNo.No); | ||
projectStatus.ProjectWithdrawnDueToNationalReviewOfPipelineProjects.Should().BeNull(); | ||
projectStatus.CommentaryForCancellation.Should().Be(commentaryForCancellation); | ||
projectStatus.CommentaryForWithdrawal.Should().BeNull(); | ||
|
||
|
||
} | ||
|
||
} | ||
} |
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
Oops, something went wrong.