Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update funding and ID pages #104

Merged
merged 10 commits into from
Feb 20, 2025
1 change: 1 addition & 0 deletions assets/scss/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ $govuk-page-width: $moj-page-width;
margin-bottom: govuk-spacing(3);
}
}

2 changes: 1 addition & 1 deletion e2e-tests/steps/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const completeBeforeYouStartSection = async (page: Page, name: string) =>

export const completeAreaAndFundingSection = async (page: Page, name: string) => {
await completeAreaInformationTask(page, name)
await completeFundingInformationTask(page, name)
await completeFundingInformationTask(page)
}

export const completeAboutThePersonSection = async (page: Page, name: string) => {
Expand Down
22 changes: 7 additions & 15 deletions e2e-tests/steps/areaAndFundingSection.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import { Page } from '@playwright/test'
import { ApplyPage, TaskListPage } from '../pages/apply'

export const completeFundingInformationTask = async (page: Page, name: string) => {
export const completeFundingInformationTask = async (page: Page) => {
const taskListPage = new TaskListPage(page)
await taskListPage.clickTask('Confirm funding and ID')

const fundingInformationPage = await ApplyPage.initialize(
page,
`How will ${name} pay for their accommodation and service charge?`,
)
await fundingInformationPage.checkRadio('Personal money or wages', true)
const fundingInformationPage = await ApplyPage.initialize(page, 'Funding CAS-2 accommodation')
await fundingInformationPage.checkRadio('Personal savings, salary or pension', true)
await fundingInformationPage.checkRadioInGroup('Does the applicant have a National Insurance number?', 'Yes')
await fundingInformationPage.checkRadioByTestId('receiving-benefits-radio-yes')
await fundingInformationPage.checkRadioByTestId('received-benefit-sanctions-radio-yes')
await fundingInformationPage.checkRadioInGroup('Is the applicant in education or receiving any training?', 'No')
await fundingInformationPage.clickSave()
await completeNationalInsurancePage(page, name)
}

async function completeNationalInsurancePage(page: Page, name: string) {
const willAnswerEqualityQuestionsPage = await ApplyPage.initialize(
page,
`What is ${name}'s National Insurance number? (Optional)`,
)
await willAnswerEqualityQuestionsPage.clickSave()
}

export const completeAreaInformationTask = async (page: Page, name: string) => {
Expand Down
17 changes: 10 additions & 7 deletions integration_tests/fixtures/applicationData.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@
}
},
"funding-information": {
"funding-source": {
"fundingSource": "benefits"
},
"identification": {
"funding-cas2-accommodation": {
"fundingSource": "personalSavings",
"fundingSourceDetail": "Personal savings details",
"hasNationalInsuranceNumber": "yes",
"nationalInsuranceNumber": "SF123456X",
"receivingBenefits": "yes",
"receivedBenefitSanctions": "no",
"inEducationOrTraining": "no"
},
"applicant-id": {
"idDocuments": "passport"
},
"national-insurance": {
"nationalInsuranceNumber": "12345"
}
},
"solicitor-details": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Cas2v2Application as Application } from '../../../../../server/@types/shared/models/Cas2v2Application'
import ApplyPage from '../../applyPage'
import paths from '../../../../../server/paths/apply'

export default class AlternativeApplicantIdPage extends ApplyPage {
constructor(private readonly application: Application) {
super(
'What other identification document (ID) does the applicant have?',
application,
'funding-information',
'alternative-applicant-id',
)
}

static visit(application: Application): void {
cy.visit(
paths.applications.pages.show({
id: application.id,
task: 'funding-information',
page: 'alternative-applicant-id',
}),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Cas2v2Application as Application } from '../../../../../server/@types/shared/models/Cas2v2Application'
import ApplyPage from '../../applyPage'
import paths from '../../../../../server/paths/apply'

export default class ApplicantIdPage extends ApplyPage {
constructor(private readonly application: Application) {
super(`What identity document (ID) does the applicant have?`, application, 'funding-information', 'applicant-id')
}

static visit(application: Application): void {
cy.visit(
paths.applications.pages.show({
id: application.id,
task: 'funding-information',
page: 'applicant-id',
}),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Cas2v2Application as Application } from '@approved-premises/api'
import ApplyPage from '../../applyPage'
import { FundingSources } from '../../../../../server/form-pages/apply/area-and-funding/funding-information/fundingCas2Accommodation'

export default class FundingCas2AccommodationPage extends ApplyPage {
constructor(private readonly application: Application) {
super('Funding CAS-2 accommodation', application, 'funding-information', 'funding-cas2-accommodation')
}

completeWithPersonalSavings(): void {
this.selectFundingSource('personalSavings')
this.enterFundingSourceDetails()
this.enterNationalInsuranceNumber()
this.enterBenefitsDetails()
this.selectInEducationOrTraining()
}

completeWithHousingBenefits(): void {
this.selectFundingSource('benefits')
this.enterNationalInsuranceNumber()
this.enterBenefitsDetails()
this.selectInEducationOrTraining()
}

private selectFundingSource(fundingSource: FundingSources): void {
this.checkRadioByNameAndValue('fundingSource', fundingSource)
}

private enterFundingSourceDetails(): void {
this.getTextInputByIdAndEnterDetails('fundingSourceDetail', 'Funding source details')
}

private enterNationalInsuranceNumber(): void {
this.checkRadioByNameAndValue('hasNationalInsuranceNumber', 'yes')
this.getTextInputByIdAndEnterDetails('nationalInsuranceNumber', 'SF123456X')
}

private enterBenefitsDetails(): void {
this.checkRadioByNameAndValue('receivingBenefits', 'yes')
this.checkRadioByNameAndValue('receivedBenefitSanctions', 'no')
}

private selectInEducationOrTraining(): void {
this.checkRadioByNameAndValue('inEducationOrTraining', 'no')
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Feature: Referrer completes 'alternative applicant ID' page
// So that I can complete the "Funding information" task
// As a referrer
// I want to complete the 'alternative applicant ID' page
//
// Background:
// Given an application exists
// And I am logged in
// And I visit the 'alternative applicant ID' page
//
// Scenario: navigate to task list page
// When I select a form of ID
// And I continue to the next task / page
// Then I am redirected to the task list page

import Page from '../../../../pages/page'
import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index'
import AlternativeApplicantIdPage from '../../../../pages/apply/area-and-funding/funding-information/alternativeApplicantIdPage'
import TaskListPage from '../../../../pages/apply/taskListPage'

context('Visit alternative applicant ID 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['funding-information'] = {}
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()

// And I am on the alternative applicant ID page
// --------------------------------
AlternativeApplicantIdPage.visit(this.application)
})
Comment on lines +50 to +53
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want a Page.verifyOnPage() here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patrickjfl Hmm, is this required if we call verifyOnPage in the tests that follow? Maybe the comment should read something like "And I visit the alternative applicant ID page".


// Scenario: navigate to task list page
// ----------------------------------------
it('redirects to the task list page', function test() {
// When I select a form of ID
const page = Page.verifyOnPage(AlternativeApplicantIdPage, this.application)
page.checkCheckboxByValue('contract')

// And I continue to the next task / page
page.clickSubmit()

// Then I am redirected to the task list page
Page.verifyOnPage(TaskListPage, this.application)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Feature: Referrer completes 'applicant ID' page
// So that I can complete the "Funding information" task
// As a referrer
// I want to complete the 'applicant ID' page
//
// Background:
// Given an application exists
// And I am logged in
// And I visit the 'applicant ID' page
//
// Scenario: navigate to alternative applicant ID page
// When I select 'none'
// And I continue to the next task / page
// Then I am redirected to the alternative applicant ID page
//
// Scenario: navigate to task list page
// When I select a form of ID
// And I continue to the next task / page
// Then I am redirected to the task list page

import Page from '../../../../pages/page'
import ApplicantIdPage from '../../../../pages/apply/area-and-funding/funding-information/applicantIdPage'
import TaskListPage from '../../../../pages/apply/taskListPage'
import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index'
import AlternativeApplicantIdPage from '../../../../pages/apply/area-and-funding/funding-information/alternativeApplicantIdPage'

context('Visit applicant ID 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['funding-information'] = {}
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()

// And I am on the applicant ID page
// --------------------------------
ApplicantIdPage.visit(this.application)
})
Comment on lines +56 to +59
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above


// Scenario: navigate to alternative applicant ID page
// ----------------------------------------
it('redirects to the alternative applicant ID page', function test() {
// When I select 'none'
const page = Page.verifyOnPage(ApplicantIdPage, this.application)
page.checkCheckboxByValue('none')

// And I continue to the next task / page
page.clickSubmit()

// Then I am redirected to the alternative applicant ID page
Page.verifyOnPage(AlternativeApplicantIdPage, this.application)
})

// Scenario: navigate to the task list page
// ----------------------------------------
it('redirects to the task list page', function test() {
// When I select a form of ID
const page = Page.verifyOnPage(ApplicantIdPage, this.application)
page.checkCheckboxByValue('passport')

// And I continue to the next task / page
page.clickSubmit()

// Then I am redirected to the task list page
Page.verifyOnPage(TaskListPage, this.application)
})
})
Loading
Loading