-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b382bda
commit 832cf1f
Showing
9 changed files
with
297 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
@if (Model.PageStatus.HasPreviousPage) | ||
{ | ||
<div class="govuk-pagination__prev"> | ||
<a class="govuk-link govuk-pagination__link" asp-page="@("/" + Model.PageName)" asp-all-route-data="@Model.PaginationRouteData" asp-route-PageNumber="@(Model.PageStatus.PageIndex - 1)" rel="prev"> | ||
<a class="govuk-link govuk-pagination__link" asp-page="@("/" + Model.PageName)" asp-all-route-data="@Model.PaginationRouteData" asp-route-PageNumber="@(Model.PageStatus.PageIndex - 1)" rel="prev" data-testid="previous-page"> | ||
<svg class="govuk-pagination__icon govuk-pagination__icon--prev" xmlns="http://www.w3.org/2000/svg" height="13" width="15" aria-hidden="true" focusable="false" viewBox="0 0 15 13"> | ||
<path d="m6.5938-0.0078125-6.7266 6.7266 6.7441 6.4062 1.377-1.449-4.1856-3.9768h12.896v-2h-12.984l4.2931-4.293-1.414-1.414z"></path> | ||
</svg> | ||
|
@@ -18,7 +18,7 @@ | |
@if (Model.PageStatus.PageIndex != 1) | ||
{ | ||
<li class="govuk-pagination__item"> | ||
<a class="govuk-link govuk-pagination__link" asp-page="@("/" + Model.PageName)" asp-all-route-data="@Model.PaginationRouteData" asp-route-PageNumber="1" aria-label="Page 1"> | ||
<a class="govuk-link govuk-pagination__link" asp-page="@("/" + Model.PageName)" asp-all-route-data="@Model.PaginationRouteData" asp-route-PageNumber="1" aria-label="Page 1" data-testid="page-1"> | ||
1 | ||
</a> | ||
</li> | ||
|
@@ -32,22 +32,22 @@ | |
@if (Model.PageStatus.HasPreviousPage && Model.PageStatus.PageIndex - 1 != 1) | ||
{ | ||
<li class="govuk-pagination__item"> | ||
<a class="govuk-link govuk-pagination__link" asp-page="@("/" + Model.PageName)" asp-all-route-data="@Model.PaginationRouteData" asp-route-PageNumber="@(Model.PageStatus.PageIndex - 1)" aria-label="Page @(Model.PageStatus.PageIndex - 1)"> | ||
<a class="govuk-link govuk-pagination__link" asp-page="@("/" + Model.PageName)" asp-all-route-data="@Model.PaginationRouteData" asp-route-PageNumber="@(Model.PageStatus.PageIndex - 1)" aria-label="Page @(Model.PageStatus.PageIndex - 1)" data-testid="page-@(Model.PageStatus.PageIndex - 1)"> | ||
@(Model.PageStatus.PageIndex - 1) | ||
</a> | ||
</li> | ||
} | ||
@* Current page *@ | ||
<li class="govuk-pagination__item govuk-pagination__item--current"> | ||
<a class="govuk-link govuk-pagination__link" href="#" aria-label="Page @Model.PageStatus.PageIndex" aria-current="page"> | ||
<a class="govuk-link govuk-pagination__link" href="#" aria-label="Page @Model.PageStatus.PageIndex" aria-current="page" data-testid="[email protected]"> | ||
@Model.PageStatus.PageIndex | ||
</a> | ||
</li> | ||
@* Next Page *@ | ||
@if (Model.PageStatus.PageIndex != Model.PageStatus.TotalPages && Model.PageStatus.PageIndex + 1 != Model.PageStatus.TotalPages) | ||
{ | ||
<li class="govuk-pagination__item"> | ||
<a class="govuk-link govuk-pagination__link" asp-page="@("/" + Model.PageName)" asp-all-route-data="@Model.PaginationRouteData" asp-route-PageNumber="@(Model.PageStatus.PageIndex + 1)" aria-label="Page @(Model.PageStatus.PageIndex + 1)"> | ||
<a class="govuk-link govuk-pagination__link" asp-page="@("/" + Model.PageName)" asp-all-route-data="@Model.PaginationRouteData" asp-route-PageNumber="@(Model.PageStatus.PageIndex + 1)" aria-label="Page @(Model.PageStatus.PageIndex + 1)" data-testid="page-@(Model.PageStatus.PageIndex + 1)"> | ||
@(Model.PageStatus.PageIndex + 1) | ||
</a> | ||
</li> | ||
|
@@ -61,7 +61,7 @@ | |
@if (Model.PageStatus.PageIndex != Model.PageStatus.TotalPages) | ||
{ | ||
<li class="govuk-pagination__item"> | ||
<a class="govuk-link govuk-pagination__link" asp-page="@("/" + Model.PageName)" asp-all-route-data="@Model.PaginationRouteData" asp-route-PageNumber="@(Model.PageStatus.TotalPages)" aria-label="Page @(Model.PageStatus.TotalPages)"> | ||
<a class="govuk-link govuk-pagination__link" asp-page="@("/" + Model.PageName)" asp-all-route-data="@Model.PaginationRouteData" asp-route-PageNumber="@(Model.PageStatus.TotalPages)" aria-label="Page @(Model.PageStatus.TotalPages)" data-testid="[email protected]"> | ||
@(Model.PageStatus.TotalPages) | ||
</a> | ||
</li> | ||
|
@@ -71,7 +71,7 @@ | |
@if (Model.PageStatus.HasNextPage) | ||
{ | ||
<div class="govuk-pagination__next"> | ||
<a class="govuk-link govuk-pagination__link" asp-page="@("/" + Model.PageName)" asp-all-route-data="@Model.PaginationRouteData" asp-route-PageNumber="@(Model.PageStatus.PageIndex + 1)"> | ||
<a class="govuk-link govuk-pagination__link" asp-page="@("/" + Model.PageName)" asp-all-route-data="@Model.PaginationRouteData" asp-route-PageNumber="@(Model.PageStatus.PageIndex + 1)" data-testid="next-page"> | ||
<span class="govuk-pagination__link-title">Next</span> | ||
<svg class="govuk-pagination__icon govuk-pagination__icon--next" xmlns="http://www.w3.org/2000/svg" height="13" width="15" aria-hidden="true" focusable="false" viewBox="0 0 15 13"> | ||
<path d="m8.107-0.0078125-1.4136 1.414 4.2926 4.293h-12.986v2h12.896l-4.1855 3.9766 1.377 1.4492 6.7441-6.4062-6.7246-6.7266z"></path> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
158 changes: 158 additions & 0 deletions
158
tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/e2e/regression/search.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
import { Logger } from "cypress/common/logger"; | ||
import paginationComponent from "cypress/pages/paginationComponent"; | ||
import searchTrustPage from "cypress/pages/searchTrustPage"; | ||
import trustPage from "cypress/pages/trustPage"; | ||
|
||
describe("Testing the search trust functionality", () => { | ||
beforeEach(() => { | ||
cy.login(); | ||
}); | ||
|
||
it("Should return no results found when searching for a trust that doesn't exist", () => { | ||
searchTrustPage | ||
.enterSearchText("The missing trust") | ||
.getOption("No results found"); | ||
|
||
searchTrustPage.search(); | ||
|
||
searchTrustPage | ||
.hasNumberOfResults(`0 results for "the missing trust"`); | ||
|
||
cy.excuteAccessibilityTests(); | ||
}); | ||
|
||
it("Should return results when there is only one page of results", () => { | ||
|
||
Logger.log("Ensure that the search shows the results that match the search string"); | ||
|
||
searchTrustPage | ||
.enterSearchText("St Mary") | ||
.getOption("ST MARY'S ACADEMY TRUST") | ||
.then((option) => { | ||
option | ||
.hasName("ST MARY'S ACADEMY TRUST") | ||
.hasHint("150 Madison Ville, Lempi Junction, Darrellport, HR52 1BO"); | ||
}); | ||
|
||
searchTrustPage | ||
.getOption("ST MARY'S ANGLICAN ACADEMY") | ||
.then((option) => { | ||
option | ||
.hasName("ST MARY'S ANGLICAN ACADEMY") | ||
.hasHint("054 Kendrick Summit, South Michele, EP37 6WY"); | ||
}); | ||
|
||
searchTrustPage | ||
.getOption("ST MARY'S CATHOLIC PRIMARY SCHOOL") | ||
.then((option) => { | ||
option | ||
.hasName("ST MARY'S CATHOLIC PRIMARY SCHOOL") | ||
.hasHint("82929 Reynold Key, DV28 0EM"); | ||
}); | ||
|
||
searchTrustPage.search(); | ||
|
||
searchTrustPage.hasNumberOfResults(`17 results for "st mary"`); | ||
|
||
cy.excuteAccessibilityTests(); | ||
|
||
Logger.log("Checking a selection of the results"); | ||
|
||
searchTrustPage | ||
.getSearchResult("ST MARY'S ACADEMY TRUST") | ||
.then((result) => { | ||
result | ||
.hasName("ST MARY'S ACADEMY TRUST") | ||
.hasAddress("150 Madison Ville, Lempi Junction, Darrellport, HR52 1BO") | ||
.hasTrn("TR1471") | ||
.hasUid("1283") | ||
}); | ||
|
||
searchTrustPage | ||
.getSearchResult("ST MARY'S ANGLICAN ACADEMY") | ||
.then((result) => { | ||
result | ||
.hasName("ST MARY'S ANGLICAN ACADEMY") | ||
.hasAddress("054 Kendrick Summit, South Michele, EP37 6WY") | ||
.hasTrn("TR1464") | ||
.hasUid("1284") | ||
}); | ||
|
||
searchTrustPage | ||
.getSearchResult("ST MARY'S CATHOLIC PRIMARY SCHOOL") | ||
.then((result) => { | ||
result | ||
.hasName("ST MARY'S CATHOLIC PRIMARY SCHOOL") | ||
.hasAddress("82929 Reynold Key, DV28 0EM") | ||
.hasTrn("TR3814") | ||
.hasUid("1286") | ||
.select(); | ||
}); | ||
|
||
trustPage | ||
.hasName("ST MARY'S CATHOLIC PRIMARY SCHOOL") | ||
.hasType("Single-academy trust"); | ||
}); | ||
|
||
it.only("should pagination the results when there is a large number of matches", () => { | ||
searchTrustPage | ||
.enterSearchText("trust") | ||
.search(); | ||
|
||
searchTrustPage.hasNumberOfResults(`69 results for "trust"`); | ||
|
||
let trustsPageOne: Array<string> = []; | ||
let trustsPageTwo: Array<string> = []; | ||
|
||
searchTrustPage.getAllTrustResults() | ||
.then((trusts) => { | ||
trustsPageOne = trusts; | ||
|
||
expect(trustsPageOne.length).to.equal(20); | ||
|
||
paginationComponent.hasNoPrevious(); | ||
|
||
paginationComponent.isCurrentPage("1"); | ||
paginationComponent.goToPage("2"); | ||
return searchTrustPage.getAllTrustResults(); | ||
}) | ||
.then((trusts) => { | ||
trustsPageTwo = trusts; | ||
|
||
expect(trustsPageTwo.length).to.equal(20); | ||
|
||
paginationComponent.isCurrentPage("2"); | ||
|
||
paginationComponent.previous(); | ||
|
||
return searchTrustPage.getAllTrustResults(); | ||
}) | ||
.then((trusts) => { | ||
|
||
paginationComponent.isCurrentPage("1"); | ||
|
||
expect(trusts).to.deep.equal(trustsPageOne); | ||
|
||
paginationComponent.next(); | ||
|
||
return searchTrustPage.getAllTrustResults(); | ||
}) | ||
.then((trusts) => { | ||
paginationComponent.isCurrentPage("2"); | ||
|
||
expect(trustsPageTwo).to.deep.equal(trusts); | ||
|
||
paginationComponent.goToPage("4"); | ||
|
||
return searchTrustPage.getAllTrustResults(); | ||
}) | ||
.then((trusts) => { | ||
paginationComponent.isCurrentPage("4"); | ||
|
||
paginationComponent.hasNoNext(); | ||
|
||
expect(trusts.length).to.equal(9); | ||
}) | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/pages/cookiesPage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/DFE.FindInformationAcademiesTrusts.CypressTests/cypress/pages/paginationComponent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Logger } from "cypress/common/logger"; | ||
|
||
export class PaginationComponent { | ||
constructor() { | ||
|
||
} | ||
|
||
public next(): this { | ||
cy.getByTestId(`next-page`).click(); | ||
|
||
return this; | ||
} | ||
|
||
public hasNoNext(): this { | ||
cy.getByTestId("next-page").should("not.exist"); | ||
|
||
return this; | ||
} | ||
|
||
public previous(): this { | ||
cy.getByTestId(`previous-page`).click(); | ||
|
||
return this; | ||
} | ||
|
||
public hasNoPrevious(): this { | ||
cy.getByTestId("previous-page").should("not.exist"); | ||
|
||
return this; | ||
} | ||
|
||
public goToPage(pageNumber: string) { | ||
Logger.log(`Moving to page ${pageNumber}`); | ||
|
||
cy.getByTestId(`page-${pageNumber}`).click(); | ||
|
||
return this; | ||
} | ||
|
||
public isCurrentPage(pageNumber: string): this { | ||
cy.getByTestId(`page-${pageNumber}`).parent().should("have.class", "govuk-pagination__item--current"); | ||
|
||
return this; | ||
} | ||
} | ||
|
||
const paginationComponent = new PaginationComponent(); | ||
|
||
export default paginationComponent; |
Oops, something went wrong.