From edb9a2504c950cbaace4f57842d3cf331c07a3f6 Mon Sep 17 00:00:00 2001 From: Mark Fee Date: Tue, 21 Jan 2025 17:44:35 +0000 Subject: [PATCH] FCRM-5495 added appType to the payload for requestProductFour --- config/.env-example | 2 +- config/__tests__/config.spec.js | 2 +- .../__tests__/check-your-details.spec.js | 26 +++++++++++++++++-- server/routes/check-your-details.js | 1 + 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/config/.env-example b/config/.env-example index 47d6aa03..6c6de2e2 100644 --- a/config/.env-example +++ b/config/.env-example @@ -20,7 +20,7 @@ ordnanceSurveyOsClientId=replace_this ordnanceSurveyOsClientSecret=replace_this ordnanceSurveyOsMapsKey=replace_this siteUrl=http://dummyuri -functionAppUrl==http://dummyuri +functionAppUrl=http://dummyuri ignoreUseAutomatedService=true placeApiUrl=http://dummyuri #AGOL diff --git a/config/__tests__/config.spec.js b/config/__tests__/config.spec.js index 57ec2c37..40add3ac 100644 --- a/config/__tests__/config.spec.js +++ b/config/__tests__/config.spec.js @@ -29,7 +29,7 @@ describe('Ensure config is correct', () => { osClientSecret: 'replace_this' }, siteUrl: 'http://dummyuri', - functionAppUrl: '=http://dummyuri', + functionAppUrl: 'http://dummyuri', ignoreUseAutomatedService: true, placeApi: { url: 'http://dummyuri' }, agol: { diff --git a/server/routes/__tests__/check-your-details.spec.js b/server/routes/__tests__/check-your-details.spec.js index 0782c454..d5c81c7c 100644 --- a/server/routes/__tests__/check-your-details.spec.js +++ b/server/routes/__tests__/check-your-details.spec.js @@ -5,6 +5,7 @@ const { submitPostRequest } = require('../../__test-helpers__/server') const { mockPolygons } = require('../../services/__tests__/__mocks__/floodZonesByPolygonMock') +const { getCentreOfPolygon } = require('../../services/shape-utils') jest.mock('../../services/agol/getContacts') jest.mock('../../services/address') jest.mock('@hapi/wreck') @@ -25,6 +26,7 @@ describe('Check your details page', () => { } }) }) + describe('GET', () => { const floodZoneGets = [ { polygon: mockPolygons.fz1_only, floodZone: '1' }, @@ -42,6 +44,7 @@ describe('Check your details page', () => { }) }) }) + describe('POST', () => { // Makes a first request with no cookie const postTests = [ @@ -91,10 +94,11 @@ describe('Check your details page', () => { request.state = { p4Request: p4Cookie } return h.continue }) - + const { polygon } = payload + const { x, y } = getCentreOfPolygon(polygon) const queryParams = { applicationReferenceNumber: expectedAppRef, - polygon: payload.polygon, + polygon, recipientemail: payload.recipientemail, zoneNumber: expectedZoneNumber } @@ -103,6 +107,24 @@ describe('Check your details page', () => { expect(response.headers.location).toEqual(`/confirmation?${new URLSearchParams(queryParams).toString()}`) expect(response.request.state.p4Request).toEqual(p4Cookie) expect(wreck.post).toHaveBeenCalledTimes(expectedWreckCalls) + if (expectedWreckCalls) { + const expectedPayload = JSON.stringify({ + appType: 'internal', + name: user.fullName, + recipientemail: user.email, + x, + y, + polygon: `[${polygon}]`, + zoneNumber: expectedZoneNumber, + plotSize: '0', + areaName: 'Yorkshire', + psoEmailAddress: 'neyorkshire@environment-agency.gov.uk', + llfa: 'North Yorkshire', + postcode: 'M1 1AA' + }) + + expect(wreck.post).toHaveBeenCalledWith('http://dummyuri/order-product-four', { json: true, payload: expectedPayload }) + } }) }) // Sad paths diff --git a/server/routes/check-your-details.js b/server/routes/check-your-details.js index 2b4a8748..d18384d4 100644 --- a/server/routes/check-your-details.js +++ b/server/routes/check-your-details.js @@ -53,6 +53,7 @@ module.exports = [ const plotSize = getAreaInHectares(polygon) const psoResults = await request.server.methods.getPsoContactsByPolygon(polygon) const data = JSON.stringify({ + appType: config.appType, name: fullName, recipientemail, x: coordinates.x,