Skip to content

Commit

Permalink
Merge pull request #922 from DFE-Digital/137739-cypress-sponsored-rat…
Browse files Browse the repository at this point in the history
…ionale

137739 Cypress sponsored Add rationale test
  • Loading branch information
nwarms authored Sep 28, 2023
2 parents eae0cb7 + b53aa39 commit a7069b3
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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'] }, () => {
Expand Down Expand Up @@ -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');
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types ='Cypress'/>

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

0 comments on commit a7069b3

Please sign in to comment.