Skip to content

Commit

Permalink
Updated site information for central route. Awaiting confirmation of … (
Browse files Browse the repository at this point in the history
#888)

* Updated site information for central route. Awaiting confirmation of correct wording

* Updated API tests

* Updated inset text and tests

* Updated inset text width
  • Loading branch information
jack-nimbleapproach authored Oct 11, 2024
1 parent d011c2f commit b41a54b
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public class GetProjectSitesResponse
public ProjectSite PermanentSite { get; set; } = new();
public ProjectSite TemporarySite { get; set; } = new();
public string SchoolName { get; set; }
public string ProjectType { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Sites;
using Dfe.ManageFreeSchoolProjects.API.Contracts.Project;
using Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Sites;
using Dfe.ManageFreeSchoolProjects.API.Contracts.ResponseModels;
using Dfe.ManageFreeSchoolProjects.API.Tests.Fixtures;
using Dfe.ManageFreeSchoolProjects.API.Tests.Helpers;
Expand All @@ -22,6 +23,8 @@ public async Task When_SitesDoNotExist_Returns_200()
var project = DatabaseModelBuilder.BuildProject();
var projectId = project.ProjectStatusProjectId;

project.ProjectStatusFreeSchoolApplicationWave = DatabaseModelBuilder.CreateProjectWave(ProjectType.PresumptionRoute);

using var context = _testFixture.GetContext();
context.Kpi.Add(project);
await context.SaveChangesAsync();
Expand All @@ -46,6 +49,7 @@ public async Task When_SitesDoNotExist_Returns_200()
AssertionHelper.AssertProjectSite(actualTemporarySite, updateTemporarySiteRequest);

content.Data.SchoolName.Should().Be(project.ProjectStatusCurrentFreeSchoolName);
content.Data.ProjectType.Should().Be("Presumption");
}

[Fact]
Expand All @@ -54,6 +58,8 @@ public async Task When_SitesExist_Returns_200()
var project = DatabaseModelBuilder.BuildProject();
var projectId = project.ProjectStatusProjectId;

project.ProjectStatusFreeSchoolApplicationWave = DatabaseModelBuilder.CreateProjectWave(ProjectType.PresumptionRoute);

using var context = _testFixture.GetContext();
context.Kpi.Add(project);
await context.SaveChangesAsync();
Expand All @@ -78,6 +84,8 @@ public async Task When_SitesExist_Returns_200()

AssertionHelper.AssertProjectSite(actualPermanentSite, updatePermanentSiteRequest);
AssertionHelper.AssertProjectSite(actualTemporarySite, updateTemporarySiteRequest);

content.Data.ProjectType.Should().Be("Presumption");
}

[Fact]
Expand All @@ -86,6 +94,8 @@ public async Task When_SiteNotConfigured_Returns_200()
var project = DatabaseModelBuilder.BuildProject();
var projectId = project.ProjectStatusProjectId;

project.ProjectStatusFreeSchoolApplicationWave = DatabaseModelBuilder.CreateProjectWave(ProjectType.PresumptionRoute);

using var context = _testFixture.GetContext();
context.Kpi.Add(project);
await context.SaveChangesAsync();
Expand All @@ -97,6 +107,8 @@ public async Task When_SiteNotConfigured_Returns_200()

AssertBlankSite(content.Data.PermanentSite);
AssertBlankSite(content.Data.TemporarySite);

content.Data.ProjectType.Should().Be("Presumption");
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Sites;
using Dfe.ManageFreeSchoolProjects.API.Contracts.Project;
using Dfe.ManageFreeSchoolProjects.API.Contracts.Project.Sites;
using Dfe.ManageFreeSchoolProjects.API.Exceptions;
using Dfe.ManageFreeSchoolProjects.Data;
using Dfe.ManageFreeSchoolProjects.Data.Entities.Existing;
Expand Down Expand Up @@ -41,11 +42,17 @@ public async Task<GetProjectSitesResponse> Execute(Kpi project)
var permanentSite = sites.FirstOrDefault(p => p.IsPermanentSite());
var temporarySite = sites.FirstOrDefault(p => p.IsTemporarySite());

var projectType =
project.ProjectStatusFreeSchoolApplicationWave == "FS - Presumption"
? "Presumption"
: "Central Route";

var result = new GetProjectSitesResponse()
{
PermanentSite = MapToSite(permanentSite),
TemporarySite = MapToSite(temporarySite),
SchoolName = project.ProjectStatusCurrentFreeSchoolName,
ProjectType = projectType,
};

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import editSiteInformationPage from "cypress/pages/siteInformation/editSiteInfor
import viewSiteInformationPage from "cypress/pages/siteInformation/viewSiteInformationPage";
import validationComponent from "cypress/pages/validationComponent";

describe("Testing the setting up of project sites", () => {
describe("Testing the setting up of project sites - presumption route", () => {
let project: ProjectDetailsRequest;

beforeEach(() => {
Expand Down Expand Up @@ -150,4 +150,51 @@ describe("Testing the setting up of project sites", () => {
.hasTemporarySiteAddress("Alternative temporary site", "Alternative temporary street", "Alternative temporary town")
.hasTemporarySitePostcode("TE1 3RD");
});

});

describe("Testing the setting up of project sites - central route", () => {
let project: ProjectDetailsRequest;
beforeEach(() => {
cy.login();

project = RequestBuilder.createProjectDetailsCentralRoute();

projectApi
.post({
projects: [project],
})
.then(() => {
cy.visit(`/projects/${project.projectId}/overview`);
});
});

it("Should be not allow user to able to edit the project sites for a central route project", () => {
Logger.log("When there are no project sites should display empty");
projectOverviewPage
.hasTemporarySiteAddress("Empty", "", "")
.hasTemporarySitePostcode("Empty")
.hasPermanentSiteAddress("Empty", "", "")
.hasPermanentSitePostcode("Empty");

projectOverviewPage.changeSiteInformation();

viewSiteInformationPage
.hasSchoolName(project.schoolName)
.checkInsetTextExists()
.hasTemporarySiteAddress("Empty", "", "")
.hasTemporarySitePostcode("Empty")
.hasTemporarySiteDatePlanningPermissionObtained("Empty")
.hasTemporarySiteStartDateOfOccupation("Empty")
.changeTemporarySiteShouldNotExist()
.hasPermanentSiteAddress("Empty", "", "")
.hasPermanentSitePostcode("Empty")
.hasPermanentSiteDatePlanningPermissionObtained("Empty")
.hasPermanentSiteStartDateOfOccupation("Empty")
.changePermanentSiteShouldNotExist();

cy.executeAccessibilityTests();

});

});
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ export class ViewSiteInformationPage {
return this;
}

public checkInsetTextExists() {
cy.getByTestId("central-route-hint").should("exist");

return this;
}

public changeTemporarySiteShouldNotExist(): this {
cy.getById("change-temporary-site").should("not.exist");

return this;
}

public changePermanentSiteShouldNotExist(): this {
cy.getById("change-permanent-site").should("not.exist");

return this;
}

public backToProject(): this {
cy.get(".govuk-back-link").click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ public EditSiteInformationModel(

public async Task<IActionResult> OnGet()
{

var sites = await _getProjectSitesService.Execute(ProjectId);

if(sites.ProjectType == "Central Route")
{
return new NotFoundResult();
}

var site = GetProjectSite(sites);

AddressLine1 = site.Address.AddressLine1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
@model Dfe.ManageFreeSchoolProjects.Pages.Project.SiteInformation.ViewSiteInformationModel
@{
var backLink = string.Format(RouteConstants.ProjectOverview, Model.ProjectId);
var editPermanentSite = string.Format(RouteConstants.EditPermanentSiteInformation, Model.ProjectId);
var editTemporarySite = string.Format(RouteConstants.EditTemporarySiteInformation, Model.ProjectId);
var projectType = Model.SiteInformation.ProjectType;
var editPermanentSite = projectType == "Central Route" ? "" : string.Format(RouteConstants.EditPermanentSiteInformation, Model.ProjectId);
var editTemporarySite = projectType == "Central Route" ? "" : string.Format(RouteConstants.EditTemporarySiteInformation, Model.ProjectId);

ViewData["Title"] = $"Site information - {Model.SiteInformation.SchoolName}";
}
@section BeforeMain {
<div class="govuk-width-container">
<a href="@backLink" class="govuk-back-link">Back to about the project</a>
<a href="@backLink" class="govuk-back-link">Back</a>
</div>
}

Expand All @@ -20,5 +21,14 @@
Site information
</h1>

<govuk-site-details site="@Model.SiteInformation.TemporarySite" edit-link="@editTemporarySite" site-type="@ProjectSiteType.Temporary.ToString()" />
<govuk-site-details site="@Model.SiteInformation.PermanentSite" edit-link="@editPermanentSite" site-type="@ProjectSiteType.Permanent.ToString()" />
@{
if (projectType == "Central Route")
{
<div class="govuk-inset-text govuk-!-width-two-thirds" data-testid="central-route-hint">
Site information is in the Construct system for central route projects. Contact Education Estates to access it.
</div>
}
}

<govuk-site-details site="@Model.SiteInformation.TemporarySite" edit-link="@editTemporarySite" site-type="@ProjectSiteType.Temporary.ToString()" project-type="@Model.SiteInformation.ProjectType" />
<govuk-site-details site="@Model.SiteInformation.PermanentSite" edit-link="@editPermanentSite" site-type="@ProjectSiteType.Permanent.ToString()" project-type="@Model.SiteInformation.ProjectType" />
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
<div class="govuk-summary-card">
<div class="govuk-summary-card__title-wrapper">
<h2 class="govuk-summary-card__title">@Model.SiteType site</h2>
<div class="govuk-summary-card__actions">
<a class="govuk-link" href="@Model.EditLink" data-testid="change-@Model.IdPrefix-site">
Change<span class="govuk-visually-hidden">Change @Model.SiteType?.ToLower() site information</span>
</a>
</div>
@if(Model.EditLink != "")
{
<div class="govuk-summary-card__actions">
<a class="govuk-link" href="@Model.EditLink" data-testid="change-@Model.IdPrefix-site">
Change<span class="govuk-visually-hidden">Change @Model.SiteType?.ToLower() site information</span>
</a>
</div>
}
</div>

<div class="govuk-summary-card__content">
Expand Down

0 comments on commit b41a54b

Please sign in to comment.