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 643bf3eee..5e3bc6412 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 @@ -4,6 +4,11 @@ import projectList from "../../pages/projectList"; import projectTaskList from "../../pages/projectTaskList"; import projectAssignment from "../../pages/projectAssignment"; import schoolOverview from "../../pages/schoolOverview"; +import budget from "../../pages/budget"; + +const currentYear = new Date(); +const nextYear = new Date(); +nextYear.setFullYear(new Date().getFullYear() + 1); const testData = { @@ -15,6 +20,14 @@ const testData = { distance: '15', distanceDecription: 'Distance description', mp: 'Important Politician, Indepentent', + budget: { + endOfFinanicalYear: currentYear, + forecastedRevenueCurrentYear: 20, + forecastedCapitalCurrentYear: 10, + endOfNextFinancialYear: nextYear, + forecastedRevenueNextYear: 15, + forecastedCapitalNextYear: 12 + } } describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { @@ -26,9 +39,9 @@ describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { }) it('TC01: Sponsored conversion journey ', () => { - // ----------------------- - // Assign Delivery Officer - // ----------------------- + // --------------------------- + // - Assign Delivery Officer - + // --------------------------- projectTaskList.selectAssignProject(); projectAssignment.assignProject(testData.deliveryOfficer) @@ -37,9 +50,9 @@ describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { projectList.filterProjectList(testData.projectName); projectList.getNthProjectDeliveryOfficer().should('contain.text', testData.deliveryOfficer); - // --------------- - // School Overview - // --------------- + // ------------------- + // - School Overview - + // ------------------- projectList.selectProject(testData.projectName); projectTaskList.selectSchoolOverview(); @@ -70,6 +83,25 @@ describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => { //Complete schoolOverview.markComplete(); cy.confirmContinueBtn().click(); - projectTaskList.getSchoolOverviewStatus().should('contain.text', 'Completed') + projectTaskList.getSchoolOverviewStatus().should('contain.text', 'Completed'); + + // ---------- + // - Budget - + // ---------- + + projectTaskList.selectBudget(); + budget.updateBudgetInfomation(testData.budget); + + budget.getCurrentFinancialYear().should('contain.text', testData.budget.endOfFinanicalYear.getDate()); + budget.getCurrentFinancialYear().should('contain.text', testData.budget.endOfFinanicalYear.toLocaleString('default', { month: 'long' })); + budget.getCurrentFinancialYear().should('contain.text', testData.budget.endOfFinanicalYear.getFullYear()); + budget.getCurrentRevenue().should('contain.text', `£${testData.budget.forecastedRevenueCurrentYear}`); + budget.getCurrentCapital().should('contain.text', `£${testData.budget.forecastedCapitalCurrentYear}`); + + budget.getNextFinancialYear().should('contain.text', testData.budget.endOfNextFinancialYear.getDate()); + budget.getNextFinancialYear().should('contain.text', testData.budget.endOfNextFinancialYear.toLocaleString('default', { month: 'long' })); + budget.getNextFinancialYear().should('contain.text', testData.budget.endOfNextFinancialYear.getFullYear()); + budget.getNextRevenue().should('contain.text', `£${testData.budget.forecastedRevenueNextYear}`); + budget.getNextCapital().should('contain.text', `£${testData.budget.forecastedCapitalNextYear}`); }) }) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/budget.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/budget.js new file mode 100644 index 000000000..ac4c13fab --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/budget.js @@ -0,0 +1,95 @@ +/// + +import BasePage from "./BasePage"; + +const currentYear = new Date(); +const nextYear = new Date().setFullYear(new Date().getFullYear() + 1); + +export default class Budget extends BasePage { + static selectors = { + changeEndOfFinancialYearLink: '[data-test="change-financial-year"]', + currentFinancialYearDayInput: '[id="financial-year-day"]', + currentFinancialYearMonthInput: '[id="financial-year-month"]', + currentFinancialYearYearInput: '[id="financial-year-year"]', + currentFinancialYearValue: '[id="financial-year"]', + currentFinancialYearRevenueInput: '[id="finance-year-current"]', + currentFinancialYearRevenueValue: '[id="finance-year-current"]', + currentFinancialYearCapitalInput: '[id="finance-current-capital"]', + currentFinancialYearCapitalValue: '[id="finance-current-capital"]', + nextFinancialYearDayInput: '[id="next-financial-year-day"]', + nextFinancialYearMonthInput: '[id="next-financial-year-month"]', + nextFinancialYearYearInput: '[id="next-financial-year-year"]', + nextFinancialYearValue: '[id="next-financial-year"]', + nextFinancialYearRevenueInput: '[id="finance-year-following"]', + nextFinancialYearRevenueValue: '[id="finance-year-following"]', + nextFinancialYearCapitalInput: '[id="finance-projected-capital"]', + nextFinancialYearCapitalValue: '[id="finance-projected-capital"]', + saveButton: '[class="govuk-button"]' + }; + + static path = 'budget'; + + static updateBudgetInfomation({ + endOfFinanicalYear, + forecastedRevenueCurrentYear, + forecastedCapitalCurrentYear, + endOfNextFinancialYear, + forecastedRevenueNextYear, + forecastedCapitalNextYear + }) { + if (!endOfFinanicalYear) { + endOfFinanicalYear = currentYear; + } + + if (!endOfNextFinancialYear) { + endOfNextFinancialYear = nextYear; + } + cy.checkPath(this.path); + + cy.get(this.selectors.changeEndOfFinancialYearLink).click() + + cy.get(this.selectors.currentFinancialYearDayInput).clear().type(endOfFinanicalYear.getDate()); + cy.get(this.selectors.currentFinancialYearMonthInput).clear().type(endOfFinanicalYear.getMonth() + 1); // Add 1 as months start at 0 + cy.get(this.selectors.currentFinancialYearYearInput).clear().type(endOfFinanicalYear.getFullYear()); + cy.get(this.selectors.currentFinancialYearRevenueInput).clear().type(forecastedRevenueCurrentYear); + cy.get(this.selectors.currentFinancialYearCapitalInput).clear().type(forecastedCapitalCurrentYear); + + cy.get(this.selectors.nextFinancialYearDayInput).clear().type(endOfNextFinancialYear.getDate()); + cy.get(this.selectors.nextFinancialYearMonthInput).clear().type(endOfNextFinancialYear.getMonth() + 1); // Add 1 as months start at 0 + cy.get(this.selectors.nextFinancialYearYearInput).clear().type(endOfNextFinancialYear.getFullYear()); + cy.get(this.selectors.nextFinancialYearRevenueInput).clear().type(forecastedRevenueNextYear); + cy.get(this.selectors.nextFinancialYearCapitalInput).clear().type(forecastedCapitalNextYear); + + cy.get(this.selectors.saveButton).click(); + }; + + static getCurrentFinancialYear() { + cy.checkPath(this.path); + return cy.get(this.selectors.currentFinancialYearValue); + } + + static getCurrentRevenue() { + cy.checkPath(this.path); + return cy.get(this.selectors.currentFinancialYearRevenueValue); + } + + static getCurrentCapital() { + cy.checkPath(this.path); + return cy.get(this.selectors.currentFinancialYearCapitalValue) + } + + static getNextFinancialYear() { + cy.checkPath(this.path); + return cy.get(this.selectors.nextFinancialYearValue); + } + + static getNextRevenue() { + cy.checkPath(this.path); + return cy.get(this.selectors.nextFinancialYearRevenueValue); + } + + static getNextCapital() { + cy.checkPath(this.path); + return cy.get(this.selectors.nextFinancialYearCapitalValue); + } +}; diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js index b4cbd649e..8fc652faa 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js @@ -9,7 +9,8 @@ export default class ProjectTaskList extends BasePage { assignedUser: '[data-id="assigned-user"]', notificationMessage: '[id="notification-message"]', schoolOverviewLink: 'a[href*="/school-overview"]', - schoolOverviewStatus: '[id="school-overview-status"]' + schoolOverviewStatus: '[id="school-overview-status"]', + budgetLink: 'a[href*="/budget"]' } static path = 'task-list'; @@ -39,4 +40,9 @@ export default class ProjectTaskList extends BasePage { return cy.get(this.selectors.schoolOverviewStatus); } + static selectBudget() { + cy.checkPath(this.path); + cy.get(this.selectors.budgetLink).click() + } + };