Skip to content

Commit

Permalink
CDPS-44 - Display address data from the API on the personal page (#83)
Browse files Browse the repository at this point in the history
* Display address data from the API on the personal page

* Move address to separate file
  • Loading branch information
danielburnley authored Mar 24, 2023
1 parent 14d2ddc commit 663868d
Show file tree
Hide file tree
Showing 20 changed files with 563 additions and 8 deletions.
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

0 comments on commit 663868d

Please sign in to comment.