Skip to content

Commit dc2f0ff

Browse files
committed
add log prisoner details e2e tests
1 parent ba172d2 commit dc2f0ff

File tree

6 files changed

+88
-14
lines changed

6 files changed

+88
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
context('Log Prisoner Details Page', () => {
2+
beforeEach(() => {
3+
cy.task('reset')
4+
cy.task('stubSignIn')
5+
cy.signIn()
6+
cy.request('/mock-session').then(() => {
7+
cy.visit('/log/prisoner-details')
8+
})
9+
})
10+
11+
it('should display the page title', () => {
12+
cy.title().should('include', 'Log prisoner details')
13+
cy.log('Checked page title')
14+
})
15+
16+
it('should display the back link', () => {
17+
cy.get('.govuk-back-link')
18+
.should('exist')
19+
.and('have.attr', 'href', '/log/application-type')
20+
.and('have.text', 'Back')
21+
cy.log('Checked back link')
22+
})
23+
24+
it('should display the prisoner details form', () => {
25+
cy.get('form#log-prisoner-details').should('exist')
26+
cy.log('Checked prisoner details form')
27+
})
28+
29+
it('should display the hidden CSRF token field', () => {
30+
cy.get('input[name="_csrf"]').should('exist').and('have.attr', 'type', 'hidden')
31+
cy.log('Checked CSRF token field')
32+
})
33+
34+
it('should display the prison number input field', () => {
35+
cy.get('input#prisonNumber')
36+
.should('exist')
37+
.and('have.attr', 'type', 'text')
38+
.and('have.attr', 'name', 'prisonNumber')
39+
cy.log('Checked prison number input field')
40+
})
41+
42+
it('should display the "Find prisoner" button', () => {
43+
cy.get('#prison-number-lookup')
44+
.should('exist')
45+
.and('include.text', 'Find prisoner')
46+
.and('have.class', 'govuk-button--secondary')
47+
cy.log('Checked "Find prisoner" button')
48+
})
49+
50+
it('should display the prisoner name inset text', () => {
51+
cy.get('.govuk-inset-text').should('exist').and('contain.text', 'Prisoner name: Patel, Taj')
52+
cy.log('Checked prisoner name inset text')
53+
})
54+
55+
it('should display the date picker', () => {
56+
cy.get('#date').should('exist')
57+
cy.get('label[for="date"]').should('exist').and('include.text', 'Date')
58+
cy.log('Checked date picker')
59+
})
60+
61+
it('should display the continue button', () => {
62+
cy.get('[data-test="continue-button"]')
63+
.should('exist')
64+
.and('include.text', 'Continue')
65+
.and('have.class', 'govuk-button--primary')
66+
cy.log('Checked continue button')
67+
})
68+
})

server/@types/express/express-session.d.ts

-12
This file was deleted.

server/@types/express/index.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ export declare module 'express-session' {
55
interface SessionData {
66
returnTo: string
77
nowInMinutes: number
8+
applicationData?: {
9+
type: {
10+
value: string
11+
name: string
12+
}
13+
}
814
}
915
}
1016

server/app.ts

+11
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ export default function createApp(services: Services): express.Application {
5252

5353
app.use(routes(services))
5454

55+
if (process.env.NODE_ENV === 'development') {
56+
app.get('/mock-session', (req, res) => {
57+
req.session.applicationData = {
58+
type: {
59+
value: 'application-type',
60+
name: 'Application Type',
61+
},
62+
}
63+
})
64+
}
65+
5566
app.use((req, res, next) => next(createError(404, 'Not found')))
5667
app.use(errorHandler(process.env.NODE_ENV === 'production'))
5768

server/routes/applications/prisonerDetailsRoutes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default function prisonerDetailsRoutes({ auditService }: { auditService:
1414
})
1515

1616
if (!req.session.applicationData?.type) {
17-
return res.redirect('log/application-type')
17+
return res.redirect('/log/application-type')
1818
}
1919

2020
return res.render('pages/log/prisoner-details', {

server/views/pages/log/prisoner-details.njk

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151

5252
{{ govukButton({
5353
text: "Continue",
54-
classes: "govuk-button--primary"
54+
classes: "govuk-button--primary",
55+
attributes: { "data-test": "continue-button" }
5556
}) }}
5657
</form>
5758
</div>

0 commit comments

Comments
 (0)