Skip to content

Commit 5a8afd7

Browse files
authored
Merge pull request #131 from ministryofjustice/CBA-303-create-gender-identity-page-in-applicant-details-section
CBA-303 create gender identity page in applicant details section
2 parents b35db87 + 5355001 commit 5a8afd7

22 files changed

+842
-39
lines changed

e2e-tests/steps/aboutThePersonSection.ts

+11
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,17 @@ export const completePersonalInformationTask = async (page: Page, name: string)
131131

132132
await completeWorkingMobilePhonePage(page, name)
133133
await completeImmigrationStatusPage(page, name)
134+
await completeGenderPage(page, name)
135+
}
136+
137+
async function completeGenderPage(page: Page, name: string) {
138+
const genderPage = await ApplyPage.initialize(
139+
page,
140+
`Is the gender ${name} identifies with the same as the sex registered at birth?`,
141+
)
142+
143+
await genderPage.checkRadio('Yes')
144+
await genderPage.clickSave()
134145
}
135146

136147
async function completeWorkingMobilePhonePage(page: Page, name: string) {

integration_tests/fixtures/applicationData.json

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
"immigration-status": {
7575
"immigrationStatus": "UK citizen"
7676
},
77+
"gender": {
78+
"gender": "no",
79+
"genderIdentity": "Non binary"
80+
},
7781
"pregnancy-information": {
7882
"isPregnant": "yes",
7983
"dueDate-day": "5",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Cas2v2Application as Application } from '@approved-premises/api'
2+
import ApplyPage from '../../applyPage'
3+
import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils'
4+
import paths from '../../../../../server/paths/apply'
5+
6+
export default class GenderPage extends ApplyPage {
7+
constructor(private readonly application: Application) {
8+
super(
9+
`Is the gender ${nameOrPlaceholderCopy(application.person)} identifies with the same as the sex registered at birth?`,
10+
application,
11+
'personal-information',
12+
'gender',
13+
)
14+
}
15+
16+
static visit(application: Application): void {
17+
cy.visit(
18+
paths.applications.pages.show({
19+
id: application.id,
20+
task: 'personal-information',
21+
page: 'gender',
22+
}),
23+
)
24+
}
25+
26+
completeForm(): void {
27+
this.checkRadioByNameAndValue('gender', 'no')
28+
this.getTextInputByIdAndEnterDetails('genderIdentity', 'Non binary')
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Cas2v2Application as Application } from '@approved-premises/api'
2+
import ApplyPage from '../../applyPage'
3+
import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils'
4+
import paths from '../../../../../server/paths/apply'
5+
6+
export default class ImmigrationStatusPage extends ApplyPage {
7+
constructor(private readonly application: Application) {
8+
super(
9+
`What is ${nameOrPlaceholderCopy(application.person)}'s immigration status?`,
10+
application,
11+
'personal-information',
12+
'immigration-status',
13+
)
14+
}
15+
16+
static visit(application: Application): void {
17+
cy.visit(
18+
paths.applications.pages.show({
19+
id: application.id,
20+
task: 'personal-information',
21+
page: 'immigration-status',
22+
}),
23+
)
24+
}
25+
26+
completeForm(): void {
27+
this.getSelectInputByIdAndSelectAnEntry('immigrationStatus', 'UK citizen')
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Cas2v2Application as Application } from '@approved-premises/api'
2+
import ApplyPage from '../../applyPage'
3+
import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils'
4+
import paths from '../../../../../server/paths/apply'
5+
6+
export default class PregnancyInformationPage extends ApplyPage {
7+
constructor(private readonly application: Application) {
8+
super(
9+
`Is ${nameOrPlaceholderCopy(application.person)} pregnant?`,
10+
application,
11+
'personal-information',
12+
'pregnancy-information',
13+
)
14+
}
15+
16+
static visit(application: Application): void {
17+
cy.visit(
18+
paths.applications.pages.show({
19+
id: application.id,
20+
task: 'personal-information',
21+
page: 'pregnancy-information',
22+
}),
23+
)
24+
}
25+
26+
completeForm(): void {
27+
this.checkRadioByNameAndValue('isPregnant', 'yes')
28+
this.completeDateInputs('dueDate', '2023-07-15')
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Cas2v2Application as Application } from '@approved-premises/api'
2+
import ApplyPage from '../../applyPage'
3+
import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils'
4+
import paths from '../../../../../server/paths/apply'
5+
6+
export default class SupportWorkerPreferencePage extends ApplyPage {
7+
constructor(private readonly application: Application) {
8+
super(
9+
`Does ${nameOrPlaceholderCopy(application.person)} have a gender preference for their support worker?`,
10+
application,
11+
'personal-information',
12+
'support-worker-preference',
13+
)
14+
}
15+
16+
static visit(application: Application): void {
17+
cy.visit(
18+
paths.applications.pages.show({
19+
id: application.id,
20+
task: 'personal-information',
21+
page: 'support-worker-preference',
22+
}),
23+
)
24+
}
25+
26+
completeForm(): void {
27+
this.checkRadioByNameAndValue('hasSupportWorkerPreference', 'yes')
28+
this.checkRadioByNameAndValue('supportWorkerPreference', 'female')
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Cas2v2Application as Application } from '@approved-premises/api'
2+
import ApplyPage from '../../applyPage'
3+
import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils'
4+
import paths from '../../../../../server/paths/apply'
5+
6+
export default class WorkingMobilePhonePage extends ApplyPage {
7+
constructor(private readonly application: Application) {
8+
super(
9+
`Will ${nameOrPlaceholderCopy(application.person)} have a working mobile phone?`,
10+
application,
11+
'personal-information',
12+
'working-mobile-phone',
13+
)
14+
}
15+
16+
static visit(application: Application): void {
17+
cy.visit(
18+
paths.applications.pages.show({
19+
id: application.id,
20+
task: 'personal-information',
21+
page: 'working-mobile-phone',
22+
}),
23+
)
24+
}
25+
26+
completeForm(): void {
27+
this.checkRadioByNameAndValue('hasWorkingMobilePhone', 'yes')
28+
this.getTextInputByIdAndEnterDetails('mobilePhoneNumber', '11111111111')
29+
this.checkRadioByNameAndValue('isSmartPhone', 'yes')
30+
}
31+
}

integration_tests/pages/page.ts

+4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ export default abstract class Page {
9595
cy.get('a').contains('Remove').click()
9696
}
9797

98+
getSelectInputByIdAndSelectAnEntry(id: string, entry: string): void {
99+
cy.get(`#${id}`).select(entry)
100+
}
101+
98102
completeDateInputs(prefix: string, date: string): void {
99103
const parsedDate = DateFormats.isoToDateObj(date)
100104
cy.get(`#${prefix}-day`).type(parsedDate.getDate().toString())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
// Feature: Referrer completes 'gender' page
2+
// So that I can complete the "personal information" task
3+
// As a referrer
4+
// I want to complete the 'gender' page
5+
//
6+
// Background:
7+
// Given an application exists
8+
// And I am logged in
9+
// And I visit the 'gender' page
10+
//
11+
// Scenario: view 'gender' page
12+
// Then I see the "gender" page
13+
//
14+
// Scenario: navigate to the task list if the applicant is male
15+
// Given the applicant is male
16+
// When I complete the "gender" page
17+
// And I continue to the next task / page
18+
// Then I am taken to the task list page
19+
//
20+
// Scenario: navigate to the pregnancy information page if the applicant is not male
21+
// Given the applicant is female
22+
// When I complete the "gender" page
23+
// And I continue to the next task / page
24+
// Then I am taken to the pregnancy information page
25+
26+
import Page from '../../../../pages/page'
27+
import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index'
28+
import GenderPage from '../../../../pages/apply/about_the_person/personal_information/genderPage'
29+
import TaskListPage from '../../../../pages/apply/taskListPage'
30+
import PregnancyInformationPage from '../../../../pages/apply/about_the_person/personal_information/pregnancyInformationPage'
31+
32+
context('Visit "gender" page with male applicant', () => {
33+
const male = personFactory.build({ name: 'Roger Smith', sex: 'Male' })
34+
35+
beforeEach(function test() {
36+
cy.task('reset')
37+
cy.task('stubSignIn')
38+
cy.task('stubAuthUser')
39+
40+
cy.fixture('applicationData.json').then(applicationData => {
41+
delete applicationData['personal-information'].gender
42+
const application = applicationFactory.build({
43+
id: 'abc123',
44+
person: male,
45+
data: applicationData,
46+
})
47+
cy.wrap(application).as('maleApplication')
48+
})
49+
})
50+
51+
beforeEach(function test() {
52+
// And an application exists
53+
// -------------------------
54+
cy.task('stubApplicationGet', { application: this.maleApplication })
55+
cy.task('stubApplicationUpdate', { application: this.maleApplication })
56+
57+
// Given I am logged in
58+
//---------------------
59+
cy.signIn()
60+
61+
// And I visit the 'gender' page
62+
// --------------------------------
63+
GenderPage.visit(this.maleApplication)
64+
})
65+
66+
// Scenario: view 'gender' page
67+
// ----------------------------------------------
68+
69+
it('presents gender page', function test() {
70+
// Then I see the "gender" page
71+
Page.verifyOnPage(GenderPage, this.maleApplication)
72+
})
73+
74+
// Scenario: navigate to the task list page if the applicant is male
75+
// ----------------------------------------------
76+
it('navigates to the task list page', function test() {
77+
// Given the applicant is male
78+
79+
// When I complete the "gender" page
80+
const page = Page.verifyOnPage(GenderPage, this.maleApplication)
81+
page.completeForm()
82+
83+
// When I continue to the next task / page
84+
page.clickSubmit()
85+
86+
// Then I am taken to the task list page
87+
Page.verifyOnPage(TaskListPage, this.maleApplication)
88+
})
89+
})
90+
91+
context('Visit "gender" page with female applicant', () => {
92+
const female = personFactory.build({ name: 'Rogella Smith', sex: 'Female' })
93+
94+
beforeEach(function test() {
95+
cy.task('reset')
96+
cy.task('stubSignIn')
97+
cy.task('stubAuthUser')
98+
99+
cy.fixture('applicationData.json').then(applicationData => {
100+
delete applicationData['personal-information'].gender
101+
const application = applicationFactory.build({
102+
id: 'abc123',
103+
person: female,
104+
data: applicationData,
105+
})
106+
cy.wrap(application).as('femaleApplication')
107+
})
108+
})
109+
110+
beforeEach(function test() {
111+
// And a female application exists
112+
// -------------------------
113+
cy.task('stubApplicationGet', { application: this.femaleApplication })
114+
cy.task('stubApplicationUpdate', { application: this.femaleApplication })
115+
116+
// Given I am logged in
117+
//---------------------
118+
cy.signIn()
119+
120+
// And I visit the 'gender' page
121+
// --------------------------------
122+
GenderPage.visit(this.femaleApplication)
123+
})
124+
125+
// Scenario: navigate to the pregnancy information page if the applicant is not male
126+
// ----------------------------------------------
127+
it('navigates to the pregnancy information page', function test() {
128+
// When I complete the "gender" page
129+
const page = Page.verifyOnPage(GenderPage, this.femaleApplication)
130+
page.completeForm()
131+
132+
// When I continue to the next task / page
133+
page.clickSubmit()
134+
135+
// Then I am taken to the pregnancy information page
136+
Page.verifyOnPage(PregnancyInformationPage, this.femaleApplication)
137+
})
138+
})

0 commit comments

Comments
 (0)