Skip to content

Commit

Permalink
CDPS-788: implement roll count summary endpoint for homepage. Remove …
Browse files Browse the repository at this point in the history
…unused functionality
  • Loading branch information
whitfield-mj committed Jun 27, 2024
1 parent 3f656df commit 4e892fe
Show file tree
Hide file tree
Showing 40 changed files with 96 additions and 685 deletions.
2 changes: 0 additions & 2 deletions helm_deploy/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ generic-service:
HMPPS_AUTH_URL: https://sign-in-dev.hmpps.service.justice.gov.uk/auth
HMPPS_COOKIE_DOMAIN: digital-dev.prison.service.justice.gov.uk
HMPPS_COOKIE_NAME: hmpps-session-dev
TODAY_CACHE_TTL: 10

# Maintainance mode
KEYWORKER_MAINTENANCE_MODE: false
Expand Down Expand Up @@ -86,7 +85,6 @@ generic-service:
COMPONENT_API_LATEST: true
COVID_UNITS_ENABLED: false
ACCREDITED_PROGRAMMES_ENABLED: true
ESTABLISHMENT_ROLL_EXCLUDED: ""

generic-prometheus-alerts:
alertSeverity: hmpps-digital-prison-services-non-prod
3 changes: 1 addition & 2 deletions helm_deploy/values-preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ generic-service:
HMPPS_AUTH_URL: https://sign-in-preprod.hmpps.service.justice.gov.uk/auth
HMPPS_COOKIE_DOMAIN: digital-preprod.prison.service.justice.gov.uk
HMPPS_COOKIE_NAME: hmpps-session-preprod
TODAY_CACHE_TTL: 10


# Maintainance mode
KEYWORKER_MAINTENANCE_MODE: false
Expand Down Expand Up @@ -84,7 +84,6 @@ generic-service:
COMPONENT_API_LATEST: true
COVID_UNITS_ENABLED: false
ACCREDITED_PROGRAMMES_ENABLED: true
ESTABLISHMENT_ROLL_EXCLUDED: ""

allowlist:
sscl-blackpool: 31.121.5.27/32
Expand Down
2 changes: 0 additions & 2 deletions helm_deploy/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ generic-service:
HMPPS_AUTH_URL: https://sign-in.hmpps.service.justice.gov.uk/auth
HMPPS_COOKIE_DOMAIN: digital.prison.service.justice.gov.uk
HMPPS_COOKIE_NAME: hmpps-session-preprod
TODAY_CACHE_TTL: 10

# Maintainance mode
KEYWORKER_MAINTENANCE_MODE: false
Expand Down Expand Up @@ -88,7 +87,6 @@ generic-service:
COMPONENT_API_LATEST: false
COVID_UNITS_ENABLED: false
ACCREDITED_PROGRAMMES_ENABLED: false
ESTABLISHMENT_ROLL_EXCLUDED: ""

allowlist:
sscl-blackpool: 31.121.5.27/32
Expand Down
35 changes: 17 additions & 18 deletions integration_tests/e2e/homepage.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Page from '../pages/page'
import IndexPage from '../pages'
import { Role } from '../../server/enums/role'
import { todayDataMock } from '../../server/mocks/todayDataMock'
import { prisonEstablishmentRollSummaryMock } from '../../server/mocks/prisonRollCountSummaryMock'

context('Homepage (with FE Components services)', () => {
beforeEach(() => {
Expand All @@ -12,12 +12,10 @@ context('Homepage (with FE Components services)', () => {
{ caseloadFunction: '', caseLoadId: 'LEI', currentlyActive: true, description: 'Leeds (HMP)', type: '' },
],
})
cy.task('stubRollCount')
cy.task('stubRollCountUnassigned')
cy.task('stubMovements')
cy.task('stubWhatsNewPosts')
cy.task('stubOutageBanner')
cy.task('stubFeComponents')
cy.task('stubPrisonRollCountSummary')
cy.signIn()
cy.visit('/')
})
Expand Down Expand Up @@ -75,21 +73,28 @@ context('Homepage (with FE Components services)', () => {
it('should display today data', () => {
const page = Page.verifyOnPage(IndexPage)
page.today().heading().should('be.visible').and('contain.text', 'Today in Leeds (HMP)')
page.today().lastUpdated().should('be.visible')

page.today().unlockRollCard().should('be.visible').find('h3').contains("Today's unlock roll")
page.today().unlockRollCard().find('.today-card__count').contains(todayDataMock.unlockRollCount)
page
.today()
.unlockRollCard()
.find('.today-card__count')
.contains(prisonEstablishmentRollSummaryMock.numUnlockRollToday)

page.today().populationCard().should('be.visible').find('h3').contains('Current population')
page.today().populationCard().find('.today-card__count').contains(todayDataMock.currentPopulationCount)
page
.today()
.populationCard()
.find('.today-card__count')
.contains(prisonEstablishmentRollSummaryMock.numCurrentPopulation)
page.today().populationCard().find('a').contains('Establishment roll')

page.today().inTodayCard().should('be.visible').find('h3').contains('Arrived today')
page.today().inTodayCard().find('.today-card__count').contains(todayDataMock.inTodayCount)
page.today().inTodayCard().find('.today-card__count').contains(prisonEstablishmentRollSummaryMock.numArrivedToday)
page.today().inTodayCard().find('a').contains('Arrived today')

page.today().outTodayCard().should('be.visible').find('h3').contains('Out today')
page.today().outTodayCard().find('.today-card__count').contains(todayDataMock.outTodayCount)
page.today().outTodayCard().find('.today-card__count').contains(prisonEstablishmentRollSummaryMock.numOutToday)
page.today().outTodayCard().find('a').contains('People out today')
})
})
Expand Down Expand Up @@ -125,9 +130,7 @@ context('Homepage - no global search', () => {
{ caseloadFunction: '', caseLoadId: 'LEI', currentlyActive: true, description: 'Leeds (HMP)', type: '' },
],
})
cy.task('stubRollCount')
cy.task('stubRollCountUnassigned')
cy.task('stubMovements')
cy.task('stubPrisonRollCountSummary')
cy.task('stubWhatsNewPosts')
cy.task('stubOutageBanner')

Expand Down Expand Up @@ -155,9 +158,7 @@ context('Homepage - no active caseload', () => {
{ caseloadFunction: '', caseLoadId: 'MOR', currentlyActive: false, description: 'Moorland', type: '' },
],
})
cy.task('stubRollCount', { prisonCode: 'MOR' })
cy.task('stubRollCountUnassigned', 'MOR')
cy.task('stubMovements', 'MOR')
cy.task('stubPrisonRollCountSummary', { prisonCode: 'MOR' })
cy.task('stubWhatsNewPosts')
cy.task('stubOutageBanner')
cy.task('stubSetActiveCaseload')
Expand Down Expand Up @@ -200,9 +201,7 @@ context('Homepage (without FE Components services)', () => {
{ caseloadFunction: '', caseLoadId: 'LEI', currentlyActive: true, description: 'Leeds (HMP)', type: '' },
],
})
cy.task('stubRollCount')
cy.task('stubRollCountUnassigned')
cy.task('stubMovements')
cy.task('stubPrisonRollCountSummary')
cy.task('stubWhatsNewPosts')
cy.task('stubOutageBanner')
cy.signIn()
Expand Down
16 changes: 1 addition & 15 deletions integration_tests/e2e/login.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ context('SignIn', () => {
cy.task('reset')
cy.task('stubUserCaseLoads')
cy.task('stubUserLocations')
cy.task('stubRollCount')
cy.task('stubRollCountUnassigned')
cy.task('stubMovements')
cy.task('stubWhatsNewPosts')
cy.task('stubOutageBanner')
cy.task('stubPrisonRollCountSummary')
cy.task('changeCaseload')
cy.setupUserAuth()
})
Expand Down Expand Up @@ -62,16 +60,4 @@ context('SignIn', () => {

indexPage.headerUserName().contains('B. Brown')
})

it('Page shown ok when roles are not found', () => {
cy.task('stubGetStaffRoles', 403)
cy.signIn()
Page.verifyOnPage(IndexPage)
})

it('Page shown ok when roles call is unauthorised', () => {
cy.task('stubGetStaffRoles', 404)
cy.signIn()
Page.verifyOnPage(IndexPage)
})
})
93 changes: 6 additions & 87 deletions integration_tests/mockApis/prison.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { stubFor } from './wiremock'
import { CaseLoad } from '../../server/data/interfaces/caseLoad'
import { Location } from '../../server/data/interfaces/location'
import { locationMock, locationsMock } from '../../server/mocks/locationMock'
import { assignedRollCountMock, unassignedRollCountMock } from '../../server/mocks/rollCountMock'
import { movementsMock } from '../../server/mocks/movementsMock'
import { mockStaffRoles } from '../../server/mocks/staffRolesMock'
import { movementsInMock } from '../../server/test/mocks/movementsInMock'
import { movementsOutMock } from '../../server/test/mocks/movementsOutMock'
import { movementsEnRouteMock } from '../../server/test/mocks/movementsEnRouteMock'
Expand All @@ -15,6 +13,7 @@ import { userDetailsMock } from '../../server/test/mocks/userDetailsMock'
import { pagedListMock } from '../../server/test/mocks/pagedListMock'
import { prisonRollCountMock } from '../../server/mocks/prisonRollCountMock'
import { prisonRollCountForWingWithSpurMock } from '../../server/mocks/prisonRollCountForWingWithSpurMock'
import { prisonEstablishmentRollSummaryMock } from '../../server/mocks/prisonRollCountSummaryMock'

export default {
stubUserCaseLoads: (caseLoads: CaseLoad[] = []) => {
Expand Down Expand Up @@ -49,11 +48,11 @@ export default {
})
},

stubRollCount: ({ prisonCode = 'LEI', payload = assignedRollCountMock, query = '' } = {}) => {
stubPrisonRollCount: ({ prisonCode = 'LEI', payload = prisonRollCountMock } = {}) => {
return stubFor({
request: {
method: 'GET',
url: `/prison/api/movements/rollcount/${prisonCode}${query}`,
url: `/prison/api/prison/roll-count/${prisonCode}`,
},
response: {
status: 200,
Expand All @@ -65,18 +64,18 @@ export default {
})
},

stubPrisonRollCount: ({ prisonCode = 'LEI', payload = prisonRollCountMock } = {}) => {
stubPrisonRollCountSummary: ({ prisonCode = 'LEI' } = {}) => {
return stubFor({
request: {
method: 'GET',
url: `/prison/api/prison/roll-count/${prisonCode}`,
url: `/prison/api/prison/roll-count/${prisonCode}/summary`,
},
response: {
status: 200,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
jsonBody: payload,
jsonBody: { ...prisonEstablishmentRollSummaryMock, prisonId: prisonCode },
},
})
},
Expand All @@ -101,22 +100,6 @@ export default {
})
},

stubRollCountUnassigned: (prisonCode = 'LEI') => {
return stubFor({
request: {
method: 'GET',
url: `/prison/api/movements/rollcount/${prisonCode}?unassigned=true`,
},
response: {
status: 200,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
jsonBody: unassignedRollCountMock,
},
})
},

stubMovements: (prisonCode = 'LEI') => {
return stubFor({
request: {
Expand Down Expand Up @@ -247,38 +230,6 @@ export default {
})
},

stubEnrouteRollCount: (prisonCode = 'LEI') => {
return stubFor({
request: {
method: 'GET',
urlPattern: `/prison/api/movements/rollcount/${prisonCode}/enroute`,
},
response: {
status: 200,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
jsonBody: 1,
},
})
},

stubGetLocationsForPrison: (prisonCode = 'LEI') => {
return stubFor({
request: {
method: 'GET',
urlPattern: `/prison/api/agencies/${prisonCode}/locations`,
},
response: {
status: 200,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
jsonBody: [{ description: 'CSWAP', locationId: 1 }],
},
})
},

stubGetLocation: ({ locationId = 123, payload = locationMock } = {}) => {
return stubFor({
request: {
Expand All @@ -295,38 +246,6 @@ export default {
})
},

getAttributesForLocation: (locationId = 1) => {
return stubFor({
request: {
method: 'GET',
urlPattern: `/prison/api/cell/${locationId}/attributes`,
},
response: {
status: 200,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
jsonBody: { noOfOccupants: 31 },
},
})
},

stubGetStaffRoles: (status = 200) => {
return stubFor({
request: {
method: 'GET',
urlPattern: `/prison/api/staff/231232/LEI/roles`,
},
response: {
status,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
jsonBody: mockStaffRoles,
},
})
},

stubSetActiveCaseload: (status = 200) => {
return stubFor({
request: {
Expand Down
1 change: 0 additions & 1 deletion integration_tests/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export default class IndexPage extends Page {

return {
heading: () => todaySection().find('h2'),
lastUpdated: () => todaySection().find('.today-last-updated'),
unlockRollCard: () => todaySection().find('[data-qa=today-unlock-roll-card]'),
populationCard: () => todaySection().find('[data-qa=today-current-population-card]'),
inTodayCard: () => todaySection().find('[data-qa=today-in-card]'),
Expand Down
4 changes: 0 additions & 4 deletions server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ export default {
changeSomeonesCell: get('CHANGE_SOMEONES_CELL_URL', 'http://localhost:3002', requiredInProduction),
},
domain: get('INGRESS_URL', 'http://localhost:3000', requiredInProduction),
todayCacheTTL: Number(get('TODAY_CACHE_TTL', 0, requiredInProduction)),
contentful: {
host: get('CONTENTFUL_HOST', ''), // This is only required for Cypress testing
spaceId: get('CONTENTFUL_SPACE_ID', 'spaceId', requiredInProduction),
Expand All @@ -254,7 +253,4 @@ export default {
analytics: {
tagManagerContainerId: get('TAG_MANAGER_CONTAINER_ID', ''),
},
features: {
establishmentRollExcluded: get('ESTABLISHMENT_ROLL_EXCLUDED', ''),
},
}
Loading

0 comments on commit 4e892fe

Please sign in to comment.