Skip to content

Commit

Permalink
Merge pull request #838 from DFE-Digital/test/readiness-to-open-meeting
Browse files Browse the repository at this point in the history
Readiness to open meeting test
  • Loading branch information
sukhybhullar-nimble authored Sep 23, 2024
2 parents a8cb395 + 87c2671 commit 686b432
Show file tree
Hide file tree
Showing 3 changed files with 277 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import { ProjectDetailsRequest } from "cypress/api/domain";
import projectApi from "cypress/api/projectApi";
import { RequestBuilder } from "cypress/api/requestBuilder";
import { Logger } from "cypress/common/logger";
import summaryPage from "cypress/pages/task-summary-base";
import taskListPage from "cypress/pages/taskListPage";
import readinessToOpenMeetingEditPage from "../../../pages/tasks/Getting-ready-to-open/edit-readiness-to-open-meeting-cy";

describe("Testing readiness to open meeting task", () => {

let project: ProjectDetailsRequest;

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

project = RequestBuilder.createProjectDetails();

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

it("Should be able to set readiness to open meeting", () => {
Logger.log("Select moving to open");
taskListPage.isTaskStatusIsNotStarted("ReadinessToOpenMeeting")
.selectReadinessToOpenMeetingFromTaskList();

summaryPage
.schoolNameIs(project.schoolName)
.titleIs("Readiness to open meeting (ROM)")
.inOrder()
.summaryShows("Type of meeting held").IsEmpty().HasChangeLink()
.summaryShows("Principal designate (PD) has provided the checklist").IsEmpty().HasChangeLink()
.summaryShows("Commissioned an external expert to attend any meetings (if applicable)").IsEmpty().HasChangeLink()
.summaryShows("Saved the internal ROM report in Workplaces folder").IsEmpty().HasChangeLink()
.summaryShows("Saved the external ROM report in Workplaces folder").IsEmpty().HasChangeLink()
.isNotMarkedAsComplete()
.reviewRiskRating();

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

taskListPage.selectReadinessToOpenMeetingFromTaskList();
summaryPage.clickChange();

Logger.log("Readiness to Open Meeting can save null values");

readinessToOpenMeetingEditPage
.clickContinue()

Logger.log("Readiness to Open Meeting can be edited");

summaryPage.clickChange();

readinessToOpenMeetingEditPage
.selectFormalMeeting()
.dateOfTheFormalMeeting("60", "12", "2050")
.clickContinue()
.errorForFormalMeetingDate("Day must be between 1 and 31")
.dateOfTheFormalMeeting("30", "12", "1999")
.clickContinue()
.errorForFormalMeetingDate("Year must be between 2000 and 2050")
.dateOfTheFormalMeeting("5", "5", "2040")
.checkPrincipalDesignate()
.checkCommissionedAnExternalExpert()
.checkSavedTheInternalRomReport()
.checkSavedTheExternalRomReport()
.clickContinue()

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

summaryPage
.schoolNameIs(project.schoolName)
.titleIs("Readiness to open meeting (ROM)")
.inOrder()
.summaryShows("Type of meeting held").HasValue("Formal meeting").HasChangeLink()
.summaryShows("Date of the meeting").HasValue("5 May 2040").HasChangeLink()
.summaryShows("Principal designate (PD) has provided the checklist").HasValue("Yes").HasChangeLink()
.summaryShows("Commissioned an external expert to attend any meetings (if applicable)").HasValue("Yes").HasChangeLink()
.summaryShows("Saved the internal ROM report in Workplaces folder").HasValue("Yes").HasChangeLink()
.summaryShows("Saved the external ROM report in Workplaces folder").HasValue("Yes").HasChangeLink()
.isNotMarkedAsComplete()
.clickConfirmAndContinue()

taskListPage.isTaskStatusInProgress("ReadinessToOpenMeeting");

taskListPage.selectReadinessToOpenMeetingFromTaskList();

Logger.log("Readiness to Open Meeting can be edited again with No ROM held option");

summaryPage.clickChange();

readinessToOpenMeetingEditPage
.selectNoRomHeld()
.whyMeetingWasNotHeld()
.uncheckPrincipalDesignate()
.checkCommissionedAnExternalExpert()
.uncheckSavedTheInternalRomReport()
.checkSavedTheExternalRomReport()
.clickContinue()

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

summaryPage
.schoolNameIs(project.schoolName)
.titleIs("Readiness to open meeting (ROM)")
.inOrder()
.summaryShows("Type of meeting held").HasValue("No meeting held").HasChangeLink()
.summaryShows("Why a meeting was not held").HasValue("This is the reason why meeting was not held").HasChangeLink()
.summaryShows("Principal designate (PD) has provided the checklist").IsEmpty().HasChangeLink()
.summaryShows("Commissioned an external expert to attend any meetings (if applicable)").HasValue("Yes").HasChangeLink()
.summaryShows("Saved the internal ROM report in Workplaces folder").IsEmpty().HasChangeLink()
.summaryShows("Saved the external ROM report in Workplaces folder").HasValue("Yes").HasChangeLink()
.isNotMarkedAsComplete()
.clickConfirmAndContinue()

taskListPage.isTaskStatusInProgress("ReadinessToOpenMeeting");

taskListPage.selectReadinessToOpenMeetingFromTaskList();
summaryPage.clickChange();

Logger.log("Should be able to select Informal meeting");

readinessToOpenMeetingEditPage
.selectInformalMeeting()
.dateOfTheInformalMeeting("60", "12", "2050")
.clickContinue()
.errorForInformalMeetingDate("Day must be between 1 and 31")
.dateOfTheInformalMeeting("30", "12", "1999")
.clickContinue()
.errorForInformalMeetingDate("Year must be between 2000 and 2050")
.dateOfTheInformalMeeting("23", "5", "2030")
.checkPrincipalDesignate()
.checkCommissionedAnExternalExpert()
.checkSavedTheInternalRomReport()
.checkSavedTheExternalRomReport()
.clickContinue()

summaryPage
.schoolNameIs(project.schoolName)
.titleIs("Readiness to open meeting (ROM)")
.inOrder()
.summaryShows("Type of meeting held").HasValue("Informal meeting").HasChangeLink()
.summaryShows("Date of the meeting").HasValue("23 May 2030").HasChangeLink()
.summaryShows("Principal designate (PD) has provided the checklist").HasValue("Yes").HasChangeLink()
.summaryShows("Commissioned an external expert to attend any meetings (if applicable)").HasValue("Yes").HasChangeLink()
.summaryShows("Saved the internal ROM report in Workplaces folder").HasValue("Yes").HasChangeLink()
.summaryShows("Saved the external ROM report in Workplaces folder").HasValue("Yes").HasChangeLink()
.isNotMarkedAsComplete()
.MarkAsComplete()
.clickConfirmAndContinue()

taskListPage.isTaskStatusIsCompleted("ReadinessToOpenMeeting");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ export class SummaryPage {
cy.getByTestId("create-project").contains(name);
return this;
}

public reviewRiskRating() {
cy.get('h2').contains('Review risk rating')
}
}

const summaryPage = new SummaryPage();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
class ReadinessToOpenMeetingEditPage {
private errorTracking = "";

selectFormalMeeting(): this {
cy.getById("formal-meeting-option").click()
return this
}

selectInformalMeeting(): this {
cy.getById("informal-meeting-option").click()
return this
}

selectNoRomHeld(): this {
cy.getById("no-rom-held-option").click()
return this
}

checkPrincipalDesignate(): this {
cy.getById("principal-designate-has-provided-checklist").check()
return this
}

checkCommissionedAnExternalExpert(): this {
cy.getById("commissioned-external-expert-to-attend-any-meetings").check()
return this
}

checkSavedTheInternalRomReport(): this {
cy.getById("saved-the-internal-rom-report-workplaces-folder").check()
return this
}

checkSavedTheExternalRomReport(): this {
cy.getById("saved-the-external-rom-report-workplaces-folder").check()
return this
}

whyMeetingWasNotHeld(): this {
cy.getById("why-meeting-not-held").type('This is the reason why meeting was not held')
return this
}

uncheckPrincipalDesignate(): this {
cy.getById("principal-designate-has-provided-checklist").uncheck()
return this
}

uncheckCommissionedAnExternalExpert(): this {
cy.getById("commissioned-external-expert-to-attend-any-meetings").uncheck()
return this
}

uncheckSavedTheInternalRomReport(): this {
cy.getById("saved-the-internal-rom-report-workplaces-folder").uncheck()
return this
}

uncheckSavedTheExternalRomReport(): this {
cy.getById("saved-the-external-rom-report-workplaces-folder").uncheck()
return this
}

dateOfTheFormalMeeting(day: string, month: string, year: string): this {
const key = "date-of-the-formal-meeting";
this.setDate(key, day, month, year);
return this
}

dateOfTheInformalMeeting(day: string, month: string, year: string): this {
const key = "date-of-the-informal-meeting";
this.setDate(key, day, month, year);
return this
}

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);
}
clickContinue(): this {
cy.getByTestId("continue").click();
return this;
}

errorForFormalMeetingDate(error: string): this {
cy.getById('date-of-the-formal-meeting-error').contains(error)
return this
}

errorForInformalMeetingDate(error: string): this {
cy.getById('date-of-the-informal-meeting-error').contains(error)
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;
}

}

const readinessToOpenMeetingEditPage = new ReadinessToOpenMeetingEditPage();
export default readinessToOpenMeetingEditPage;

0 comments on commit 686b432

Please sign in to comment.