generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindependent_living.cy.ts
72 lines (62 loc) · 2.46 KB
/
independent_living.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
// Feature: Referrer completes 'Independent living' page
// So that I can complete the "Health needs" task
// As a referrer
// I want to complete the independent living page
//
// Scenario: Follows link from task list
// Given there is a section with a task
// And an application exists
// And I am logged in
//
// Scenario: view Independent living page
// When I visit the Independent living page
// Then I see the Independent living page
//
// Scenario: continues to next page in "health needs" task
// When I continue to the next task/page
// Then I should be on the substance misuse page
import Page from '../../../../pages/page'
import HealthNeedsInformationPage from '../../../../pages/apply/risks_and_needs/health-needs/healthNeedsInformationPage'
import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index'
import IndependentLivingPage from '../../../../pages/apply/risks_and_needs/health-needs/independentLivingPage'
context('Visit Independent living page', () => {
const person = personFactory.build({ name: 'Roger Smith' })
beforeEach(function test() {
cy.task('reset')
cy.task('stubSignIn')
cy.task('stubAuthUser')
cy.fixture('applicationData.json').then(applicationData => {
applicationData['health-needs'] = {}
const application = applicationFactory.build({
id: 'abc123',
person,
data: applicationData,
})
cy.wrap(application).as('application')
})
})
beforeEach(function test() {
// And an application exists
// -------------------------
cy.task('stubApplicationGet', { application: this.application })
cy.task('stubApplicationUpdate', { application: this.application })
// Given I am logged in
//---------------------
cy.signIn()
})
// Scenario: view Independent living page
it('shows the page', function test() {
// When I visit the Independent living page
IndependentLivingPage.visit(this.application)
// Then I see the Independent living page
Page.verifyOnPage(IndependentLivingPage, this.application)
})
// Scenario: continues to next page in "health needs" task
it('continues to the next page', function test() {
// When I continue to the next task/page
const page = IndependentLivingPage.visit(this.application)
page.clickSubmit()
// Then I should be on the health needs information page
Page.verifyOnPage(HealthNeedsInformationPage, this.application)
})
})