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

6050 enhancements r50a r50c #63

Merged
merged 5 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<AppOutput label="Name" :value="fullName" />
</AppCol>
</AppRow>
<AppButton @click="addAnotherPermitHolder()" mode="primary" type="button">{{ addAnotherButtonText }}</AppButton>
</div>
</template>

Expand All @@ -28,6 +29,21 @@ export default {
fullName() {
return formatPersonName(this.resident)
},
addAnotherButtonText() {
return this.$route.query.pageAction === 'REGISTRATION' || this.$route.name === 'AddVisaResidentWithoutPHN' ? 'Add Another Permit Holder without PHN' : 'Add Another Permit Holder with PHN'
},
},

methods: {
addAnotherPermitHolder() {
if (this.$route.query.pageAction === 'REGISTRATION') {
this.$store.commit('alert/dismissAlert')
this.$router.replace({ query: null })
this.$router.push('/coverage/enrollment/addStudyPermitHolderWithoutPHN')
} else {
this.$router.go()
}
},
},
}
</script>
1 change: 1 addition & 0 deletions frontend/src/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const PROVINCES = [
export const IMMIGRATION_CODES = [
{ text: 'Select', value: '' },
{ text: 'Student Authorization', value: 'S' },
{ text: 'Employment Authorization', value: 'W' },
]

// Prior Residence drop down options
Expand Down
255 changes: 140 additions & 115 deletions frontend/tests/e2e/tests/enrollment/AddVisaResidentWithPHNTest.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import dayjs from 'dayjs'

import { OUTPUT_DATE_FORMAT } from '../../../../src/util/constants'
import { SITE_UNDER_TEST } from '../../configuration'
import AlertPage from '../../pages/AlertPage'
import AddVisaResidentWithPHNPage from '../../pages/enrollment/AddVisaResidentWithPHNPage'
import AlertPage from '../../pages/AlertPage'
import { OUTPUT_DATE_FORMAT } from '../../../../src/util/constants'
import PersonDetails from '../../pages/enrollment/PersonDetailsPage'
import { SITE_UNDER_TEST } from '../../configuration'
import dayjs from 'dayjs'
import { regularAccUser } from '../../roles/roles'

const immigrationCodeOption = AddVisaResidentWithPHNPage.immigrationCodeSelect.find('option')
Expand All @@ -31,125 +30,151 @@ const PHONE_NUMBER_VALIDATION_MESSAGE = 'Only numbers 0 to 9 are valid. Phone Nu

const PAGE_TO_TEST = SITE_UNDER_TEST + '/coverage/enrollment/addStudyPermitHolderWithPHN'

fixture(`AddVisaResidentWithPHN Page`)
.disablePageCaching `Test AddVisaResidentWithPHN`
.beforeEach(async t => {
await t
.useRole(regularAccUser)
})
.page(PAGE_TO_TEST)
fixture(`AddVisaResidentWithPHN Page`).disablePageCaching`Test AddVisaResidentWithPHN`
.beforeEach(async (t) => {
await t.useRole(regularAccUser)
})
.page(PAGE_TO_TEST)

test('Check required fields validation', async t => {
await t
.typeText(PersonDetails.phnInput, '9882807277')
.click(PersonDetails.submitButton)
.wait(5000)
// Given required fields aren't filled out

// When I click the submit button
.click(AddVisaResidentWithPHNPage.submitButton)
.wait(1000)
// I expect an error message stating the page had errors and individual error messages for each required field
.expect(AlertPage.alertBannerText.textContent).contains(ERROR_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(0).textContent).contains(GROUPNUMBER_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(1).textContent).contains(IMMIGRATION_CODE_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(2).textContent).contains(PERMIT_ISSUE_DATE_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(3).textContent).contains(PERMIT_EXPIRY_DATE_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(4).textContent).contains(RESIDENCE_DATE_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(5).textContent).contains(COVERAGE_CANCELLATION_DATE_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(6).textContent).contains(HOME_ADDRESS_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(7).textContent).contains(CITY_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(8).textContent).contains(PROVINCE_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(9).textContent).contains(POSTAL_CODE_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(10).textContent).contains(PRIOR_RESIDENCE_REQUIRED_MESSAGE)
test('Check required fields validation', async (t) => {
await t
.typeText(PersonDetails.phnInput, '9882807277')
.click(PersonDetails.submitButton)
.wait(5000)
// Given required fields aren't filled out

// When I click the submit button
.click(AddVisaResidentWithPHNPage.submitButton)
.wait(1000)
// I expect an error message stating the page had errors and individual error messages for each required field
.expect(AlertPage.alertBannerText.textContent)
.contains(ERROR_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(0).textContent)
.contains(GROUPNUMBER_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(1).textContent)
.contains(IMMIGRATION_CODE_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(2).textContent)
.contains(PERMIT_ISSUE_DATE_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(3).textContent)
.contains(PERMIT_EXPIRY_DATE_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(4).textContent)
.contains(RESIDENCE_DATE_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(5).textContent)
.contains(COVERAGE_CANCELLATION_DATE_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(6).textContent)
.contains(HOME_ADDRESS_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(7).textContent)
.contains(CITY_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(8).textContent)
.contains(PROVINCE_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(9).textContent)
.contains(POSTAL_CODE_REQUIRED_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(10).textContent)
.contains(PRIOR_RESIDENCE_REQUIRED_MESSAGE)
})

test('Check properly filled form passes validation', async t => {
await t
.typeText(PersonDetails.phnInput, '9882807277')
.click(PersonDetails.submitButton)
.wait(5000)
// Given the page is filled out correctly
.typeText(AddVisaResidentWithPHNPage.groupNumberInput, '6337109')
.click(AddVisaResidentWithPHNPage.immigrationCodeSelect)
.click(immigrationCodeOption.withText("Student Authorization"))
.typeText(AddVisaResidentWithPHNPage.departmentNumberInput, '123456')
.typeText(AddVisaResidentWithPHNPage.visaIssueDateInput, '20210101')
.typeText(AddVisaResidentWithPHNPage.visaExpiryDateInput, '20221231')
.typeText(AddVisaResidentWithPHNPage.residenceDateInput, '20191108')
.typeText(AddVisaResidentWithPHNPage.coverageEffectiveDateInput, '20210401')
.typeText(AddVisaResidentWithPHNPage.coverageCancellationDateInput, '20211231')
.typeText(AddVisaResidentWithPHNPage.telephoneInput, '7802024022')
.typeText(AddVisaResidentWithPHNPage.address1Input, 'Test 111 ST')
.typeText(AddVisaResidentWithPHNPage.cityInput, 'VICTORIA')
.click(AddVisaResidentWithPHNPage.provinceSelect)
.click(provinceOption.withText('British Columbia'))
.typeText(AddVisaResidentWithPHNPage.postalCodeInput, 'V8V8V8')
.click(AddVisaResidentWithPHNPage.priorResidenceCodeInput)
.click(priorResidenceCodeOption.withText('British Columbia'))
test('Check properly filled form passes validation', async (t) => {
await t
.typeText(PersonDetails.phnInput, '9882807277')
.click(PersonDetails.submitButton)
.wait(5000)
// Given the page is filled out correctly
.typeText(AddVisaResidentWithPHNPage.groupNumberInput, '6337109')
.click(AddVisaResidentWithPHNPage.immigrationCodeSelect)
.click(immigrationCodeOption.withText('Employment Authorization'))
.typeText(AddVisaResidentWithPHNPage.departmentNumberInput, '123456')
.typeText(AddVisaResidentWithPHNPage.visaIssueDateInput, '20210101')
.typeText(AddVisaResidentWithPHNPage.visaExpiryDateInput, '20221231')
.typeText(AddVisaResidentWithPHNPage.residenceDateInput, '20191108')
.typeText(AddVisaResidentWithPHNPage.coverageEffectiveDateInput, '20210401')
.typeText(AddVisaResidentWithPHNPage.coverageCancellationDateInput, '20211231')
.typeText(AddVisaResidentWithPHNPage.telephoneInput, '7802024022')
.typeText(AddVisaResidentWithPHNPage.address1Input, 'Test 111 ST')
.typeText(AddVisaResidentWithPHNPage.cityInput, 'VICTORIA')
.click(AddVisaResidentWithPHNPage.provinceSelect)
.click(provinceOption.withText('British Columbia'))
.typeText(AddVisaResidentWithPHNPage.postalCodeInput, 'V8V8V8')
.click(AddVisaResidentWithPHNPage.priorResidenceCodeInput)
.click(priorResidenceCodeOption.withText('British Columbia'))

// When I click the submit button
.click(AddVisaResidentWithPHNPage.submitButton)
// I expect a success message
.expect(AlertPage.alertBannerText.textContent).contains(SUCCESS_MESSAGE)
// When I click the submit button
.click(AddVisaResidentWithPHNPage.submitButton)
// I expect a success message
.expect(AlertPage.alertBannerText.textContent)
.contains(SUCCESS_MESSAGE)
})

test('Check invalid field validation', async t => {
await t
test('Check invalid field validation', async (t) => {
await t
.typeText(PersonDetails.phnInput, '9882807277')
.click(PersonDetails.submitButton)
.wait(1000)
// Given a Group Number entered with an invalid format
.typeText(AddVisaResidentWithPHNPage.groupNumberInput, '9000444000')
.typeText(AddVisaResidentWithPHNPage.groupMemberNumberInput, '9000444000')
.typeText(AddVisaResidentWithPHNPage.departmentNumberInput, '9000444^^')
.typeText(AddVisaResidentWithPHNPage.telephoneInput, '7807777')
// When I click the submit button
.click(AddVisaResidentWithPHNPage.submitButton)
// I expect an error message stating the page had errors and an individual error message for the PHN format
.expect(AddVisaResidentWithPHNPage.errorText.nth(0).textContent).contains(INVALID_GROUP_NUMBER_ERROR_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(2).textContent).contains(INVALID_GROUP_MEMBER_NUMBER_ERROR_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(4).textContent).contains(INVALID_DEPARTMENT_NUMBER_VALIDATION_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(7).textContent).contains(PHONE_NUMBER_VALIDATION_MESSAGE)
.expect(AlertPage.alertBannerText.textContent).contains(ERROR_MESSAGE)

.wait(1000)
// Given a Group Number entered with an invalid format
.typeText(AddVisaResidentWithPHNPage.groupNumberInput, '9000444000')
.typeText(AddVisaResidentWithPHNPage.groupMemberNumberInput, '9000444000')
.typeText(AddVisaResidentWithPHNPage.departmentNumberInput, '9000444^^')
.typeText(AddVisaResidentWithPHNPage.telephoneInput, '7807777')
// When I click the submit button
.click(AddVisaResidentWithPHNPage.submitButton)
// I expect an error message stating the page had errors and an individual error message for the PHN format
.expect(AddVisaResidentWithPHNPage.errorText.nth(0).textContent)
.contains(INVALID_GROUP_NUMBER_ERROR_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(2).textContent)
.contains(INVALID_GROUP_MEMBER_NUMBER_ERROR_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(4).textContent)
.contains(INVALID_DEPARTMENT_NUMBER_VALIDATION_MESSAGE)
.expect(AddVisaResidentWithPHNPage.errorText.nth(7).textContent)
.contains(PHONE_NUMBER_VALIDATION_MESSAGE)
.expect(AlertPage.alertBannerText.textContent)
.contains(ERROR_MESSAGE)
})

test('Check clear button clears the form', async t => {
await t
test('Check clear button clears the form', async (t) => {
await t
.typeText(PersonDetails.phnInput, '9882807277')
.click(PersonDetails.submitButton)
// Given the page is filled out correctly
.typeText(AddVisaResidentWithPHNPage.groupNumberInput, '6337109')
.click(AddVisaResidentWithPHNPage.immigrationCodeSelect)
.click(immigrationCodeOption.withText("Student Authorization"))
.typeText(AddVisaResidentWithPHNPage.departmentNumberInput, '6337109')
.typeText(AddVisaResidentWithPHNPage.visaIssueDateInput, '20210101')
.typeText(AddVisaResidentWithPHNPage.visaExpiryDateInput, '20221231')
.typeText(AddVisaResidentWithPHNPage.residenceDateInput, '20191108')
.typeText(AddVisaResidentWithPHNPage.coverageEffectiveDateInput, '20210301')
.typeText(AddVisaResidentWithPHNPage.coverageCancellationDateInput, '20211231')
.typeText(AddVisaResidentWithPHNPage.telephoneInput, '7802024022')
.typeText(AddVisaResidentWithPHNPage.address1Input, 'Test 111 ST')
.typeText(AddVisaResidentWithPHNPage.cityInput, 'VICTORIA')
.click(AddVisaResidentWithPHNPage.provinceSelect)
.click(provinceOption.withText('British Columbia'))
.typeText(AddVisaResidentWithPHNPage.postalCodeInput, 'V8V8V8')
.click(AddVisaResidentWithPHNPage.priorResidenceCodeInput)
.click(priorResidenceCodeOption.withText('British Columbia'))

// When I click the clear button
.click(AddVisaResidentWithPHNPage.clearButton)
// I expect the form to be cleared
.expect(AddVisaResidentWithPHNPage.groupNumberInput.value).eql('')
.expect(AddVisaResidentWithPHNPage.immigrationCodeSelect.value).eql('')
.expect(AddVisaResidentWithPHNPage.visaIssueDateInput.value).eql('')
.expect(AddVisaResidentWithPHNPage.visaExpiryDateInput.value).eql('')
.expect(AddVisaResidentWithPHNPage.residenceDateInput.value).eql('')
.expect(AddVisaResidentWithPHNPage.coverageEffectiveDateInput.value).eql(dayjs().startOf('month').format(OUTPUT_DATE_FORMAT))
.expect(AddVisaResidentWithPHNPage.coverageCancellationDateInput.value).eql('')
.expect(AddVisaResidentWithPHNPage.cityInput.value).eql('')
.expect(AddVisaResidentWithPHNPage.provinceSelect.value).eql('')
.expect(AddVisaResidentWithPHNPage.postalCodeInput.value).eql('')
.expect(AddVisaResidentWithPHNPage.telephoneInput.value).eql('')
})
// Given the page is filled out correctly
.typeText(AddVisaResidentWithPHNPage.groupNumberInput, '6337109')
.click(AddVisaResidentWithPHNPage.immigrationCodeSelect)
.click(immigrationCodeOption.withText('Student Authorization'))
.typeText(AddVisaResidentWithPHNPage.departmentNumberInput, '6337109')
.typeText(AddVisaResidentWithPHNPage.visaIssueDateInput, '20210101')
.typeText(AddVisaResidentWithPHNPage.visaExpiryDateInput, '20221231')
.typeText(AddVisaResidentWithPHNPage.residenceDateInput, '20191108')
.typeText(AddVisaResidentWithPHNPage.coverageEffectiveDateInput, '20210301')
.typeText(AddVisaResidentWithPHNPage.coverageCancellationDateInput, '20211231')
.typeText(AddVisaResidentWithPHNPage.telephoneInput, '7802024022')
.typeText(AddVisaResidentWithPHNPage.address1Input, 'Test 111 ST')
.typeText(AddVisaResidentWithPHNPage.cityInput, 'VICTORIA')
.click(AddVisaResidentWithPHNPage.provinceSelect)
.click(provinceOption.withText('British Columbia'))
.typeText(AddVisaResidentWithPHNPage.postalCodeInput, 'V8V8V8')
.click(AddVisaResidentWithPHNPage.priorResidenceCodeInput)
.click(priorResidenceCodeOption.withText('British Columbia'))

// When I click the clear button
.click(AddVisaResidentWithPHNPage.clearButton)
// I expect the form to be cleared
.expect(AddVisaResidentWithPHNPage.groupNumberInput.value)
.eql('')
.expect(AddVisaResidentWithPHNPage.immigrationCodeSelect.value)
.eql('')
.expect(AddVisaResidentWithPHNPage.visaIssueDateInput.value)
.eql('')
.expect(AddVisaResidentWithPHNPage.visaExpiryDateInput.value)
.eql('')
.expect(AddVisaResidentWithPHNPage.residenceDateInput.value)
.eql('')
.expect(AddVisaResidentWithPHNPage.coverageEffectiveDateInput.value)
.eql(dayjs().startOf('month').format(OUTPUT_DATE_FORMAT))
.expect(AddVisaResidentWithPHNPage.coverageCancellationDateInput.value)
.eql('')
.expect(AddVisaResidentWithPHNPage.cityInput.value)
.eql('')
.expect(AddVisaResidentWithPHNPage.provinceSelect.value)
.eql('')
.expect(AddVisaResidentWithPHNPage.postalCodeInput.value)
.eql('')
.expect(AddVisaResidentWithPHNPage.telephoneInput.value)
.eql('')
})