Skip to content

Commit

Permalink
Merge pull request #921 from DFE-Digital/137750-cypress-sponsored-con…
Browse files Browse the repository at this point in the history
…version-details

137750 cypress sponsored conversion details
  • Loading branch information
nwarms authored Sep 27, 2023
2 parents 81077d0 + b312a07 commit eae0cb7
Show file tree
Hide file tree
Showing 6 changed files with 329 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ import projectAssignment from "../../pages/projectAssignment";
import schoolOverview from "../../pages/schoolOverview";
import budget from "../../pages/budget";
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(currentDate.getFullYear() + 1);
const oneMonthAgoDate = new Date();
oneMonthAgoDate.setMonth(currentDate.getMonth() - 1);
const nextMonthDate = new Date();
nextMonthDate.setMonth(currentDate.getMonth() + 1);


const testData = {
Expand All @@ -23,18 +28,18 @@ 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
},
pupilForecast: {
additionalInfomation: 'Pupil Forecast Additional Infomation'
additionalInfomation: 'Pupil Forecast Additional Information'
}
}

Expand Down Expand Up @@ -126,5 +131,61 @@ describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => {
PupilForecast.getAdditionalInfomation().should('contain.text', testData.pupilForecast.additionalInfomation);
cy.confirmContinueBtn().click();

// ----------------------
// - Conversion Details -
// ----------------------

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' }));
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());

// 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');
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
/// <reference types ='Cypress'/>

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-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"]',
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).click();
} else {
cy.get(this.selectors.fundingAmountDefaultNoRadio).click();
cy.get(this.selectors.fundingAmountInput).clear().type(amount);
}
cy.get(this.selectors.saveButton).click();
}

static getFundingAmount() {
cy.checkPath(this.path);
return cy.get(this.selectors.fundingAmountValue);
}

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.fundingAmountReasonValue);
}

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.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.previousAdvisoryBoardValue);
}

// 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();
}

};
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"]')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<govuk-summary-list-row if="@Model.IsDao" name="grant-funding-type" label="Grant funding type" key-width="@kw" value="@Model.ConversionSupportGrantType" asp-route-id="@Model.Id" asp-page="@Links.SchoolAndTrustInformationSection.GrantType.Page" hidden-text="grant funding type" />
<govuk-summary-list-row if="@Model.IsDao" name="grant-funding-amount" label="Grant funding amount" key-width="@kw" value="@Model.ConversionSupportGrantAmount" asp-route-id="@Model.Id" asp-page="@Links.SchoolAndTrustInformationSection.GrantDetails.Page" hidden-text="grant funding amount" />
<govuk-summary-list-row if="@Model.IsDao && string.IsNullOrEmpty(Model.ConversionSupportGrantChangeReason) != true" name="grant-funding-reason" label="Grant funding reason" key-width="@kw" value="@Model.ConversionSupportGrantChangeReason" asp-route-id="@Model.Id" asp-page="@Links.SchoolAndTrustInformationSection.GrantDetails.Page" hidden-text="grant funding reason" />
<govuk-summary-list-row if="@Model.IsDao && (Model.ConversionSupportGrantType == grantTypeFull || Model.ConversionSupportGrantType == grantTypeIntermediate)" name="grant-funding-environmental-imporvement-grant" label="Is the school applying for an EIG (Environmental Improvement Grant)?" key-width="@kw" value="@Model.ConversionSupportGrantEnvironmentalImprovementGrant" asp-route-id="@Model.Id" asp-page="@Links.SchoolAndTrustInformationSection.GrantDetails.Page" hidden-text="grant environmental improvement" />
<govuk-summary-list-row if="@Model.IsDao && (Model.ConversionSupportGrantType == grantTypeFull || Model.ConversionSupportGrantType == grantTypeIntermediate)" name="grant-funding-environmental-improvement-grant" label="Is the school applying for an EIG (Environmental Improvement Grant)?" key-width="@kw" value="@Model.ConversionSupportGrantEnvironmentalImprovementGrant" asp-route-id="@Model.Id" asp-page="@Links.SchoolAndTrustInformationSection.GrantDetails.Page" hidden-text="grant environmental improvement" />

<govuk-summary-list-row name="advisory-board-date" label="Date of advisory board" key-width="@kw" value="@Model.HeadTeacherBoardDate" asp-page="@Links.SchoolAndTrustInformationSection.HeadTeacherBoardDate.Page" asp-route-id="@Model.Id" hidden-text="head teacher board date" />
<govuk-summary-list-row name="proposed-academy-opening-date" label="Proposed academy opening date" key-width="@kw" value="@Model.ProposedAcademyOpeningDate" asp-page="@Links.SchoolAndTrustInformationSection.ProposedAcademyOpeningDate.Page" asp-route-id="@Model.Id" hidden-text="proposed academy opening date" />
Expand Down
Loading

0 comments on commit eae0cb7

Please sign in to comment.