From ba5dc08170b40e6674fa2ad04474b47b0ef94f82 Mon Sep 17 00:00:00 2001 From: Nick Warms Date: Wed, 27 Sep 2023 16:00:14 +0100 Subject: [PATCH] Add risks test --- .../Core-journeys/sponsored-conversion.cy.js | 15 +++++++- .../cypress/pages/projectTaskList.js | 14 ++++++- .../cypress/pages/risksAndIssues.js | 37 +++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/risksAndIssues.js 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 f2e2dd502..986a40f5a 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 @@ -8,6 +8,7 @@ import budget from "../../pages/budget"; import PupilForecast from "../../pages/pupilForecast"; import ConversionDetails from "../../pages/conversionDetails"; import Rationale from "../../pages/rationale"; +import RisksAndIssues from "../../pages/risksAndIssues"; const currentDate = new Date(); const nextYearDate = new Date(); @@ -42,7 +43,8 @@ const testData = { pupilForecast: { additionalInfomation: 'Pupil Forecast Additional Information' }, - rationale: 'This is why this school should become an academy' + rationale: 'This is why this school should become an academy', + risksAndIssues: 'Here are the risks and issues for this conversion', } describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { @@ -200,5 +202,16 @@ describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { Rationale.markComplete(); cy.confirmContinueBtn().click(); projectTaskList.getRationaleStatus().should('contain.text', 'Completed'); + + // -------------------- + // - Risks and issues - + // -------------------- + + projectTaskList.selectRisksAndIssues(); + RisksAndIssues.changeRisksAndIssues(testData.risksAndIssues); + RisksAndIssues.getRisksAndIssues().should('contain.text', testData.risksAndIssues); + RisksAndIssues.markComplete(); + cy.confirmContinueBtn().click(); + projectTaskList.getRisksAndIssuesStatus().should('contain.text', 'Completed'); }) }) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js index 85e6666ce..6266dc127 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js @@ -16,7 +16,9 @@ export default class ProjectTaskList extends BasePage { conversionDetailsLink: 'a[href*="/conversion-details"]', conversionDetailsStatus: '[id="school-and-trust-information-status"]', rationaleLink: 'a[href*="/confirm-project-trust-rationale"]', - rationaleStatus: '[id="rationale-status"]' + rationaleStatus: '[id="rationale-status"]', + riskAndIssuesLink: 'a[href*="/confirm-risks-issues"]', + riskAndIssuesStatus: '[id="risks-and-issues-status"]' } static path = 'task-list'; @@ -80,4 +82,14 @@ export default class ProjectTaskList extends BasePage { cy.checkPath(this.path); return cy.get(this.selectors.rationaleStatus); } + + static selectRisksAndIssues() { + cy.checkPath(this.path); + cy.get(this.selectors.riskAndIssuesLink).click(); + } + + static getRisksAndIssuesStatus() { + cy.checkPath(this.path); + return cy.get(this.selectors.riskAndIssuesStatus); + } }; diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/risksAndIssues.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/risksAndIssues.js new file mode 100644 index 000000000..c69c3aa35 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/risksAndIssues.js @@ -0,0 +1,37 @@ +/// + +import BasePage from "./BasePage"; + +export default class RisksAndIssues extends BasePage { + static selectors = { + rationaleLink: '[data-test="change-risks-and-issues"]', + rationaleInput: '[id="risks-and-issues"]', + rationaleValue: '[id="risks-and-issues"]', + saveButton: '[class="govuk-button"]', + completeCheckbox: '[id="risks-and-issues-complete"]' + }; + + static path = 'confirm-risks-issues'; + + static changeRisksAndIssues(rationale) { + cy.checkPath(this.path); + cy.get(this.selectors.rationaleLink).click() + cy.get(this.selectors.rationaleInput).clear().type(rationale); + cy.get(this.selectors.saveButton).click(); + }; + + static getRisksAndIssues() { + cy.checkPath(this.path) + return cy.get(this.selectors.rationaleValue); + }; + + static markComplete() { + cy.checkPath(this.path); + cy.get(this.selectors.completeCheckbox).check(); + } + + static markIncomplete() { + cy.checkPath(this.path); + cy.get(this.selectors.completeCheckbox).uncheck(); + } +};