Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #751 from DFE-Digital/decisions_tests
Browse files Browse the repository at this point in the history
Decisions tests
  • Loading branch information
FahadDarw authored Jun 14, 2024
2 parents 06d7a92 + e1aa5ea commit c9af62c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -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');
}
});
});
});
19 changes: 19 additions & 0 deletions end-to-end-tests/cypress/pages/newTransferProjectWithDecisions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit c9af62c

Please sign in to comment.