Skip to content

Commit

Permalink
Add risks test
Browse files Browse the repository at this point in the history
  • Loading branch information
nwarms committed Sep 27, 2023
1 parent ba8fad8 commit ba5dc08
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import budget from "../../pages/budget";
import PupilForecast from "../../pages/pupilForecast";
import ConversionDetails from "../../pages/conversionDetails";
import Rationale from "../../pages/rationale";
import RisksAndIssues from "../../pages/risksAndIssues";

const currentDate = new Date();
const nextYearDate = new Date();
Expand Down Expand Up @@ -42,7 +43,8 @@ const testData = {
pupilForecast: {
additionalInfomation: 'Pupil Forecast Additional Information'
},
rationale: 'This is why this school should become an academy'
rationale: 'This is why this school should become an academy',
risksAndIssues: 'Here are the risks and issues for this conversion',
}

describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => {
Expand Down Expand Up @@ -200,5 +202,16 @@ describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => {
Rationale.markComplete();
cy.confirmContinueBtn().click();
projectTaskList.getRationaleStatus().should('contain.text', 'Completed');

// --------------------
// - Risks and issues -
// --------------------

projectTaskList.selectRisksAndIssues();
RisksAndIssues.changeRisksAndIssues(testData.risksAndIssues);
RisksAndIssues.getRisksAndIssues().should('contain.text', testData.risksAndIssues);
RisksAndIssues.markComplete();
cy.confirmContinueBtn().click();
projectTaskList.getRisksAndIssuesStatus().should('contain.text', 'Completed');
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export default class ProjectTaskList extends BasePage {
conversionDetailsLink: 'a[href*="/conversion-details"]',
conversionDetailsStatus: '[id="school-and-trust-information-status"]',
rationaleLink: 'a[href*="/confirm-project-trust-rationale"]',
rationaleStatus: '[id="rationale-status"]'
rationaleStatus: '[id="rationale-status"]',
riskAndIssuesLink: 'a[href*="/confirm-risks-issues"]',
riskAndIssuesStatus: '[id="risks-and-issues-status"]'
}

static path = 'task-list';
Expand Down Expand Up @@ -80,4 +82,14 @@ export default class ProjectTaskList extends BasePage {
cy.checkPath(this.path);
return cy.get(this.selectors.rationaleStatus);
}

static selectRisksAndIssues() {
cy.checkPath(this.path);
cy.get(this.selectors.riskAndIssuesLink).click();
}

static getRisksAndIssuesStatus() {
cy.checkPath(this.path);
return cy.get(this.selectors.riskAndIssuesStatus);
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types ='Cypress'/>

import BasePage from "./BasePage";

export default class RisksAndIssues extends BasePage {
static selectors = {
rationaleLink: '[data-test="change-risks-and-issues"]',
rationaleInput: '[id="risks-and-issues"]',
rationaleValue: '[id="risks-and-issues"]',
saveButton: '[class="govuk-button"]',
completeCheckbox: '[id="risks-and-issues-complete"]'
};

static path = 'confirm-risks-issues';

static changeRisksAndIssues(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 getRisksAndIssues() {
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 ba5dc08

Please sign in to comment.