generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
8816d0b
commit eb23132
Showing
24 changed files
with
322 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import Page from '../pages/page' | ||
import { Role } from '../../server/enums/role' | ||
import CurrentlyOutPage from '../pages/currentlyOut' | ||
|
||
context('En Route Page', () => { | ||
beforeEach(() => { | ||
cy.task('reset') | ||
cy.setupUserAuth({ | ||
roles: [`ROLE_PRISON`, `ROLE_${Role.GlobalSearch}`], | ||
caseLoads: [ | ||
{ caseloadFunction: '', caseLoadId: 'LEI', currentlyActive: true, description: 'Leeds (HMP)', type: '' }, | ||
], | ||
}) | ||
cy.task('stubOutToday', '123') | ||
cy.task('stubPostSearchPrisonersById') | ||
cy.task('stubRecentMovements') | ||
cy.task('stubGetLocation') | ||
cy.signIn({ redirectPath: '/establishment-roll/123/currently-out' }) | ||
cy.visit('/establishment-roll/123/currently-out') | ||
}) | ||
|
||
it('Page is visible', () => { | ||
Page.verifyOnPage(CurrentlyOutPage) | ||
}) | ||
|
||
it('should display a table row for each prisoner en-route', () => { | ||
const page = Page.verifyOnPage(CurrentlyOutPage) | ||
page.currentlyOutRows().should('have.length', 2) | ||
|
||
page.currentlyOutRows().first().find('td').eq(1).should('contain.text', 'Shannon, Eddie') | ||
page.currentlyOutRows().first().find('td').eq(2).should('contain.text', 'A1234AB') | ||
page.currentlyOutRows().first().find('td').eq(3).should('contain.text', '01/01/1980') | ||
page.currentlyOutRows().first().find('td').eq(4).should('contain.text', '1-1-1') | ||
page.currentlyOutRows().first().find('td').eq(5).should('contain.text', '') | ||
page.currentlyOutRows().first().find('td').eq(6).should('contain.text', 'Sheffield') | ||
page.currentlyOutRows().first().find('td').eq(7).should('contain.text', 'Some Sheffield comment') | ||
}) | ||
|
||
it('should display alerts and category if cat A', () => { | ||
const page = Page.verifyOnPage(CurrentlyOutPage) | ||
page.currentlyOutRows().should('have.length', 2) | ||
|
||
page.currentlyOutRows().eq(1).find('td').eq(5).should('contain.text', 'Hidden disability') | ||
page.currentlyOutRows().eq(1).find('td').eq(5).should('contain.text', 'CAT A') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Page, { PageElement } from './page' | ||
|
||
export default class CurrentlyOutPage extends Page { | ||
constructor() { | ||
super(`Currently out - A-wing`) | ||
} | ||
|
||
currentlyOutRows = (): PageElement => cy.get('table.currently-out-roll__table tbody tr') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import prisonApiClientMock from '../test/mocks/prisonApiClientMock' | ||
import LocationService from './locationsService' | ||
import { locationMock } from '../mocks/locationMock' | ||
|
||
describe('establishmentRollService', () => { | ||
let locationRollService: LocationService | ||
|
||
beforeEach(() => { | ||
locationRollService = new LocationService(() => prisonApiClientMock) | ||
}) | ||
|
||
describe('getLocationInfo', () => { | ||
it('should call api and return response', async () => { | ||
prisonApiClientMock.getLocation = jest.fn().mockResolvedValueOnce(locationMock) | ||
|
||
const locationInfo = await locationRollService.getLocationInfo('token', 'loc') | ||
|
||
expect(locationInfo).toEqual(locationMock) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { RestClientBuilder } from '../data' | ||
import { PrisonApiClient } from '../data/interfaces/prisonApiClient' | ||
import { Location } from '../data/interfaces/location' | ||
|
||
export default class LocationService { | ||
constructor(private readonly prisonApiClientBuilder: RestClientBuilder<PrisonApiClient>) {} | ||
|
||
public async getLocationInfo(clientToken: string, locationId: string): Promise<Location> { | ||
const prisonApi = this.prisonApiClientBuilder(clientToken) | ||
|
||
return prisonApi.getLocation(locationId) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.