Skip to content

Commit

Permalink
FCRM-5495 added appType to the payload for requestProductFour
Browse files Browse the repository at this point in the history
  • Loading branch information
markfee committed Jan 21, 2025
1 parent 8a3dac0 commit edb9a25
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/.env-example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/__tests__/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
26 changes: 24 additions & 2 deletions server/routes/__tests__/check-your-details.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -25,6 +26,7 @@ describe('Check your details page', () => {
}
})
})

describe('GET', () => {
const floodZoneGets = [
{ polygon: mockPolygons.fz1_only, floodZone: '1' },
Expand All @@ -42,6 +44,7 @@ describe('Check your details page', () => {
})
})
})

describe('POST', () => {
// Makes a first request with no cookie
const postTests = [
Expand Down Expand Up @@ -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
}
Expand All @@ -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: '[email protected]',
llfa: 'North Yorkshire',
postcode: 'M1 1AA'
})

expect(wreck.post).toHaveBeenCalledWith('http://dummyuri/order-product-four', { json: true, payload: expectedPayload })
}
})
})
// Sad paths
Expand Down
1 change: 1 addition & 0 deletions server/routes/check-your-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit edb9a25

Please sign in to comment.