generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
health.cy.ts
44 lines (38 loc) · 1.46 KB
/
health.cy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
context('Healthcheck', () => {
context('All healthy', () => {
beforeEach(() => {
cy.task('reset')
cy.task('stubAuthPing')
cy.task('stubManageUsersPing')
cy.task('stubTokenVerificationPing')
})
it('Health check page is visible and UP', () => {
cy.request('/health').its('body.status').should('equal', 'UP')
})
it('Ping is visible and UP', () => {
cy.request('/ping').its('body.status').should('equal', 'UP')
})
it('Info is visible', () => {
cy.request('/info').its('body').should('exist')
})
})
context('Some unhealthy', () => {
beforeEach(() => {
cy.task('reset')
cy.task('stubAuthPing')
cy.task('stubManageUsersPing')
cy.task('stubTokenVerificationPing', 500)
})
it('Reports correctly when token verification down', () => {
cy.request({ url: '/health', method: 'GET', failOnStatusCode: false }).then(response => {
expect(response.body.components.hmppsAuth.status).to.equal('UP')
expect(response.body.components.manageUsersApi.status).to.equal('UP')
expect(response.body.components.tokenVerification.status).to.equal('DOWN')
expect(response.body.components.tokenVerification.details).to.contain({ status: 500, retries: 2 })
})
})
it('Health check page is visible and DOWN', () => {
cy.request({ url: '/health', method: 'GET', failOnStatusCode: false }).its('body.status').should('equal', 'DOWN')
})
})
})