Skip to content

Commit

Permalink
Updated wording impact assessment and improved cypress tests (#893)
Browse files Browse the repository at this point in the history
* Updated wording impact assessment and improved cypress tests]

* Release notes

* Removed booleans literals
  • Loading branch information
jack-nimbleapproach authored Oct 9, 2024
1 parent 554041d commit 63473c9
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import summaryPage from "cypress/pages/task-summary-base";
import taskListPage from "cypress/pages/taskListPage";
import impactAssessmentEditPage from "../../../pages/tasks/Getting-ready-to-open/edit-impact-assessment-cy";

describe("Testing the impact assessment task", () => {
describe("Testing the impact assessment task - presumption route", () => {

let project: ProjectDetailsRequest;

Expand Down Expand Up @@ -34,6 +34,103 @@ describe("Testing the impact assessment task", () => {
.titleIs("Impact assessment")
.inOrder()
.summaryShows("Conducted the impact assessment").IsEmpty().HasChangeLink()
.summaryShows("Saved the signed-off impact assessment in Workplaces folder").IsEmpty().HasChangeLink()
.isNotMarkedAsComplete();

Logger.log("Go back to task list");
summaryPage.clickBack();

taskListPage.selectImpactAssessmentFromTaskList();
summaryPage.clickChange();

Logger.log("Impact assessment can save null values");

impactAssessmentEditPage
.clickContinue()

summaryPage
.schoolNameIs(project.schoolName)
.titleIs("Impact assessment")
.inOrder()
.summaryShows("Conducted the impact assessment").IsEmpty().HasChangeLink()
.summaryShows("Saved the signed-off impact assessment in Workplaces folder").IsEmpty().HasChangeLink()
.isNotMarkedAsComplete()
.clickChange();

cy.executeAccessibilityTests();

Logger.log("Impact assessment can be edited");

impactAssessmentEditPage
.checkImpactAssessmentDone()
.checkSavedToWorkplaces()
.clickContinue()

Logger.log("Should update the task status");

summaryPage
.schoolNameIs(project.schoolName)
.titleIs("Impact assessment")
.inOrder()
.summaryShows("Conducted the impact assessment").HasValue("Yes").HasChangeLink()
.summaryShows("Saved the signed-off impact assessment in Workplaces folder").HasValue("Yes").HasChangeLink()
.isNotMarkedAsComplete()
.clickConfirmAndContinue()

taskListPage.isTaskStatusInProgress("ImpactAssessment");

taskListPage.selectImpactAssessmentFromTaskList();
summaryPage.clickChange();

impactAssessmentEditPage
.uncheckImpactAssessmentDone()
.uncheckSavedToWorkplaces()
.clickContinue()

summaryPage
.schoolNameIs(project.schoolName)
.titleIs("Impact assessment")
.inOrder()
.summaryShows("Conducted the impact assessment").IsEmpty().HasChangeLink()
.summaryShows("Saved the signed-off impact assessment in Workplaces folder").IsEmpty().HasChangeLink()
.isNotMarkedAsComplete()
.MarkAsComplete()
.clickConfirmAndContinue()

taskListPage.isTaskStatusIsCompleted("ImpactAssessment");
});
});

describe("Testing the impact assessment task - central route", () => {

let project: ProjectDetailsRequest;

beforeEach(() => {
cy.login();

project = RequestBuilder.createProjectDetailsCentralRoute();

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

it("Should include section 9 letter wording for saved in workplaces label", () => {
Logger.log("Select impact assessment");
taskListPage.isTaskStatusIsNotStarted("ImpactAssessment")
.selectImpactAssessmentFromTaskList();

summaryPage
.schoolNameIs(project.schoolName)
.titleIs("Impact assessment")
.inOrder()
.summaryShows("Sent the section 9 letter to local authority").HasValue("No").HasChangeLink()
.summaryShows("Date sent").IsEmpty().HasChangeLink()
.summaryShows("Conducted the impact assessment").IsEmpty().HasChangeLink()
.summaryShows("Saved the section 9 letter and signed-off impact assessment in Workplaces folder").IsEmpty().HasChangeLink()
.isNotMarkedAsComplete();

Expand All @@ -52,6 +149,8 @@ describe("Testing the impact assessment task", () => {
.schoolNameIs(project.schoolName)
.titleIs("Impact assessment")
.inOrder()
.summaryShows("Sent the section 9 letter to local authority").HasValue("No").HasChangeLink()
.summaryShows("Date sent").IsEmpty().HasChangeLink()
.summaryShows("Conducted the impact assessment").IsEmpty().HasChangeLink()
.summaryShows("Saved the section 9 letter and signed-off impact assessment in Workplaces folder").IsEmpty().HasChangeLink()
.isNotMarkedAsComplete()
Expand All @@ -72,6 +171,8 @@ describe("Testing the impact assessment task", () => {
.schoolNameIs(project.schoolName)
.titleIs("Impact assessment")
.inOrder()
.summaryShows("Sent the section 9 letter to local authority").HasValue("No").HasChangeLink()
.summaryShows("Date sent").IsEmpty().HasChangeLink()
.summaryShows("Conducted the impact assessment").HasValue("Yes").HasChangeLink()
.summaryShows("Saved the section 9 letter and signed-off impact assessment in Workplaces folder").HasValue("Yes").HasChangeLink()
.isNotMarkedAsComplete()
Expand All @@ -80,9 +181,37 @@ describe("Testing the impact assessment task", () => {
taskListPage.isTaskStatusInProgress("ImpactAssessment");

taskListPage.selectImpactAssessmentFromTaskList();

summaryPage.clickChange();

impactAssessmentEditPage
.checkSentSection9()
.withDateSent("2","ds","2050")
.clickContinue()
.errorDateSent().showsError("Enter a date in the correct format")
.withDateSent("2","2","2090")
.clickContinue()
.errorDateSent().showsError("Year must be between 2000 and 2050")
.withDateSent("2","2","1999")
.clickContinue()
.errorDateSent().showsError("Year must be between 2000 and 2050")
.withDateSent("2","2","2049")
.clickContinue()

summaryPage
.schoolNameIs(project.schoolName)
.titleIs("Impact assessment")
.inOrder()
.summaryShows("Sent the section 9 letter to local authority").HasValue("Yes").HasChangeLink()
.summaryShows("Date sent").HasValue("2 February 2049").HasChangeLink()
.summaryShows("Conducted the impact assessment").HasValue("Yes").HasChangeLink()
.summaryShows("Saved the section 9 letter and signed-off impact assessment in Workplaces folder").HasValue("Yes").HasChangeLink()
.isNotMarkedAsComplete()
.clickChange();

impactAssessmentEditPage
.uncheckSentSection9()
.withDateSent("", "", "")
.uncheckImpactAssessmentDone()
.uncheckSavedToWorkplaces()
.clickContinue()
Expand All @@ -91,6 +220,8 @@ describe("Testing the impact assessment task", () => {
.schoolNameIs(project.schoolName)
.titleIs("Impact assessment")
.inOrder()
.summaryShows("Sent the section 9 letter to local authority").HasValue("No").HasChangeLink()
.summaryShows("Date sent").IsEmpty().HasChangeLink()
.summaryShows("Conducted the impact assessment").IsEmpty().HasChangeLink()
.summaryShows("Saved the section 9 letter and signed-off impact assessment in Workplaces folder").IsEmpty().HasChangeLink()
.isNotMarkedAsComplete()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
class ImpactAssessmentEditPage {


private errorTracking = "";
private setDate(key: string, day: string, month: string, year: string) {
cy.get('#' + `${key}-day`).typeFast(day);
cy.get('#' + `${key}-month`).typeFast(month);
cy.get('#' + `${key}-year`).typeFast(year);
}

checkImpactAssessmentDone(): this {
cy.getById("impact-assessment-done").check()
Expand All @@ -21,6 +25,44 @@ class ImpactAssessmentEditPage {
cy.getById("saved-to-workplaces").uncheck()
return this
}

checkSentSection9(): this {
cy.getById("sent-section9-letter-to-local-authority").check()
return this
}

uncheckSentSection9(): this {
cy.getById("sent-section9-letter-to-local-authority").uncheck()
return this
}

withDateSent(day: string, month: string, year: string): this {
const key = "date-sent";
this.setDate(key, day, month, year);
return this
}

errorDateSent(): this {
this.errorTracking = "date-sent";
return this;
}

showsError(error: string)
{
cy.get(`#${this.errorTracking}-error-link`)
.should("contain.text", error);

cy.get(`#${this.errorTracking}-error-link`)
.invoke('attr', 'href')
.then((href) => {
cy.get(href as string).should("exist");
});

cy.get(`#${this.errorTracking}-error`)
.should("contain.text", error);
return this;
}

clickContinue() : this {
cy.getByTestId("continue").click();
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
ViewData["Title"] = $"Edit Impact assessment - {Model.SchoolName}";

var backlink = string.Format(RouteConstants.ViewImpactAssessmentTask, Model.ProjectId);

var SavedInWorkplacesFolderLabel = Model.IsPresumptionRoute
? "Saved the signed-off impact assessment in Workplaces folder"
: "Saved the section 9 letter and signed-off impact assessment in Workplaces folder";

}

@section BeforeMain {
Expand Down Expand Up @@ -59,7 +64,7 @@
id="impact-assessment-done"
add-margin=false />

<govuk-checkbox-input label="Saved section 9 letter and signed-off impact assessment in Workplaces folder"
<govuk-checkbox-input label="@SavedInWorkplacesFolderLabel"
asp-for="@Model.SavedToWorkplaces"
name="saved-to-workplaces"
id="saved-to-workplaces"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.Extensions.Logging;
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using Dfe.ManageFreeSchoolProjects.Models;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
var editlink = string.Format(RouteConstants.EditImpactAssessmentTask, Model.ProjectId);
var impactAssessment = Model.Project.ImpactAssessment;

var SavedInWorkplacesFolderLabel = Model.Project.IsPresumptionRoute
? "Saved the signed-off impact assessment in Workplaces folder"
: "Saved the section 9 letter and signed-off impact assessment in Workplaces folder";

Model.Section9LetterSentToLocalAuthority = impactAssessment.Section9LetterDateSent != null;
}

Expand Down Expand Up @@ -35,7 +39,7 @@
}
}
<govuk-summary-item label="Conducted the impact assessment" asp-for="@impactAssessment.ImpactAssessment" href="@editlink"/>
<govuk-summary-item label="Saved the section 9 letter and signed-off impact assessment in Workplaces folder" asp-for="@impactAssessment.SavedToWorkplaces" href="@editlink"/>
<govuk-summary-item label="@SavedInWorkplacesFolderLabel" asp-for="@impactAssessment.SavedToWorkplaces" href="@editlink" />
</govuk-summary-list>
<form method="post">
<govuk-checkbox-input label="Mark this section as complete, you can still make changes later"
Expand Down
1 change: 1 addition & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* 181754 - Build: readiness to open meeting (ROM) forecast date
* 183590 - BUG: Start End Year component still refers to "start date" in error message
* 180341 - Build: MFSP team to amend the footer
* 182832 - Build: Remove ‘section 9 letter’ from Workplaces checkbox

## 0.13.0
* 147110 - Build: Readiness to open meeting (ROM)
Expand Down

0 comments on commit 63473c9

Please sign in to comment.