From ceaee40ed9d23a748791e4cb941796cca6a6b768 Mon Sep 17 00:00:00 2001 From: FahadDarw Date: Tue, 2 Jul 2024 12:25:24 +0100 Subject: [PATCH 1/2] Cypress Tests for School Improvement Plans --- .../school_improvement_plan_test.cy.js | 83 +++++++++++++ .../cypress/fixtures/cypress.env.json | 4 - .../cypress/fixtures/example.json | 5 - .../cypress/pages/SchoolImprovementPage.js | 115 ++++++++++++++++++ .../Pages/SchoolImprovementPlans/Index.cshtml | 16 +-- .../Pages/Shared/_SubMenu.cshtml | 2 +- 6 files changed, 207 insertions(+), 18 deletions(-) create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/school_improvement_plan_test.cy.js delete mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/fixtures/cypress.env.json delete mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/fixtures/example.json create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/SchoolImprovementPage.js diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/school_improvement_plan_test.cy.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/school_improvement_plan_test.cy.js new file mode 100644 index 000000000..acba46ac8 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/school_improvement_plan_test.cy.js @@ -0,0 +1,83 @@ +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("Delete the project and verify that it was deleted successfully - Project ID: " + projectId); + schoolImprovementPage.deleteProject(projectId); + }); + }); +}); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/fixtures/cypress.env.json b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/fixtures/cypress.env.json deleted file mode 100644 index 86ded3af0..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/fixtures/cypress.env.json +++ /dev/null @@ -1,4 +0,0 @@ - -{ - "academisationApiKey": "pass-a-key" -} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/fixtures/example.json b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/fixtures/example.json deleted file mode 100644 index 02e425437..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/fixtures/example.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Using fixtures to represent data", - "email": "hello@cypress.io", - "body": "Fixtures are a great way to mock data for responses to routes" -} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/SchoolImprovementPage.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/SchoolImprovementPage.js new file mode 100644 index 000000000..55aa94c02 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/SchoolImprovementPage.js @@ -0,0 +1,115 @@ +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').type(day); + cy.get('#plan-start-date-month').type(month); + 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').type(day); + cy.get('#plan-end-date-other-month').type(month); + 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').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; + } + deleteProject(projectId) { + cy.callAcademisationApi("DELETE", `/conversion-project/${projectId}/Delete`).then((response) => { + expect(response.status).to.eq(200); + }); + } +} + +export const schoolImprovementPage = new SchoolImprovementPage(); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SchoolImprovementPlans/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SchoolImprovementPlans/Index.cshtml index 1e2047974..c84be6522 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SchoolImprovementPlans/Index.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SchoolImprovementPlans/Index.cshtml @@ -37,7 +37,7 @@
Arranged by
-
+
@plan.ArrangedBy.Select(x => x.ToDescription()).Aggregate(string.Empty, (partialPhrase, word) => { var result = string.IsNullOrWhiteSpace(partialPhrase) ? word : $"{partialPhrase}, {word}"; @@ -60,7 +60,7 @@
Provided by
-
+
@plan.ProvidedBy
@@ -71,18 +71,18 @@
Start date
-
+
@plan.StartDate.Value.ToString(Constants.DateTimeFormat)
Change the start date of the plan
-
+
Expected end date
-
+
@if (plan.ExpectedEndDate.Value == SchoolImprovementPlanExpectedEndDate.Other) { @plan.ExpectedEndDateOther.Value.ToString(Constants.DateTimeFormat) @@ -111,7 +111,7 @@
Confidence level
-
+
@plan.ConfidenceLevel.ToDescription()
@@ -122,7 +122,7 @@
Comments
-
+
@plan.PlanComments
@@ -134,7 +134,7 @@
} } - + Add school improvement plan
diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml index 4cf911315..7f3b229c8 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml @@ -66,7 +66,7 @@ Project notes -
  • +
  • From 4721dc4223d3f87a61abe7a7ea2d9b65e07c0da5 Mon Sep 17 00:00:00 2001 From: FahadDarw Date: Tue, 2 Jul 2024 15:47:50 +0100 Subject: [PATCH 2/2] refactored school imprvoment plan to add change tests --- .../school_improvement_plan_test.cy.js | 5 +++ .../cypress/pages/SchoolImprovementPage.js | 35 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/school_improvement_plan_test.cy.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/school_improvement_plan_test.cy.js index acba46ac8..bf054e990 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/school_improvement_plan_test.cy.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/school_improvement_plan_test.cy.js @@ -76,6 +76,11 @@ describe('School Improvement Plan Tests', () => { 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); }); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/SchoolImprovementPage.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/SchoolImprovementPage.js index 55aa94c02..febdbb7b7 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/SchoolImprovementPage.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/SchoolImprovementPage.js @@ -59,8 +59,11 @@ export class SchoolImprovementPage { } 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; @@ -68,8 +71,11 @@ export class SchoolImprovementPage { 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; @@ -80,6 +86,7 @@ export class SchoolImprovementPage { return this; } enterComments(comments) { + cy.get('#PlanComments').clear(); cy.get('#PlanComments').type(comments); cy.get('#submit-btn').click(); return this; @@ -105,6 +112,34 @@ export class SchoolImprovementPage { 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);