From ba8fad8265aebd82e73a04284dc3b9c319c78818 Mon Sep 17 00:00:00 2001 From: Nick Warms Date: Wed, 27 Sep 2023 15:25:06 +0100 Subject: [PATCH] Add rationale test --- .../Core-journeys/sponsored-conversion.cy.js | 15 +++++++- .../cypress/pages/projectTaskList.js | 13 ++++++- .../cypress/pages/rationale.js | 37 +++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/rationale.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 c959255e8..f2e2dd502 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 @@ -7,6 +7,7 @@ import schoolOverview from "../../pages/schoolOverview"; import budget from "../../pages/budget"; import PupilForecast from "../../pages/pupilForecast"; import ConversionDetails from "../../pages/conversionDetails"; +import Rationale from "../../pages/rationale"; const currentDate = new Date(); const nextYearDate = new Date(); @@ -40,7 +41,8 @@ const testData = { }, pupilForecast: { additionalInfomation: 'Pupil Forecast Additional Information' - } + }, + rationale: 'This is why this school should become an academy' } describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { @@ -187,5 +189,16 @@ describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { ConversionDetails.markComplete(); cy.confirmContinueBtn().click(); projectTaskList.getConversionDetailsStatus().should('contain.text', 'Completed'); + + // ------------- + // - Rationale - + // ------------- + + projectTaskList.selectRationale(); + Rationale.changeRationale(testData.rationale); + Rationale.getRationale().should('contain.text', testData.rationale); + Rationale.markComplete(); + cy.confirmContinueBtn().click(); + projectTaskList.getRationaleStatus().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 fef78e3e2..85e6666ce 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js @@ -15,7 +15,8 @@ export default class ProjectTaskList extends BasePage { pupilForecastLink: 'a[href*="/pupil-forecast"]', conversionDetailsLink: 'a[href*="/conversion-details"]', conversionDetailsStatus: '[id="school-and-trust-information-status"]', - + rationaleLink: 'a[href*="/confirm-project-trust-rationale"]', + rationaleStatus: '[id="rationale-status"]' } static path = 'task-list'; @@ -69,4 +70,14 @@ export default class ProjectTaskList extends BasePage { cy.checkPath(this.path); return cy.get(this.selectors.conversionDetailsStatus); } + + static selectRationale() { + cy.checkPath(this.path); + cy.get(this.selectors.rationaleLink).click(); + } + + static getRationaleStatus() { + cy.checkPath(this.path); + return cy.get(this.selectors.rationaleStatus); + } }; diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/rationale.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/rationale.js new file mode 100644 index 000000000..6782a1746 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/rationale.js @@ -0,0 +1,37 @@ +/// + +import BasePage from "./BasePage"; + +export default class Rationale extends BasePage { + static selectors = { + rationaleLink: '[data-test="change-rationale-for-trust"]', + rationaleInput: '[id="trust-rationale"]', + rationaleValue: '[id="rationale-for-trust"]', + saveButton: '[class="govuk-button"]', + completeCheckbox: '[id="rationale-complete"]' + }; + + static path = 'confirm-project-trust-rationale'; + + static changeRationale(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 getRationale() { + 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(); + } +};