diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/decisions_tests.cy.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/decisions_tests.cy.js index 34f2feed0..0ae1194ab 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/decisions_tests.cy.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/e2e/Core-journeys/decisions_tests.cy.js @@ -42,29 +42,44 @@ describe('Decisions Tests', () => { Logger.log("Capture the projectId dynamically from the URL"); cy.url().then((url) => { - projectId = url.match(/task-list\/(\d+)/)[1]; + projectId = url.match(/task-list\/(\d+)/)[1]; Logger.log(`Project ID: ${projectId}`); }).then(() => { Logger.log("Click on record a decision menubar button"); decisionPage.clickRecordDecisionMenu(); - + Logger.log("Click on record a decision button"); decisionPage.clickRecordDecision(); - + + Logger.log("Check error and add necessary details to record the decision"); + decisionPage.checkErrorAndAddDetails('15', '10', '2024', 'Paul Lockwood'); + + Logger.log("Click on record a decision menubar button"); + decisionPage.clickRecordDecisionMenu(); + + Logger.log("Click on record a decision button"); + decisionPage.clickRecordDecisionWithoutError(); + Logger.log("Record the decision with the necessary details"); - decisionPage.makeDecision("approved") + decisionPage.makeDecision("deferred") .decsionMaker("grade6") - .selectNoConditions() + .selectReasonWhyDeferred() .enterDecisionMakerName('Fahad Darwish') .enterDecisionDate('12', '12', '2023') - .verifyDecisionDetails('Approved', 'Grade 6', 'Fahad Darwish', 'No', '12 December 2023'); - + .verifyDecisionDetails('Deferred', 'Grade 6', 'Fahad Darwish', '12 December 2023'); + Logger.log("Verify that decision was recorded successfully then change the decision details, verify the changes"); decisionPage.changeDecisionDetails(); - + Logger.log("Change the current decision to DAO (Directive Academy Order) revoked and verify the changes"); decisionPage.changeDecisionDAODetails(); - + + Logger.log("Change the current decision to Approved, verify the changes then check if the project is readonly"); + decisionPage.changeDecisionApproved(); + + Logger.log("Check if this project is readonly after adding a decision"); + decisionPage.clickToGoBackandCheckReadOnly(); + Logger.log("Delete the project and verify that it was deleted successfully - Project ID: " + projectId); decisionPage.deleteProject(projectId); }); 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 c8443ab53..d3015d339 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 @@ -173,6 +173,7 @@ describe('Sponsored conversion journey', { tags: ['@dev', '@stage'] }, () => { // Complete ConversionDetails.markComplete(); cy.confirmContinueBtn().click(); + projectTaskList.getConversionDetailsStatus().should('contain.text', testData.completedText); }); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/decisionPage.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/decisionPage.js index ca4cfeaa2..646248993 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/decisionPage.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/decisionPage.js @@ -1,3 +1,5 @@ +import { Logger } from "../support/logger"; + export class DecisionPage { @@ -39,10 +41,54 @@ export class DecisionPage { } clickRecordDecision() { + cy.get('[data-test="record_decision_error_btn"]').click(); + return this; + } + + clickRecordDecisionWithoutError() { cy.get('[data-cy="record_decision_btn"]').click(); return this; } + + checkErrorAndAddDetails(day, month, year, userName) { + + cy.get('#errorSummary').should('be.visible'); + cy.get('#error-summary-title').should('contain', 'There is a problem'); + cy.get('[data-cy="error-summary"]') + .find('a') + .should('have.length', 2) + .eq(0) + .should('contain', 'You must enter an advisory board date before you can record a decision.') + .and('be.visible'); + cy.get('[data-cy="error-summary"]') + .find('a') + .eq(1) + .should('contain', 'You must enter the name of the person who worked on this project before you can record a decision.') + .and('be.visible'); + cy.contains('a', 'You must enter an advisory board date before you can record a decision').click(); + cy.get('#head-teacher-board-date-day').type(day); + cy.get('#head-teacher-board-date-month').type(month); + cy.get('#head-teacher-board-date-year').type(year); + cy.get('[data-cy="select-common-submitbutton"]').click(); + + cy.get('[data-cy="record_decision_menu"] > .moj-sub-navigation__link').click(); + + + cy.get('[data-test="record_decision_error_btn"]').click(); + cy.contains('a', 'You must enter the name of the person who worked on this project before you can record a decision.').click(); + cy.get('#delivery-officer').type(userName); + cy.get('.autocomplete__option').first().click(); + cy.get('[data-cy="continue-Btn"]').click(); + + + cy.get('#notification-message').should('include.text', 'Project is assigned'); + cy.get('#main-content > :nth-child(2) > :nth-child(2)').should('include.text', userName); + + return this; + } + + makeDecision(decision) { cy.get(`#${decision}-radio`).click(); cy.get('#submit-btn').click(); @@ -67,6 +113,13 @@ export class DecisionPage { return this; } + selectReasonWhyDeferred() { + cy.get('#additionalinformationneeded-checkbox').click(); + cy.get('#additionalinformationneeded-txtarea').type('Fahads Cypress Reason is Additional Information Needed'); + cy.get('#submit-btn').click(); + return this; + } + enterDecisionDate(day, month, year) { cy.get('#decision-date-day').type(day); cy.get('#decision-date-month').type(month); @@ -83,26 +136,40 @@ export class DecisionPage { return this; } - verifyDecisionDetails(decision, grade, name, conditions, date) { - cy.get('#decision').should('contain', decision); + verifyDecisionDetails(decision, grade, name, date) { + Logger.log(`Decision: ${decision}, Name: ${name}, Date: ${date}`); + cy.log(`Decision: ${decision}, Name: ${name}, Date: ${date}`); + cy.get('#decision') + .invoke('text') + .then((text) => { + expect(text.trim()).to.contain(decision); + }); cy.get('#decision-made-by').eq(0).should('contain', grade); cy.get('#decision-maker-name').should('contain', name); - cy.get('#condition-set').should('contain', conditions); cy.get('#decision-date').should('contain', date); cy.get('#submit-btn').click(); return this; } - verifyDecisionDetailsBeforeChanging(decision, name, conditions, date) { - cy.get('#decision').should('contain', decision); + verifyDecisionDetailsBeforeChanging(decision, name, date) { + Logger.log(`Decision: ${decision}, Name: ${name}, Date: ${date}`); + cy.log(`Decision: ${decision}, Name: ${name}, Date: ${date}`); + cy.get('#decision') + .invoke('text') + .then((text) => { + expect(text.trim().toLowerCase()).to.contain(decision.toLowerCase().trim()); + }); cy.get('#decision-maker-name').should('contain', name); - cy.get('#condition-set').should('contain', conditions); cy.get('#decision-date').should('contain', date); return this; } verifyDecisionDetailsAfterChanging(decision, name, date) { - cy.get('#decision').should('contain', decision); + cy.get('#decision') + .invoke('text') + .then((text) => { + expect(text.trim().toLowerCase()).to.contain(decision.toLowerCase().trim()); + }); cy.get('#decision-made-by').should('contain', name); console.log('Date:', date); cy.get('#decision-date').should('contain', date); @@ -111,7 +178,7 @@ export class DecisionPage { changeDecisionDetails() { cy.get('[data-cy="record_decision_menu"]').click(); - this.verifyDecisionDetailsBeforeChanging('Approved', 'Fahad Darwish', 'No', '12 December 2023'); + this.verifyDecisionDetailsBeforeChanging('DEFERRED', 'Fahad Darwish', '12 December 2023'); cy.get('#record-decision-link').click(); cy.get('#declined-radio').click(); cy.get('#submit-btn').click(); @@ -121,7 +188,6 @@ export class DecisionPage { cy.get('#declined-reasons-finance').click(); cy.get('#reason-finance').type('Fahads Cypress Reason is Finance'); cy.get('#submit-btn').click(); - //decision maker name will stay as name Fahad Darwish then click continue cy.get('#submit-btn').click(); //change the date to 12th November 2023 @@ -155,6 +221,39 @@ export class DecisionPage { cy.get('#submit-btn').click(); cy.get('#submit-btn').click(); this.verifyDecisionDetailsAfterChanging('DAO', 'Minister', '12 November 2023'); + cy.get('#submit-btn').click(); + return this; + } + + + changeDecisionApproved() { + cy.get('[data-cy="record_decision_menu"]').click(); + cy.get('#record-decision-link').click(); + cy.get('#approved-radio').click(); + cy.get('#submit-btn').click(); + cy.get('#minister-radio').click(); + cy.get('#submit-btn').click(); + cy.get('#no-radio').click(); + cy.get('#submit-btn').click(); + cy.get('#decision-maker-name').clear().type('Fahad Darwish'); + cy.get('#submit-btn').click(); + cy.get('#decision-date-day').clear(); + cy.get('#decision-date-day').type('12'); + cy.get('#decision-date-month').clear(); + cy.get('#decision-date-month').type('11'); + cy.get('#decision-date-year').clear(); + cy.get('#decision-date-year').type('2023'); + cy.get('#submit-btn').click(); + this.verifyDecisionDetailsAfterChanging('Approved', 'Minister', '12 November 2023'); + cy.get('#submit-btn').click(); + cy.get('[data-cy="decision-recorded-confirmation"]') + .should('be.visible'); + cy.get('[data-cy="decision-recorded-confirmation"]').should('contain', 'Decision recorded'); + cy.get('[data-cy="approved-body"]').should('contain', 'Manchester Academy') + .and('contain', 'Approved'); + + cy.get('[data-cy="open-in-compelete-btn"]') + .should('be.visible'); return this; } deleteProject(projectId) { @@ -162,6 +261,25 @@ export class DecisionPage { expect(response.status).to.eq(200); }); } + + clickToGoBackandCheckReadOnly() { + cy.get('[data-cy="select-backlink"]').click(); + cy.get('[data-cy="record_decision_menu"]').click(); + cy.get('[data-cy="approved-message_banner"]') + .should('be.visible') + .and('contain', 'This project was approved'); + + return this; + } + + + + goBackToTaskList() { + cy.get('[data-cy="back-link"]').click(); + return this; + } + + } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js index 79edbee19..2a0638ddc 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/projectTaskList.js @@ -24,7 +24,7 @@ export default class ProjectTaskList extends BasePage { ofstedLink: 'a[href*="/school-performance-ofsted-information"]', keyStageLink: (keyStageNumber) => `a[href*="/key-stage-${keyStageNumber}-performance-tables"]`, createNewConversionButton: '[data-cy="create_new_conversion_btn"]', - recordDecisionButton: '[data-cy="record_decision_btn"]', + recordDecisionButton: '[data-cy="record_decision_error_btn"]', schoolName: '[data-cy="school-name"]', urn: '[data-cy="urn"]', urnId: '.govuk-caption-xl', diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/ProjectAssignment/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/ProjectAssignment/Index.cshtml index 009d73d84..03e5ca012 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/ProjectAssignment/Index.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Areas/Transfers/Pages/Projects/ProjectAssignment/Index.cshtml @@ -47,7 +47,7 @@