Skip to content

Commit

Permalink
Add hq-team-region-or-post metadata endpoint to sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgain committed Mar 19, 2024
1 parent c60fef3 commit 9db0519
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,6 @@ describe('Adding an export win from an export project', () => {
cy.intercept('GET', '/api-proxy/v4/export-win/*', exportWin).as(
'apiGetExportWin'
)
cy.intercept('GET', '/api-proxy/v4/metadata/hq-team-region-or-post?*', [
{ name: 'DIT Education' },
{ name: 'Healthcare UK' },
])
cy.intercept('GET', `/api-proxy/v4/contact?company_id=${company.id}`, {
results: [
contactFaker({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ describe('Adding an export win', () => {
{ id: '200', name: 'Investment (ITFG or IG)' },
{ id: '201', name: 'Trade (TD or ST)' },
])
cy.intercept('GET', '/api-proxy/v4/metadata/hq-team-region-or-post?*', [
{ id: '300', name: 'DIT Education' },
{ id: '301', name: 'Healthcare UK' },
])
cy.intercept('POST', '/api-proxy/v4/export-win', {
statusCode: 201,
}).as('apiPostExportWin')
Expand Down Expand Up @@ -275,12 +271,12 @@ describe('Adding an export win', () => {
expect(omit(request.body, '_csrf')).to.deep.equal({
lead_officer: '100',
team_type: '42bdaf2e-ae19-4589-9840-5dbb67b50add',
hq_team: '300',
hq_team: 'adc1596b-7468-487f-a251-e873f1732583', // DIT Education
team_members: [],
advisers: [
{
adviser: '101',
hq_team: '301',
hq_team: '88819506-2d67-4f7e-96f8-1f9d9a849bc5', // Healthcare UK
team_type: '201',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ import { clickContinueButton } from '../../support/actions'
describe('Credit for this win', () => {
const { creditForThisWin } = formFields

beforeEach(() => {
cy.intercept('GET', '/api-proxy/v4/metadata/hq-team-region-or-post?*', [
{ name: 'DIT Education' },
{ name: 'Healthcare UK' },
])
cy.visit(creditForThisWinStep)
})
beforeEach(() => cy.visit(creditForThisWinStep))

it('should render a step heading', () => {
cy.get(creditForThisWin.heading).should('have.text', 'Credit for this win')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ import {
describe('Officer details', () => {
const { officerDetails } = formFields

beforeEach(() => {
cy.intercept('GET', '/api-proxy/v4/metadata/hq-team-region-or-post?*', [
{ name: 'DIT Education' },
{ name: 'Healthcare UK' },
])
cy.visit(officerDetailsStep)
})
beforeEach(() => cy.visit(officerDetailsStep))

it('should render an officer details heading', () => {
cy.get(officerDetails.heading).should('have.text', 'Officer details')
Expand Down
119 changes: 119 additions & 0 deletions test/sandbox/fixtures/v4/metadata/hq-team-region-or-post.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
[
{
"id": "adc1596b-7468-487f-a251-e873f1732583",
"name": "DIT Education",
"disabled_on": null,
"team_type": {
"name": "Other HQ Team",
"id": "bbb7fad4-417c-411e-a40a-11184b0c635d"
}
},
{
"id": "88819506-2d67-4f7e-96f8-1f9d9a849bc5",
"name": "Healthcare UK",
"disabled_on": null,
"team_type": {
"name": "Other HQ Team",
"id": "bbb7fad4-417c-411e-a40a-11184b0c635d"
}
},
{
"id": "de6ce5d1-cdc5-4acb-ade2-0433cf695d7f",
"name": "Offshore Wind Investment Organisation",
"disabled_on": null,
"team_type": {
"name": "Other HQ Team",
"id": "bbb7fad4-417c-411e-a40a-11184b0c635d"
}
},
{
"id": "bc0fdcb7-76f7-4dac-9319-625986afedd2",
"name": "Tech City Project",
"disabled_on": null,
"team_type": {
"name": "Other HQ Team",
"id": "bbb7fad4-417c-411e-a40a-11184b0c635d"
}
},
{
"id": "1170a853-8459-44fc-98c8-d3fa181812cd",
"name": "BG - Tech City",
"disabled_on": null,
"team_type": {
"name": "Other HQ Team",
"id": "bbb7fad4-417c-411e-a40a-11184b0c635d"
}
},
{
"id": "ca498c9e-238d-4063-a7ae-f646c5325a0f",
"name": "Financial Services Organisation (FSO)",
"disabled_on": null,
"team_type": {
"name": "Other HQ Team",
"id": "bbb7fad4-417c-411e-a40a-11184b0c635d"
}
},
{
"id": "30eaa72c-2575-47b1-9cf0-41f92a615ae4",
"name": "Export Control Unit",
"disabled_on": null,
"team_type": {
"name": "Other HQ Team",
"id": "bbb7fad4-417c-411e-a40a-11184b0c635d"
}
},
{
"id": "11a33251-11a1-4584-b763-e5337ce83075",
"name": "Life Sciences Organisation",
"disabled_on": null,
"team_type": {
"name": "Other HQ Team",
"id": "bbb7fad4-417c-411e-a40a-11184b0c635d"
}
},
{
"id": "56a62305-aa36-46ec-867f-407bcf9a23e9",
"name": "UK Export Finance",
"disabled_on": null,
"team_type": {
"name": "Other HQ Team",
"id": "bbb7fad4-417c-411e-a40a-11184b0c635d"
}
},
{
"id": "c7d92da7-e04e-45bd-abae-473be99faf29",
"name": "GREAT BRITAIN Campaign",
"disabled_on": null,
"team_type": {
"name": "Other HQ Team",
"id": "bbb7fad4-417c-411e-a40a-11184b0c635d"
}
},
{
"id": "7290b44c-bcd6-4402-a851-4a24e4f5cde7",
"name": "DBT Scotland",
"disabled_on": null,
"team_type": {
"name": "Other HQ Team",
"id": "bbb7fad4-417c-411e-a40a-11184b0c635d"
}
},
{
"id": "59f61555-e10c-4698-8291-7e8c444c4c89",
"name": "DBT Northern Ireland",
"disabled_on": null,
"team_type": {
"name": "Other HQ Team",
"id": "bbb7fad4-417c-411e-a40a-11184b0c635d"
}
},
{
"id": "90008657-99ce-476c-8711-cb7c92e5407a",
"name": "DBT Wales",
"disabled_on": null,
"team_type": {
"name": "Other HQ Team",
"id": "bbb7fad4-417c-411e-a40a-11184b0c635d"
}
}
]
5 changes: 5 additions & 0 deletions test/sandbox/routes/v4/metadata/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import withoutOurSupport from '../../../fixtures/v4/export/without-our-support.j
import supportType from '../../../fixtures/v4/metadata/support-type.json' assert { type: 'json' }
import hvc from '../../../fixtures/v4/metadata/hvc.json' assert { type: 'json' }
import associatedProgramme from '../../../fixtures/v4/metadata/associated-programme.json' assert { type: 'json' }
import hqTeamRegionOrPost from '../../../fixtures/v4/metadata/hq-team-region-or-post.json' assert { type: 'json' }

export const getLikelihoodToLand = function (req, res) {
res.json(likelihoodToLand)
Expand Down Expand Up @@ -328,3 +329,7 @@ export const getHVC = function (req, res) {
export const getAssociatedProgramme = function (req, res) {
res.json(associatedProgramme)
}

export const getHqTeamRegionOrPost = function (req, res) {
res.json(hqTeamRegionOrPost)
}
8 changes: 8 additions & 0 deletions test/sandbox/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ import {
getSupportType,
getHVC,
getAssociatedProgramme,
getHqTeamRegionOrPost,
} from './routes/v4/metadata/index.js'
import { searchCompanies as __companies } from './routes/v4/search/company.js'
import { companiesAutocomplete } from './routes/v4/search/company/autocomplete.js'
Expand Down Expand Up @@ -530,6 +531,13 @@ app.get('/v4/metadata/support-type', getSupportType)
app.get('/v4/metadata/hvc', getHVC)
app.get('/v4/metadata/associated-programme', getAssociatedProgramme)

// The endpoint 'hq-team-region-or-post' returns ~5000 lines of JSON,
// it's never called directly. It's called with the query param filter
// 'team_type' of which there are 8 team types (see /v4/metadata/team-type).
// This endpoint is hardcoded to respond with a subset of data based
// on the 'Other HQ Team' team type.
app.get('/v4/metadata/hq-team-region-or-post', getHqTeamRegionOrPost)

// Ping
app.get('/ping.xml', ping)

Expand Down

0 comments on commit 9db0519

Please sign in to comment.