generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for funding cas2 accommodation page
- Loading branch information
Daniel Liburd
committed
Feb 19, 2025
1 parent
fc54824
commit 793e2b9
Showing
7 changed files
with
343 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...tion_tests/pages/apply/area-and-funding/funding-information/alternativeApplicantIdPage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}), | ||
) | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
integration_tests/pages/apply/area-and-funding/funding-information/applicantIdPage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}), | ||
) | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...on_tests/pages/apply/area-and-funding/funding-information/fundingCas2AccommodationPage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...s/apply/area-and-funding/funding-information/complete_alternative_applicant_id_page.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
|
||
// 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) | ||
}) | ||
}) |
88 changes: 88 additions & 0 deletions
88
...n_tests/tests/apply/area-and-funding/funding-information/complete_applicant_id_page.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
|
||
// 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) | ||
}) | ||
}) |
88 changes: 88 additions & 0 deletions
88
...ests/apply/area-and-funding/funding-information/complete_funding_cas2_accommodation.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Feature: Referrer completes 'Funding CAS-2 Accommodation' question page | ||
// As a referrer, | ||
// I want to confirm how the applicant is funding their CAS2 accommodation | ||
// So that I can get the applicant into accommodation as quickly as possible with no FIEs | ||
// | ||
// Scenario: When the applicant is using personal savings to fund the accommodation | ||
// Given I'm on the 'Funding CAS-2 Accommodation' question page | ||
// When I select personal savings and give valid answers for all other questions | ||
// Then I am taken to the task list page | ||
// | ||
// Scenario: When the applicant is using house benefits to fund the accommodation | ||
// Given I'm on the 'Funding CAS-2 Accommodation' question page | ||
// When I select housing benefits and give valid answers for all other questions | ||
// Then I am taken to the task list page | ||
|
||
import FundingCas2AccommodationPage from '../../../../pages/apply/area-and-funding/funding-information/fundingCas2AccommodationPage' | ||
import Page from '../../../../pages/page' | ||
import TaskListPage from '../../../../pages/apply/taskListPage' | ||
import ApplicantIdPage from '../../../../pages/apply/area-and-funding/funding-information/applicantIdPage' | ||
import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index' | ||
|
||
context('Visit "Confirm funding and ID" section', () => { | ||
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, | ||
}) | ||
application.data = applicationData | ||
cy.wrap(application).as('application') | ||
cy.wrap(application.data).as('applicationData') | ||
}) | ||
}) | ||
|
||
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 Funding CAS-2 accommodation page | ||
// -------------------------------- | ||
cy.visit('applications/abc123/tasks/funding-information/pages/funding-cas2-accommodation') | ||
Page.verifyOnPage(FundingCas2AccommodationPage, this.application) | ||
}) | ||
|
||
// Scenario: When the applicant is using personal savings to fund the accommodation | ||
// ---------------------------- | ||
it('continues to the task list page', function test() { | ||
// Given I am on the Funding CAS-2 Accommodation | ||
const page = Page.verifyOnPage(FundingCas2AccommodationPage, this.application) | ||
|
||
// When I complete the answers on the page | ||
page.completeWithPersonalSavings() | ||
|
||
// And I click submit | ||
page.clickSubmit() | ||
|
||
// I am taken to the task list page | ||
Page.verifyOnPage(TaskListPage, this.application) | ||
}) | ||
|
||
// Scenario: When the applicant is using house benefits to fund the accommodation | ||
// ---------------------------- | ||
it('continues to the applicant ID page', function test() { | ||
// Given I am on the Funding CAS-2 Accommodation | ||
const page = Page.verifyOnPage(FundingCas2AccommodationPage, this.application) | ||
|
||
// When I complete the answers on the page | ||
page.completeWithHousingBenefits() | ||
|
||
// And I click submit | ||
page.clickSubmit() | ||
|
||
// I am taken to the applicant ID page | ||
Page.verifyOnPage(ApplicantIdPage, this.application) | ||
}) | ||
}) |