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

CDPS-44 - Display address data from the API on the personal page #83

Merged
merged 2 commits into from
Mar 24, 2023
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
24 changes: 24 additions & 0 deletions integration_tests/e2e/personalPage.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { mockAddresses } from '../../server/data/localMockData/addresses'
import { yearsBetweenDateStrings } from '../../server/utils/utils'
import Page from '../pages/page'
import PersonalPage from '../pages/personalPage'
Expand All @@ -17,6 +18,7 @@ context('When signed in', () => {
cy.task('stubPrisonerDetail', 'G6123VU')
cy.task('stubSecondaryLanguages', 1102484)
cy.task('stubProperty', 1102484)
cy.task('stubAddresses', 1102484)
})

it('displays the personal details page', () => {
Expand Down Expand Up @@ -107,4 +109,26 @@ context('When signed in', () => {
page.property().item(2).location().should('include.text', 'Property Box 3')
})
})

context('Addresses', () => {
it('Displays the prisoners address', () => {
const page = visitPersonalDetailsPage()
page.addresess().address().should('include.text', 'Flat 7, premises address, street field')
page.addresess().address().should('include.text', 'Leeds')
page.addresess().address().should('include.text', 'LS1 AAA')
page.addresess().address().should('include.text', 'England')

page.addresess().addressTypes().should('include.text', 'Discharge - Permanent Housing')
page.addresess().addressTypes().should('include.text', 'HDC Address')
page.addresess().addressTypes().should('include.text', 'Other')

page.addresess().phoneNumbers().should('include.text', '4444555566')
page.addresess().phoneNumbers().should('include.text', '0113444444')
page.addresess().phoneNumbers().should('include.text', '0113 333444')
page.addresess().phoneNumbers().should('include.text', '0800 222333')

page.addresess().comments().should('include.text', mockAddresses[0].comment)
page.addresess().addedOn().should('include.text', '1 May 2020')
})
})
})
17 changes: 17 additions & 0 deletions integration_tests/mockApis/prison.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { inmateDetailMock } from '../../server/data/localMockData/inmateDetailMo
import { prisonerDetailMock } from '../../server/data/localMockData/prisonerDetailMock'
import { secondaryLanguagesMock } from '../../server/data/localMockData/secondaryLanguages'
import { propertyMock } from '../../server/data/localMockData/property'
import { mockAddresses } from '../../server/data/localMockData/addresses'
import { CaseNotesByTypeA } from '../../server/data/localMockData/caseNotes'
import { offenderContact } from '../../server/data/localMockData/offenderContacts'
import { mapToQueryString } from '../../server/utils/utils'
Expand Down Expand Up @@ -223,6 +224,22 @@ export default {
})
},

stubAddresses: (bookingId: number) => {
return stubFor({
request: {
method: 'GET',
urlPattern: `/prison/api/bookings/${bookingId}/addresses`,
},
response: {
status: 200,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
jsonBody: mockAddresses,
},
})
},

stubActiveAlerts: (bookingId: number) => {
let jsonResp
if (bookingId === 1102484) {
Expand Down
12 changes: 12 additions & 0 deletions integration_tests/pages/personalPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,16 @@ export default class PersonalPage extends Page {
}),
}
}

addresess = () => {
const cardData = () => cy.get('[data-qa=addresses]')
const summaryListValues = () => cardData().find('.govuk-summary-list__value')
return {
address: () => summaryListValues().eq(0),
addressTypes: () => summaryListValues().eq(1),
phoneNumbers: () => summaryListValues().eq(2),
comments: () => summaryListValues().eq(3),
addedOn: () => cardData().find('[data-qa=address-added-on]'),
}
}
}
2 changes: 2 additions & 0 deletions server/data/interfaces/prisonApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { OffenderAttendanceHistory } from '../../interfaces/offenderAttendanceHi
import { SecondaryLanguage } from '../../interfaces/prisonApi/secondaryLanguage'
import { PagedList, PagedListQueryParams } from '../../interfaces/prisonApi/pagedList'
import { PropertyContainer } from '../../interfaces/prisonApi/propertyContainer'
import { Address } from '../../interfaces/prisonApi/address'

export interface PrisonApiClient {
getUserLocations(): Promise<Location[]>
Expand All @@ -42,4 +43,5 @@ export interface PrisonApiClient {
getSecondaryLanguages(bookingId: number): Promise<SecondaryLanguage[]>
getAlerts(bookingId: number, queryParams: PagedListQueryParams): Promise<PagedList>
getProperty(bookingId: number): Promise<PropertyContainer[]>
getAddresses(bookingId: number): Promise<Address[]>
}
Loading