Skip to content

Commit

Permalink
add ofsted single headline grade tests and page objects
Browse files Browse the repository at this point in the history
  • Loading branch information
CMurrell148 committed Jan 30, 2025
1 parent 0fde5b3 commit f1d5e61
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,84 @@ import navigation from "../../../pages/navigation";
import dataDownload from "../../../pages/trusts/dataDownload";
import commonPage from "../../../pages/commonPage";

const testTrustOfstedData = [
{
typeOfTrust: "single academy trust",
uid: 5527
},
{
typeOfTrust: "multi academy trust",
uid: 5712
}
];

describe("Testing the Ofsted page and its subpages ", () => {

testTrustOfstedData.forEach(({ typeOfTrust, uid }) => {
describe(`Testing the single headline grades page for a ${typeOfTrust}`, () => {
beforeEach(() => {
cy.login();
cy.visit(`/trusts/ofsted/single-headline-grades?uid=${uid}`);

cy.task('checkForFiles', 'cypress/downloads').then((files) => {
if (files) {
cy.task('clearDownloads', 'cypress/downloads');
}
});
});

it("Checks the correct Ofsted single headline grades subpage header is present", () => {
ofstedPage
.checkOfstedSHGPageHeaderPresent();
});

it("Checks the browser title is correct", () => {
commonPage
.checkThatBrowserTitleForTrustPageMatches('Single headline grades - Ofsted - {trustName} - Find information about academies and trusts');
});

it("Checks the breadcrumb shows the correct page name", () => {
navigation
.checkPageNameBreadcrumbPresent("Ofsted");
});

it("Checks the correct Ofsted single headline grades table headers are present", () => {
ofstedPage
.checkOfstedSHGTableHeadersPresent();
});

it("Checks the Ofsted current ratings page sorting", () => {
ofstedPage
.checkOfstedSHGSorting();
});

it("Checks that a trusts current and previous ratings correct judgement types are present", () => {
ofstedPage
.checkSHGCurrentSHGJudgementsPresent()
.checkSHGPreviousSHGJudgementsPresent()
.checkSHGCurrentSHGBeforeOrAfterPresent()
.checkSHGPreviousSHGBeforeOrAfterPresent();
});

it("Checks that the single headline grades dates are within the correct parameters", () => {
ofstedPage
.checkSHGDateJoinedPresent()
.checkSHGDateOfCurrentInspectionPresent()
.checkSHGDateOfPreviousInspectionPresent();
});

it('should export academies data as an xlsx and verify it has downloaded and has content', () => {
ofstedPage
.clickDownloadButton();
dataDownload
.checkFileDownloaded()
.checkFileHasContent()
.deleteDownloadedFile();
});

});
});

describe("Testing the Ofsted current ratings page ", () => {
beforeEach(() => {
cy.login();
Expand Down Expand Up @@ -273,7 +349,8 @@ describe("Testing the Ofsted page and its subpages ", () => {
describe("Testing a trust that has no ofsted data within it to ensure the issue of a 500 page appearing does not happen", () => {
beforeEach(() => {
cy.login();
commonPage.interceptAndVerifyNo500Errors();
commonPage
.interceptAndVerifyNo500Errors();
});

['/trusts/ofsted/current-ratings?uid=17728', '/trusts/ofsted/previous-ratings?uid=17728', '/trusts/ofsted/important-dates?uid=17728', '/trusts/ofsted/safeguarding-and-concerns?uid=17728'].forEach((url) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ class OfstedPage {
elements = {
subpageHeader: () => cy.get('[data-testid="subpage-header"]'),
downloadButton: () => cy.get('[data-testid="download-all-ofsted-data-button"]'),
singleHeadlineGrades: {
section: () => cy.get('[data-testid="ofsted-single-headline-grades-school-name-table"]'),
schoolName: () => this.elements.singleHeadlineGrades.section().find('[data-testid="ofsted-single-headline-grades-school-name"]'),
schoolNameHeader: () => this.elements.singleHeadlineGrades.section().find('[data-testid="ofsted-single-headline-grades-school-name-header"]'),
dateJoined: () => this.elements.singleHeadlineGrades.section().find('[data-testid="ofsted-single-headline-grades-date-joined"]'),
dateJoinedHeader: () => this.elements.singleHeadlineGrades.section().find('[data-testid="ofsted-single-headline-grades-date-joined-header"]'),
currentSHG: () => this.elements.singleHeadlineGrades.section().find('[data-testid="ofsted-single-headline-grades-current-single-headline-grade"]'),
currentSHGBeforeOrAfter: () => this.elements.singleHeadlineGrades.section().find('[data-testid="ofsted-single-headline-grades-current-before-after-joining"]'),
currentSHGHeader: () => this.elements.singleHeadlineGrades.section().find('[data-testid="ofsted-single-headline-grades-current-single-headline-grade-header"]'),
dateOfCurrentInspection: () => this.elements.singleHeadlineGrades.section().find('[data-testid="ofsted-single-headline-grades-current-date-of-inspection"]'),
dateOfCurrentInspectionHeader: () => this.elements.singleHeadlineGrades.section().find('[data-testid="ofsted-single-headline-grades-date-of-current-inspection-header"]'),
previousSHG: () => this.elements.singleHeadlineGrades.section().find('[data-testid="ofsted-single-headline-grades-previous-single-headline-grade"]'),
previousSHGBeforeOrAfter: () => this.elements.singleHeadlineGrades.section().find('[data-sort-value="3"] > [data-testid="ofsted-single-headline-grades-previous-before-after-joining"]'),
previousSHGHeader: () => this.elements.singleHeadlineGrades.section().find('[data-testid="ofsted-single-headline-grades-previous-single-headline-grade-header"]'),
dateOfPreviousInspection: () => this.elements.singleHeadlineGrades.section().find('[data-testid="ofsted-single-headline-grades-previous-date-of-inspection"]'),
dateOfPreviousInspectionHeader: () => this.elements.singleHeadlineGrades.section().find('[data-testid="ofsted-single-headline-grades-date-of-previous-inspection-header"]'),
},
currentRatings: {
section: () => cy.get('[data-testid="ofsted-current-ratings-table"]'),
schoolName: () => this.elements.currentRatings.section().find('[data-testid="ofsted-current-ratings-school-name"]'),
Expand Down Expand Up @@ -83,10 +100,92 @@ class OfstedPage {

private readonly checkValueIsValidBeforeOrAfterJoiningTag = (element: JQuery<HTMLElement>) => {
const text = element.text().trim();
expect(text).to.match(/^(Before|After|Not yet inspected)$/);
expect(text).to.match(/^(Before|After|Not yet inspected|After joining|Before joining)$/);
};

// #endregion

// #region Single headline grades
public checkOfstedSHGPageHeaderPresent(): this {
this.elements.subpageHeader().should('contain', 'Single headline grades');
return this;
}

public checkOfstedSHGTableHeadersPresent(): this {
this.elements.singleHeadlineGrades.schoolNameHeader().should('be.visible');
this.elements.singleHeadlineGrades.dateJoinedHeader().should('be.visible');
this.elements.singleHeadlineGrades.currentSHGHeader().should('be.visible');
this.elements.singleHeadlineGrades.dateOfCurrentInspectionHeader().should('be.visible');
this.elements.singleHeadlineGrades.previousSHGHeader().should('be.visible');
this.elements.singleHeadlineGrades.dateOfPreviousInspectionHeader().should('be.visible');
return this;
}

public checkOfstedSHGSorting(): this {
TableUtility.checkStringSorting(
this.elements.singleHeadlineGrades.schoolName,
this.elements.singleHeadlineGrades.schoolNameHeader
);
TableUtility.checkStringSorting(
this.elements.singleHeadlineGrades.dateJoined,
this.elements.singleHeadlineGrades.dateJoinedHeader
);
TableUtility.checkStringSorting(
this.elements.singleHeadlineGrades.currentSHG,
this.elements.singleHeadlineGrades.currentSHGHeader
);
TableUtility.checkStringSorting(
this.elements.singleHeadlineGrades.dateOfCurrentInspection,
this.elements.singleHeadlineGrades.dateOfCurrentInspectionHeader
);
TableUtility.checkStringSorting(
this.elements.singleHeadlineGrades.previousSHG,
this.elements.singleHeadlineGrades.previousSHGHeader
);
TableUtility.checkStringSorting(
this.elements.singleHeadlineGrades.dateOfPreviousInspection,
this.elements.singleHeadlineGrades.dateOfPreviousInspectionHeader
);
return this;
}

public checkSHGDateJoinedPresent(): this {
this.elements.singleHeadlineGrades.dateJoined().each(this.checkValueIsValidDate);
return this;
}

public checkSHGDateOfCurrentInspectionPresent(): this {
this.elements.singleHeadlineGrades.dateOfCurrentInspection().each(this.checkValueIsValidDate);
return this;
}

public checkSHGDateOfPreviousInspectionPresent(): this {
this.elements.singleHeadlineGrades.dateOfPreviousInspection().each(this.checkValueIsValidDate);
return this;
}

public checkSHGCurrentSHGJudgementsPresent(): this {
this.elements.singleHeadlineGrades.currentSHG().each(this.checkValueIsValidOfstedRating);
return this;
}

public checkSHGPreviousSHGJudgementsPresent(): this {
this.elements.singleHeadlineGrades.previousSHG().each(this.checkValueIsValidOfstedRating);
return this;
}

public checkSHGCurrentSHGBeforeOrAfterPresent(): this {
this.elements.singleHeadlineGrades.currentSHGBeforeOrAfter().each(this.checkValueIsValidBeforeOrAfterJoiningTag);
return this;
}

public checkSHGPreviousSHGBeforeOrAfterPresent(): this {
this.elements.singleHeadlineGrades.previousSHGBeforeOrAfter().each(this.checkValueIsValidBeforeOrAfterJoiningTag);
return this;
}

// #endreigon

// #region Current ratings

public checkOfstedCurrentRatingsPageHeaderPresent(): this {
Expand Down

0 comments on commit f1d5e61

Please sign in to comment.