Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAP-1599 Tests for old and new establishment count via either prison-api for locations api #165

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions integration_tests/e2e/currentlyOut.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,37 @@ context('Currently Out Page', () => {
{ caseloadFunction: '', caseLoadId: 'LEI', currentlyActive: true, description: 'Leeds (HMP)', type: '' },
],
})
const locationId = '01922e9a-ffd2-77cb-ba6b-3c9c9b623194'

cy.task('stubFeComponents')
cy.task('stubOutToday', '123')
cy.task('stubGetLocation')

cy.task('stubPostSearchPrisonersById')
cy.task('stubRecentMovements')
})

function dataSourceSetup(residentialLocationActive: boolean, locationId: string) {
cy.task('stubFeComponents', residentialLocationActive)
if (residentialLocationActive) {
cy.task('stubLocationsOutToday', locationId)
cy.task('stubInternalLocation', locationId)
} else {
cy.task('stubOutToday', locationId)
cy.task('stubGetLocation', locationId)
}

cy.task('stubLocationsOutToday', locationId)
cy.task('stubInternalLocation', locationId)
cy.signIn({ redirectPath: `/establishment-roll/${locationId}/currently-out` })
cy.visit(`/establishment-roll/${locationId}/currently-out`)
}

it('Page is visible for old data way', () => {
dataSourceSetup(false, '123')
Page.verifyOnPage(CurrentlyOutPage)
})

it('Page is visible', () => {
it('Page is visible for new data way', () => {
dataSourceSetup(true, '01922e9a-ffd2-77cb-ba6b-3c9c9b623194')
Page.verifyOnPage(CurrentlyOutPage)
})

it('should display a table row for each prisoner en-route', () => {
dataSourceSetup(true, '01922e9a-ffd2-77cb-ba6b-3c9c9b623194')
const page = Page.verifyOnPage(CurrentlyOutPage)
page.currentlyOutRows().should('have.length', 2)

Expand All @@ -44,6 +55,7 @@ context('Currently Out Page', () => {
})

it('should display alerts and category if cat A', () => {
dataSourceSetup(true, '01922e9a-ffd2-77cb-ba6b-3c9c9b623194')
const page = Page.verifyOnPage(CurrentlyOutPage)
page.currentlyOutRows().should('have.length', 2)

Expand Down
84 changes: 78 additions & 6 deletions integration_tests/e2e/establishmentRoll.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,32 @@ context('Establishment Roll Page', () => {
{ caseloadFunction: '', caseLoadId: 'LEI', currentlyActive: true, description: 'Leeds (HMP)', type: '' },
],
})
cy.task('stubFeComponents')
cy.task('stubPrisonRollCount')
cy.task('stubLocationPrisonRollCount')
})

function dataSourceSetup(residentialLocationActive: boolean) {
cy.task('stubFeComponents', residentialLocationActive)
if (residentialLocationActive) {
cy.task('stubLocationPrisonRollCount')
} else {
cy.task('stubPrisonRollCount')
}

cy.signIn({ redirectPath: '/establishment-roll' })
cy.visit('/establishment-roll')
}

it('Page is visible with data from prison api', () => {
dataSourceSetup(false)
Page.verifyOnPage(EstablishmentRollPage)
})

it('Page is visible', () => {
it('Page is visible with data from locations', () => {
dataSourceSetup(true)
Page.verifyOnPage(EstablishmentRollPage)
})

it('should display todays stats', () => {
dataSourceSetup(true)
const page = Page.verifyOnPage(EstablishmentRollPage)
page.todaysStats().unlockRoll().should('contain.text', '100')
page.todaysStats().currentPopulation().should('contain.text', '200')
Expand All @@ -43,6 +57,7 @@ context('Establishment Roll Page', () => {
})

it('should display a table row for each wing level assignedRollCount', () => {
dataSourceSetup(true)
const page = Page.verifyOnPage(EstablishmentRollPage)
page.assignedRollCountRows().should('have.length', 7)

Expand All @@ -62,6 +77,7 @@ context('Establishment Roll Page', () => {
})

it('should display a table row for totals', () => {
dataSourceSetup(true)
const page = Page.verifyOnPage(EstablishmentRollPage)

page.assignedRollCountRows().last().find('td').eq(0).should('contain.text', 'Totals')
Expand All @@ -80,6 +96,7 @@ context('Establishment Roll Page', () => {
})

it('should reveal spurs and landings when click on link', () => {
dataSourceSetup(true)
const page = Page.verifyOnPage(EstablishmentRollPage)

page.assignedRollCountRows().eq(0).find('td').eq(0).should('contain.text', 'B Wing').should('be.visible')
Expand All @@ -106,8 +123,63 @@ context('Establishment Roll Page', () => {
page.assignedRollCountRows().eq(4).find('td').eq(0).should('not.be.visible')
})

it('should show link to landing pages when wing has spur', () => {
it('should show link to landing pages when wing has spur old way', () => {
dataSourceSetup(false)
cy.task('stubPrisonRollCountForLanding', { landingId: '20000', payload: prisonRollCountForWingWithSpurMock })

const page = Page.verifyOnPage(EstablishmentRollPage)

const wing2Reveal = page.assignedRollCountRows().eq(3).find('td').eq(0).find('a')
wing2Reveal.click()
page.assignedRollCountRows().eq(5).find('td').eq(0).find('a').click()

const landingPage = Page.verifyOnPageWithTitle(LandingRollPage, '2 - 1 - B')

landingPage.rollCountRows().should('have.length', 13)

landingPage.rollCountRows().eq(0).find('td').eq(0).should('contain.text', '013')
landingPage.rollCountRows().eq(1).find('td').eq(0).should('contain.text', '014')
landingPage.rollCountRows().eq(2).find('td').eq(0).should('contain.text', '015')

landingPage.rollCountRows().first().find('td').eq(1).should('contain.text', '1')
landingPage.rollCountRows().first().find('td').eq(2).should('contain.text', '1')
landingPage.rollCountRows().first().find('td').eq(3).should('contain.text', '0')
landingPage.rollCountRows().first().find('td').eq(4).should('contain.text', '1')
landingPage.rollCountRows().first().find('td').eq(5).should('contain.text', '0')
})

it('should show link to landing pages when wing does not have spur old way', () => {
dataSourceSetup(false)
cy.task('stubPrisonRollCountForLanding', { landingId: '10000', payload: prisonRollCountForWingNoSpurMock })
const page = Page.verifyOnPage(EstablishmentRollPage)

const wing2Reveal = page.assignedRollCountRows().eq(0).find('td').eq(0).find('a')
wing2Reveal.click()
page.assignedRollCountRows().eq(2).find('td').eq(0).find('a').click()

const landingPage = Page.verifyOnPageWithTitle(LandingRollPage, 'E - 5')

landingPage.rollCountRows().should('have.length', 34)

landingPage.rollCountRows().eq(0).find('td').eq(0).should('contain.text', '003')
landingPage.rollCountRows().eq(1).find('td').eq(0).should('contain.text', '004')
landingPage.rollCountRows().eq(2).find('td').eq(0).should('contain.text', '005')

landingPage.rollCountRows().first().find('td').eq(1).should('contain.text', '1')
landingPage.rollCountRows().first().find('td').eq(2).should('contain.text', '1')
landingPage
.rollCountRows()
.first()
.find('td')
.eq(3)
.find('a[href="/establishment-roll/13138/currently-out"]')
.should('contain.text', '1')
landingPage.rollCountRows().first().find('td').eq(4).should('contain.text', '1')
landingPage.rollCountRows().first().find('td').eq(5).should('contain.text', '0')
})

it('should show link to landing pages when wing has spur', () => {
dataSourceSetup(true)
cy.task('stubLocationPrisonRollCountForLanding', {
landingId: '01922dda-5d40-70d7-8fde-70e8e763dd94',
payload: locationPrisonRollCountForWingWithSpurMock,
Expand Down Expand Up @@ -135,7 +207,7 @@ context('Establishment Roll Page', () => {
})

it('should show link to landing pages when wing does not have spur', () => {
cy.task('stubPrisonRollCountForLanding', { landingId: '10000', payload: prisonRollCountForWingNoSpurMock })
dataSourceSetup(true)
cy.task('stubLocationPrisonRollCountForLanding', {
landingId: '01922dda-5d40-7bef-b74a-c8be0541d5ae',
payload: locationPrisonRollCountForWingNoSpurMock,
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/mockApis/feComponents.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { stubFor } from './wiremock'

export default {
stubFeComponents: () => {
stubFeComponents: (residentialLocationsActive = false) => {
return stubFor({
request: {
method: 'GET',
Expand Down Expand Up @@ -36,7 +36,7 @@ export default {
heading: 'Residential Locations',
description: 'Manage residential locations.',
href: 'http://localhost:3001/locations',
navEnabled: true,
navEnabled: residentialLocationsActive,
},
],
},
Expand Down