diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/.eslintrc.json b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/.eslintrc.json index 5debb67d9..12f6203e4 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/.eslintrc.json +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/.eslintrc.json @@ -14,6 +14,7 @@ "cypress/globals": true }, "extends": [ - "plugin:cypress/recommended" + "plugin:cypress/recommended", + "eslint:recommended" ] } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/sponsored-conversion.cy.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/sponsored-conversion.cy.js index 06c8fa07e..643bf3eee 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/sponsored-conversion.cy.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/sponsored-conversion.cy.js @@ -3,26 +3,73 @@ import projectList from "../../pages/projectList"; import projectTaskList from "../../pages/projectTaskList"; import projectAssignment from "../../pages/projectAssignment"; +import schoolOverview from "../../pages/schoolOverview"; -const projectName = 'Sponsored Cypress Project'; -const deliveryOfficer = 'Richika Dogra'; + +const testData = { + projectName: 'Sponsored Cypress Project', + deliveryOfficer: 'Richika Dogra', + assignedOfficerMessage: 'Project is assigned', + pan: '98765', + pfiDescription: 'PFI Description', + distance: '15', + distanceDecription: 'Distance description', + mp: 'Important Politician, Indepentent', +} describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { beforeEach(() => { cy.callAcademisationApi('POST', `cypress-data/add-sponsored-project.cy`, "{}") .then(() => { - projectList.selectProject(projectName) + projectList.selectProject(testData.projectName) }); }) it('TC01: Sponsored conversion journey ', () => { + // ----------------------- // Assign Delivery Officer + // ----------------------- projectTaskList.selectAssignProject(); - projectAssignment.assignProject(deliveryOfficer) + projectAssignment.assignProject(testData.deliveryOfficer) projectTaskList.getNotificationMessage().should('contain.text', 'Project is assigned'); - projectTaskList.getAssignedUser().should('contain.text', deliveryOfficer); - projectList.filterProjectList(projectName); - projectList.getNthProjectDeliveryOfficer().should('contain.text', deliveryOfficer); + projectTaskList.getAssignedUser().should('contain.text', testData.deliveryOfficer); + projectList.filterProjectList(testData.projectName); + projectList.getNthProjectDeliveryOfficer().should('contain.text', testData.deliveryOfficer); + + // --------------- + // School Overview + // --------------- + + projectList.selectProject(testData.projectName); + projectTaskList.selectSchoolOverview(); + //PAN + schoolOverview.changePan(testData.pan); + schoolOverview.getPan().should('contain.text', testData.pan); + //Viability issues + schoolOverview.changeViabilityIssues(true); + schoolOverview.getViabilityIssues().should('contain.text', 'Yes'); + schoolOverview.changeViabilityIssues(false); + schoolOverview.getViabilityIssues().should('contain.text', 'No'); + //Financial deficit + schoolOverview.changeFinancialDeficit(true); + schoolOverview.getFinancialDeficit().should('contain.text', 'Yes'); + schoolOverview.changeFinancialDeficit(false); + schoolOverview.getFinancialDeficit().should('contain.text', 'No'); + //PFI + details + schoolOverview.changePFI(true, testData.pfiDescription); + schoolOverview.getPFI().should('contain.text', 'Yes'); + schoolOverview.getPFIDetails().should('contain.text', testData.pfiDescription); + //Distance plus details + schoolOverview.changeDistance(testData.distance, testData.distanceDecription); + schoolOverview.getDistance().should('contain.text', testData.distance); + schoolOverview.getDistanceDetails().should('contain.text', testData.distanceDecription); + //MP + schoolOverview.changeMP(testData.mp); + schoolOverview.getMP().should('contain.text', testData.mp); + //Complete + schoolOverview.markComplete(); + cy.confirmContinueBtn().click(); + projectTaskList.getSchoolOverviewStatus().should('contain.text', 'Completed') }) }) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectAssignment.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectAssignment.js index 2baee8db6..7c0a56932 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectAssignment.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectAssignment.js @@ -1,31 +1,26 @@ /// -export const selectors = { - assignInput: '[id="delivery-officer"]', - unassignLink: '[id="unassign-link"]', - saveButton: '[class="govuk-button"]' -}; - -export const path = 'project-assignment'; +import BasePage from "./BasePage"; -class ProjectAssignment { +export default class ProjectAssignment extends BasePage { + static selectors = { + assignInput: '[id="delivery-officer"]', + unassignLink: '[id="unassign-link"]', + saveButton: '[class="govuk-button"]' + }; - checkProjectAssignmentPage() { - cy.url().should('include', path); - } + static path = 'project-assignment'; - assignProject(deliveryOfficer) { - this.checkProjectAssignmentPage(); - cy.get(selectors.assignInput).click() - cy.get(selectors.assignInput).type(`${deliveryOfficer}{enter}`); - cy.get(selectors.saveButton).click(); + static assignProject(deliveryOfficer) { + cy.checkPath(this.path); + cy.get(this.selectors.assignInput).click() + cy.get(this.selectors.assignInput).type(`${deliveryOfficer}{enter}`); + cy.get(this.selectors.saveButton).click(); }; - unassignProject() { - this.checkProjectAssignmentPage(); - cy.get(selectors.unassignLink).click() + static unassignProject() { + cy.checkPath(this.path) + cy.get(this.selectors.unassignLink).click() }; }; - -export default new ProjectAssignment(); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectList.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectList.js index c910cc644..67ef744c4 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectList.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectList.js @@ -1,49 +1,48 @@ /// - -export const path = 'project-list'; - import BasePage from './BasePage' -export default new class projectList extends BasePage { +export default class projectList extends BasePage { + + static path = 'project-list'; - checkProjectListPage() { - cy.url().should('include', path); + static checkProjectListPage() { + cy.url().should('include', this.path); } - getNthProject(n = 0){ + static getNthProject(n = 0) { this.checkProjectListPage(); return cy.get(`[id="school-name-${n}"]`); } - getNthProjectDeliveryOfficer(n = 0){ + static getNthProjectDeliveryOfficer(n = 0) { this.checkProjectListPage(); return cy.get(`[id="delivery-officer-${n}"]`); } - filterProjectList( titleFilter ) { + static filterProjectList(titleFilter) { const filterQuery = `?Title=${encodeURIComponent(titleFilter)}`; - cy.visit(`${Cypress.env('url')}/${path}${filterQuery}`) + cy.visit(`${Cypress.env('url')}/${this.path}${filterQuery}`) }; - selectFirstItem(){ + static selectFirstItem() { this.checkProjectListPage(); this.getNthProject().click(); } - selectProject(projectName = 'Gloucester School') { + static selectProject(projectName = 'Gloucester school') { this.filterProjectList(projectName); this.selectFirstItem(); return cy.url().then(url => this.getIdFromUrl(url)); }; - selectVoluntaryProject() { + static selectVoluntaryProject() { cy.login({titleFilter: 'Voluntary Cypress Project'}); cy.get('[id="school-name-0"]').click(); return cy.url().then(url => this.getIdFromUrl(url)); }; - getIdFromUrl(url) { + static getIdFromUrl(url) { const urlSplit = url.toString().split('/'); for (let i = urlSplit.length - 1; i > 0; i--) { const potentialId = parseInt(urlSplit[i]); @@ -53,4 +52,4 @@ export default new class projectList extends BasePage { return ''; }; -}; \ No newline at end of file +}; diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js index a3c89b4ce..b4cbd649e 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js @@ -1,31 +1,42 @@ /// -export const selectors = { - assignProjectButton: 'a[href*="project-assignment"]', - assignedUser: '[data-id="assigned-user"]', - notificationMessage: '[id="notification-message"]' -} +import BasePage from "./BasePage"; -export const path = 'task-list'; +export default class ProjectTaskList extends BasePage { -class ProjectTaskList { - - checkProjectPage() { - cy.url().should('include', path); + static selectors = { + assignProjectButton: 'a[href*="project-assignment"]', + assignedUser: '[data-id="assigned-user"]', + notificationMessage: '[id="notification-message"]', + schoolOverviewLink: 'a[href*="/school-overview"]', + schoolOverviewStatus: '[id="school-overview-status"]' } - selectAssignProject() { - cy.get(selectors.assignProjectButton).click(); + static path = 'task-list'; + + static selectAssignProject() { + cy.checkPath(this.path); + cy.get(this.selectors.assignProjectButton).click(); }; - getAssignedUser() { - return cy.get(selectors.assignedUser); + static getAssignedUser() { + cy.checkPath(this.path); + return cy.get(this.selectors.assignedUser); } - getNotificationMessage() { - return cy.get(selectors.notificationMessage); + static getNotificationMessage() { + cy.checkPath(this.path); + return cy.get(this.selectors.notificationMessage); } -}; + static selectSchoolOverview() { + cy.checkPath(this.path); + cy.get(this.selectors.schoolOverviewLink).click() + } -export default new ProjectTaskList(); + static getSchoolOverviewStatus() { + cy.checkPath(this.path); + return cy.get(this.selectors.schoolOverviewStatus); + } + +}; diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/schoolOverview.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/schoolOverview.js new file mode 100644 index 000000000..f41dc168d --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/schoolOverview.js @@ -0,0 +1,140 @@ +/// + +import BasePage from "./BasePage"; + +export default class SchoolOverview extends BasePage { + + static selectors = { + panValue: '[id="published-admission-number"]', + panLink: '[data-test="change-published-admission-number"]', + panInput: '[id="published-admission-number"]', + viabilityIssuesValue: '[id="viability-issues"]', + viabilityIssuesLink: '[data-test="change-viability-issues"]', + financialDeficitValue: '[id="financial-deficit"]', + financialDeficitLink: '[data-test="change-financial-deficit"]', + pfiValue: '[id="part-of-pfi"]', + pifDetails: '[id="pfi-scheme-details"]', + pfiLink: '[data-test="change-part-of-pfi"]', + pfiDetailsInput: '[id="PfiSchemeDetails"]', + distanceValue: '[id="distance-to-trust-headquarters"]', + distanceDetails: '[id="distance-to-trust-headquarters-additional-text"]', + distanceLink: '[data-test="change-distance-to-trust-headquarters"]', + distanceInput: '[id="distance-to-trust-headquarters"]', + distanceDetailsInput: '[id="distance-to-trust-headquarters-additional-information"]', + mpValue: '[id="member-of-parliament-name-and-party"', + mpLink: '[data-test="change-member-of-parliament-name-and-party"]', + mpInput: '[id="member-of-parliament-name-and-party"]', + completeCheckbox: '[name="school-overview-complete"]' + } + + static path = 'school-overview'; + + static getPan() { + cy.checkPath(this.path); + return cy.get(this.selectors.panValue); + } + + static changePan(newPanNumber) { + cy.checkPath(this.path); + cy.get(this.selectors.panLink).click(); + cy.get(this.selectors.panInput).clear().type(newPanNumber); + cy.saveContinue().click(); + } + + static getViabilityIssues() { + cy.checkPath(this.path); + return cy.get(this.selectors.viabilityIssuesValue); + } + + static changeViabilityIssues(viabilityIssues) { + cy.checkPath(this.path); + cy.get(this.selectors.viabilityIssuesLink).click(); + if (viabilityIssues) { + cy.YesRadioBtn().check(); + } + else { + cy.NoRadioBtn().check(); + } + cy.saveContinue().click(); + } + + static getFinancialDeficit() { + cy.checkPath(this.path); + return cy.get(this.selectors.financialDeficitValue); + } + + static changeFinancialDeficit(financialDeficit) { + cy.checkPath(this.path); + cy.get(this.selectors.financialDeficitLink).click(); + if (financialDeficit) { + cy.YesRadioBtn().check(); + } + else { + cy.NoRadioBtn().check(); + } + cy.saveContinue().click(); + } + + static getPFI() { + cy.checkPath(this.path); + return cy.get(this.selectors.pfiValue); + } + + static getPFIDetails() { + cy.checkPath(this.path); + return cy.get(this.selectors.pifDetails); + } + + static changePFI(pfi, description = '') { + cy.checkPath(this.path); + cy.get(this.selectors.pfiLink).click(); + if (pfi) { + cy.YesRadioBtn().check(); + cy.get(this.selectors.pfiDetailsInput).clear().type(description); + } + else { + cy.NoRadioBtn().check(); + } + cy.saveContinue().click(); + } + + static getDistance() { + cy.checkPath(this.path); + return cy.get(this.selectors.distanceValue); + } + + static getDistanceDetails() { + cy.checkPath(this.path); + return cy.get(this.selectors.distanceDetails); + } + + static changeDistance(distance, description = '') { + cy.checkPath(this.path); + cy.get(this.selectors.distanceLink).click(); + cy.get(this.selectors.distanceInput).clear().type(distance); + cy.get(this.selectors.distanceDetailsInput).clear().type(description); + cy.saveContinue().click() + } + + static getMP() { + cy.checkPath(this.path); + return cy.get(this.selectors.mpValue); + } + + static changeMP(mp) { + cy.checkPath(this.path); + cy.get(this.selectors.mpLink).click(); + cy.get(this.selectors.mpInput).clear().type(mp); + cy.saveContinue().click(); + } + + static markComplete() { + cy.checkPath(this.path); + cy.get(this.selectors.completeCheckbox).check(); + } + + static markIncomplete() { + cy.checkPath(this.path); + cy.get(this.selectors.completeCheckbox).uncheck(); + } +}; diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/support/commands.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/support/commands.js index b0cd954c3..2ef6f032a 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/support/commands.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/support/commands.js @@ -32,6 +32,8 @@ sqlServer.loadDBCommands(); Cypress.Commands.add('urlPath', () => cy.location().then(location => `${location.origin}${location.pathname}`)); +Cypress.Commands.add('checkPath', (path) => cy.url().should("include", path)); + Cypress.Commands.add('login', ({ titleFilter } = {}) => { const filterQuery = titleFilter ? `?Title=${encodeURIComponent(titleFilter)}` : ''; cy.visit(`${Cypress.env('url')}/project-list${filterQuery}`) @@ -246,12 +248,12 @@ Cypress.Commands.add('changeDecision', () => { // Approved No Btn Cypress.Commands.add('NoRadioBtn', () => { - cy.get('[id="no-radio"]') + cy.get('[data-cy="select-radio-no" i]') }) // Approved Yes Btn Cypress.Commands.add('YesRadioBtn', () => { - cy.get('[id="yes-radio"]') + cy.get('[data-cy="select-radio-yes" i]') }) // Approved Changed Condition @@ -588,23 +590,23 @@ Cypress.Commands.add('clearFilters', () => { Cypress.Commands.add("excuteAccessibilityTests", () => { // FUNCTION COURTESY OF FAHAD DARWISH - NIMBLE APPROACH CONFLUENECE - const wcagStandards = ["wcag22aa", "wcag21aa"]; - const impactLevel = ["critical", "minor", "moderate", "serious"]; - const continueOnFail = false; - cy.injectAxe(); - cy.checkA11y( - null, - { - runOnly: { - type: "tag", - values: wcagStandards, - }, - includedImpacts: impactLevel, + const wcagStandards = ["wcag22aa", "wcag21aa"]; + const impactLevel = ["critical", "minor", "moderate", "serious"]; + const continueOnFail = false; + cy.injectAxe(); + cy.checkA11y( + null, + { + runOnly: { + type: "tag", + values: wcagStandards, }, - null, - continueOnFail - ); - }); + includedImpacts: impactLevel, + }, + null, + continueOnFail + ); +}); Cypress.Commands.add('createInvoluntaryProject', () => { cy.get('[role="button"]').should('contain.text', "Start a new involuntary conversion project") @@ -721,28 +723,28 @@ Cypress.Commands.add('schoolApplicationForm', () => { // Interceptors do not run for cy.request or cy.Api. Therefore use a command to make the request instead, an include the required headers etc. Cypress.Commands.add('callAcademisationApi', -(method, url, body=null, failOnStatusCode=true) => { - let requestDefinition = + (method, url, body = null, failOnStatusCode = true) => { + let requestDefinition = { method: method, - url: `${Cypress.env('academisationApiUrl')}/${url}`, + url: `${Cypress.env('academisationApiUrl')}/${url}`, headers: { 'x-api-key': Cypress.env('academisationApiKey'), 'x-api-cypress-endpoints-key': Cypress.env('cypressApiKey'), - 'Content-Type' : 'application/json' + 'Content-Type': 'application/json' }, failOnStatusCode: failOnStatusCode, response: [] }; - - // add body to a post/put/patch request, otherwise leave as not supplied - switch (method.toUpperCase()) { - case 'POST': - case 'PUT': - case 'PATCH': - requestDefinition.body = body; - break; - } - - return cy.request(requestDefinition); -}); \ No newline at end of file + + // add body to a post/put/patch request, otherwise leave as not supplied + switch (method.toUpperCase()) { + case 'POST': + case 'PUT': + case 'PATCH': + requestDefinition.body = body; + break; + } + + return cy.request(requestDefinition); + }); \ No newline at end of file