From 3445ece6f32525533e2d474f4dc796d1bdc996e1 Mon Sep 17 00:00:00 2001 From: Nick Warms Date: Tue, 26 Sep 2023 15:45:09 +0100 Subject: [PATCH 01/10] Add cypress tags to radio buttons --- .../SchoolAndTrustInformation/Sponsored/GrantDetails.cshtml | 1 + 1 file changed, 1 insertion(+) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/Sponsored/GrantDetails.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/Sponsored/GrantDetails.cshtml index a19b8635d..014f79c5b 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/Sponsored/GrantDetails.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/SchoolAndTrustInformation/Sponsored/GrantDetails.cshtml @@ -101,6 +101,7 @@ id="@value" name="conversion-support-grant-environmental-improvement-grant" value="@value" + data-cy="select-radio-@value" @(value == Model.Project.ConversionSupportGrantEnvironmentalImprovementGrant ? "checked" : "") /> From b4f8ae6f602e88da0f42af244a4e7e814f6aca06 Mon Sep 17 00:00:00 2001 From: Nick Warms Date: Tue, 26 Sep 2023 16:42:44 +0100 Subject: [PATCH 02/10] Add date command --- .../cypress/support/commands.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/support/commands.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/support/commands.js index 2ef6f032a..35f218c99 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/support/commands.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/support/commands.js @@ -79,6 +79,13 @@ Cypress.Commands.add('generateProjectTempBtn', () => { cy.get('[id="generate-project-template-button"]') }); +Cypress.Commands.add('enterDate', (idSelector, day, month, year) => { + cy.get(`[id*="${idSelector}-day]`).should('be.visible'); + cy.get(`[id*="${idSelector}-day]`).clear().type(day); + cy.get(`[id*="${idSelector}-month]`).clear().type(month); + cy.get(`[id*="${idSelector}-year]`).clear().type(year); +}) + //--LA Info Page // Submit Date 'Sent' (LA Info Page) @@ -256,6 +263,11 @@ Cypress.Commands.add('YesRadioBtn', () => { cy.get('[data-cy="select-radio-yes" i]') }) +// Any radio button +Cypress.Commands.add('RadioBtn', (label) => { + cy.get(`[data-cy="select-radio-${label}" i]`) +}) + // Approved Changed Condition Cypress.Commands.add('ChangeConditionsLink', () => { cy.get('[id="change-conditions-set-btn"]') From 3bc10945dcf354b8be66a5f82bee16849b3f5b17 Mon Sep 17 00:00:00 2001 From: Nick Warms Date: Tue, 26 Sep 2023 16:43:02 +0100 Subject: [PATCH 03/10] Add conversion details page object model --- .../cypress/pages/conversionDetails.js | 232 ++++++++++++++++++ .../cypress/pages/projectTaskList.js | 13 + 2 files changed, 245 insertions(+) create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/conversionDetails.js diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/conversionDetails.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/conversionDetails.js new file mode 100644 index 000000000..6a0ba045d --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/conversionDetails.js @@ -0,0 +1,232 @@ +/// + +import BasePage from "./BasePage"; + +const today = new Date(); + +export default class ConversionDetails extends BasePage { + static selectors = { + saveButton: '[class="govuk-button"]', + form7ReceivedLink: '[data-test="change-form-7-received"]', + form7ReveicedValue: '[id="form-7-received"]', + form7DateLink: '[data-test="change-form-7-received-date"]', + form7DateInput: 'form-7-received-date', + form7DateValue: '[id="form-7-received-date"]', + DAOLink: '[data-test="change-dao-pack-sent-date"]', + DAODateInput: 'dao-pack-sent-date', + DAOValue: '[id="dao-pack-sent-date"]', + fundingTypeLink: '[data-test="change-grant-funding-type"]', + fundingTypeValue: '[id="grant-funding-type"]', + fundingAmountLink: '[data-test="change-grant-funding-amount"]', + fundingAmountValue: '[id="grant-funding-amount"]', + fundingAmountDefaultYesRadio: '[name="conversion-support-grant-amount-changed"][data-cy="select-radio-yes"]', + fundingAmountDefaultNoRadio: '[name="conversion-support-grant-amount-changed"][data-cy="select-radio-no"]', + fundingAmountInput: '[id="conversion-support-grant-amount"]', + fundingAmountReasonInput: '[id="conversion-support-grant-change-reason"]', + fundingAmountReasonValue: '[id="grant-funding-reason"]', + fundingAmountReasonLink: '[data-test="change-grant-funding-reason"]', + EIGLink: '[data-test="change-grant-funding-environmental-imporvement-grant"]', + EIGValue: '[id="grant-funding-environmental-imporvement-grant"]', + EIGYesRadio: '[name="conversion-support-grant-environmental-improvement-grant"][data-cy="select-radio-yes" i]', + EIGNoRadio: '[name="conversion-support-grant-environmental-improvement-grant"][data-cy="select-radio-no" i]', + advisoryBoardDateLink: '[data-test="change-advisory-board-date"]', + advisoryBoardDateValue: '[id="advisory-board-date"]', + advisoryBoardDateInput: 'head-teacher-board-date', + proposedOpeningLink: '[data-test="change-proposed-academy-opening-date"]', + proposedOpeningValue: '[id="proposed-academy-opening-date"]', + proposedOpeningRadioButton: (month, year) => `input[data-cy="select-radio-01/${month}/${year} 00:00:00"]`, + previousAdvisoryBoardLink: '[data-test="change-previous-advisory-board"]', + previousAdvisoryBoardValue: '[id="previous-advisory-board"]', + previousAdvisoryBoardDateInput: 'previous-head-teacher-board-date', + authorLink: '[data-test="change-author"]', + authorValue: '[id="author"]', + authorInput: '[id="author"]', + clearedByLink: '[data-test="change-cleared-by"]', + clearedByValue: '[id="cleared-by"]', + clearedByInput: '[id="cleared-by"]', + completeCheckbox: '[id="school-and-trust-information-complete"]' + }; + + static path = 'conversion-details'; + + static setForm7Receivied(status = 'Yes') { + cy.checkPath(this.path); + cy.get(this.selectors.form7ReceivedLink).click() + cy.RadioBtn(status).check(); + cy.get(this.selectors.saveButton).click(); + }; + + static getForm7Receivied() { + cy.checkPath(this.path); + return cy.get(this.selectors.form7ReveicedValue); + } + + static setForm7Date(date = today) { + cy.checkPath(this.path); + cy.get(this.selectors.form7DateLink).click(); + cy.enterDate(this.selectors.form7DateInput, date.getDate(), date.getMonth() + 1, date.getFullYear()); + cy.get(this.selectors.saveButton).click(); + } + + static getForm7Date() { + cy.checkPath(this.path); + return cy.get(this.selectors.form7DateValue); + } + + // DAO + + static setDAODate(date = today) { + cy.checkPath(this.path); + cy.get(this.selectors.DAOLink).click(); + cy.enterDate(this.selectors.DAODateInput, date.getDate(), date.getMonth() + 1, date.getFullYear()); + cy.get(this.selectors.saveButton).click(); + } + + static getDAODate() { + cy.checkPath(this.path); + return cy.get(this.selectors.DAOValue); + } + + // Funding + + static setFundingType(type = 'Full') { + cy.checkPath(this.path); + cy.get(this.selectors.fundingTypeLink).click(); + cy.RadioBtn(type).check(); + //Save button twice to get back to the details page + cy.get(this.selectors.saveButton).click(); + cy.get(this.selectors.saveButton).click(); + } + + static getFundingType() { + cy.checkPath(this.path); + return cy.get(this.selectors.fundingTypeValue); + } + + static setFundingAmount(useDefaultAmount = false, amount = 20000) { + cy.checkPath(this.path); + cy.get(this.selectors.fundingAmountLink).click(); + if (useDefaultAmount) { + cy.get(this.selectors.fundingAmountDefaultYesRadio); + } else { + cy.get(this.selectors.fundingAmountDefaultNoRadio); + cy.get(this.selectors.fundingAmountInput).clear().type(amount); + } + cy.get(this.selectors.saveButton).click(); + } + + static getFundingType() { + cy.checkPath(this.path); + return cy.get(this.selectors.fundingTypeValue); + } + + static setFundingReason(reason = 'Funding Reason') { + cy.checkPath(this.path); + cy.get(this.selectors.fundingAmountLink).click(); + cy.get(this.selectors.fundingAmountReasonInput).clear().type(reason); + cy.get(this.selectors.saveButton).click(); + } + + static getFundingReason() { + cy.checkPath(this.path); + return cy.get(this.selectors.fundingTypeValue); + } + + static setEIG(value = true){ + cy.checkPath(this.path); + cy.get(this.selectors.EIGLink).click(); + if(value){ + cy.get(this.selectors.EIGYesRadio).check(); + } else { + cy.get(this.selectors.EIGNoRadio).check(); + } + cy.get(this.selectors.saveButton).click(); + } + + static getEIG(){ + cy.checkPath(this.path); + return cy.get(this.selectors.EIGValue); + } + + // Dates + + static setAdvisoryBoardDate(date = today) { + cy.checkPath(this.path); + cy.get(this.selectors.advisoryBoardDateLink).click(); + cy.enterDate(this.selectors.advisoryBoardDateInput, date.getDate(), date.getMonth() + 1, date.getFullYear()); + cy.get(this.selectors.saveButton).click(); + } + + static getAdvisoryBoardDate() { + cy.checkPath(this.path); + return cy.get(this.selectors.advisoryBoardDateValue); + } + + static setProposedAcademyOpening(month, year){ + cy.checkPath(this.path); + cy.get(this.selectors.proposedOpeningLink).click(); + cy.get(this.selectors.proposedOpeningRadioButton(month, year)).check() + cy.get(this.selectors.saveButton).click(); + } + + static getProposedAcademyOpening(){ + cy.checkPath(this.path); + return cy.get(this.selectors.proposedOpeningValue); + } + + static setPreviousAdvisoryBoardDate(previousBoard = true, date = today) { + cy.checkPath(this.path); + cy.get(this.selectors.advisoryBoardDateLink).click(); + if(previousBoard){ + cy.YesRadioBtn(); + cy.get(this.selectors.saveButton).click(); + cy.enterDate(this.selectors.previousAdvisoryBoardDateInput, date.getDate(), date.getMonth() + 1, date.getFullYear()); + + } + cy.get(this.selectors.saveButton).click(); + } + + static getPreviousAdvisoryBoardDate() { + cy.checkPath(this.path); + return cy.get(this.selectors.advisoryBoardDateValue); + } + + // People + + static setAuthor(author = 'Nicholas Warms'){ + cy.checkPath(this.path); + cy.get(this.selectors.authorLink).click(); + cy.get(this.selectors.authorInput).clear().type(author); + cy.get(this.selectors.saveButton).click(); + } + + static getAuthor(){ + cy.checkPath(this.path); + return cy.get(this.selectors.authorValue); + } + + static setClearedBy(clearedBy = 'Nicholas Warms') { + cy.checkPath(this.path); + cy.get(this.selectors.clearedByLink).click(); + cy.get(this.selectors.clearedByInput).clear().type(clearedBy); + cy.get(this.selectors.saveButton).click(); + } + + static getClearedBy() { + cy.checkPath(this.path); + return cy.get(this.selectors.clearedByValue); + } + + // Complete + + 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/pages/projectTaskList.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js index 8dc370c67..fef78e3e2 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js @@ -13,6 +13,9 @@ export default class ProjectTaskList extends BasePage { budgetLink: 'a[href*="/budget"]', budgetStatus: '[id="school-budget-information-status"]', pupilForecastLink: 'a[href*="/pupil-forecast"]', + conversionDetailsLink: 'a[href*="/conversion-details"]', + conversionDetailsStatus: '[id="school-and-trust-information-status"]', + } static path = 'task-list'; @@ -56,4 +59,14 @@ export default class ProjectTaskList extends BasePage { cy.checkPath(this.path); cy.get(this.selectors.pupilForecastLink).click() } + + static selectConversionDetails() { + cy.checkPath(this.path); + cy.get(this.selectors.conversionDetailsLink).click() + } + + static getConversionDetailsStatus() { + cy.checkPath(this.path); + return cy.get(this.selectors.conversionDetailsStatus); + } }; From 22ff25fdfc372b12e42dec814aeff123c20d833b Mon Sep 17 00:00:00 2001 From: Nick Warms Date: Tue, 26 Sep 2023 17:01:57 +0100 Subject: [PATCH 04/10] Update function name --- .../cypress/pages/conversionDetails.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/conversionDetails.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/conversionDetails.js index 6a0ba045d..b4c30b64a 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/conversionDetails.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/conversionDetails.js @@ -115,9 +115,9 @@ export default class ConversionDetails extends BasePage { cy.get(this.selectors.saveButton).click(); } - static getFundingType() { + static getFundingAmount() { cy.checkPath(this.path); - return cy.get(this.selectors.fundingTypeValue); + return cy.get(this.selectors.fundingAmountValue); } static setFundingReason(reason = 'Funding Reason') { From 1c58f9ef33b006fa37cc539ae25f38213b77da3c Mon Sep 17 00:00:00 2001 From: Nick Warms Date: Tue, 26 Sep 2023 17:02:10 +0100 Subject: [PATCH 05/10] Add conversion details tests --- .../Core-journeys/sponsored-conversion.cy.js | 57 +++++++++++++++++-- 1 file changed, 51 insertions(+), 6 deletions(-) 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 02f47a1b2..5e27ceba6 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,10 +7,11 @@ import schoolOverview from "../../pages/schoolOverview"; import budget from "../../pages/budget"; import ProjectTaskList from "../../pages/projectTaskList"; import PupilForecast from "../../pages/pupilForecast"; +import ConversionDetails from "../../pages/conversionDetails"; -const currentYear = new Date(); -const nextYear = new Date(); -nextYear.setFullYear(new Date().getFullYear() + 1); +const currentDate = new Date(); +const nextYearDate = new Date(); +nextYearDate.setFullYear(new Date().getFullYear() + 1); const testData = { @@ -24,13 +25,13 @@ const testData = { pfiDescription: 'PFI Description', distance: '15', distanceDecription: 'Distance description', - mp: 'Important Politician, Indepentent', + mp: 'Important Politician, Independent', }, budget: { - endOfFinanicalYear: currentYear, + endOfFinanicalYear: currentDate, forecastedRevenueCurrentYear: 20, forecastedCapitalCurrentYear: 10, - endOfNextFinancialYear: nextYear, + endOfNextFinancialYear: nextYearDate, forecastedRevenueNextYear: 15, forecastedCapitalNextYear: 12 }, @@ -127,5 +128,49 @@ describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { PupilForecast.getAdditionalInfomation().should('contain.text', testData.pupilForecast.additionalInfomation); cy.confirmContinueBtn().click(); + // ---------------------- + // - Conversion Details - + // ---------------------- + + /* + select the conversion details + form 7 + date form 7 recieved + DAO date sent + Grant type + Grant ammount + EIG + Advisory date + Proposed opening date + Previous Advisory board + Author + Cleared by + Completed + */ + + projectTaskList.selectConversiontDetails(); + ConversionDetails.setForm7Receivied('Yes'); + ConversionDetails.getForm7Receivied().should('contain.text', 'Yes'); + ConversionDetails.setForm7Date(); + ConversionDetails.getForm7Date().should('contain.text', currentDate.getDate()); + ConversionDetails.getForm7Date().should('contain.text', currentDate.toLocaleString('default', { month: 'long' })); + ConversionDetails.getForm7Date().should('contain.text', currentDate.getFullYear()); + ConversionDetails.setDAODate(); + ConversionDetails.getDAODate().should('contain.text', currentDate.getDate()); + ConversionDetails.getDAODate().should('contain.text', currentDate.toLocaleString('default', { month: 'long' })); + ConversionDetails.getDAODate().should('contain.text', currentDate.getFullYear()); + ConversionDetails.setFundingType('Full'); + ConversionDetails.getFundingType().should('contain.text', 'Full'); + ConversionDetails.setFundingAmount(false, 100000); + ConversionDetails.getFundingAmount().should('contain.text', '£100,000'); + ConversionDetails.setFundingReason(); + ConversionDetails.getFundingReason().should('contain.text', 'Funding Reason'); + ConversionDetails.setEIG(true); + ConversionDetails.getEIG().should('contain.value', 'Yes'); + ConversionDetails.setAdvisoryBoardDate(); + ConversionDetails.getAdvisoryBoardDate().should('contain.text', currentDate.getDate()); + ConversionDetails.getAdvisoryBoardDate().should('contain.text', currentDate.toLocaleString('default', { month: 'long' })); + ConversionDetails.getAdvisoryBoardDate().should('contain.text', currentDate.getFullYear()); + ConversionDetails.setProposedAcademyOpening(); }) }) From 905bc01bd3541b466a5fdf2914f846fb4626b88e Mon Sep 17 00:00:00 2001 From: Nick Warms Date: Wed, 27 Sep 2023 09:42:49 +0100 Subject: [PATCH 06/10] Add more Conversion details tests --- .../cypress/e2e/Core-journeys/sponsored-conversion.cy.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 5e27ceba6..483111b59 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 @@ -146,7 +146,7 @@ describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { Author Cleared by Completed - */ + */ projectTaskList.selectConversiontDetails(); ConversionDetails.setForm7Receivied('Yes'); @@ -171,6 +171,9 @@ describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { ConversionDetails.getAdvisoryBoardDate().should('contain.text', currentDate.getDate()); ConversionDetails.getAdvisoryBoardDate().should('contain.text', currentDate.toLocaleString('default', { month: 'long' })); ConversionDetails.getAdvisoryBoardDate().should('contain.text', currentDate.getFullYear()); - ConversionDetails.setProposedAcademyOpening(); + ConversionDetails.setProposedAcademyOpening(nextYearDate.getMonth() + 1, nextYearDate.getFullYear); + ConversionDetails.getAdvisoryBoardDate().should('contain.text', 1); + ConversionDetails.getAdvisoryBoardDate().should('contain.text', nextYearDate.toLocaleString('default', { month: 'long' })); + ConversionDetails.getAdvisoryBoardDate().should('contain.text', nextYearDate.getFullYear()); }) }) From 2ac9109f77b2603cf6b7a22e540037b2adde9446 Mon Sep 17 00:00:00 2001 From: Nick Warms Date: Wed, 27 Sep 2023 11:17:25 +0100 Subject: [PATCH 07/10] Fix spelling mistake --- .../Pages/Components/SchoolAndTrustInformation/default.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml index 3fc5a8ac0..b6503154c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Components/SchoolAndTrustInformation/default.cshtml @@ -24,7 +24,7 @@ - + From 7170bdb45188a1941c457b793df7940581fc0d7b Mon Sep 17 00:00:00 2001 From: Nick Warms Date: Wed, 27 Sep 2023 11:18:01 +0100 Subject: [PATCH 08/10] Close speach marks on date command --- .../cypress/support/commands.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/support/commands.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/support/commands.js index 35f218c99..3b9c77ed3 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/support/commands.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/support/commands.js @@ -80,10 +80,10 @@ Cypress.Commands.add('generateProjectTempBtn', () => { }); Cypress.Commands.add('enterDate', (idSelector, day, month, year) => { - cy.get(`[id*="${idSelector}-day]`).should('be.visible'); - cy.get(`[id*="${idSelector}-day]`).clear().type(day); - cy.get(`[id*="${idSelector}-month]`).clear().type(month); - cy.get(`[id*="${idSelector}-year]`).clear().type(year); + cy.get(`[id*="${idSelector}-day"]`).should('be.visible'); + cy.get(`[id*="${idSelector}-day"]`).clear().type(day); + cy.get(`[id*="${idSelector}-month"]`).clear().type(month); + cy.get(`[id*="${idSelector}-year"]`).clear().type(year); }) //--LA Info Page From 3e0f8a2e8e6a0768b676d23d3054d249f087bb3b Mon Sep 17 00:00:00 2001 From: Nick Warms Date: Wed, 27 Sep 2023 12:58:47 +0100 Subject: [PATCH 09/10] Finish Conversion details tests --- .../Core-journeys/sponsored-conversion.cy.js | 55 ++++++++++++------- .../cypress/pages/conversionDetails.js | 34 ++++++------ 2 files changed, 53 insertions(+), 36 deletions(-) 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 36303068c..7597f71dc 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 @@ -10,7 +10,11 @@ import ConversionDetails from "../../pages/conversionDetails"; const currentDate = new Date(); const nextYearDate = new Date(); -nextYearDate.setFullYear(new Date().getFullYear() + 1); +nextYearDate.setFullYear(currentDate.getFullYear() + 1); +const oneMonthAgoDate = new Date(); +oneMonthAgoDate.setMonth(currentDate.getMonth() - 1); +const nextMonthDate = new Date(); +nextMonthDate.setMonth(currentDate.getMonth() + 1); const testData = { @@ -35,7 +39,7 @@ const testData = { forecastedCapitalNextYear: 12 }, pupilForecast: { - additionalInfomation: 'Pupil Forecast Additional Infomation' + additionalInfomation: 'Pupil Forecast Additional Information' } } @@ -147,17 +151,17 @@ describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { Completed */ - projectTaskList.selectConversiontDetails(); + projectTaskList.selectConversionDetails(); ConversionDetails.setForm7Receivied('Yes'); ConversionDetails.getForm7Receivied().should('contain.text', 'Yes'); - ConversionDetails.setForm7Date(); - ConversionDetails.getForm7Date().should('contain.text', currentDate.getDate()); - ConversionDetails.getForm7Date().should('contain.text', currentDate.toLocaleString('default', { month: 'long' })); - ConversionDetails.getForm7Date().should('contain.text', currentDate.getFullYear()); - ConversionDetails.setDAODate(); - ConversionDetails.getDAODate().should('contain.text', currentDate.getDate()); - ConversionDetails.getDAODate().should('contain.text', currentDate.toLocaleString('default', { month: 'long' })); - ConversionDetails.getDAODate().should('contain.text', currentDate.getFullYear()); + ConversionDetails.setForm7Date(oneMonthAgoDate); + ConversionDetails.getForm7Date().should('contain.text', oneMonthAgoDate.getDate()); + ConversionDetails.getForm7Date().should('contain.text', oneMonthAgoDate.toLocaleString('default', { month: 'long' })); + ConversionDetails.getForm7Date().should('contain.text', oneMonthAgoDate.getFullYear()); + ConversionDetails.setDAODate(oneMonthAgoDate); + ConversionDetails.getDAODate().should('contain.text', oneMonthAgoDate.getDate()); + ConversionDetails.getDAODate().should('contain.text', oneMonthAgoDate.toLocaleString('default', { month: 'long' })); + ConversionDetails.getDAODate().should('contain.text', oneMonthAgoDate.getFullYear()); ConversionDetails.setFundingType('Full'); ConversionDetails.getFundingType().should('contain.text', 'Full'); ConversionDetails.setFundingAmount(false, 100000); @@ -165,14 +169,25 @@ describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { ConversionDetails.setFundingReason(); ConversionDetails.getFundingReason().should('contain.text', 'Funding Reason'); ConversionDetails.setEIG(true); - ConversionDetails.getEIG().should('contain.value', 'Yes'); - ConversionDetails.setAdvisoryBoardDate(); - ConversionDetails.getAdvisoryBoardDate().should('contain.text', currentDate.getDate()); - ConversionDetails.getAdvisoryBoardDate().should('contain.text', currentDate.toLocaleString('default', { month: 'long' })); - ConversionDetails.getAdvisoryBoardDate().should('contain.text', currentDate.getFullYear()); - ConversionDetails.setProposedAcademyOpening(nextYearDate.getMonth() + 1, nextYearDate.getFullYear); - ConversionDetails.getAdvisoryBoardDate().should('contain.text', 1); - ConversionDetails.getAdvisoryBoardDate().should('contain.text', nextYearDate.toLocaleString('default', { month: 'long' })); - ConversionDetails.getAdvisoryBoardDate().should('contain.text', nextYearDate.getFullYear()); + ConversionDetails.getEIG().should('contain.text', 'Yes'); + ConversionDetails.setAdvisoryBoardDate(nextMonthDate); + ConversionDetails.getAdvisoryBoardDate().should('contain.text', nextMonthDate.getDate()); + ConversionDetails.getAdvisoryBoardDate().should('contain.text', nextMonthDate.toLocaleString('default', { month: 'long' })); + ConversionDetails.getAdvisoryBoardDate().should('contain.text', nextMonthDate.getFullYear()); + ConversionDetails.setProposedAcademyOpening(nextYearDate.toLocaleString('default', {month: '2-digit'}), nextYearDate.getFullYear()); + ConversionDetails.getProposedAcademyOpening().should('contain.text', 1); + ConversionDetails.getProposedAcademyOpening().should('contain.text', nextYearDate.toLocaleString('default', { month: 'long' })); + ConversionDetails.getProposedAcademyOpening().should('contain.text', nextYearDate.getFullYear()); + ConversionDetails.setPreviousAdvisoryBoardDate(true, oneMonthAgoDate); + ConversionDetails.getPreviousAdvisoryBoardDate().should('contain.text', oneMonthAgoDate.getDate()); + ConversionDetails.getPreviousAdvisoryBoardDate().should('contain.text', oneMonthAgoDate.toLocaleString('default', { month: 'long' })); + ConversionDetails.getPreviousAdvisoryBoardDate().should('contain.text', oneMonthAgoDate.getFullYear()); + ConversionDetails.setAuthor(); + ConversionDetails.getAuthor().should('contain.text', 'Nicholas Warms'); + ConversionDetails.setClearedBy(); + ConversionDetails.getClearedBy().should('contain.text', 'Nicholas Warms'); + ConversionDetails.markComplete(); + cy.confirmContinueBtn().click(); + projectTaskList.getConversionDetailsStatus().should('contain.text', 'Completed'); }) }) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/conversionDetails.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/conversionDetails.js index b4c30b64a..e3f382b1b 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/conversionDetails.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/conversionDetails.js @@ -25,8 +25,8 @@ export default class ConversionDetails extends BasePage { fundingAmountReasonInput: '[id="conversion-support-grant-change-reason"]', fundingAmountReasonValue: '[id="grant-funding-reason"]', fundingAmountReasonLink: '[data-test="change-grant-funding-reason"]', - EIGLink: '[data-test="change-grant-funding-environmental-imporvement-grant"]', - EIGValue: '[id="grant-funding-environmental-imporvement-grant"]', + EIGLink: '[data-test="change-grant-funding-environmental-improvement-grant"]', + EIGValue: '[id="grant-funding-environmental-improvement-grant"]', EIGYesRadio: '[name="conversion-support-grant-environmental-improvement-grant"][data-cy="select-radio-yes" i]', EIGNoRadio: '[name="conversion-support-grant-environmental-improvement-grant"][data-cy="select-radio-no" i]', advisoryBoardDateLink: '[data-test="change-advisory-board-date"]', @@ -107,9 +107,9 @@ export default class ConversionDetails extends BasePage { cy.checkPath(this.path); cy.get(this.selectors.fundingAmountLink).click(); if (useDefaultAmount) { - cy.get(this.selectors.fundingAmountDefaultYesRadio); + cy.get(this.selectors.fundingAmountDefaultYesRadio).click(); } else { - cy.get(this.selectors.fundingAmountDefaultNoRadio); + cy.get(this.selectors.fundingAmountDefaultNoRadio).click(); cy.get(this.selectors.fundingAmountInput).clear().type(amount); } cy.get(this.selectors.saveButton).click(); @@ -129,13 +129,13 @@ export default class ConversionDetails extends BasePage { static getFundingReason() { cy.checkPath(this.path); - return cy.get(this.selectors.fundingTypeValue); + return cy.get(this.selectors.fundingAmountReasonValue); } - static setEIG(value = true){ + static setEIG(value = true) { cy.checkPath(this.path); cy.get(this.selectors.EIGLink).click(); - if(value){ + if (value) { cy.get(this.selectors.EIGYesRadio).check(); } else { cy.get(this.selectors.EIGNoRadio).check(); @@ -143,7 +143,7 @@ export default class ConversionDetails extends BasePage { cy.get(this.selectors.saveButton).click(); } - static getEIG(){ + static getEIG() { cy.checkPath(this.path); return cy.get(this.selectors.EIGValue); } @@ -162,45 +162,47 @@ export default class ConversionDetails extends BasePage { return cy.get(this.selectors.advisoryBoardDateValue); } - static setProposedAcademyOpening(month, year){ + static setProposedAcademyOpening(month, year) { cy.checkPath(this.path); cy.get(this.selectors.proposedOpeningLink).click(); cy.get(this.selectors.proposedOpeningRadioButton(month, year)).check() cy.get(this.selectors.saveButton).click(); } - static getProposedAcademyOpening(){ + static getProposedAcademyOpening() { cy.checkPath(this.path); return cy.get(this.selectors.proposedOpeningValue); } static setPreviousAdvisoryBoardDate(previousBoard = true, date = today) { cy.checkPath(this.path); - cy.get(this.selectors.advisoryBoardDateLink).click(); - if(previousBoard){ - cy.YesRadioBtn(); + cy.get(this.selectors.previousAdvisoryBoardLink).click(); + if (previousBoard) { + cy.YesRadioBtn().check(); cy.get(this.selectors.saveButton).click(); cy.enterDate(this.selectors.previousAdvisoryBoardDateInput, date.getDate(), date.getMonth() + 1, date.getFullYear()); + } else { + cy.NoRadioBtn().check(); } cy.get(this.selectors.saveButton).click(); } static getPreviousAdvisoryBoardDate() { cy.checkPath(this.path); - return cy.get(this.selectors.advisoryBoardDateValue); + return cy.get(this.selectors.previousAdvisoryBoardValue); } // People - static setAuthor(author = 'Nicholas Warms'){ + static setAuthor(author = 'Nicholas Warms') { cy.checkPath(this.path); cy.get(this.selectors.authorLink).click(); cy.get(this.selectors.authorInput).clear().type(author); cy.get(this.selectors.saveButton).click(); } - static getAuthor(){ + static getAuthor() { cy.checkPath(this.path); return cy.get(this.selectors.authorValue); } From 83343bf28b59a12a2a313f1bc7413e6f918b258a Mon Sep 17 00:00:00 2001 From: Nick Warms Date: Wed, 27 Sep 2023 13:18:33 +0100 Subject: [PATCH 10/10] Add comments --- .../Core-journeys/sponsored-conversion.cy.js | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) 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 7597f71dc..c959255e8 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 @@ -135,41 +135,35 @@ describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { // - Conversion Details - // ---------------------- - /* - select the conversion details - form 7 - date form 7 recieved - DAO date sent - Grant type - Grant ammount - EIG - Advisory date - Proposed opening date - Previous Advisory board - Author - Cleared by - Completed - */ - projectTaskList.selectConversionDetails(); + + // Form 7 ConversionDetails.setForm7Receivied('Yes'); ConversionDetails.getForm7Receivied().should('contain.text', 'Yes'); ConversionDetails.setForm7Date(oneMonthAgoDate); ConversionDetails.getForm7Date().should('contain.text', oneMonthAgoDate.getDate()); ConversionDetails.getForm7Date().should('contain.text', oneMonthAgoDate.toLocaleString('default', { month: 'long' })); ConversionDetails.getForm7Date().should('contain.text', oneMonthAgoDate.getFullYear()); + + // DAO ConversionDetails.setDAODate(oneMonthAgoDate); ConversionDetails.getDAODate().should('contain.text', oneMonthAgoDate.getDate()); ConversionDetails.getDAODate().should('contain.text', oneMonthAgoDate.toLocaleString('default', { month: 'long' })); ConversionDetails.getDAODate().should('contain.text', oneMonthAgoDate.getFullYear()); + + // Funding ConversionDetails.setFundingType('Full'); ConversionDetails.getFundingType().should('contain.text', 'Full'); ConversionDetails.setFundingAmount(false, 100000); ConversionDetails.getFundingAmount().should('contain.text', '£100,000'); ConversionDetails.setFundingReason(); ConversionDetails.getFundingReason().should('contain.text', 'Funding Reason'); + + //EIG ConversionDetails.setEIG(true); ConversionDetails.getEIG().should('contain.text', 'Yes'); + + // Dates ConversionDetails.setAdvisoryBoardDate(nextMonthDate); ConversionDetails.getAdvisoryBoardDate().should('contain.text', nextMonthDate.getDate()); ConversionDetails.getAdvisoryBoardDate().should('contain.text', nextMonthDate.toLocaleString('default', { month: 'long' })); @@ -182,10 +176,14 @@ describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { ConversionDetails.getPreviousAdvisoryBoardDate().should('contain.text', oneMonthAgoDate.getDate()); ConversionDetails.getPreviousAdvisoryBoardDate().should('contain.text', oneMonthAgoDate.toLocaleString('default', { month: 'long' })); ConversionDetails.getPreviousAdvisoryBoardDate().should('contain.text', oneMonthAgoDate.getFullYear()); + + // Author ConversionDetails.setAuthor(); ConversionDetails.getAuthor().should('contain.text', 'Nicholas Warms'); ConversionDetails.setClearedBy(); ConversionDetails.getClearedBy().should('contain.text', 'Nicholas Warms'); + + // Complete ConversionDetails.markComplete(); cy.confirmContinueBtn().click(); projectTaskList.getConversionDetailsStatus().should('contain.text', 'Completed');