Skip to content

Commit

Permalink
MAP-1878: update e2e mock
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleygyngell committed Feb 5, 2025
1 parent ce7d034 commit 2544492
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { defineConfig } from 'cypress'
import { resetStubs } from './integration_tests/mockApis/wiremock'
import auth from './integration_tests/mockApis/auth'
import tokenVerification from './integration_tests/mockApis/tokenVerification'
import prisonerSearch from './integration_tests/mockApis/prisonerSearch'
import feComponents from './integration_tests/mockApis/feComponents'
import locations from './integration_tests/mockApis/locations'
import prison from './integration_tests/mockApis/prison'
import prisonerSearch from './integration_tests/mockApis/prisonerSearch'
import tokenVerification from './integration_tests/mockApis/tokenVerification'

export default defineConfig({
chromeWebSecurity: false,
Expand All @@ -21,10 +22,11 @@ export default defineConfig({
on('task', {
reset: resetStubs,
...auth,
...tokenVerification,
...prison,
...feComponents,
...locations,
...prison,
...prisonerSearch,
...tokenVerification,
})
},
baseUrl: 'http://localhost:3007',
Expand Down
1 change: 1 addition & 0 deletions integration_tests/e2e/health.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ context('Healthcheck', () => {
cy.task('reset')
cy.task('stubAuthPing')
cy.task('stubLocationsApiPing')
cy.task('stubFeComponentsPing')
cy.task('stubPrisonApiPing')
cy.task('stubPrisonerSearchApiPing')
cy.task('stubTokenVerificationPing')
Expand Down
78 changes: 78 additions & 0 deletions integration_tests/mockApis/feComponents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import type Service from '@ministryofjustice/hmpps-connect-dps-components/dist/types/Service'
import { stubFor } from './wiremock'
import { CaseLoad } from '../../server/data/interfaces/caseLoad'

export default {
stubFeComponentsPing: () =>
stubFor({
request: {
method: 'GET',
urlPath: '/frontend-components/health/ping',
},
response: {
status: 200,
},
}),

stubFeComponents: (
options: {
caseLoads?: CaseLoad[]
services?: Service[]
residentialLocationsActive?: boolean
} = {},
) => {
const caseLoads = options.caseLoads || [
{
caseLoadId: 'LEI',
currentlyActive: true,
description: 'Leeds (HMP)',
type: '',
caseloadFunction: '',
},
]

return stubFor({
request: {
method: 'GET',
urlPattern: '/frontend-components/components\\?.*',
},
response: {
status: 200,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
jsonBody: {
header: { html: '', css: [], javascript: [] },
footer: { html: '', css: [], javascript: [] },
meta: {
caseLoads,
activeCaseLoad: caseLoads.find(caseLoad => caseLoad.currentlyActive === true),
services: options.services || [
{
id: 'check-my-diary',
heading: 'Check my diary',
description: 'View your prison staff detail (staff rota) from home.',
href: 'http://localhost:3001',
navEnabled: true,
},
{
id: 'key-worker-allocations',
heading: 'My key worker allocation',
description: 'View your key worker cases.',
href: 'http://localhost:3001/key-worker/111111',
navEnabled: true,
},
{
id: 'residential-locations',
heading: 'Residential Locations',
description: 'Manage residential locations.',
href: 'http://localhost:3001/locations',
navEnabled: options.residentialLocationsActive,
},
],
},
},
},
})
},
}

0 comments on commit 2544492

Please sign in to comment.