From f69052dfcede6fc5b166e0088aa29a1b44e115d5 Mon Sep 17 00:00:00 2001 From: FahadDarw Date: Wed, 12 Jun 2024 16:49:38 +0100 Subject: [PATCH 1/3] delete created project on decisions tests --- .../e2e/e2e-tests/decisions/decisions_test.cy.ts | 11 +++++++++++ .../cypress/pages/newTransferProjectWithDecisions.ts | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/end-to-end-tests/cypress/e2e/e2e-tests/decisions/decisions_test.cy.ts b/end-to-end-tests/cypress/e2e/e2e-tests/decisions/decisions_test.cy.ts index efedc4894..d0d0e7b39 100644 --- a/end-to-end-tests/cypress/e2e/e2e-tests/decisions/decisions_test.cy.ts +++ b/end-to-end-tests/cypress/e2e/e2e-tests/decisions/decisions_test.cy.ts @@ -2,6 +2,7 @@ import { NewTransferProjectWithDecisions } from 'cypress/pages/newTransferProjec describe('Transfer Project Tests', () => { const transferProject = new NewTransferProjectWithDecisions(); + let projectId: string | undefined; beforeEach(() => { transferProject.visit(Cypress.env('url')); @@ -29,5 +30,15 @@ describe('Transfer Project Tests', () => { .enterDecisionDate('12', '12', '2023') .submitFormRecordDecision() .verifyDecisionDetails(); + + // Capture the projectId dynamically from the URL + cy.url().then((url) => { + projectId = url.match(/project\/(\d+)/)?.[1]; + }); + + // Delete the project and verify that it was deleted successfully + if (projectId) { + transferProject.deleteProject(projectId); + } }); }); diff --git a/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts b/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts index 4591ab653..2074fcbe1 100644 --- a/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts +++ b/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts @@ -99,4 +99,13 @@ export class NewTransferProjectWithDecisions { cy.get('[data-cy="URN_Id"]').should('contain', expectedNumber); return this; } + + public deleteProject(projectId: string): this { + const deleteUrl = `https://dev.prepare-transfers.education.gov.uk/project/${projectId}/delete`; + cy.request('DELETE', deleteUrl).then((response) => { + expect(response.status).to.eq(200); // Verify the response status + }); + return this; + } + } From 81e97c7566828248d2f7960cc9dcf67651faba8f Mon Sep 17 00:00:00 2001 From: FahadDarw Date: Thu, 13 Jun 2024 15:56:14 +0100 Subject: [PATCH 2/3] delete created project in decisions tests --- .../e2e-tests/decisions/decisions_test.cy.ts | 19 +++++++++++-------- .../pages/newTransferProjectWithDecisions.ts | 15 ++++++++++++--- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/end-to-end-tests/cypress/e2e/e2e-tests/decisions/decisions_test.cy.ts b/end-to-end-tests/cypress/e2e/e2e-tests/decisions/decisions_test.cy.ts index d0d0e7b39..aa56abd56 100644 --- a/end-to-end-tests/cypress/e2e/e2e-tests/decisions/decisions_test.cy.ts +++ b/end-to-end-tests/cypress/e2e/e2e-tests/decisions/decisions_test.cy.ts @@ -2,7 +2,7 @@ import { NewTransferProjectWithDecisions } from 'cypress/pages/newTransferProjec describe('Transfer Project Tests', () => { const transferProject = new NewTransferProjectWithDecisions(); - let projectId: string | undefined; + let projectId: string; beforeEach(() => { transferProject.visit(Cypress.env('url')); @@ -31,14 +31,17 @@ describe('Transfer Project Tests', () => { .submitFormRecordDecision() .verifyDecisionDetails(); - // Capture the projectId dynamically from the URL + // Capture the projectId dynamically from the URL cy.url().then((url) => { - projectId = url.match(/project\/(\d+)/)?.[1]; + const match = url.match(/project\/(\d+)/); + if (match && match[1]) { + projectId = match[1]; + + // Delete the project and verify that it was deleted successfully + transferProject.deleteProject(projectId); + } else { + throw new Error('Project ID not found in the URL'); + } }); - - // Delete the project and verify that it was deleted successfully - if (projectId) { - transferProject.deleteProject(projectId); - } }); }); diff --git a/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts b/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts index 2074fcbe1..0264feb48 100644 --- a/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts +++ b/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts @@ -101,11 +101,20 @@ export class NewTransferProjectWithDecisions { } public deleteProject(projectId: string): this { - const deleteUrl = `https://dev.prepare-transfers.education.gov.uk/project/${projectId}/delete`; - cy.request('DELETE', deleteUrl).then((response) => { + const deleteUrl = `${Cypress.env('url')}/project/${projectId}/delete`; + const authToken = Cypress.env('authToken'); + + cy.request({ + method: 'DELETE', + url: deleteUrl, + headers: { + 'Authorization': `Bearer ${authToken}` + } + }).then((response) => { expect(response.status).to.eq(200); // Verify the response status }); + return this; } - } + From e1aa5ea838882d9036a64f49194502e60f555a49 Mon Sep 17 00:00:00 2001 From: FahadDarw Date: Thu, 13 Jun 2024 16:23:41 +0100 Subject: [PATCH 3/3] delete created project for Decision tests --- .../cypress/pages/newTransferProjectWithDecisions.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts b/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts index 0264feb48..4aaa1aaec 100644 --- a/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts +++ b/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts @@ -101,14 +101,15 @@ export class NewTransferProjectWithDecisions { } public deleteProject(projectId: string): this { - const deleteUrl = `${Cypress.env('url')}/project/${projectId}/delete`; - const authToken = Cypress.env('authToken'); + const deleteUrl = `${Cypress.env('academisationApiUrl')}/transfer-project/${projectId}/delete`; + const academisationApiKey = Cypress.env('academisationApiKey'); + cy.request({ method: 'DELETE', url: deleteUrl, headers: { - 'Authorization': `Bearer ${authToken}` + 'x-api-key': academisationApiKey, } }).then((response) => { expect(response.status).to.eq(200); // Verify the response status