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..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,6 +2,7 @@ import { NewTransferProjectWithDecisions } from 'cypress/pages/newTransferProjec describe('Transfer Project Tests', () => { const transferProject = new NewTransferProjectWithDecisions(); + let projectId: string; beforeEach(() => { transferProject.visit(Cypress.env('url')); @@ -29,5 +30,18 @@ describe('Transfer Project Tests', () => { .enterDecisionDate('12', '12', '2023') .submitFormRecordDecision() .verifyDecisionDetails(); + + // Capture the projectId dynamically from the URL + cy.url().then((url) => { + 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'); + } + }); }); }); diff --git a/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts b/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts index 4591ab653..4aaa1aaec 100644 --- a/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts +++ b/end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts @@ -99,4 +99,23 @@ export class NewTransferProjectWithDecisions { cy.get('[data-cy="URN_Id"]').should('contain', expectedNumber); return this; } + + public deleteProject(projectId: string): this { + const deleteUrl = `${Cypress.env('academisationApiUrl')}/transfer-project/${projectId}/delete`; + const academisationApiKey = Cypress.env('academisationApiKey'); + + + cy.request({ + method: 'DELETE', + url: deleteUrl, + headers: { + 'x-api-key': academisationApiKey, + } + }).then((response) => { + expect(response.status).to.eq(200); // Verify the response status + }); + + return this; + } } +