generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit-client-instances.cy.ts
108 lines (85 loc) · 3.62 KB
/
edit-client-instances.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import Page from '../pages/page'
import ViewBaseClientPage from '../pages/viewBaseClient'
import ViewClientSecretsPage from '../pages/viewClientSecrets'
import ConfirmDeleteClientPage from '../pages/confirmDeleteClient'
const visitBaseClientPage = (): ViewBaseClientPage => {
cy.signIn({ failOnStatusCode: true, redirectPath: '/base-clients/base_client_id_1' })
return Page.verifyOnPage(ViewBaseClientPage)
}
const visitConfirmDeleteClientPage = (): ConfirmDeleteClientPage => {
cy.signIn({
failOnStatusCode: true,
redirectPath: '/base-clients/base_client_id_1/clients/base_client_id_1_01/delete',
})
return Page.verifyOnPage(ConfirmDeleteClientPage)
}
context('Base client page - client instances', () => {
beforeEach(() => {
cy.task('reset')
cy.task('stubSignIn')
cy.task('stubGetBaseClient')
cy.task('stubManageUser')
cy.task('stubGetListClientInstancesList')
})
context('Add client instances', () => {
let baseClientsPage: ViewBaseClientPage
beforeEach(() => {
cy.task('stubAddClientInstance')
baseClientsPage = visitBaseClientPage()
})
it('User can click Add on base-client page to create new client instance', () => {
baseClientsPage.addClientInstanceButton().click()
Page.verifyOnPage(ViewClientSecretsPage)
})
context('Client secrets page', () => {
let clientSecretsPage: ViewClientSecretsPage
beforeEach(() => {
baseClientsPage.addClientInstanceButton().click()
clientSecretsPage = Page.verifyOnPage(ViewClientSecretsPage)
})
it('User can see client secrets', () => {
clientSecretsPage.secretsTable().should('be.visible')
})
it('User can click continue to be taken back to base client page', () => {
clientSecretsPage.continueButton().click()
Page.verifyOnPage(ViewBaseClientPage)
})
})
})
context('Delete client instances', () => {
let confirmDeleteClientPage: ConfirmDeleteClientPage
beforeEach(() => {
cy.task('stubDeleteClientInstance')
confirmDeleteClientPage = visitConfirmDeleteClientPage()
})
it('User can see warning message', () => {
confirmDeleteClientPage.warningMessage().should('be.visible')
})
it('Should not have error message by default', () => {
confirmDeleteClientPage.errorMessage().should('not.exist')
})
it('User can fill out confirm then click Delete on base-client page to delete client instance', () => {
confirmDeleteClientPage.confirmInput().clear()
confirmDeleteClientPage.confirmInput().type('base_client_id_1_01')
confirmDeleteClientPage.deleteButton().click()
Page.verifyOnPage(ViewBaseClientPage)
})
it('User does not fill out Confirmation input clicking delete returns to page with error', () => {
confirmDeleteClientPage.confirmInput().clear()
confirmDeleteClientPage.deleteButton().click()
confirmDeleteClientPage = Page.verifyOnPage(ConfirmDeleteClientPage)
confirmDeleteClientPage.errorMessage().should('be.visible')
})
it('User fills out incorrect Confirmation input clicking delete returns to page with error', () => {
confirmDeleteClientPage.confirmInput().clear()
confirmDeleteClientPage.confirmInput().type('incorrect_client_id')
confirmDeleteClientPage.deleteButton().click()
confirmDeleteClientPage = Page.verifyOnPage(ConfirmDeleteClientPage)
confirmDeleteClientPage.errorMessage().should('be.visible')
})
it('User can click cancel to return to base client screen', () => {
confirmDeleteClientPage.cancelButton().click()
Page.verifyOnPage(ViewBaseClientPage)
})
})
})