Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

137740 cypress sponsored budget #912

Merged
merged 4 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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'] }, () => {
Expand All @@ -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)
Expand All @@ -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();
Expand Down Expand Up @@ -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}`);
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/// <reference types ='Cypress'/>

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);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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()
}

};
Loading