diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress.config.ts b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress.config.ts index 14bd9e9d4..d89feba00 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress.config.ts +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress.config.ts @@ -5,7 +5,7 @@ import { generateZapReport } from './cypress/plugins/generateZapReport' export default defineConfig({ video: false, - retries: 2, + retries: 0, e2e: { // We've imported your old cypress plugins here. // You may want to clean this up later by importing these. diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/filteration-test.cy.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/filteration-test.cy.js new file mode 100644 index 000000000..2e9851241 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/filteration-test.cy.js @@ -0,0 +1,150 @@ +/// +import projectList from "../../pages/projectList"; + + +describe('Filteration Tests', { tags: ['@dev', '@stage'] }, () => { + + 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 = { + projectName: 'Sponsored Cypress Project', + completedText: 'Completed', + projectAssignment: { + deliveryOfficer: 'Richika Dogra', + assignedOfficerMessage: 'Project is assigned', + }, + schoolOverview: { + pan: '98765', + pfiDescription: 'PFI Description', + distance: '15', + distanceDecription: 'Distance description', + mp: 'Important Politician, Independent', + }, + budget: { + endOfFinanicalYear: currentDate, + forecastedRevenueCurrentYear: 20, + forecastedCapitalCurrentYear: 10, + endOfNextFinancialYear: nextYearDate, + forecastedRevenueNextYear: 15, + forecastedCapitalNextYear: 12 + }, + pupilForecast: { + additionalInfomation: 'Pupil Forecast Additional Information' + }, + rationale: 'This is why this school should become an academy', + risksAndIssues: 'Here are the risks and issues for this conversion', + localAuthority: { + comment: 'Comment', + sharepointLink: 'https://sharepoint.com' + }, + performanceInfo: 'Additional Information', + keyStages: [4, 5] + } + + before(() => { + + }) + + beforeEach(() => { + projectList.selectProject(testData.projectName) + }) + + it('Should filter projects by region', () => { + // Visit the home page or the initial project list page + cy.visit(`${Cypress.env('url')}/`); + // Check if the Region accordion section is not expanded + cy.get('[data-cy="select-projectlist-filter-region"]').should('have.attr', 'aria-expanded', 'false').then(($accordion) => { + const isAccordionExpanded = $accordion.attr('aria-expanded') === 'true'; + + // If the accordion is not expanded, click to expand it + if (!isAccordionExpanded) { + cy.get('[data-cy="select-projectlist-filter-region"]').click(); + } + // Select the region checkbox + cy.get('#filter-project-region-east-midlands').check(); + cy.get('#filter-project-region-east-of-england').check(); + cy.get('#filter-project-region-london').check(); + cy.get('#filter-project-region-north-east').check(); + + // Apply the selections + cy.get('[data-cy="select-projectlist-filter-apply"]').click(); + + // Assert that the results are updated based on the selected regions + for (let i = 0; i < 10; i++) { + const regionSelector = `#region-${i}`; + + // Ensure that the selected regions are present in the results + cy.get(regionSelector).each(($regionElement) => { + const region = $regionElement.text(); + expect(region).to.satisfy((text) => { + return ( + text.includes('East Midlands') || + text.includes('East of England') || + text.includes('London') || + text.includes('North East') + ); + }); + }); + } + + // Clear the filters + cy.get('[data-cy="clear-filter"]').click(); + }); + }); + + it('Filter by Project Status', () => { + // Visit the home page or the initial project list page + cy.visit(`${Cypress.env('url')}/`); + + // Check if the Project Status accordion section is not expanded + cy.get('[data-cy="select-projectlist-filter-project-status"]').should('have.attr', 'aria-expanded', 'false').then(($accordion) => { + const isAccordionExpanded = $accordion.attr('aria-expanded') === 'true'; + + // If the accordion is not expanded, click to expand it + if (!isAccordionExpanded) { + cy.get('[data-cy="select-projectlist-filter-project-status"]').click(); + } + + const projectStatuses = ['Approved', 'Approved with conditions', 'Declined', 'Deferred', 'Pre advisory board']; + + // Select each project status checkbox and check the URL + projectStatuses.forEach((statusToFilter) => { + // Select the project status checkbox + cy.get(`[data-cy="select-projectlist-filter-status-${statusToFilter}"]`).check(); + + // Perform actions to apply the filter by project status + cy.get('[data-cy="select-projectlist-filter-apply"]').click(); + + // Log the actual URL to help debug the issue + cy.url().then((url) => { + cy.log(`Actual URL for ${statusToFilter}: ${url}`); + + // Add assertions to check if the filter applied correctly + cy.get('[id^="project-status-"]').invoke('text').then((text) => { + // Convert text to an array if it's not already + const texts = Array.isArray(text) ? text : [text]; + + // Check each text for inclusion (case-insensitive) + texts.forEach((individualText) => { + expect(individualText.toLowerCase()).to.include(statusToFilter.toLowerCase()); + }); + }); + }); + + // Clear the filter + cy.get('[data-cy="clear-filter"]').click(); + + }); + + }); + }); + +}); + + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/sponsored-conversion.cy.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/sponsored-conversion.cy.js index f12032332..368ca24c1 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/sponsored-conversion.cy.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/sponsored-conversion.cy.js @@ -245,4 +245,6 @@ describe('Sponsored conversion journey', { tags: ['@dev', '@stage'] }, () => { cy.confirmContinueBtn().click(); } }); -}) + + +}); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/voluntary-conversion.cy.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/voluntary-conversion.cy.js index 5580f7ab2..42556f94b 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/voluntary-conversion.cy.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/voluntary-conversion.cy.js @@ -6,7 +6,7 @@ describe('Voluntary conversion', { tags: ['@dev', '@stage'] }, () => { // Do the spin up a project journey }) - it('TC01: Voluntary conversion journey ', () => { + it.skip('TC01: Voluntary conversion journey ', () => { // Go wild Dan! voluntaryProjectTaskList.voluntaryProjectElementsVisible() diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectList.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectList.js index 216649502..892c11b2f 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectList.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectList.js @@ -23,6 +23,22 @@ export default class projectList extends BasePage { const filterQuery = `?Title=${encodeURIComponent(titleFilter)}` cy.visit(`${Cypress.env('url')}/${this.path}${filterQuery}`) } + + static filterByRegion(region) { + this.filterProjectList({ region: region }); + } + + static filterByStatus(status) { + this.filterProjectList({ status: status }); + } + + static filterByAdvisoryBoardDate(advisoryBoardDate) { + this.filterProjectList({ advisoryBoardDate: advisoryBoardDate }); + } + + static filterByTitle(title) { + this.filterProjectList({ title: title }); + } static selectFirstItem() { this.checkProjectListPage() @@ -53,3 +69,4 @@ export default class projectList extends BasePage { return '' } } +