Skip to content

Commit

Permalink
Merge pull request #1144 from DFE-Digital/171882/CypressTestsForSchoo…
Browse files Browse the repository at this point in the history
…lImprovementPlans

Cypress Tests for School Improvement Plans
  • Loading branch information
FahadDarw authored Jul 3, 2024
2 parents c0c0de5 + 4721dc4 commit 5a58aa8
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import projectTaskList from "../../pages/projectTaskList";
import { schoolImprovementPage } from '../../pages/SchoolImprovementPage';
import { Logger } from '../../support/logger';

describe('School Improvement Plan Tests', () => {

let projectId;

beforeEach(() => {
Logger.log("Visit the homepage before each test");
projectTaskList.getHomePage();
});

it('Creating a conversion project and recording a new interim school improvement plan', () => {
Logger.log("Go to the home page then click create new conversion");
projectTaskList.clickCreateNewConversionBtn();

Logger.log("Click on create new conversion button on the next page");
projectTaskList.clickCreateNewConversionBtn();

Logger.log("Search and select the school, then click continue");
schoolImprovementPage.searchSchool('Manchester Academy (134224)').clickContinue();

Logger.log("Select no and continue on the next 3 pages regarding the school");
schoolImprovementPage.selectNoAndContinue();
schoolImprovementPage.selectNoAndContinue();
schoolImprovementPage.selectNoAndContinue();

Logger.log("Verify the selected school details");
schoolImprovementPage.assertSchoolDetails(
'Manchester Academy',
'134224',
'Manchester',
'Academy'
);

Logger.log("Click school details are correct, click continue");
schoolImprovementPage.clickContinue();

Logger.log("Search for the created project then select first one on the list");
schoolImprovementPage.clickOnFirstProject();

Logger.log("Capture the projectId dynamically from the URL");
cy.url().then((url) => {
projectId = url.match(/task-list\/(\d+)/)[1];
Logger.log(`Project ID: ${projectId}`);
}).then(() => {
Logger.log("Navigate to the section to record interim school improvement plan");
schoolImprovementPage.navigateToSchoolImprovementSection();

Logger.log("Click on 'Add school improvement plan'");
schoolImprovementPage.clickAddSchoolImprovementPlan();

Logger.log("Select who arranged the improvement plan");
schoolImprovementPage.selectImprovementDetails();

Logger.log("Save the who arranged the school improvement plan");
schoolImprovementPage.saveImprovementDetails();

Logger.log("Enter the who is providing the interim school improvement plan details");
schoolImprovementPage.enterImprovementDetails("Fahad-Cypress Test");

Logger.log("Enter the imprvoment plan's start date");
schoolImprovementPage.enterImprovementEndDate('12', '12', '2023');

Logger.log("Entering expected end date of the improvement plan");
schoolImprovementPage.enterExpectedEndDate('12', '11', '2024');

Logger.log("Select the confidence level of the improvement plan");
schoolImprovementPage.selectHighConfidenceLevel();

Logger.log("Entering comments on the interim school improvement plan");
schoolImprovementPage.enterComments('This is a test comment');

Logger.log("Verify the interim school improvement plan details are correct");
schoolImprovementPage.verifyImprovementDetails("Local Authority", "Fahad-Cypress Test", "12 December 2023", "12 November 2024", "High", "This is a test comment");
Logger.log("Verify the submitted interim school improvement plan details are saved correctly");
schoolImprovementPage.verifyTheFinalImprovementDetails("Local Authority", "Fahad-Cypress Test", "12 December 2023", "12 November 2024", "High", "This is a test comment");
Logger.log("change the details");
schoolImprovementPage.changeImprovementDetails("Cypress Test Interim schoool plan","Test comment");
Logger.log("Verify the changed interim school improvement plan details are saved correctly");
schoolImprovementPage.verifyChangedImprovementDetails("Regional Director, Local Authority", "Cypress Test Interim schoool plan", "12 December 2023", "Unknown", "Medium", "Test comment");

Logger.log("Delete the project and verify that it was deleted successfully - Project ID: " + projectId);
schoolImprovementPage.deleteProject(projectId);
});
});
});

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
export class SchoolImprovementPage {

searchSchool(schoolName) {
cy.get('#SearchQuery').type(schoolName);
cy.get('.autocomplete__input--default').first().click();
return this;
}

clickContinue() {
cy.get('[data-id="submit"]').click();
return this;
}

selectNoAndContinue() {
cy.get('[data-cy="select-legal-input-no"]').click();
cy.get('[data-cy="select-common-submitbutton"]').click();
return this;
}

assertSchoolDetails(schoolName, urn, localAuthority, schoolType) {
cy.get('[data-cy="school-name"]').should('contain', schoolName);
cy.get('.govuk-summary-list__value').eq(1).should('contain', urn);
cy.get('.govuk-summary-list__value').eq(3).should('contain', localAuthority);
cy.get('.govuk-summary-list__value').eq(5).should('contain', schoolType);
return this;
}

clickOnFirstProject() {
cy.get('[data-cy="select-projectlist-filter-title"]').type('Manchester Academy');
cy.get('[data-cy="select-projectlist-filter-apply"]').click();
cy.get('[data-cy="trust-name-Manchester Academy-0"]').click();
return this;
}

navigateToSchoolImprovementSection() {
cy.get('[data-cy="school_improvement_plans_menu"]').click();
return this;
}

clickAddSchoolImprovementPlan() {
cy.get('[data-cy="add_school_improvement_plan"]').click();
return this;
}

selectImprovementDetails() {
cy.get('#localauthority-checkbox').click();
return this;
}

saveImprovementDetails() {
cy.get('#submit-btn').click();
return this;
}

enterImprovementDetails(details) {
cy.get('#PlanProvider').type(details);
cy.get('#submit-btn').click();
return this;
}

enterImprovementEndDate(day, month, year) {
cy.get('#plan-start-date-day').clear();
cy.get('#plan-start-date-day').type(day);
cy.get('#plan-start-date-month').clear();
cy.get('#plan-start-date-month').type(month);
cy.get('#plan-start-date-year').clear();
cy.get('#plan-start-date-year').type(year);
cy.get('#submit-btn').click();
return this;
}

enterExpectedEndDate(day, month, year) {
cy.get('#Other-radio').click();
cy.get('#plan-end-date-other-day').clear;
cy.get('#plan-end-date-other-day').type(day);
cy.get('#plan-end-date-other-month').clear();
cy.get('#plan-end-date-other-month').type(month);
cy.get('#plan-end-date-other-year').clear()
cy.get('#plan-end-date-other-year').type(year);
cy.get('#submit-btn').click();
return this;
}
selectHighConfidenceLevel() {
cy.get('#High-radio').click();
cy.get('#submit-btn').click();
return this;
}
enterComments(comments) {
cy.get('#PlanComments').clear();
cy.get('#PlanComments').type(comments);
cy.get('#submit-btn').click();
return this;
}

verifyImprovementDetails(arrangedBy, providedBy, startDate, endDate, confidenceLevel, comments) {
cy.get('#arranged-by').should('contain', arrangedBy);
cy.get('#provided-by').eq(0).should('contain', providedBy);
cy.get('#start-date').should('contain', startDate);
cy.get('#end-date').should('contain', endDate);
cy.get('#confidence-level').should('contain', confidenceLevel);
cy.get('#comments').should('contain', comments);
cy.get('#submit-btn').click();
return this;
}

verifyTheFinalImprovementDetails(arrangedBy, providedBy, startDate, endDate, confidenceLevel, comments) {
cy.get('[data-cy="arranged-by"]').should('contain', arrangedBy);
cy.get('[data-cy="provided-by"]').eq(0).should('contain', providedBy);
cy.get('[data-cy="start-date"]').should('contain', startDate);
cy.get('[data-cy="end-date"]').should('contain', endDate);
cy.get('[data-cy="confidence-leve"]').should('contain', confidenceLevel);
cy.get('[data-cy="comments"]').should('contain', comments);
return this;
}
changeImprovementDetails(providedBy,comments) {
cy.get('#change-arranger-btn').click();
cy.get('#regionaldirector-checkbox').click();
cy.get('#submit-btn').click();
cy.get('#PlanProvider').clear();
cy.get('#PlanProvider').type(providedBy);
cy.get('#submit-btn').click();
cy.get('#submit-btn').click();
cy.get('#Unknown-radio').click();
cy.get('#submit-btn').click();
cy.get('#Medium-radio').click();
cy.get('#submit-btn').click();
cy.get('#PlanComments').clear();
cy.get('#PlanComments').type(comments);
cy.get('#submit-btn').click();
return this;
}

verifyChangedImprovementDetails(arrangedBy, providedBy, startDate, endDate, confidenceLevel, comments) {
cy.get('#arranged-by').should('contain', arrangedBy);
cy.get('#provided-by').eq(0).should('contain', providedBy);
cy.get('#start-date').should('contain', startDate);
cy.get('#end-date').should('contain', endDate);
cy.get('#confidence-level').should('contain', confidenceLevel);
cy.get('#comments').should('contain', comments);
cy.get('#submit-btn').click();
return this;
}
deleteProject(projectId) {
cy.callAcademisationApi("DELETE", `/conversion-project/${projectId}/Delete`).then((response) => {
expect(response.status).to.eq(200);
});
}
}

export const schoolImprovementPage = new SchoolImprovementPage();
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<dt class="govuk-summary-list__key">
Arranged by
</dt>
<dd class="govuk-summary-list__value">
<dd class="govuk-summary-list__value" data-cy="arranged-by">
@plan.ArrangedBy.Select(x => x.ToDescription()).Aggregate(string.Empty, (partialPhrase, word) =>
{
var result = string.IsNullOrWhiteSpace(partialPhrase) ? word : $"{partialPhrase}, {word}";
Expand All @@ -60,7 +60,7 @@
<dt class="govuk-summary-list__key">
Provided by
</dt>
<dd class="govuk-summary-list__value">
<dd class="govuk-summary-list__value" data-cy="provided-by">
@plan.ProvidedBy
</dd>
<dd class="govuk-summary-list__actions">
Expand All @@ -71,18 +71,18 @@
<dt class="govuk-summary-list__key">
Start date
</dt>
<dd class="govuk-summary-list__value">
<dd class="govuk-summary-list__value" data-cy="start-date">
@plan.StartDate.Value.ToString(Constants.DateTimeFormat)
</dd>
<dd class="govuk-summary-list__actions">
<a class="govuk-link" asp-page="@Links.SchoolImprovementPlans.StartDateOfThePlan.Page" asp-route-id="@Model.Project.Id" asp-route-sipId="@plan.Id">Change<span class="govuk-visually-hidden"> the start date of the plan</span></a>
</dd>
</div>
<div class="govuk-summary-list__row">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
Expected end date
</dt>
<dd class="govuk-summary-list__value">
<dd class="govuk-summary-list__value" data-cy="end-date">
@if (plan.ExpectedEndDate.Value == SchoolImprovementPlanExpectedEndDate.Other)
{
@plan.ExpectedEndDateOther.Value.ToString(Constants.DateTimeFormat)
Expand Down Expand Up @@ -111,7 +111,7 @@
<dt class="govuk-summary-list__key">
Confidence level
</dt>
<dd class="govuk-summary-list__value">
<dd class="govuk-summary-list__value" data-cy="confidence-leve">
@plan.ConfidenceLevel.ToDescription()
</dd>
<dd class="govuk-summary-list__actions">
Expand All @@ -122,7 +122,7 @@
<dt class="govuk-summary-list__key">
Comments
</dt>
<dd class="govuk-summary-list__value">
<dd class="govuk-summary-list__value" data-cy="comments">
@plan.PlanComments
</dd>
<dd class="govuk-summary-list__actions">
Expand All @@ -134,7 +134,7 @@
</div>
}
}
<a asp-page="@Links.SchoolImprovementPlans.WhoArrangedThePlan.Page" asp-route-id="@Model.Project.Id" role="button" draggable="false" class="govuk-button govuk-button" data-module="govuk-button">
<a asp-page="@Links.SchoolImprovementPlans.WhoArrangedThePlan.Page" asp-route-id="@Model.Project.Id" data-cy="add_school_improvement_plan" role="button" draggable="false" class="govuk-button govuk-button" data-module="govuk-button">
Add school improvement plan
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
Project notes
</sub-menu-link>
</li>
<li if="@Model.IsSponsored" class="moj-sub-navigation__item">
<li if="@Model.IsSponsored" class="moj-sub-navigation__item" data-cy="school_improvement_plans_menu">
<sub-menu-link class="moj-sub-navigation__link"
asp-page="@Links.SchoolImprovementPlans.Index.Page"
asp-route-id="@id">
Expand Down

0 comments on commit 5a58aa8

Please sign in to comment.