diff --git a/frontend/src/components/coverage/enrollment/NameSearch.vue b/frontend/src/components/coverage/enrollment/NameSearch.vue index 1db11445..7ea6561d 100644 --- a/frontend/src/components/coverage/enrollment/NameSearch.vue +++ b/frontend/src/components/coverage/enrollment/NameSearch.vue @@ -44,7 +44,7 @@ import useVuelidate from '@vuelidate/core' import dayjs from 'dayjs' import { API_DATE_FORMAT, GENDERS } from '../../../util/constants' -import { validateDOB, validateFirstName, validateSecondName, validateSurname, VALIDATE_DOB_MESSAGE, VALIDATE_FIRST_NAME_MESSAGE, VALIDATE_SECOND_NAME_MESSAGE, VALIDATE_SURNAME_MESSAGE } from '../../../util/validators' +import { validateFutureDate, validateFirstName, validateSecondName, validateSurname, VALIDATE_DOB_MESSAGE, VALIDATE_FIRST_NAME_MESSAGE, VALIDATE_SECOND_NAME_MESSAGE, VALIDATE_SURNAME_MESSAGE } from '../../../util/validators' import { required, helpers, maxLength } from '@vuelidate/validators' import { useAlertStore } from '../../../stores/alert' import AppRadioButton from '../../ui/AppRadioButton.vue' @@ -128,7 +128,7 @@ export default { }, dateOfBirth: { required, - validateDOB: helpers.withMessage(VALIDATE_DOB_MESSAGE, validateDOB), + validateDOB: helpers.withMessage(VALIDATE_DOB_MESSAGE, validateFutureDate), }, gender: { required, diff --git a/frontend/src/components/coverage/enrollment/ResidentDetailsWithoutPHN.vue b/frontend/src/components/coverage/enrollment/ResidentDetailsWithoutPHN.vue index d0ed0921..4b7979a9 100644 --- a/frontend/src/components/coverage/enrollment/ResidentDetailsWithoutPHN.vue +++ b/frontend/src/components/coverage/enrollment/ResidentDetailsWithoutPHN.vue @@ -155,7 +155,7 @@ import { validateGroupNumber, validateGroupMemberNumber, validateDepartmentNumber, - validateDOB, + validateFutureDate, validateTelephone, validateMailingPostalCode, validatePostalCode, @@ -353,7 +353,7 @@ export default { }, dateOfBirth: { required, - validateDOB: helpers.withMessage(VALIDATE_DOB_MESSAGE, validateDOB), + validateDOB: helpers.withMessage(VALIDATE_DOB_MESSAGE, validateFutureDate), }, gender: { required, diff --git a/frontend/src/util/validators.js b/frontend/src/util/validators.js index d1ab75c3..64470338 100644 --- a/frontend/src/util/validators.js +++ b/frontend/src/util/validators.js @@ -79,16 +79,13 @@ function validatePostalCodeFormat(postalCode) { } /** - * Validates that the Date of Birth is not in the future. + * Validates that the Date is not in the future. */ -export function validateDOB(dateOfBirth) { - if (!helpers.req(dateOfBirth)) { +export function validateFutureDate(date) { + if (!helpers.req(date)) { return true } - if (dayjs(dateOfBirth).isAfter(dayjs().startOf('day'))) { - return false - } - return true + return !dayjs(date).isAfter(dayjs(), 'day') } /** diff --git a/frontend/src/views/eligibility/CoverageStatusCheck.vue b/frontend/src/views/eligibility/CoverageStatusCheck.vue index f23ab9f0..2aa8dd85 100644 --- a/frontend/src/views/eligibility/CoverageStatusCheck.vue +++ b/frontend/src/views/eligibility/CoverageStatusCheck.vue @@ -127,7 +127,7 @@ import AppHelp from '../../components/ui/AppHelp.vue' import AppTooltip from '../../components/ui/AppTooltip.vue' import EligibilityService from '../../services/EligibilityService' import useVuelidate from '@vuelidate/core' -import { validateDOB, validatePHN, VALIDATE_DOB_MESSAGE, VALIDATE_PHN_MESSAGE } from '../../util/validators' +import { validateFutureDate, validatePHN, VALIDATE_DOB_MESSAGE, VALIDATE_PHN_MESSAGE } from '../../util/validators' import { API_DATE_FORMAT, COVERAGE_END_REASONS } from '../../util/constants' import { required, helpers } from '@vuelidate/validators' import dayjs from 'dayjs' @@ -305,7 +305,7 @@ export default { }, dateOfBirth: { required, - validateDOB: helpers.withMessage(VALIDATE_DOB_MESSAGE, validateDOB), + validateDOB: helpers.withMessage(VALIDATE_DOB_MESSAGE, validateFutureDate), }, dateOfService: { required, diff --git a/frontend/src/views/reports/AuditReporting.vue b/frontend/src/views/reports/AuditReporting.vue index 65b62cd6..14883d16 100644 --- a/frontend/src/views/reports/AuditReporting.vue +++ b/frontend/src/views/reports/AuditReporting.vue @@ -103,7 +103,7 @@ import { API_DATE_TIME_FORMAT } from '../../util/constants' import useVuelidate from '@vuelidate/core' import { required, helpers } from '@vuelidate/validators' import { DEFAULT_ERROR_MESSAGE } from '../../util/constants.js' -import { validateUserIdLength, VALIDATE_USER_ID_MESSAGE } from '../../util/validators' +import { validateFutureDate, validateUserIdLength, VALIDATE_USER_ID_MESSAGE } from '../../util/validators' import { useAlertStore } from '../../stores/alert' import { handleServiceError } from '../../util/utils' import AppLabel from '../../components/ui/AppLabel.vue' @@ -113,6 +113,9 @@ import isSameOrBefore from 'dayjs/plugin/isSameOrBefore' import DataTable from 'primevue/datatable' import Column from 'primevue/column' +const VALIDATE_END_DATE_MESSAGE = 'End Date must not be in the future' +const VALIDATE_START_DATE_MESSAGE = 'Start Date must not be in the future' + export default { components: { AppLabel, Column, DataTable, AppDownloadLink }, name: 'AuditReporting', @@ -358,9 +361,11 @@ export default { }, startDate: { required, + validateFutureDate: helpers.withMessage(VALIDATE_START_DATE_MESSAGE, validateFutureDate), }, endDate: { required, + validateFutureDate: helpers.withMessage(VALIDATE_END_DATE_MESSAGE, validateFutureDate), }, } }, diff --git a/frontend/tests/e2e/tests/eligibility/CoverageStatusCheckTest.js b/frontend/tests/e2e/tests/eligibility/CoverageStatusCheckTest.js index 4ff06a83..b50872cc 100644 --- a/frontend/tests/e2e/tests/eligibility/CoverageStatusCheckTest.js +++ b/frontend/tests/e2e/tests/eligibility/CoverageStatusCheckTest.js @@ -12,7 +12,7 @@ const INVALID_DOB_ERROR_MESSAGE = 'Date of Birth must not be in the future' const DOS_REQUIRED_MESSAGE = 'Date Of Service is required' const INVALID_PHN_ERROR_MESSAGE = 'PHN format is invalid' -const SUCCESS_MESSAGE = 'HJMB001I SUCCESSFULLY COMPLETED' +const SUCCESS_MESSAGE = 'HJMB001I TRANSACTION COMPLETED' const PAGE_TO_TEST = SITE_UNDER_TEST + '/eligibility/coverageStatusCheck' diff --git a/frontend/tests/e2e/tests/reports/AuditReportingTest.js b/frontend/tests/e2e/tests/reports/AuditReportingTest.js index f2b4cadb..df3d2630 100644 --- a/frontend/tests/e2e/tests/reports/AuditReportingTest.js +++ b/frontend/tests/e2e/tests/reports/AuditReportingTest.js @@ -1,14 +1,17 @@ -import AlertPage from '../../pages/AlertPage' -import AuditReportingPage from '../../pages/reports/AuditReportingPage' +import dayjs from 'dayjs' + import { OUTPUT_DATE_FORMAT } from '../../../../src/util/constants' import { SITE_UNDER_TEST } from '../../configuration' -import dayjs from 'dayjs' +import AlertPage from '../../pages/AlertPage' +import AuditReportingPage from '../../pages/reports/AuditReportingPage' import { regularAccUser } from '../../roles/roles' const ERROR_MESSAGE = 'Please correct errors before submitting' const USER_ID_EXCEEDS_LENGTH = 'User ID cannot be longer than 100 characters' const START_DATE_REQUIRED_MESSAGE = 'Start Date is required' const END_DATE_REQUIRED_MESSAGE = 'End Date is required' +const START_DATE_FUTURE_MESSAGE = 'Start Date must not be in the future' +const END_DATE_FUTURE_MESSAGE = 'End Date must not be in the future' const START_DATE_AFTER_END_DATE = 'Start Date should not be after End Date' const DATE_RANGE_EXCEEDS_THREE_MONTH = 'End Date should not be more than 3 months from Start Date' const SUCCESS_MESSAGE = 'Transaction completed successfully' @@ -38,7 +41,8 @@ test('Check required fields validation', async (t) => { .expect(AuditReportingPage.errorText.nth(1).textContent) .contains(END_DATE_REQUIRED_MESSAGE) }) -test('Check user id not exceeds 100 character validation', async (t) => { + +test('Check user id not exceeds 100 character validation', async (t) => { await t // Given required fields aren't filled out (Start Date, End Date) // When I click the submit button @@ -68,7 +72,7 @@ test('Check Error message when end date exceeds 3 months from start date', async .pressKey('tab') // When I click the submit button .click(AuditReportingPage.submitButton) - // I expect a success message + // I expect an error message .expect(AlertPage.alertBannerText.textContent) .contains(DATE_RANGE_EXCEEDS_THREE_MONTH) }) @@ -91,11 +95,40 @@ test('Check Error message when end date is before start date', async (t) => { .pressKey('tab') // When I click the submit button .click(AuditReportingPage.submitButton) - // I expect a success message + // I expect an error message .expect(AlertPage.alertBannerText.textContent) .contains(START_DATE_AFTER_END_DATE) }) +test('Check Error message when start date and end date are in the future', async (t) => { + let tomorrow = dayjs().add(1, 'day') + await t + // Given the page is filled out correctly + .typeText(AuditReportingPage.userIdInput, 'hnweb1') + .click(AuditReportingPage.checkBoxInput1) //Check box + .click(AuditReportingPage.checkBoxInput2) //Check box + .click(AuditReportingPage.checkBoxInput3) //Check box + .click(AuditReportingPage.checkBoxInput4) //Check box + .selectText(AuditReportingPage.startDateInput) + .pressKey('delete') + .typeText(AuditReportingPage.startDateInput, tomorrow.format(OUTPUT_DATE_FORMAT)) + .pressKey('tab') + .selectText(AuditReportingPage.endDateInput) + .pressKey('delete') + .typeText(AuditReportingPage.endDateInput, tomorrow.format(OUTPUT_DATE_FORMAT)) + .pressKey('tab') + // When I click the submit button + .click(AuditReportingPage.submitButton) + // I expect an error message stating the page had errors and individual error messages for + // the Start Date and End Date fields + .expect(AlertPage.alertBannerText.textContent) + .contains(ERROR_MESSAGE) + .expect(AuditReportingPage.errorText.nth(0).textContent) + .contains(START_DATE_FUTURE_MESSAGE) + .expect(AuditReportingPage.errorText.nth(1).textContent) + .contains(END_DATE_FUTURE_MESSAGE) +}) + test('Check properly filled form passes validation and validate results', async (t) => { await t // Given the page is filled out correctly @@ -136,16 +169,18 @@ test('Check properly filled form passes validation and validate results', async .expect(AuditReportingPage.resultsRow1.child('td').nth(1).textContent) .eql('00000010') .expect(AuditReportingPage.resultsRow1.child('td').nth(2).textContent) - .eql('TRAININGHEALTHAUTH') + .eql('') .expect(AuditReportingPage.resultsRow1.child('td').nth(3).textContent) - .eql('hnweb1') + .eql('TRAININGHEALTHAUTH') .expect(AuditReportingPage.resultsRow1.child('td').nth(4).textContent) - .eql('2022-12-12T13:53:12.059') + .eql('hnweb1') .expect(AuditReportingPage.resultsRow1.child('td').nth(5).textContent) - .eql('9873102617') + .contains('2022-12-12') .expect(AuditReportingPage.resultsRow1.child('td').nth(6).textContent) - .eql('PHN') + .eql('9873102617') .expect(AuditReportingPage.resultsRow1.child('td').nth(7).textContent) + .eql('PHN') + .expect(AuditReportingPage.resultsRow1.child('td').nth(8).textContent) .eql('d9291fb5-6a30-43ea-bd71-891c02b939d0') })