From 8138acc4bcd026a73530e7246e812bbddc2c78ab Mon Sep 17 00:00:00 2001 From: FahadDarw Date: Fri, 21 Jun 2024 16:17:27 +0100 Subject: [PATCH] Cypress refactor added DAO revoke fix and deleted end point --- .../e2e/Core-journeys/decisions_tests.cy.js | 52 +++++++++---------- .../cypress/pages/decisionPage.js | 18 ++++--- 2 files changed, 37 insertions(+), 33 deletions(-) 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 bbe1c05e4..34f2feed0 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 @@ -40,35 +40,33 @@ describe('Decisions Tests', () => { Logger.log("Search for the created project then select first one on the list"); decisionPage.clickOnFirstProject(); - Logger.log("Capture the projectId dynamically from the URL"); - cy.url().then((url) => { + Logger.log("Capture the projectId dynamically from the URL"); + cy.url().then((url) => { projectId = url.match(/task-list\/(\d+)/)[1]; Logger.log(`Project ID: ${projectId}`); - }); - - Logger.log("Click on record a decision menubar button"); - decisionPage.clickRecordDecisionMenu(); - - Logger.log("Click on record a decision button"); - decisionPage.clickRecordDecision(); - - Logger.log("Record the decision with the necessary details"); - decisionPage.makeDecision("approved") - .decsionMaker("grade6") - .enterDecisionMakerName('Fahad Darwish') - .selectNoConditions() - .enterDecisionDate('12', '12', '2023') - .verifyDecisionDetails('Approved', 'Grade 6', 'Fahad Darwish', 'No', '12 December 2023'); - - Logger.log("Verify that decision was recoded 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("Delete the project and verify that it was deleted successfully"); - decisionPage.deleteProject(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("Record the decision with the necessary details"); + decisionPage.makeDecision("approved") + .decsionMaker("grade6") + .selectNoConditions() + .enterDecisionMakerName('Fahad Darwish') + .enterDecisionDate('12', '12', '2023') + .verifyDecisionDetails('Approved', 'Grade 6', 'Fahad Darwish', 'No', '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("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/pages/decisionPage.js b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/decisionPage.js index 1fff036aa..ca4cfeaa2 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/decisionPage.js +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/pages/decisionPage.js @@ -117,11 +117,12 @@ export class DecisionPage { cy.get('#submit-btn').click(); cy.get('#directorgeneral-radio').click(); cy.get('#submit-btn').click(); - //decision maker name will stay as name Fahad Darwish then click continue cy.get('#submit-btn').click(); 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 cy.get('#decision-date-day').clear(); @@ -142,19 +143,24 @@ export class DecisionPage { cy.get('#submit-btn').click(); cy.get('#submit-btn').click(); cy.get('#submit-btn').click(); + cy.get('#MinisterApproval').click(); + cy.get('#LetterSent').click(); + cy.get('#LetterSaved').click(); + cy.get('#submit-btn').click(); cy.get('#schoolclosedorclosing-checkbox').click(); cy.get('#schoolclosedorclosing-txtarea').type('Cypress Test Fahad - Reason school is closing'); cy.get('#submit-btn').click(); + cy.get('#decision-maker-name').clear(); + cy.get('#decision-maker-name').type('Fahad Darwish'); + cy.get('#submit-btn').click(); cy.get('#submit-btn').click(); - this.verifyDecisionDetailsAfterChanging('DAO', 'Director General', '12 November 2023'); + this.verifyDecisionDetailsAfterChanging('DAO', 'Minister', '12 November 2023'); return this; } deleteProject(projectId) { - const deleteUrl = `http://s184d01-acacdnendpoint-ata0dwfremepeff8.z01.azurefd.net/conversion-project/${projectId}/Delete`; - cy.request('DELETE', deleteUrl).then((response) => { - expect(response.status).to.eq(200); // Verify the response status + cy.callAcademisationApi("DELETE", `/conversion-project/${projectId}/Delete`).then((response) => { + expect(response.status).to.eq(200); }); - return this; } }