|
| 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