From 054bc2660f315a387b3c748338577a29e7b0d776 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Thu, 31 Aug 2023 11:43:05 +0100 Subject: [PATCH 01/16] Added Transfers folder and payloads within it --- .../AuthorisedUserCanAssignUser.spec.js | 9 ++++++ ...horisedUserCanCreateNewMATTransfer.spec.js | 14 ++++++++ ...horisedUserCanCreateNewSATTransfer.spec.js | 12 +++++++ ...isedUserCanSetAdditionalSchoolData.spec.js | 12 +++++++ .../AuthorisedUserCanSetBenefits.spec.js | 32 +++++++++++++++++++ .../AuthorisedUserCanSetFeatures.spec.js | 10 ++++++ ...horisedUserCanSetLegalRequirements.spec.js | 9 ++++++ .../AuthorisedUserCanSetRationale.spec.js | 10 ++++++ .../AuthorisedUserCanSetTransferDates.spec.js | 7 ++++ ...serCanSetTrustInfoAndProjectsDates.spec.js | 7 ++++ 10 files changed, 122 insertions(+) create mode 100644 CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanAssignUser.spec.js create mode 100644 CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanCreateNewMATTransfer.spec.js create mode 100644 CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanCreateNewSATTransfer.spec.js create mode 100644 CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetAdditionalSchoolData.spec.js create mode 100644 CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetBenefits.spec.js create mode 100644 CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetFeatures.spec.js create mode 100644 CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetLegalRequirements.spec.js create mode 100644 CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetRationale.spec.js create mode 100644 CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetTransferDates.spec.js create mode 100644 CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetTrustInfoAndProjectsDates.spec.js diff --git a/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanAssignUser.spec.js b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanAssignUser.spec.js new file mode 100644 index 00000000..c485d1a3 --- /dev/null +++ b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanAssignUser.spec.js @@ -0,0 +1,9 @@ + +const AuthorisedUserCanAssignUserDataPayload = +{ + "urn": Cypress.env('URN'), + "userId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", + "userEmail": "userEmail@useremailval.com", + "userFullName": "userFullName value" + } +module.exports = { AuthorisedUserCanAssignUserDataPayload } \ No newline at end of file diff --git a/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanCreateNewMATTransfer.spec.js b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanCreateNewMATTransfer.spec.js new file mode 100644 index 00000000..615fe30c --- /dev/null +++ b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanCreateNewMATTransfer.spec.js @@ -0,0 +1,14 @@ + +const transferringAcademyUkprnAAndOutgoingTrustUkprn = 10066875 +const transferringAcademyUkprnB = 10066884 +const incomingTrustUkprn = 10066876 +const AuthorisedUserCanCreateNewMATTransferPayload = +{ + "transferringAcademyUkprns": [ + transferringAcademyUkprnAAndOutgoingTrustUkprn, + transferringAcademyUkprnB + ], + "outgoingTrustUkprn": transferringAcademyUkprnAAndOutgoingTrustUkprn, + "incomingTrustUkprn": incomingTrustUkprn +} +module.exports = {AuthorisedUserCanCreateNewMATTransferPayload} \ No newline at end of file diff --git a/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanCreateNewSATTransfer.spec.js b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanCreateNewSATTransfer.spec.js new file mode 100644 index 00000000..3678694b --- /dev/null +++ b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanCreateNewSATTransfer.spec.js @@ -0,0 +1,12 @@ + +const transferringAcademyUkprnAAndOutgoingTrustUkprn = 10066875 +const incomingTrustUkprn = 10066876 +const AuthorisedUserCanCreateNewSATTransferPayload = +{ + "transferringAcademyUkprns": [ + transferringAcademyUkprnAAndOutgoingTrustUkprn, + ], + "outgoingTrustUkprn": transferringAcademyUkprnAAndOutgoingTrustUkprn, + "incomingTrustUkprn": incomingTrustUkprn +} +module.exports = {AuthorisedUserCanCreateNewSATTransferPayload} \ No newline at end of file diff --git a/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetAdditionalSchoolData.spec.js b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetAdditionalSchoolData.spec.js new file mode 100644 index 00000000..0402c4cc --- /dev/null +++ b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetAdditionalSchoolData.spec.js @@ -0,0 +1,12 @@ + +const AuthorisedUserCanSetAdditionalSchoolDataPayload = +{ + "urn": Cypress.env('URN'), + "transferringAcademyUkprn": 10066875, + "latestOfstedReportAdditionalInformation": "latestOfstedReportAdditionalInformation value", + "pupilNumbersAdditionalInformation": "pupilNumbersAdditionalInformation value", + "keyStage2PerformanceAdditionalInformation": "keyStage2PerformanceAdditionalInformation value", + "keyStage4PerformanceAdditionalInformation": "KeyStage4PerformanceAdditionalInformation value", + "keyStage5PerformanceAdditionalInformation": "keyStage5PerformanceAdditionalInformation value" +} +module.exports = { AuthorisedUserCanSetAdditionalSchoolDataPayload } \ No newline at end of file diff --git a/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetBenefits.spec.js b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetBenefits.spec.js new file mode 100644 index 00000000..b6503807 --- /dev/null +++ b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetBenefits.spec.js @@ -0,0 +1,32 @@ +const AuthorisedUserCanSetBenefitsPayload = +{ + "urn": Cypress.env('URN'), + "intendedTransferBenefits": { + "selectedBenefits": [ + "selectedBenefits value" + ], + "otherBenefitValue": "otherBenefitValue value" + }, + "otherFactorsToConsider": { + "highProfile": { + "shouldBeConsidered": true, + "furtherSpecification": "highProfile furtherSpecification value" + }, + "complexLandAndBuilding": { + "shouldBeConsidered": true, + "furtherSpecification": "complexLandAndBuildingFurtherSpecification Value" + }, + "financeAndDebt": { + "shouldBeConsidered": true, + "furtherSpecification": "financeAndDebtFurtherSpecification value" + }, + "otherRisks": { + "shouldBeConsidered": true, + "furtherSpecification": "otherRisksfurtherSpecification value" + } + }, + "equalitiesImpactAssessmentConsidered": true, + "anyRisks": true, + "isCompleted": true + } +module.exports = { AuthorisedUserCanSetBenefitsPayload } \ No newline at end of file diff --git a/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetFeatures.spec.js b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetFeatures.spec.js new file mode 100644 index 00000000..6e0bc985 --- /dev/null +++ b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetFeatures.spec.js @@ -0,0 +1,10 @@ + +const AuthorisedUserCanSetFeaturesPayload = +{ + "urn": Cypress.env('URN'), + "id": 1, + "typeOfTransfer": "typeOfTransfer Value", + "whoInitiatedTheTransfer": "whoInitiatedTheTransfer Value", + "isCompleted": true + } +module.exports = { AuthorisedUserCanSetFeaturesPayload } \ No newline at end of file diff --git a/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetLegalRequirements.spec.js b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetLegalRequirements.spec.js new file mode 100644 index 00000000..94f7d26f --- /dev/null +++ b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetLegalRequirements.spec.js @@ -0,0 +1,9 @@ +const AuthorisedUserCanSetLegalRequirementsPayload = +{ + "urn": Cypress.env('URN'), + "outgoingTrustConsent": "outgoing Trust Consent Value", + "incomingTrustAgreement": "incoming Trust Consent Value", + "diocesanConsent": "diocesanConsent Value", + "isCompleted": true + } +module.exports = { AuthorisedUserCanSetLegalRequirementsPayload } \ No newline at end of file diff --git a/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetRationale.spec.js b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetRationale.spec.js new file mode 100644 index 00000000..8df9717b --- /dev/null +++ b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetRationale.spec.js @@ -0,0 +1,10 @@ + +const AuthorisedUserCanSetRationalePayload = +{ + "urn": Cypress.env('URN'), + "projectRationale": "projectRationale", + "trustSponsorRationale": "trustSponsorRationale", + "isCompleted": true + +} +module.exports = {AuthorisedUserCanSetRationalePayload} \ No newline at end of file diff --git a/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetTransferDates.spec.js b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetTransferDates.spec.js new file mode 100644 index 00000000..55f88334 --- /dev/null +++ b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetTransferDates.spec.js @@ -0,0 +1,7 @@ +const AuthorisedUserCanSetTransferDatesPayload = +{ + "urn": Cypress.env('urn'), + "htbDate": "2023-08-23T09:50:45.404Z", + "targetDateForTransfer": "2023-08-23T09:50:45.404Z" +} +module.exports = { AuthorisedUserCanSetTransferDatesPayload } \ No newline at end of file diff --git a/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetTrustInfoAndProjectsDates.spec.js b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetTrustInfoAndProjectsDates.spec.js new file mode 100644 index 00000000..ac77c695 --- /dev/null +++ b/CypressTests/cypress/support/payloads/Transfers/AuthorisedUserCanSetTrustInfoAndProjectsDates.spec.js @@ -0,0 +1,7 @@ +const AuthorisedUserCanSetTrustInfoAndProjectDatesPayload = +{ + "urn": Cypress.env('urn'), + "recommendation": "recommendationString value", + "author": "authorString value" +} +module.exports = { AuthorisedUserCanSetTrustInfoAndProjectDatesPayload } \ No newline at end of file From a5ec9551bdb835f06fb470b3e25c1b5796016d2e Mon Sep 17 00:00:00 2001 From: Dan Good Date: Thu, 31 Aug 2023 11:44:12 +0100 Subject: [PATCH 02/16] Added Transfers-MAT.cy.js Cypress specfile --- CypressTests/cypress/e2e/Transfers-MAT.cy.js | 793 +++++++++++++++++++ 1 file changed, 793 insertions(+) create mode 100644 CypressTests/cypress/e2e/Transfers-MAT.cy.js diff --git a/CypressTests/cypress/e2e/Transfers-MAT.cy.js b/CypressTests/cypress/e2e/Transfers-MAT.cy.js new file mode 100644 index 00000000..b6b958c4 --- /dev/null +++ b/CypressTests/cypress/e2e/Transfers-MAT.cy.js @@ -0,0 +1,793 @@ +/// +import { AuthorisedUserCanCreateNewMATTransferPayload } from "../support/payloads/Transfers/AuthorisedUserCanCreateNewMATTransfer.spec"; +import { AuthorisedUserCanSetRationalePayload } from "../support/payloads/Transfers/AuthorisedUserCanSetRationale.spec"; +import { AuthorisedUserCanSetTransferDatesPayload } from "../support/payloads/Transfers/AuthorisedUserCanSetTransferDates.spec"; +import { AuthorisedUserCanSetLegalRequirementsPayload } from "../support/payloads/Transfers/AuthorisedUserCanSetLegalRequirements.spec"; +import { AuthorisedUserCanSetFeaturesPayload } from "../support/payloads/Transfers/AuthorisedUserCanSetFeatures.spec"; +import { AuthorisedUserCanSetBenefitsPayload } from "../support/payloads/Transfers/AuthorisedUserCanSetBenefits.spec"; +import { AuthorisedUserCanSetAdditionalSchoolDataPayload } from "../support/payloads/Transfers/AuthorisedUserCanSetAdditionalSchoolData.spec"; +import { AuthorisedUserCanSetTrustInfoAndProjectDatesPayload } from "../support/payloads/Transfers/AuthorisedUserCanSetTrustInfoAndProjectsDates.spec"; +import { AuthorisedUserCanAssignUserDataPayload } from "../support/payloads/Transfers/AuthorisedUserCanAssignUser.spec"; + +describe('Academisation API Testing - Transfers MAT Projects', () => { + // DEV API KEY AND URL + let apiKey = '***REMOVED***' //Cypress.env('apiKey'); + let url = Cypress.config('baseUrl', '***REMOVED***')//Cypress.env('url') + let URN = Cypress.env('URN') + + // STAGING API KEY AND URL + // let apiKey = '***REMOVED***' //Cypress.env('apiKey'); + // let url = Cypress.config('baseUrl', '***REMOVED***') + + let getTransferDateTimeFormatRegex = /^\d{2}\/\d{2}\/\d{4}$/ + + // TRY TO CREATE A NEW TRANSFER AS AN UNAUTH USER AND HOPE FOR 401 UNAUTH + it('POST - Verify An UN-Authorised User CANNOT Create A New MAT Transfer - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project', + failOnStatusCode: false, + method: 'POST', + headers: + { + 'x-api-key': 'INCORRECTAPIKEY FOR 401 UNAUTH RESPONSE' + }, + body: + AuthorisedUserCanCreateNewMATTransferPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + }) + }) + + // TRY TO CREATE A NEW MAT TRANSFER AS AN AUTH USER AND HOPE WE GET A 201 CREATED RESPONSE AND EXPECTED FIELDS + it('POST - Verify An Authorised User Can Create A New MAT Transfer - 201 CREATED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project', + method: 'POST', + headers: + { + 'x-api-key': apiKey + }, + body: + AuthorisedUserCanCreateNewMATTransferPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 201) + + expect(response.body).to.have.property('projectUrn') + + URN = response.body.projectUrn + expect(response.body).to.have.property('projectReference', 'MAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + cy.log(URN) + }) + }) + + // TRY TO GET THE NEW MAT TRANSFER WE CREATED AS AN AUTH USER AND HOPE WE GET A 200 OK RESPONSE AND EXPECTED FIELDS + it('GET - Verify An Authorised User Can GET THE New MAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'MAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + cy.log(URN) + }) + }) + + // VERIFY AN UNAUTHORISED USER IS UNABLE TO GET ACCESS TO THE NEW TRANSFER PROJECT + it('GET - Verify An UNAuthorised User CANNOT GET THE New MAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + failOnStatusCode: false, + method: 'GET', + headers: + { + 'x-api-key': 'INVALID API KEY FOR 401 RESPONSE' + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + }) + }) + // VERIFY AN UNAUTHORISED USER GETS A 401 UNAUTH RESPONSE WHEN TRYING TO SET RATIONALE + it('PUT - Verify An UN-authorised User CANNOT SET-RATIONALE On New MAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-rationale/', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT API KEY - 401 UNAUTHORISED EXPECTED' + }, + body: AuthorisedUserCanSetRationalePayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + // TRY TO SET RATIONALE ON THE NEW MAT PROJECT AND HOPE WE GET A 200 OK RESPONSE + it('PUT - Verify An Authorised User Can SET-RATIONALE On New MAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-rationale/', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanSetRationalePayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // VERIFY SET-RATIONALE STUFF COMES BACK CORRECTLY IN GET RESPONSE + it('GET - Verify An Authorised User Can GET THE New MAT Transfer We Created WITH THE UPDATED RATIONALE - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'MAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + // OK LET'S CHECK OUR RATIONALE STUFF HERE + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + cy.log(URN) + }) + }) + + // TRY FOR AN UNAUTH USER TO SET TRANSFER DATES IN PUT REQUEST + it('PUT - Verify An UNAuthorised User CANNOT SET-TRANSFER DATES On New MAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-transfer-dates', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT APIKEY 401 EXPECTED' + }, + body: AuthorisedUserCanSetTransferDatesPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + + // TRY TO SET TRANSFER DATES IN PUT REQUEST + it('PUT - Verify An Authorised User Can SET-TRANSFER DATES On New MAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-transfer-dates', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanSetTransferDatesPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + it('GET - Verify An Authorised User Can GET THE New MAT Transfer We Created WITH THE UPDATED TRANSFER DATES - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'MAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + + // CHECK OUR SET TRANSFER DATES COME BACK CORRECTLY HERE + expect(response.body.dates).to.have.property('targetDateForTransfer').to.match(getTransferDateTimeFormatRegex) + expect(response.body.dates).to.have.property('htbDate').to.match(getTransferDateTimeFormatRegex) + cy.log(URN) + }) + }) + + // TRY FOR AN UNAUTH USER TO SET LEGAL REQUIREMENTS IN PUT REQUEST + it('PUT - Verify An UNAuthorised User CANNOT SET-LEGAL REQUIREMENTS On New MAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-legal-requirements', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT API KEY 401 UNAUTH EXPECTED' + }, + body: AuthorisedUserCanSetLegalRequirementsPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + + // TRY TO SET LEGAL REQUIREMENTS IN PUT REQUEST + it('PUT - Verify An Authorised User Can SET-LEGAL REQUIREMENTS On New MAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-legal-requirements', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanSetLegalRequirementsPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // CHECK UPDATED LEGAL REQUIREMENTS COME BACK CORRECTLY IN GET RESPONSE + it('GET - Verify An Authorised User Can GET THE New MAT Transfer We Created WITH THE UPDATED LEGAL REQUIREMENTS - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'MAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + + expect(response.body.dates).to.have.property('targetDateForTransfer').to.match(getTransferDateTimeFormatRegex) + expect(response.body.dates).to.have.property('htbDate').to.match(getTransferDateTimeFormatRegex) + + // CHECK LEGAL REQUIREMENTS IN GET RESPONSE + expect(response.body.legalRequirements).to.have.property('incomingTrustAgreement', 'incoming Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('diocesanConsent', 'diocesanConsent Value') + expect(response.body.legalRequirements).to.have.property('outgoingTrustConsent', 'outgoing Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('isCompleted', true) + + cy.log(URN) + }) + }) + + // TRY TO SET FEATURES IN PUT REQUEST AS AN UNAUTH USER + it('PUT - Verify An UNAuthorised User CANNOT SET-FEATURES On New MAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-features', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT API-KEY FOR 401 UNAUTH' + }, + body: AuthorisedUserCanSetFeaturesPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + + // TRY TO SET FEATURES IN PUT REQUEST + it('PUT - Verify An Authorised User Can SET-FEATURES On New MAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-features', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanSetFeaturesPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // CHECK UPDATED FEATURES COME BACK CORRECTLY IN GET RESPONSE + it('GET - Verify An Authorised User Can GET THE New MAT Transfer We Created WITH THE UPDATED FEATURES - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'MAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + + expect(response.body.dates).to.have.property('targetDateForTransfer').to.match(getTransferDateTimeFormatRegex) + expect(response.body.dates).to.have.property('htbDate').to.match(getTransferDateTimeFormatRegex) + + expect(response.body.legalRequirements).to.have.property('incomingTrustAgreement', 'incoming Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('diocesanConsent', 'diocesanConsent Value') + expect(response.body.legalRequirements).to.have.property('outgoingTrustConsent', 'outgoing Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('isCompleted', true) + + // NOW TO CHECK FEATURES COME BACK CORRECTLY IN THE GET RESPONSE + expect(response.body.features).to.have.property('whoInitiatedTheTransfer', 'whoInitiatedTheTransfer Value') + expect(response.body.features).to.have.property('typeOfTransfer', 'typeOfTransfer Value') + expect(response.body.features).to.have.property('isCompleted', true) + + cy.log(URN) + }) + }) + + // AN UNAUTH USER CANNOT SET BENEFITS IN PUT REQUEST + it('PUT - Verify An UNAuthorised User CANNOT SET-BENEFITS On New MAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-benefits', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT APIKEY FOR UNAUTH' + }, + body: AuthorisedUserCanSetBenefitsPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + + // TRY TO SET BENEFITS IN PUT REQUEST + it('PUT - Verify An Authorised User Can SET-BENEFITS On New MAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-benefits', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanSetBenefitsPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // CHECK SET BENEFITS IN GET RESPONSE... + it('GET - Verify An Authorised User Can GET THE New MAT Transfer We Created WITH THE UPDATED BENEFITS - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'MAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + + expect(response.body.dates).to.have.property('targetDateForTransfer').to.match(getTransferDateTimeFormatRegex) + expect(response.body.dates).to.have.property('htbDate').to.match(getTransferDateTimeFormatRegex) + + expect(response.body.legalRequirements).to.have.property('incomingTrustAgreement', 'incoming Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('diocesanConsent', 'diocesanConsent Value') + expect(response.body.legalRequirements).to.have.property('outgoingTrustConsent', 'outgoing Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('isCompleted', true) + + expect(response.body.features).to.have.property('whoInitiatedTheTransfer', 'whoInitiatedTheTransfer Value') + expect(response.body.features).to.have.property('typeOfTransfer', 'typeOfTransfer Value') + expect(response.body.features).to.have.property('isCompleted', true) + + // CHECK OUR SETBENEFITS STUFF IS COMING BACK OK IN RESPONSE BELOW + expect(response.body.benefits.intendedTransferBenefits.selectedBenefits[0]).to.equal("selectedBenefits value"); + expect(response.body.benefits.intendedTransferBenefits.otherBenefitValue).to.equal("otherBenefitValue value"); + expect(response.body.benefits.otherFactorsToConsider.highProfile.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.highProfile.furtherSpecification).to.equal("highProfile furtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.furtherSpecification).to.equal("complexLandAndBuildingFurtherSpecification Value"); + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.furtherSpecification).to.equal("financeAndDebtFurtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.otherRisks.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.otherRisks.furtherSpecification).to.equal("otherRisksfurtherSpecification value"); + expect(response.body.benefits.equalitiesImpactAssessmentConsidered).to.be.true; + expect(response.body.benefits.isCompleted).to.be.true; + expect(response.body.benefits.anyRisks).to.be.true; + + cy.log(URN) + }) + }) + + // AN UNAUTHORISED USER TRIES TO SET ADDITIONAL SCHOOL DATA IN PUT REQUEST + it('PUT - Verify An UNAuthorised User CANNOT SET-SCHOOL-ADDITIONAL-DATA On New MAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-school-additional-data', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT APIKEY - 401 UNAUTH EXPECTED' + }, + body: AuthorisedUserCanSetAdditionalSchoolDataPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + + // TRY TO SET ADDITIONAL SCHOOL DATA IN PUT REQUEST + it('PUT - Verify An Authorised User Can SET-SCHOOL-ADDITIONAL-DATA On New MAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-school-additional-data', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanSetAdditionalSchoolDataPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // CHECK SET SCHOOL ADDITIONAL DATA IN GET RESPONSE... + it('GET - Verify An Authorised User Can GET THE New MAT Transfer We Created WITH THE UPDATED SCHOOL ADDITIONAL DATA - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'MAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + + expect(response.body.dates).to.have.property('targetDateForTransfer').to.match(getTransferDateTimeFormatRegex) + expect(response.body.dates).to.have.property('htbDate').to.match(getTransferDateTimeFormatRegex) + + expect(response.body.legalRequirements).to.have.property('incomingTrustAgreement', 'incoming Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('diocesanConsent', 'diocesanConsent Value') + expect(response.body.legalRequirements).to.have.property('outgoingTrustConsent', 'outgoing Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('isCompleted', true) + + expect(response.body.features).to.have.property('whoInitiatedTheTransfer', 'whoInitiatedTheTransfer Value') + expect(response.body.features).to.have.property('typeOfTransfer', 'typeOfTransfer Value') + expect(response.body.features).to.have.property('isCompleted', true) + + expect(response.body.benefits.intendedTransferBenefits.selectedBenefits[0]).to.equal("selectedBenefits value"); + expect(response.body.benefits.intendedTransferBenefits.otherBenefitValue).to.equal("otherBenefitValue value"); + expect(response.body.benefits.otherFactorsToConsider.highProfile.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.highProfile.furtherSpecification).to.equal("highProfile furtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.furtherSpecification).to.equal("complexLandAndBuildingFurtherSpecification Value"); + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.furtherSpecification).to.equal("financeAndDebtFurtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.otherRisks.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.otherRisks.furtherSpecification).to.equal("otherRisksfurtherSpecification value"); + expect(response.body.benefits.equalitiesImpactAssessmentConsidered).to.be.true; + expect(response.body.benefits.isCompleted).to.be.true; + expect(response.body.benefits.anyRisks).to.be.true; + + // CHECK SCHOOL ADDITIONAL DETAILS RETURNING CORRECTLY IN RESPONSE + expect(response.body.transferringAcademies[0].pupilNumbersAdditionalInformation).to.equal("pupilNumbersAdditionalInformation value"); + expect(response.body.transferringAcademies[0].latestOfstedReportAdditionalInformation).to.equal("latestOfstedReportAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage2PerformanceAdditionalInformation).to.equal("keyStage2PerformanceAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage4PerformanceAdditionalInformation).to.equal("KeyStage4PerformanceAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage5PerformanceAdditionalInformation).to.equal("keyStage5PerformanceAdditionalInformation value"); + cy.log(URN) + }) + + +}) + + // AN UNAUTH USER TRIES TO SET TRUST INFO AND PROJECT DATES + // TRY TO SET TRUST INFO AND PROJECT DATES + it('PUT - Verify An Authorised User Can SET-SCHOOL-TRUST-INFORMATION-AND-PROJECT-DATES On New MAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-trust-information-and-project-dates', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT APIKEY FOR 401 RESPONSE' + }, + body: AuthorisedUserCanSetTrustInfoAndProjectDatesPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + // TRY TO SET TRUST INFO AND PROJECT DATES + it('PUT - Verify An Authorised User Can SET-SCHOOL-TRUST-INFORMATION-AND-PROJECT-DATES On New MAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-trust-information-and-project-dates', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanSetTrustInfoAndProjectDatesPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // CHECK SET TRUST INFO IN GET RESPONSE... + it('GET - Verify An Authorised User Can GET THE New MAT Transfer We Created WITH THE UPDATED SCHOOL ADDITIONAL DATA - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'MAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + + expect(response.body.dates).to.have.property('targetDateForTransfer').to.match(getTransferDateTimeFormatRegex) + expect(response.body.dates).to.have.property('htbDate').to.match(getTransferDateTimeFormatRegex) + + expect(response.body.legalRequirements).to.have.property('incomingTrustAgreement', 'incoming Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('diocesanConsent', 'diocesanConsent Value') + expect(response.body.legalRequirements).to.have.property('outgoingTrustConsent', 'outgoing Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('isCompleted', true) + + expect(response.body.features).to.have.property('whoInitiatedTheTransfer', 'whoInitiatedTheTransfer Value') + expect(response.body.features).to.have.property('typeOfTransfer', 'typeOfTransfer Value') + expect(response.body.features).to.have.property('isCompleted', true) + + expect(response.body.benefits.intendedTransferBenefits.selectedBenefits[0]).to.equal("selectedBenefits value"); + expect(response.body.benefits.intendedTransferBenefits.otherBenefitValue).to.equal("otherBenefitValue value"); + expect(response.body.benefits.otherFactorsToConsider.highProfile.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.highProfile.furtherSpecification).to.equal("highProfile furtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.furtherSpecification).to.equal("complexLandAndBuildingFurtherSpecification Value"); + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.furtherSpecification).to.equal("financeAndDebtFurtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.otherRisks.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.otherRisks.furtherSpecification).to.equal("otherRisksfurtherSpecification value"); + expect(response.body.benefits.equalitiesImpactAssessmentConsidered).to.be.true; + expect(response.body.benefits.isCompleted).to.be.true; + expect(response.body.benefits.anyRisks).to.be.true; + + expect(response.body.transferringAcademies[0].pupilNumbersAdditionalInformation).to.equal("pupilNumbersAdditionalInformation value"); + expect(response.body.transferringAcademies[0].latestOfstedReportAdditionalInformation).to.equal("latestOfstedReportAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage2PerformanceAdditionalInformation).to.equal("keyStage2PerformanceAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage4PerformanceAdditionalInformation).to.equal("KeyStage4PerformanceAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage5PerformanceAdditionalInformation).to.equal("keyStage5PerformanceAdditionalInformation value"); + + + // CHECKING THE NEW SET TRUST RETURNS HERE + expect(response.body.generalInformation).to.have.property('recommendation', 'recommendationString value') + expect(response.body.generalInformation).to.have.property('author', 'authorString value') + cy.log(URN) + }) + }) + + // UNAUTH USER TRIES TO ASSIGN A USER TO A PROJECT + it('PUT - Verify An UNAuthorised User CANNOT ASSIGN-USER to project On New MAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/assign-user', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT APIKEY - LOOKING FOR 401' + }, + body: AuthorisedUserCanAssignUserDataPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + + // TRY TO ASSIGN A USER TO A PROJECT + it('PUT - Verify An Authorised User Can ASSIGN-USER to project On New MAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/assign-user', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanAssignUserDataPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // CHECK SET ASSIGN USER DETAILS COME BACK IN GET RESPONSE... + it('GET - Verify An Authorised User Can GET THE New MAT Transfer We Created WITH THE USER ASSIGNED TO THE PROJECT - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'MAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + + expect(response.body.dates).to.have.property('targetDateForTransfer').to.match(getTransferDateTimeFormatRegex) + expect(response.body.dates).to.have.property('htbDate').to.match(getTransferDateTimeFormatRegex) + + expect(response.body.legalRequirements).to.have.property('incomingTrustAgreement', 'incoming Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('diocesanConsent', 'diocesanConsent Value') + expect(response.body.legalRequirements).to.have.property('outgoingTrustConsent', 'outgoing Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('isCompleted', true) + + expect(response.body.features).to.have.property('whoInitiatedTheTransfer', 'whoInitiatedTheTransfer Value') + expect(response.body.features).to.have.property('typeOfTransfer', 'typeOfTransfer Value') + expect(response.body.features).to.have.property('isCompleted', true) + + expect(response.body.benefits.intendedTransferBenefits.selectedBenefits[0]).to.equal("selectedBenefits value"); + expect(response.body.benefits.intendedTransferBenefits.otherBenefitValue).to.equal("otherBenefitValue value"); + expect(response.body.benefits.otherFactorsToConsider.highProfile.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.highProfile.furtherSpecification).to.equal("highProfile furtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.furtherSpecification).to.equal("complexLandAndBuildingFurtherSpecification Value"); + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.furtherSpecification).to.equal("financeAndDebtFurtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.otherRisks.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.otherRisks.furtherSpecification).to.equal("otherRisksfurtherSpecification value"); + expect(response.body.benefits.equalitiesImpactAssessmentConsidered).to.be.true; + expect(response.body.benefits.isCompleted).to.be.true; + expect(response.body.benefits.anyRisks).to.be.true; + + expect(response.body.transferringAcademies[0].pupilNumbersAdditionalInformation).to.equal("pupilNumbersAdditionalInformation value"); + expect(response.body.transferringAcademies[0].latestOfstedReportAdditionalInformation).to.equal("latestOfstedReportAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage2PerformanceAdditionalInformation).to.equal("keyStage2PerformanceAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage4PerformanceAdditionalInformation).to.equal("KeyStage4PerformanceAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage5PerformanceAdditionalInformation).to.equal("keyStage5PerformanceAdditionalInformation value"); + + expect(response.body.generalInformation).to.have.property('recommendation', 'recommendationString value') + expect(response.body.generalInformation).to.have.property('author', 'authorString value') + + // CHECK ASSIGNED USER WE SET COMES BACK IN GET RESPONSE + expect(response.body.assignedUser).to.have.property('fullName', 'userFullName value') + expect(response.body.assignedUser).to.have.property('emailAddress', 'userEmail@useremailval.com') + expect(response.body.assignedUser).to.have.property('id', '3fa85f64-5717-4562-b3fc-2c963f66afa6') + + cy.log(URN) + }) + }) + + +}) \ No newline at end of file From bca0b460421b635c7ddc484380143abe6ed56740 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Thu, 31 Aug 2023 11:46:30 +0100 Subject: [PATCH 03/16] Set apiKey, url, and URN to CI env vars --- CypressTests/cypress/e2e/Transfers-MAT.cy.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/CypressTests/cypress/e2e/Transfers-MAT.cy.js b/CypressTests/cypress/e2e/Transfers-MAT.cy.js index b6b958c4..5c87b98e 100644 --- a/CypressTests/cypress/e2e/Transfers-MAT.cy.js +++ b/CypressTests/cypress/e2e/Transfers-MAT.cy.js @@ -11,14 +11,10 @@ import { AuthorisedUserCanAssignUserDataPayload } from "../support/payloads/Tran describe('Academisation API Testing - Transfers MAT Projects', () => { // DEV API KEY AND URL - let apiKey = '***REMOVED***' //Cypress.env('apiKey'); - let url = Cypress.config('baseUrl', '***REMOVED***')//Cypress.env('url') + let apiKey = Cypress.env('apiKey') + let url = Cypress.env('url') let URN = Cypress.env('URN') - // STAGING API KEY AND URL - // let apiKey = '***REMOVED***' //Cypress.env('apiKey'); - // let url = Cypress.config('baseUrl', '***REMOVED***') - let getTransferDateTimeFormatRegex = /^\d{2}\/\d{2}\/\d{4}$/ // TRY TO CREATE A NEW TRANSFER AS AN UNAUTH USER AND HOPE FOR 401 UNAUTH From 801ef0d71b70b2c9e0c621ff5b202b5d5afb152e Mon Sep 17 00:00:00 2001 From: Dan Good Date: Thu, 31 Aug 2023 11:48:46 +0100 Subject: [PATCH 04/16] Added Transfers-SAT.cy.js Cypress specfile and set apiKey, url, and URN vars to CI env vars --- CypressTests/cypress/e2e/Transfers-SAT.cy.js | 790 +++++++++++++++++++ 1 file changed, 790 insertions(+) create mode 100644 CypressTests/cypress/e2e/Transfers-SAT.cy.js diff --git a/CypressTests/cypress/e2e/Transfers-SAT.cy.js b/CypressTests/cypress/e2e/Transfers-SAT.cy.js new file mode 100644 index 00000000..f1744449 --- /dev/null +++ b/CypressTests/cypress/e2e/Transfers-SAT.cy.js @@ -0,0 +1,790 @@ +/// +import { AuthorisedUserCanCreateNewSATTransferPayload } from "../support/payloads/Transfers/AuthorisedUserCanCreateNewSATTransfer.spec"; +import { AuthorisedUserCanSetRationalePayload } from "../support/payloads/Transfers/AuthorisedUserCanSetRationale.spec"; +import { AuthorisedUserCanSetTransferDatesPayload } from "../support/payloads/Transfers/AuthorisedUserCanSetTransferDates.spec"; +import { AuthorisedUserCanSetLegalRequirementsPayload } from "../support/payloads/Transfers/AuthorisedUserCanSetLegalRequirements.spec"; +import { AuthorisedUserCanSetFeaturesPayload } from "../support/payloads/Transfers/AuthorisedUserCanSetFeatures.spec"; +import { AuthorisedUserCanSetBenefitsPayload } from "../support/payloads/Transfers/AuthorisedUserCanSetBenefits.spec"; +import { AuthorisedUserCanSetAdditionalSchoolDataPayload } from "../support/payloads/Transfers/AuthorisedUserCanSetAdditionalSchoolData.spec"; +import { AuthorisedUserCanSetTrustInfoAndProjectDatesPayload } from "../support/payloads/Transfers/AuthorisedUserCanSetTrustInfoAndProjectsDates.spec"; +import { AuthorisedUserCanAssignUserDataPayload } from "../support/payloads/Transfers/AuthorisedUserCanAssignUser.spec"; + +describe('Academisation API Testing - Transfers SAT Projects', () => { + // DEV API KEY AND URL + let apiKey = Cypress.env('apiKey'); + let url = Cypress.env('url') + let URN = Cypress.env('URN') + + // STAGING API KEY AND URL + // let apiKey = 'XowatEEOGXqLKnsgmhIlfOfcybDLepJT' //Cypress.env('apiKey'); + // let url = Cypress.config('baseUrl', 'https://s184t01-acacdnendpoint-fhgrc9hybfffezck.z01.azurefd.net') + + let getTransferDateTimeFormatRegex = /^\d{2}\/\d{2}\/\d{4}$/ + + // TRY TO CREATE A NEW TRANSFER AS AN UNAUTH USER AND HOPE FOR 401 UNAUTH + it('POST - Verify An UN-Authorised User CANNOT Create A New SAT Transfer - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project', + failOnStatusCode: false, + method: 'POST', + headers: + { + 'x-api-key': 'INCORRECTAPIKEY FOR 401 UNAUTH RESPONSE' + }, + body: + AuthorisedUserCanCreateNewSATTransferPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + }) + }) + + // TRY TO CREATE A NEW SAT TRANSFER AS AN AUTH USER AND HOPE WE GET A 201 CREATED RESPONSE AND EXPECTED FIELDS + it('POST - Verify An Authorised User Can Create A New SAT Transfer - 201 CREATED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project', + method: 'POST', + headers: + { + 'x-api-key': apiKey + }, + body: + AuthorisedUserCanCreateNewSATTransferPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 201) + + expect(response.body).to.have.property('projectUrn') + + URN = response.body.projectUrn + expect(response.body).to.have.property('projectReference', 'SAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + + cy.log(URN) + }) + }) + + // TRY TO GET THE NEW SAT TRANSFER WE CREATED AS AN AUTH USER AND HOPE WE GET A 200 OK RESPONSE AND EXPECTED FIELDS + it('GET - Verify An Authorised User Can GET THE New SAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'SAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + + cy.log(URN) + }) + }) + + // VERIFY AN UNAUTHORISED USER IS UNABLE TO GET ACCESS TO THE NEW TRANSFER PROJECT + it('GET - Verify An UNAuthorised User CANNOT GET THE New SAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + failOnStatusCode: false, + method: 'GET', + headers: + { + 'x-api-key': 'INVALID API KEY FOR 401 RESPONSE' + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + }) + }) + // VERIFY AN UNAUTHORISED USER GETS A 401 UNAUTH RESPONSE WHEN TRYING TO SET RATIONALE + it('PUT - Verify An UN-authorised User CANNOT SET-RATIONALE On New SAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-rationale/', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT API KEY - 401 UNAUTHORISED EXPECTED' + }, + body: AuthorisedUserCanSetRationalePayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + // TRY TO SET RATIONALE ON THE NEW SAT PROJECT AND HOPE WE GET A 200 OK RESPONSE + it('PUT - Verify An Authorised User Can SET-RATIONALE On New SAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-rationale/', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanSetRationalePayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // VERIFY SET-RATIONALE STUFF COMES BACK CORRECTLY IN GET RESPONSE + it('GET - Verify An Authorised User Can GET THE New SAT Transfer We Created WITH THE UPDATED RATIONALE - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'SAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + // OK LET'S CHECK OUR RATIONALE STUFF HERE + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + cy.log(URN) + }) + }) + + // TRY FOR AN UNAUTH USER TO SET TRANSFER DATES IN PUT REQUEST + it('PUT - Verify An UNAuthorised User CANNOT SET-TRANSFER DATES On New SAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-transfer-dates', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT APIKEY 401 EXPECTED' + }, + body: AuthorisedUserCanSetTransferDatesPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + + // TRY TO SET TRANSFER DATES IN PUT REQUEST + it('PUT - Verify An Authorised User Can SET-TRANSFER DATES On New SAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-transfer-dates', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanSetTransferDatesPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // TRY TO GET BACK TRANSFER DATES WE INPUT IN GET RESPONSE... + it('GET - Verify An Authorised User Can GET THE New SAT Transfer We Created WITH THE UPDATED TRANSFER DATES - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'SAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + + // CHECK OUR SET TRANSFER DATES COME BACK CORRECTLY HERE + expect(response.body.dates).to.have.property('targetDateForTransfer').to.match(getTransferDateTimeFormatRegex) + expect(response.body.dates).to.have.property('htbDate').to.match(getTransferDateTimeFormatRegex) + cy.log(URN) + }) + }) + + // TRY FOR AN UNAUTH USER TO SET LEGAL REQUIREMENTS IN PUT REQUEST + it('PUT - Verify An UNAuthorised User CANNOT SET-LEGAL REQUIREMENTS On New SAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-legal-requirements', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT API KEY 401 UNAUTH EXPECTED' + }, + body: AuthorisedUserCanSetLegalRequirementsPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + + // TRY TO SET LEGAL REQUIREMENTS IN PUT REQUEST + it('PUT - Verify An Authorised User Can SET-LEGAL REQUIREMENTS On New SAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-legal-requirements', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanSetLegalRequirementsPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // CHECK UPDATED LEGAL REQUIREMENTS COME BACK CORRECTLY IN GET RESPONSE + it('GET - Verify An Authorised User Can GET THE New SAT Transfer We Created WITH THE UPDATED LEGAL REQUIREMENTS - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'SAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + + expect(response.body.dates).to.have.property('targetDateForTransfer').to.match(getTransferDateTimeFormatRegex) + expect(response.body.dates).to.have.property('htbDate').to.match(getTransferDateTimeFormatRegex) + + // CHECK LEGAL REQUIREMENTS IN GET RESPONSE + expect(response.body.legalRequirements).to.have.property('incomingTrustAgreement', 'incoming Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('diocesanConsent', 'diocesanConsent Value') + expect(response.body.legalRequirements).to.have.property('outgoingTrustConsent', 'outgoing Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('isCompleted', true) + + cy.log(URN) + }) + }) + + // TRY TO SET FEATURES IN PUT REQUEST AS AN UNAUTH USER + it('PUT - Verify An UNAuthorised User CANNOT SET-FEATURES On New SAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-features', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT API-KEY FOR 401 UNAUTH' + }, + body: AuthorisedUserCanSetFeaturesPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + + // TRY TO SET FEATURES IN PUT REQUEST + it('PUT - Verify An Authorised User Can SET-FEATURES On New SAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-features', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanSetFeaturesPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // CHECK UPDATED FEATURES COME BACK CORRECTLY IN GET RESPONSE + it('GET - Verify An Authorised User Can GET THE New SAT Transfer We Created WITH THE UPDATED FEATURES - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'SAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + + expect(response.body.dates).to.have.property('targetDateForTransfer').to.match(getTransferDateTimeFormatRegex) + expect(response.body.dates).to.have.property('htbDate').to.match(getTransferDateTimeFormatRegex) + + expect(response.body.legalRequirements).to.have.property('incomingTrustAgreement', 'incoming Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('diocesanConsent', 'diocesanConsent Value') + expect(response.body.legalRequirements).to.have.property('outgoingTrustConsent', 'outgoing Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('isCompleted', true) + + // NOW TO CHECK FEATURES COME BACK CORRECTLY IN THE GET RESPONSE + expect(response.body.features).to.have.property('whoInitiatedTheTransfer', 'whoInitiatedTheTransfer Value') + expect(response.body.features).to.have.property('typeOfTransfer', 'typeOfTransfer Value') + expect(response.body.features).to.have.property('isCompleted', true) + + cy.log(URN) + }) + }) + + // AN UNAUTH USER CANNOT SET BENEFITS IN PUT REQUEST + it('PUT - Verify An UNAuthorised User CANNOT SET-BENEFITS On New SAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-benefits', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT APIKEY FOR UNAUTH' + }, + body: AuthorisedUserCanSetBenefitsPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + + // TRY TO SET BENEFITS IN PUT REQUEST + it('PUT - Verify An Authorised User Can SET-BENEFITS On New SAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-benefits', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanSetBenefitsPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // CHECK SET BENEFITS IN GET RESPONSE... + it('GET - Verify An Authorised User Can GET THE New SAT Transfer We Created WITH THE UPDATED BENEFITS - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'SAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + + expect(response.body.dates).to.have.property('targetDateForTransfer').to.match(getTransferDateTimeFormatRegex) + expect(response.body.dates).to.have.property('htbDate').to.match(getTransferDateTimeFormatRegex) + + expect(response.body.legalRequirements).to.have.property('incomingTrustAgreement', 'incoming Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('diocesanConsent', 'diocesanConsent Value') + expect(response.body.legalRequirements).to.have.property('outgoingTrustConsent', 'outgoing Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('isCompleted', true) + + expect(response.body.features).to.have.property('whoInitiatedTheTransfer', 'whoInitiatedTheTransfer Value') + expect(response.body.features).to.have.property('typeOfTransfer', 'typeOfTransfer Value') + expect(response.body.features).to.have.property('isCompleted', true) + + // CHECK OUR SETBENEFITS STUFF IS COMING BACK OK IN RESPONSE BELOW + expect(response.body.benefits.intendedTransferBenefits.selectedBenefits[0]).to.equal("selectedBenefits value"); + expect(response.body.benefits.intendedTransferBenefits.otherBenefitValue).to.equal("otherBenefitValue value"); + expect(response.body.benefits.otherFactorsToConsider.highProfile.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.highProfile.furtherSpecification).to.equal("highProfile furtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.furtherSpecification).to.equal("complexLandAndBuildingFurtherSpecification Value"); + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.furtherSpecification).to.equal("financeAndDebtFurtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.otherRisks.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.otherRisks.furtherSpecification).to.equal("otherRisksfurtherSpecification value"); + expect(response.body.benefits.equalitiesImpactAssessmentConsidered).to.be.true; + expect(response.body.benefits.isCompleted).to.be.true; + expect(response.body.benefits.anyRisks).to.be.true; + + cy.log(URN) + }) + }) + + // AN UNAUTHORISED USER TRIES TO SET ADDITIONAL SCHOOL DATA IN PUT REQUEST + it('PUT - Verify An UNAuthorised User CANNOT SET-SCHOOL-ADDITIONAL-DATA On New MAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-school-additional-data', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT APIKEY - 401 UNAUTH EXPECTED' + }, + body: AuthorisedUserCanSetAdditionalSchoolDataPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + + // TRY TO SET ADDITIONAL SCHOOL DATA IN PUT REQUEST + it('PUT - Verify An Authorised User Can SET-SCHOOL-ADDITIONAL-DATA On New SAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-school-additional-data', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanSetAdditionalSchoolDataPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // CHECK SET SCHOOL ADDITIONAL DATA IN GET RESPONSE... + it('GET - Verify An Authorised User Can GET THE New SAT Transfer We Created WITH THE UPDATED SCHOOL ADDITIONAL DATA - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'SAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + + expect(response.body.dates).to.have.property('targetDateForTransfer').to.match(getTransferDateTimeFormatRegex) + expect(response.body.dates).to.have.property('htbDate').to.match(getTransferDateTimeFormatRegex) + + expect(response.body.legalRequirements).to.have.property('incomingTrustAgreement', 'incoming Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('diocesanConsent', 'diocesanConsent Value') + expect(response.body.legalRequirements).to.have.property('outgoingTrustConsent', 'outgoing Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('isCompleted', true) + + expect(response.body.features).to.have.property('whoInitiatedTheTransfer', 'whoInitiatedTheTransfer Value') + expect(response.body.features).to.have.property('typeOfTransfer', 'typeOfTransfer Value') + expect(response.body.features).to.have.property('isCompleted', true) + + expect(response.body.benefits.intendedTransferBenefits.selectedBenefits[0]).to.equal("selectedBenefits value"); + expect(response.body.benefits.intendedTransferBenefits.otherBenefitValue).to.equal("otherBenefitValue value"); + expect(response.body.benefits.otherFactorsToConsider.highProfile.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.highProfile.furtherSpecification).to.equal("highProfile furtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.furtherSpecification).to.equal("complexLandAndBuildingFurtherSpecification Value"); + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.furtherSpecification).to.equal("financeAndDebtFurtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.otherRisks.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.otherRisks.furtherSpecification).to.equal("otherRisksfurtherSpecification value"); + expect(response.body.benefits.equalitiesImpactAssessmentConsidered).to.be.true; + expect(response.body.benefits.isCompleted).to.be.true; + expect(response.body.benefits.anyRisks).to.be.true; + + // CHECK SCHOOL ADDITIONAL DETAILS RETURNING CORRECTLY IN RESPONSE + expect(response.body.transferringAcademies[0].pupilNumbersAdditionalInformation).to.equal("pupilNumbersAdditionalInformation value"); + expect(response.body.transferringAcademies[0].latestOfstedReportAdditionalInformation).to.equal("latestOfstedReportAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage2PerformanceAdditionalInformation).to.equal("keyStage2PerformanceAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage4PerformanceAdditionalInformation).to.equal("KeyStage4PerformanceAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage5PerformanceAdditionalInformation).to.equal("keyStage5PerformanceAdditionalInformation value"); + cy.log(URN) + }) + + +}) + + // AN UNAUTH USER TRIES TO SET TRUST INFO AND PROJECT DATES + // TRY TO SET TRUST INFO AND PROJECT DATES + it('PUT - Verify An Authorised User Can SET-SCHOOL-TRUST-INFORMATION-AND-PROJECT-DATES On New SAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-trust-information-and-project-dates', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT APIKEY FOR 401 RESPONSE' + }, + body: AuthorisedUserCanSetTrustInfoAndProjectDatesPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + // TRY TO SET TRUST INFO AND PROJECT DATES + it('PUT - Verify An Authorised User Can SET-SCHOOL-TRUST-INFORMATION-AND-PROJECT-DATES On New SAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/set-trust-information-and-project-dates', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanSetTrustInfoAndProjectDatesPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // CHECK SET TRUST INFO IN GET RESPONSE... + it('GET - Verify An Authorised User Can GET THE New SAT Transfer We Created WITH THE UPDATED SCHOOL ADDITIONAL DATA - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'SAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + + expect(response.body.dates).to.have.property('targetDateForTransfer').to.match(getTransferDateTimeFormatRegex) + expect(response.body.dates).to.have.property('htbDate').to.match(getTransferDateTimeFormatRegex) + + expect(response.body.legalRequirements).to.have.property('incomingTrustAgreement', 'incoming Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('diocesanConsent', 'diocesanConsent Value') + expect(response.body.legalRequirements).to.have.property('outgoingTrustConsent', 'outgoing Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('isCompleted', true) + + expect(response.body.features).to.have.property('whoInitiatedTheTransfer', 'whoInitiatedTheTransfer Value') + expect(response.body.features).to.have.property('typeOfTransfer', 'typeOfTransfer Value') + expect(response.body.features).to.have.property('isCompleted', true) + + expect(response.body.benefits.intendedTransferBenefits.selectedBenefits[0]).to.equal("selectedBenefits value"); + expect(response.body.benefits.intendedTransferBenefits.otherBenefitValue).to.equal("otherBenefitValue value"); + expect(response.body.benefits.otherFactorsToConsider.highProfile.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.highProfile.furtherSpecification).to.equal("highProfile furtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.furtherSpecification).to.equal("complexLandAndBuildingFurtherSpecification Value"); + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.furtherSpecification).to.equal("financeAndDebtFurtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.otherRisks.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.otherRisks.furtherSpecification).to.equal("otherRisksfurtherSpecification value"); + expect(response.body.benefits.equalitiesImpactAssessmentConsidered).to.be.true; + expect(response.body.benefits.isCompleted).to.be.true; + expect(response.body.benefits.anyRisks).to.be.true; + + expect(response.body.transferringAcademies[0].pupilNumbersAdditionalInformation).to.equal("pupilNumbersAdditionalInformation value"); + expect(response.body.transferringAcademies[0].latestOfstedReportAdditionalInformation).to.equal("latestOfstedReportAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage2PerformanceAdditionalInformation).to.equal("keyStage2PerformanceAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage4PerformanceAdditionalInformation).to.equal("KeyStage4PerformanceAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage5PerformanceAdditionalInformation).to.equal("keyStage5PerformanceAdditionalInformation value"); + + + // CHECKING THE NEW SET TRUST RETURNS HERE + expect(response.body.generalInformation).to.have.property('recommendation', 'recommendationString value') + expect(response.body.generalInformation).to.have.property('author', 'authorString value') + cy.log(URN) + }) + }) + + // UNAUTH USER TRIES TO ASSIGN A USER TO A PROJECT + it('PUT - Verify An UNAuthorised User CANNOT ASSIGN-USER to project On New SAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/assign-user', + failOnStatusCode: false, + method: 'PUT', + headers: + { + 'x-api-key': 'INCORRECT APIKEY - LOOKING FOR 401' + }, + body: AuthorisedUserCanAssignUserDataPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + cy.log(URN) + }) + }) + + // TRY TO ASSIGN A USER TO A PROJECT + it('PUT - Verify An Authorised User Can ASSIGN-USER to project On New SAT Transfer We Created - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN + '/assign-user', + method: 'PUT', + headers: + { + 'x-api-key': apiKey + }, + body: AuthorisedUserCanAssignUserDataPayload + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + cy.log(URN) + }) + }) + + // CHECK SET ASSIGN USER DETAILS COME BACK IN GET RESPONSE... + it('GET - Verify An Authorised User Can GET THE New SAT Transfer We Created WITH THE USER ASSIGNED TO THE PROJECT - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/' + URN, + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + + expect(response.body).to.have.property('projectUrn') + + expect(response.body).to.have.property('projectReference', 'SAT-' + URN) + + expect(response.body.transferringAcademies[0]).to.have.property('outgoingAcademyUkprn') + expect(response.body.transferringAcademies[0]).to.have.property('incomingTrustUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('outgoingAcademyUkprn') + // expect(response.body.transferringAcademies[1]).to.have.property('incomingTrustUkprn') + + expect(response.body.rationale).to.have.property('projectRationale', 'projectRationale') + expect(response.body.rationale).to.have.property('trustSponsorRationale', 'trustSponsorRationale') + expect(response.body.rationale).to.have.property('isCompleted', true) + + expect(response.body.dates).to.have.property('targetDateForTransfer').to.match(getTransferDateTimeFormatRegex) + expect(response.body.dates).to.have.property('htbDate').to.match(getTransferDateTimeFormatRegex) + + expect(response.body.legalRequirements).to.have.property('incomingTrustAgreement', 'incoming Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('diocesanConsent', 'diocesanConsent Value') + expect(response.body.legalRequirements).to.have.property('outgoingTrustConsent', 'outgoing Trust Consent Value') + expect(response.body.legalRequirements).to.have.property('isCompleted', true) + + expect(response.body.features).to.have.property('whoInitiatedTheTransfer', 'whoInitiatedTheTransfer Value') + expect(response.body.features).to.have.property('typeOfTransfer', 'typeOfTransfer Value') + expect(response.body.features).to.have.property('isCompleted', true) + + expect(response.body.benefits.intendedTransferBenefits.selectedBenefits[0]).to.equal("selectedBenefits value"); + expect(response.body.benefits.intendedTransferBenefits.otherBenefitValue).to.equal("otherBenefitValue value"); + expect(response.body.benefits.otherFactorsToConsider.highProfile.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.highProfile.furtherSpecification).to.equal("highProfile furtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.complexLandAndBuilding.furtherSpecification).to.equal("complexLandAndBuildingFurtherSpecification Value"); + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.financeAndDebt.furtherSpecification).to.equal("financeAndDebtFurtherSpecification value"); + expect(response.body.benefits.otherFactorsToConsider.otherRisks.shouldBeConsidered).to.be.true; + expect(response.body.benefits.otherFactorsToConsider.otherRisks.furtherSpecification).to.equal("otherRisksfurtherSpecification value"); + expect(response.body.benefits.equalitiesImpactAssessmentConsidered).to.be.true; + expect(response.body.benefits.isCompleted).to.be.true; + expect(response.body.benefits.anyRisks).to.be.true; + + expect(response.body.transferringAcademies[0].pupilNumbersAdditionalInformation).to.equal("pupilNumbersAdditionalInformation value"); + expect(response.body.transferringAcademies[0].latestOfstedReportAdditionalInformation).to.equal("latestOfstedReportAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage2PerformanceAdditionalInformation).to.equal("keyStage2PerformanceAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage4PerformanceAdditionalInformation).to.equal("KeyStage4PerformanceAdditionalInformation value"); + expect(response.body.transferringAcademies[0].keyStage5PerformanceAdditionalInformation).to.equal("keyStage5PerformanceAdditionalInformation value"); + + expect(response.body.generalInformation).to.have.property('recommendation', 'recommendationString value') + expect(response.body.generalInformation).to.have.property('author', 'authorString value') + + // CHECK ASSIGNED USER WE SET COMES BACK IN GET RESPONSE + expect(response.body.assignedUser).to.have.property('fullName', 'userFullName value') + expect(response.body.assignedUser).to.have.property('emailAddress', 'userEmail@useremailval.com') + expect(response.body.assignedUser).to.have.property('id', '3fa85f64-5717-4562-b3fc-2c963f66afa6') + + cy.log(URN) + }) + }) + + +}) \ No newline at end of file From 132e1feabe808208b57b1de58b0b55979ce026f2 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Fri, 1 Sep 2023 15:04:31 +0100 Subject: [PATCH 05/16] Adding dotenv functionality so we can add a .env file for environment vars when users download this Cypress project --- CypressTests/cypress.config.js | 3 +++ CypressTests/package-lock.json | 13 +++++++++++++ CypressTests/package.json | 1 + 3 files changed, 17 insertions(+) diff --git a/CypressTests/cypress.config.js b/CypressTests/cypress.config.js index 2f0a095f..531327df 100644 --- a/CypressTests/cypress.config.js +++ b/CypressTests/cypress.config.js @@ -1,6 +1,9 @@ const { defineConfig } = require('cypress') +import * as dotenv from "dotenv"; const { generateZapReport } = require('./cypress/plugins/generateZapReport') +dotenv.config(); + module.exports = defineConfig({ video: false, e2e: { diff --git a/CypressTests/package-lock.json b/CypressTests/package-lock.json index 80885fbe..0c246702 100644 --- a/CypressTests/package-lock.json +++ b/CypressTests/package-lock.json @@ -13,6 +13,7 @@ "zaproxy": "^2.0.0-rc.2" }, "devDependencies": { + "dotenv": "^16.3.1", "eslint": "^8.38.0", "eslint-plugin-cypress": "^2.13.2" } @@ -837,6 +838,18 @@ "node": ">=6.0.0" } }, + "node_modules/dotenv": { + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" + } + }, "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", diff --git a/CypressTests/package.json b/CypressTests/package.json index 7262633a..d748be87 100644 --- a/CypressTests/package.json +++ b/CypressTests/package.json @@ -16,6 +16,7 @@ "zaproxy": "^2.0.0-rc.2" }, "devDependencies": { + "dotenv": "^16.3.1", "eslint": "^8.38.0", "eslint-plugin-cypress": "^2.13.2" } From dc69462fbdb054f4daa41d58293b1583669fb5a6 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Fri, 1 Sep 2023 15:12:15 +0100 Subject: [PATCH 06/16] Amended dotenv call to library in cypress.config.js from TypeScript to JavaScript syntac --- CypressTests/cypress.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CypressTests/cypress.config.js b/CypressTests/cypress.config.js index 531327df..66694a0e 100644 --- a/CypressTests/cypress.config.js +++ b/CypressTests/cypress.config.js @@ -1,5 +1,5 @@ const { defineConfig } = require('cypress') -import * as dotenv from "dotenv"; +const dotenv = require('dotenv') const { generateZapReport } = require('./cypress/plugins/generateZapReport') dotenv.config(); From 7d6654fcbb7716aaa2f8fca9579e73c3380cb759 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Fri, 1 Sep 2023 15:22:41 +0100 Subject: [PATCH 07/16] Updated cypress.config.js with env: {} object to make it .env friendly when project downloaded from the repo --- CypressTests/cypress.config.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CypressTests/cypress.config.js b/CypressTests/cypress.config.js index 66694a0e..86ef944f 100644 --- a/CypressTests/cypress.config.js +++ b/CypressTests/cypress.config.js @@ -5,6 +5,11 @@ const { generateZapReport } = require('./cypress/plugins/generateZapReport') dotenv.config(); module.exports = defineConfig({ + env: { + url: process.env.url, + apiKey: process.env.apiKey, + URN: process.env.URN + }, video: false, e2e: { setupNodeEvents(on, config) { From f46cd6c4ce8a419bba4b80d10e79b73c399dcff5 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Fri, 1 Sep 2023 16:35:56 +0100 Subject: [PATCH 08/16] Added negative and positive tests for GET GetTransferProjects endpoint in TransfersMAT.cy.js Cypress specfile --- CypressTests/cypress/e2e/Transfers-MAT.cy.js | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/CypressTests/cypress/e2e/Transfers-MAT.cy.js b/CypressTests/cypress/e2e/Transfers-MAT.cy.js index 5c87b98e..b0cdd762 100644 --- a/CypressTests/cypress/e2e/Transfers-MAT.cy.js +++ b/CypressTests/cypress/e2e/Transfers-MAT.cy.js @@ -17,6 +17,42 @@ describe('Academisation API Testing - Transfers MAT Projects', () => { let getTransferDateTimeFormatRegex = /^\d{2}\/\d{2}\/\d{4}$/ + // VERIFY AN UNAUTH USER CANNOT GET ALL TRANSFERPROJECTS REGARDLESS OF MAT OR SAT TYPE + it('GET - Verify An UNAuthorised User CANNOT GET ALL MAT AND SAT Transfer Projects - 401 UNAUTH EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/GetTransferProjects', + failOnStatusCode: false, + method: 'GET', + headers: + { + 'x-api-key': 'INCORRECT API-KEY LOOKING FOR 401 RESPONSE' + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 401) + }) + }) + + // GET ALL TRANSFER PROJECTS REGARDLESS OF MAT OR SAT TYPE + + it('GET - Verify An Authorised User Can GET ALL MAT AND SAT Transfer Projects - 200 OK EXPECTED', () => { + cy.request({ + url: url + '/transfer-project/GetTransferProjects', + method: 'GET', + headers: + { + 'x-api-key': apiKey + }, + }).then((response) => { + cy.log(JSON.stringify(response)) + expect(response).to.have.property('status', 200) + const totalCount = response.body.totalCount + const resultsArray = response.body.results + + expect(totalCount).to.equal(resultsArray.length) + }) + }) + // TRY TO CREATE A NEW TRANSFER AS AN UNAUTH USER AND HOPE FOR 401 UNAUTH it('POST - Verify An UN-Authorised User CANNOT Create A New MAT Transfer - 401 UNAUTHORISED EXPECTED', () => { cy.request({ From ac9d5a557f4fc3d492336fd932d67c47a196bfe1 Mon Sep 17 00:00:00 2001 From: plockwood Date: Thu, 7 Sep 2023 16:03:08 +0100 Subject: [PATCH 09/16] allow nullable values on dtos --- .../TransferProject/SetTransferProjectBenefitsCommand.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectBenefitsCommand.cs b/Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectBenefitsCommand.cs index e12d6285..e2e4e00a 100644 --- a/Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectBenefitsCommand.cs +++ b/Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectBenefitsCommand.cs @@ -16,7 +16,7 @@ public class SetTransferProjectBenefitsCommand : SetTransferProjectCommand public class IntendedTransferBenefitDto { public List SelectedBenefits { get; set; } - public string OtherBenefitValue { get; set; } + public string? OtherBenefitValue { get; set; } } public class OtherFactorsToConsiderDto @@ -29,7 +29,7 @@ public class OtherFactorsToConsiderDto public class BenefitConsideredFactorDto { - public bool ShouldBeConsidered { get; set; } - public string FurtherSpecification { get; set; } + public bool? ShouldBeConsidered { get; set; } + public string? FurtherSpecification { get; set; } } } From be2b5806a7e1d42225371cd8a4fc460ed52cedbf Mon Sep 17 00:00:00 2001 From: plockwood Date: Thu, 7 Sep 2023 16:37:36 +0100 Subject: [PATCH 10/16] rename of set trust and project dates to something more accurate --- .../TransferProjectAggregate/TransferProjectTests.cs | 2 +- .../TransferProjectAggregate/TransferProject.cs | 2 +- .../TransferProjectAggregate/ITransferProject.cs | 2 +- ...tInformationAndProjectDatesCommandHandlerTests.cs | 12 ++++++------ ...ectTrustInformationAndProjectDatesCommandTests.cs | 5 +++-- .../SetTransferProjectGeneralInformationCommand.cs | 12 ++++++++++++ ...ansferProjectGeneralInformationCommandHandler.cs} | 12 ++++++------ ...rProjectTrustInformationAndProjectDatesCommand.cs | 9 --------- .../Controllers/TransferProjectController.cs | 6 +++--- 9 files changed, 33 insertions(+), 29 deletions(-) create mode 100644 Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectGeneralInformationCommand.cs rename Dfe.Academies.Academisation.Service/Commands/TransferProject/{SetTransferProjectTrustInformationAndProjectDatesCommandHandler.cs => SetTransferProjectGeneralInformationCommandHandler.cs} (60%) delete mode 100644 Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommand.cs diff --git a/Dfe.Academies.Academisation.Domain.UnitTest/TransferProjectAggregate/TransferProjectTests.cs b/Dfe.Academies.Academisation.Domain.UnitTest/TransferProjectAggregate/TransferProjectTests.cs index 7b746187..1844e49c 100644 --- a/Dfe.Academies.Academisation.Domain.UnitTest/TransferProjectAggregate/TransferProjectTests.cs +++ b/Dfe.Academies.Academisation.Domain.UnitTest/TransferProjectAggregate/TransferProjectTests.cs @@ -140,7 +140,7 @@ public void SetTransferProjectTrustInformationAndProjectDates_WithValidParameter var author = fixture.Create(); //Act - result.SetTrustInformationAndProjectDates(recommendation, author); + result.SetGeneralInformation(recommendation, author); //Assert result.Recommendation.Should().Be(recommendation); diff --git a/Dfe.Academies.Academisation.Domain/TransferProjectAggregate/TransferProject.cs b/Dfe.Academies.Academisation.Domain/TransferProjectAggregate/TransferProject.cs index 78f337dd..e0472095 100644 --- a/Dfe.Academies.Academisation.Domain/TransferProjectAggregate/TransferProject.cs +++ b/Dfe.Academies.Academisation.Domain/TransferProjectAggregate/TransferProject.cs @@ -106,7 +106,7 @@ public void SetRationale(string projectRationale, string trustSponsorRationale, TrustSponsorRationale = trustSponsorRationale; RationaleSectionIsCompleted = isCompleted; } - public void SetTrustInformationAndProjectDates(string recommendation, string author) + public void SetGeneralInformation(string recommendation, string author) { Recommendation = recommendation; Author = author; diff --git a/Dfe.Academies.Academisation.IDomain/TransferProjectAggregate/ITransferProject.cs b/Dfe.Academies.Academisation.IDomain/TransferProjectAggregate/ITransferProject.cs index 628db5de..d3fe55cd 100644 --- a/Dfe.Academies.Academisation.IDomain/TransferProjectAggregate/ITransferProject.cs +++ b/Dfe.Academies.Academisation.IDomain/TransferProjectAggregate/ITransferProject.cs @@ -72,6 +72,6 @@ void SetBenefitsAndRisks(bool? anyRisks, bool? equalitiesImpactAssessmentConside bool? otherRisksShouldBeConsidered, string? otherRisksFurtherSpecification, bool? isCompleted); - void SetTrustInformationAndProjectDates(string recommendation, string author); + void SetGeneralInformation(string recommendation, string author); } } diff --git a/Dfe.Academies.Academisation.Service.UnitTest/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommandHandlerTests.cs b/Dfe.Academies.Academisation.Service.UnitTest/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommandHandlerTests.cs index acdc9967..99572b55 100644 --- a/Dfe.Academies.Academisation.Service.UnitTest/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommandHandlerTests.cs +++ b/Dfe.Academies.Academisation.Service.UnitTest/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommandHandlerTests.cs @@ -12,21 +12,21 @@ namespace Dfe.Academies.Academisation.Service.UnitTest.Commands.TransferProject; public class SetTransferProjectTrustInformationAndProjectDatesCommandHandlerTests { private readonly Mock _transferProjectRepositoryMock; - private readonly Mock> _loggerMock; - private readonly SetTransferProjectTrustInformationAndProjectDatesCommandHandler _handler; + private readonly Mock> _loggerMock; + private readonly SetTransferProjectGeneralInformationCommandHandler _handler; public SetTransferProjectTrustInformationAndProjectDatesCommandHandlerTests() { _transferProjectRepositoryMock = new Mock(); - _loggerMock = new Mock>(); - _handler = new SetTransferProjectTrustInformationAndProjectDatesCommandHandler(_transferProjectRepositoryMock.Object, _loggerMock.Object); + _loggerMock = new Mock>(); + _handler = new SetTransferProjectGeneralInformationCommandHandler(_transferProjectRepositoryMock.Object, _loggerMock.Object); } [Fact] public async Task Handle_TransferProjectNotFound_ReturnsNotFoundCommandResult() { // Arrange - var command = new SetTransferProjectTrustInformationAndProjectDatesCommand + var command = new SetTransferProjectGeneralInformationCommand { Urn = 1, Recommendation = "Recommendation", @@ -55,7 +55,7 @@ public async Task Handle_TransferProjectNotFound_ReturnsNotFoundCommandResult() public async Task Handle_TransferProjectFound_ReturnsCommandSuccessResult() { // Arrange - var command = new SetTransferProjectTrustInformationAndProjectDatesCommand + var command = new SetTransferProjectGeneralInformationCommand { Urn = 1, Recommendation = "Recommendation", diff --git a/Dfe.Academies.Academisation.Service.UnitTest/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommandTests.cs b/Dfe.Academies.Academisation.Service.UnitTest/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommandTests.cs index 3b1b85ad..41b55cda 100644 --- a/Dfe.Academies.Academisation.Service.UnitTest/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommandTests.cs +++ b/Dfe.Academies.Academisation.Service.UnitTest/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommandTests.cs @@ -1,4 +1,5 @@ -using Xunit; +using Dfe.Academies.Academisation.Service.Commands.TransferProject; +using Xunit; namespace Dfe.Academies.Academisation.Service.UnitTest.Commands.TransferProject; @@ -13,7 +14,7 @@ public void CommandProperties_AreSetCorrectly() var author = "Author"; // Act - var command = new SetTransferProjectTrustInformationAndProjectDatesCommand + var command = new SetTransferProjectGeneralInformationCommand { Urn = urn, Recommendation = recommendation, diff --git a/Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectGeneralInformationCommand.cs b/Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectGeneralInformationCommand.cs new file mode 100644 index 00000000..8cbc455c --- /dev/null +++ b/Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectGeneralInformationCommand.cs @@ -0,0 +1,12 @@ +using Dfe.Academies.Academisation.Core; +using MediatR; +using TramsDataApi.RequestModels.AcademyTransferProject; + +namespace Dfe.Academies.Academisation.Service.Commands.TransferProject +{ + public class SetTransferProjectGeneralInformationCommand : SetTransferProjectCommand + { + public string Recommendation { get; set; } + public string Author { get; set; } + } +} diff --git a/Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommandHandler.cs b/Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectGeneralInformationCommandHandler.cs similarity index 60% rename from Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommandHandler.cs rename to Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectGeneralInformationCommandHandler.cs index 67171181..ca935b8e 100644 --- a/Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommandHandler.cs +++ b/Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectGeneralInformationCommandHandler.cs @@ -5,19 +5,19 @@ namespace Dfe.Academies.Academisation.Service.Commands.TransferProject { - public class SetTransferProjectTrustInformationAndProjectDatesCommandHandler : IRequestHandler + public class SetTransferProjectGeneralInformationCommandHandler : IRequestHandler { private readonly ITransferProjectRepository _transferProjectRepository; - private readonly ILogger _logger; + private readonly ILogger _logger; - public SetTransferProjectTrustInformationAndProjectDatesCommandHandler(ITransferProjectRepository transferProjectRepository, - ILogger logger) + public SetTransferProjectGeneralInformationCommandHandler(ITransferProjectRepository transferProjectRepository, + ILogger logger) { _transferProjectRepository = transferProjectRepository; _logger = logger; } - public async Task Handle(SetTransferProjectTrustInformationAndProjectDatesCommand request, + public async Task Handle(SetTransferProjectGeneralInformationCommand request, CancellationToken cancellationToken) { var transferProject = await _transferProjectRepository.GetByUrn(request.Urn).ConfigureAwait(false); @@ -28,7 +28,7 @@ public async Task Handle(SetTransferProjectTrustInformationAndPro return new NotFoundCommandResult(); } - transferProject.SetTrustInformationAndProjectDates(request.Recommendation, request.Author); + transferProject.SetGeneralInformation(request.Recommendation, request.Author); _transferProjectRepository.Update(transferProject as Domain.TransferProjectAggregate.TransferProject); await _transferProjectRepository.UnitOfWork.SaveChangesAsync(cancellationToken); diff --git a/Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommand.cs b/Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommand.cs deleted file mode 100644 index ea901ab3..00000000 --- a/Dfe.Academies.Academisation.Service/Commands/TransferProject/SetTransferProjectTrustInformationAndProjectDatesCommand.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Dfe.Academies.Academisation.Core; -using MediatR; -using TramsDataApi.RequestModels.AcademyTransferProject; - -public class SetTransferProjectTrustInformationAndProjectDatesCommand : SetTransferProjectCommand -{ - public string Recommendation { get; set; } - public string Author { get; set; } -} diff --git a/Dfe.Academies.Academisation.WebApi/Controllers/TransferProjectController.cs b/Dfe.Academies.Academisation.WebApi/Controllers/TransferProjectController.cs index f9d2bcf7..36df2417 100644 --- a/Dfe.Academies.Academisation.WebApi/Controllers/TransferProjectController.cs +++ b/Dfe.Academies.Academisation.WebApi/Controllers/TransferProjectController.cs @@ -166,11 +166,11 @@ public async Task SetSchoolAdditionalData(int urn, }; } - [HttpPut("{urn}/set-trust-information-and-project-dates", Name = "SetTransferProjectTrustInformationAndProjectDates")] + [HttpPut("{urn}/set-general-information", Name = "SetTransferProjectGeneralInformation")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] - public async Task SetTransferProjectTrustInformationAndProjectDates(int urn, - [FromBody] SetTransferProjectTrustInformationAndProjectDatesCommand command, CancellationToken cancellationToken) + public async Task SetTransferProjectGeneralInformation(int urn, + [FromBody] SetTransferProjectGeneralInformationCommand command, CancellationToken cancellationToken) { _logger.LogInformation("Setting transfer project trust information and project dates"); From 42a413650a9f976da0ac9bcf661d2872a9b275e3 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Fri, 8 Sep 2023 10:56:19 +0100 Subject: [PATCH 11/16] Renamed 'set-trust-information-and-project-dates' endpoint to 'set-general-information' in positive and negative PUT requests to update trust general information for Transfers-SAT tests --- CypressTests/cypress/e2e/Transfers-SAT.cy.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CypressTests/cypress/e2e/Transfers-SAT.cy.js b/CypressTests/cypress/e2e/Transfers-SAT.cy.js index f1744449..531afd1f 100644 --- a/CypressTests/cypress/e2e/Transfers-SAT.cy.js +++ b/CypressTests/cypress/e2e/Transfers-SAT.cy.js @@ -582,9 +582,9 @@ describe('Academisation API Testing - Transfers SAT Projects', () => { // AN UNAUTH USER TRIES TO SET TRUST INFO AND PROJECT DATES // TRY TO SET TRUST INFO AND PROJECT DATES - it('PUT - Verify An Authorised User Can SET-SCHOOL-TRUST-INFORMATION-AND-PROJECT-DATES On New SAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + it('PUT - Verify An Authorised User Can SET-SCHOOL-TRUST-GENERAL-INFORMATION On New SAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { cy.request({ - url: url + '/transfer-project/' + URN + '/set-trust-information-and-project-dates', + url: url + '/transfer-project/' + URN + '/set-general-information', failOnStatusCode: false, method: 'PUT', headers: @@ -599,9 +599,9 @@ describe('Academisation API Testing - Transfers SAT Projects', () => { }) }) // TRY TO SET TRUST INFO AND PROJECT DATES - it('PUT - Verify An Authorised User Can SET-SCHOOL-TRUST-INFORMATION-AND-PROJECT-DATES On New SAT Transfer We Created - 200 OK EXPECTED', () => { + it('PUT - Verify An Authorised User Can SET-SCHOOL-TRUST-GENERAL-INFORMATION On New SAT Transfer We Created - 200 OK EXPECTED', () => { cy.request({ - url: url + '/transfer-project/' + URN + '/set-trust-information-and-project-dates', + url: url + '/transfer-project/' + URN + '/set-general-information', method: 'PUT', headers: { From ad1016271fa1cdb04966393d58d0558775b0bd21 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Fri, 8 Sep 2023 11:00:06 +0100 Subject: [PATCH 12/16] Renamed 'set-trust-information-and-project-dates' endpoint to 'set-general-information' for Transfers-MAT tests --- CypressTests/cypress/e2e/Transfers-MAT.cy.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CypressTests/cypress/e2e/Transfers-MAT.cy.js b/CypressTests/cypress/e2e/Transfers-MAT.cy.js index b0cdd762..946305c8 100644 --- a/CypressTests/cypress/e2e/Transfers-MAT.cy.js +++ b/CypressTests/cypress/e2e/Transfers-MAT.cy.js @@ -615,11 +615,11 @@ describe('Academisation API Testing - Transfers MAT Projects', () => { }) - // AN UNAUTH USER TRIES TO SET TRUST INFO AND PROJECT DATES - // TRY TO SET TRUST INFO AND PROJECT DATES - it('PUT - Verify An Authorised User Can SET-SCHOOL-TRUST-INFORMATION-AND-PROJECT-DATES On New MAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { + // AN UNAUTH USER TRIES TO SET TRUST INFO GENERAL INFO + // TRY TO SET TRUST GENERAL INFO + it('PUT - Verify An Authorised User Can SET-SCHOOL-TRUST-GENERAL-INFORMATION On New MAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { cy.request({ - url: url + '/transfer-project/' + URN + '/set-trust-information-and-project-dates', + url: url + '/transfer-project/' + URN + '/set-general-information', failOnStatusCode: false, method: 'PUT', headers: @@ -633,10 +633,10 @@ describe('Academisation API Testing - Transfers MAT Projects', () => { cy.log(URN) }) }) - // TRY TO SET TRUST INFO AND PROJECT DATES - it('PUT - Verify An Authorised User Can SET-SCHOOL-TRUST-INFORMATION-AND-PROJECT-DATES On New MAT Transfer We Created - 200 OK EXPECTED', () => { + // TRY TO SET TRUST GENERAL INFO + it('PUT - Verify An Authorised User Can SET-SCHOOL-GENERAL-INFORMATION On New MAT Transfer We Created - 200 OK EXPECTED', () => { cy.request({ - url: url + '/transfer-project/' + URN + '/set-trust-information-and-project-dates', + url: url + '/transfer-project/' + URN + '/set-general-information', method: 'PUT', headers: { From 8b8d9d89d865ad79a7a9cab46f36f4e572c45053 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Fri, 8 Sep 2023 11:01:25 +0100 Subject: [PATCH 13/16] Updated comments on pos and neg set-general-information tests so they more accurately describe the tests --- CypressTests/cypress/e2e/Transfers-SAT.cy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CypressTests/cypress/e2e/Transfers-SAT.cy.js b/CypressTests/cypress/e2e/Transfers-SAT.cy.js index 531afd1f..d38bcfec 100644 --- a/CypressTests/cypress/e2e/Transfers-SAT.cy.js +++ b/CypressTests/cypress/e2e/Transfers-SAT.cy.js @@ -580,8 +580,8 @@ describe('Academisation API Testing - Transfers SAT Projects', () => { }) - // AN UNAUTH USER TRIES TO SET TRUST INFO AND PROJECT DATES - // TRY TO SET TRUST INFO AND PROJECT DATES + // AN UNAUTH USER TRIES TO SET TRUST GENERAL INFO + // TRY TO SET TRUST GENERAL INFO it('PUT - Verify An Authorised User Can SET-SCHOOL-TRUST-GENERAL-INFORMATION On New SAT Transfer We Created - 401 UNAUTHORISED EXPECTED', () => { cy.request({ url: url + '/transfer-project/' + URN + '/set-general-information', @@ -598,7 +598,7 @@ describe('Academisation API Testing - Transfers SAT Projects', () => { cy.log(URN) }) }) - // TRY TO SET TRUST INFO AND PROJECT DATES + // TRY TO SET TRUST GENERAL INFO it('PUT - Verify An Authorised User Can SET-SCHOOL-TRUST-GENERAL-INFORMATION On New SAT Transfer We Created - 200 OK EXPECTED', () => { cy.request({ url: url + '/transfer-project/' + URN + '/set-general-information', From d731368ec1ae4923d21b50d2595458788f2931ca Mon Sep 17 00:00:00 2001 From: plockwood Date: Mon, 11 Sep 2023 14:59:53 +0100 Subject: [PATCH 14/16] Fix for trust without regions, this all needs moving to the trust service once we have one --- .../Academies/AcademiesContext.cs | 8 +++++--- Dfe.Academies.Academisation.Domain/Academies/Region.cs | 5 ++--- Dfe.Academies.Academisation.Domain/Academies/Trust.cs | 6 +++--- .../Queries/TransferProjectQueryService.cs | 6 ++++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Dfe.Academies.Academisation.Data/Academies/AcademiesContext.cs b/Dfe.Academies.Academisation.Data/Academies/AcademiesContext.cs index d9ed24e1..6c823261 100644 --- a/Dfe.Academies.Academisation.Data/Academies/AcademiesContext.cs +++ b/Dfe.Academies.Academisation.Data/Academies/AcademiesContext.cs @@ -55,10 +55,12 @@ void ConfigureTrust(EntityTypeBuilder trustConfiguration) trustConfiguration.Property(i => i.RegionId) .HasColumnName("FK_Region"); + trustConfiguration - .HasOne(x => x.Region) - .WithMany(x => x.Trusts) - .HasForeignKey(s => s.RegionId); + .HasOne(x => x.Region) + .WithOne() + .HasForeignKey(x => x.RegionId); + } void ConfigureRegion(EntityTypeBuilder regionConfiguration) diff --git a/Dfe.Academies.Academisation.Domain/Academies/Region.cs b/Dfe.Academies.Academisation.Domain/Academies/Region.cs index 21a90cc5..5a7b40bb 100644 --- a/Dfe.Academies.Academisation.Domain/Academies/Region.cs +++ b/Dfe.Academies.Academisation.Domain/Academies/Region.cs @@ -1,4 +1,4 @@ -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Dfe.Academies.Academisation.Domain.Academies; @@ -6,6 +6,5 @@ public class Region { public long Id { get; set; } public string Name { get; set; } - [JsonIgnore] - public ICollection Trusts { get; set; } + } diff --git a/Dfe.Academies.Academisation.Domain/Academies/Trust.cs b/Dfe.Academies.Academisation.Domain/Academies/Trust.cs index b7258473..5162d350 100644 --- a/Dfe.Academies.Academisation.Domain/Academies/Trust.cs +++ b/Dfe.Academies.Academisation.Domain/Academies/Trust.cs @@ -1,4 +1,4 @@ -namespace Dfe.Academies.Academisation.Domain.Academies; +namespace Dfe.Academies.Academisation.Domain.Academies; public class Trust { @@ -10,6 +10,6 @@ public class Trust public string? CompaniesHouseNumber { get; set; } public string? UKPRN { get; set; } - public virtual Region Region { get; set; } - public long RegionId { get; set; } + public virtual Region? Region { get; set; } + public long? RegionId { get; set; } } diff --git a/Dfe.Academies.Academisation.Service/Queries/TransferProjectQueryService.cs b/Dfe.Academies.Academisation.Service/Queries/TransferProjectQueryService.cs index 8b88ce7d..744ca0c2 100644 --- a/Dfe.Academies.Academisation.Service/Queries/TransferProjectQueryService.cs +++ b/Dfe.Academies.Academisation.Service/Queries/TransferProjectQueryService.cs @@ -91,12 +91,14 @@ private static IEnumerable FilterByIncomi public IEnumerable AcademyTransferProjectSummaryResponse( IEnumerable atp) { + var outgoingTrustUkprns = atp.Select(x => x.OutgoingTrustUkprn).ToList(); + var outgoingGroups = - _academiesContext.Trusts.Where(trust => atp.Select(x => x.OutgoingTrustUkprn).Any(x => x == trust.UKPRN)).ToList(); + _academiesContext.Trusts.Where(trust => outgoingTrustUkprns.Contains(trust.UKPRN)).ToList(); var transferingAcademiesUrns = atp.SelectMany(x => x.TransferringAcademies.Select(ta => ta.IncomingTrustUkprn)); - var incomingGroups = _academiesContext.Trusts.Where(trust => transferingAcademiesUrns.Any(x => x == trust.UKPRN)).ToList(); + var incomingGroups = _academiesContext.Trusts.Where(trust => transferingAcademiesUrns.Contains(trust.UKPRN)).ToList(); return atp.Select(x => { From 1fc70a186d01dbabe140d8e0214ccaedf62dc588 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Mon, 11 Sep 2023 15:57:21 +0100 Subject: [PATCH 15/16] Removed comment in Transfers-SAT --- CypressTests/cypress/e2e/Transfers-SAT.cy.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CypressTests/cypress/e2e/Transfers-SAT.cy.js b/CypressTests/cypress/e2e/Transfers-SAT.cy.js index d38bcfec..339bc987 100644 --- a/CypressTests/cypress/e2e/Transfers-SAT.cy.js +++ b/CypressTests/cypress/e2e/Transfers-SAT.cy.js @@ -15,10 +15,6 @@ describe('Academisation API Testing - Transfers SAT Projects', () => { let url = Cypress.env('url') let URN = Cypress.env('URN') - // STAGING API KEY AND URL - // let apiKey = 'XowatEEOGXqLKnsgmhIlfOfcybDLepJT' //Cypress.env('apiKey'); - // let url = Cypress.config('baseUrl', 'https://s184t01-acacdnendpoint-fhgrc9hybfffezck.z01.azurefd.net') - let getTransferDateTimeFormatRegex = /^\d{2}\/\d{2}\/\d{4}$/ // TRY TO CREATE A NEW TRANSFER AS AN UNAUTH USER AND HOPE FOR 401 UNAUTH From ec61ab9305794aa4b9b79a81b3b56fe0d26a66c6 Mon Sep 17 00:00:00 2001 From: Dan Good Date: Mon, 11 Sep 2023 15:58:18 +0100 Subject: [PATCH 16/16] Removed unnecessary comments --- CypressTests/cypress/e2e/Transfers-MAT.cy.js | 2 +- CypressTests/cypress/e2e/Transfers-SAT.cy.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CypressTests/cypress/e2e/Transfers-MAT.cy.js b/CypressTests/cypress/e2e/Transfers-MAT.cy.js index 946305c8..1ef92914 100644 --- a/CypressTests/cypress/e2e/Transfers-MAT.cy.js +++ b/CypressTests/cypress/e2e/Transfers-MAT.cy.js @@ -10,7 +10,7 @@ import { AuthorisedUserCanSetTrustInfoAndProjectDatesPayload } from "../support/ import { AuthorisedUserCanAssignUserDataPayload } from "../support/payloads/Transfers/AuthorisedUserCanAssignUser.spec"; describe('Academisation API Testing - Transfers MAT Projects', () => { - // DEV API KEY AND URL + let apiKey = Cypress.env('apiKey') let url = Cypress.env('url') let URN = Cypress.env('URN') diff --git a/CypressTests/cypress/e2e/Transfers-SAT.cy.js b/CypressTests/cypress/e2e/Transfers-SAT.cy.js index 339bc987..82188a45 100644 --- a/CypressTests/cypress/e2e/Transfers-SAT.cy.js +++ b/CypressTests/cypress/e2e/Transfers-SAT.cy.js @@ -10,7 +10,7 @@ import { AuthorisedUserCanSetTrustInfoAndProjectDatesPayload } from "../support/ import { AuthorisedUserCanAssignUserDataPayload } from "../support/payloads/Transfers/AuthorisedUserCanAssignUser.spec"; describe('Academisation API Testing - Transfers SAT Projects', () => { - // DEV API KEY AND URL + let apiKey = Cypress.env('apiKey'); let url = Cypress.env('url') let URN = Cypress.env('URN')