From a6788e4d29a10a0653fd5b5077fc3475f73d6a44 Mon Sep 17 00:00:00 2001 From: Dima K Date: Wed, 12 Jul 2023 13:54:12 -0700 Subject: [PATCH] Effective Date and Time for Unit Notes (#1415) * Add EffectiveDateTime component * Add Expiry Date and Time to Unit Note * PR review updates. Added more tests. * Styling update for Effective Date component --- .../unitNotes/EffectiveDateTime.vue | 252 ++++++++++++++++++ .../components/unitNotes/UnitNoteReview.vue | 34 ++- ppr-ui/src/components/unitNotes/index.ts | 1 + ppr-ui/src/enums/effectiveDateTypes.ts | 9 + ppr-ui/src/enums/index.ts | 1 + ppr-ui/tests/unit/EffectiveDateTime.spec.ts | 68 +++++ ppr-ui/tests/unit/MhrUnitNote.spec.ts | 5 +- 7 files changed, 361 insertions(+), 9 deletions(-) create mode 100644 ppr-ui/src/components/unitNotes/EffectiveDateTime.vue create mode 100644 ppr-ui/src/enums/effectiveDateTypes.ts create mode 100644 ppr-ui/tests/unit/EffectiveDateTime.spec.ts diff --git a/ppr-ui/src/components/unitNotes/EffectiveDateTime.vue b/ppr-ui/src/components/unitNotes/EffectiveDateTime.vue new file mode 100644 index 000000000..40ab78608 --- /dev/null +++ b/ppr-ui/src/components/unitNotes/EffectiveDateTime.vue @@ -0,0 +1,252 @@ + + + + + diff --git a/ppr-ui/src/components/unitNotes/UnitNoteReview.vue b/ppr-ui/src/components/unitNotes/UnitNoteReview.vue index b5cc3cbb9..6c124b43b 100644 --- a/ppr-ui/src/components/unitNotes/UnitNoteReview.vue +++ b/ppr-ui/src/components/unitNotes/UnitNoteReview.vue @@ -23,12 +23,16 @@
-

2. Effective Date and Time

-

- Select the effective date and time for this {{ unitNoteType.header }}. Custom date and time can - be a date and time in the past. Notice of Caution will expire 90 days after the effective date. -

- // Placeholder for the component +
@@ -87,12 +91,15 @@ import { Attention } from '../mhrRegistration/ReviewConfirm' import { StaffPayment } from '@bcrs-shared-components/staff-payment' import { StaffPaymentOptions } from '@bcrs-shared-components/enums' import { StaffPaymentIF } from '@bcrs-shared-components/interfaces' +import EffectiveDateTime from './EffectiveDateTime.vue' +import { UnitNoteDocTypes } from '@/enums' export default defineComponent({ name: 'UnitNoteReview', components: { UnitNoteReviewDetailsTable, ContactInformation, + EffectiveDateTime, Attention, CertifyInformation, StaffPayment @@ -112,7 +119,7 @@ export default defineComponent({ } = storeToRefs(useStore()) const { - // setMhrUnitNote, + setMhrUnitNote, setMhrUnitNoteRegistration, setStaffPayment } = useStore() @@ -147,10 +154,21 @@ export default defineComponent({ setMhrUnitNoteRegistration({ key: 'submittingParty', value: val }) } + const handleEffectiveDateUpdate = (val: string) => { + setMhrUnitNote({ key: 'effectiveDateTime', value: val }) + // expiry date is 90 days from effective date + const expiryDateTime = new Date(new Date(val).getTime() + 90 * 24 * 60 * 60 * 1000).toISOString() + setMhrUnitNote({ key: 'expiryDateTime', value: expiryDateTime }) + } + const handleComponentValid = (component: MhrCompVal, isValid: boolean) => { setValidation(MhrSectVal.UNIT_NOTE_VALID, component, isValid) } + const effectiveDateDescForCAU = getMhrUnitNote.value.documentType === UnitNoteDocTypes.NOTICE_OF_CAUTION + ? ' Notice of Caution will expire 90 days after the effective date.' + : '' + const onStaffPaymentDataUpdate = (val: StaffPaymentIF) => { let staffPaymentData: StaffPaymentIF = { ...val @@ -202,8 +220,10 @@ export default defineComponent({ MhrCompVal, getMhrUnitNote, setSubmittingParty, + handleEffectiveDateUpdate, handleComponentValid, onStaffPaymentDataUpdate, + effectiveDateDescForCAU, ...toRefs(localState) } } diff --git a/ppr-ui/src/components/unitNotes/index.ts b/ppr-ui/src/components/unitNotes/index.ts index f45c68cb5..30578b883 100644 --- a/ppr-ui/src/components/unitNotes/index.ts +++ b/ppr-ui/src/components/unitNotes/index.ts @@ -2,3 +2,4 @@ export { default as UnitNotePanels } from './UnitNotePanels.vue' export { default as UnitNoteAdd } from './UnitNoteAdd.vue' export { default as UnitNoteReview } from './UnitNoteReview.vue' export { default as UnitNoteReviewDetailsTable } from './UnitNoteReviewDetailsTable.vue' +export { default as EffectiveDateTime } from './EffectiveDateTime.vue' diff --git a/ppr-ui/src/enums/effectiveDateTypes.ts b/ppr-ui/src/enums/effectiveDateTypes.ts new file mode 100644 index 000000000..0a90ad7ac --- /dev/null +++ b/ppr-ui/src/enums/effectiveDateTypes.ts @@ -0,0 +1,9 @@ +export enum EffectiveDateTypes { + PAST = 'past', + IMMEDIATE = 'immediate' +} + +export enum PeriodTypes { + AM = 'am', + PM = 'pm' +} diff --git a/ppr-ui/src/enums/index.ts b/ppr-ui/src/enums/index.ts index aa3098c51..a1effb0ff 100644 --- a/ppr-ui/src/enums/index.ts +++ b/ppr-ui/src/enums/index.ts @@ -29,6 +29,7 @@ export * from './business-types' export * from './transferTypes' export * from './homeOwnerPartyTypes' export * from './unitNoteDocTypes' +export * from './effectiveDateTypes' // external enums export { CorpTypeCd } from '@bcrs-shared-components/corp-type-module' diff --git a/ppr-ui/tests/unit/EffectiveDateTime.spec.ts b/ppr-ui/tests/unit/EffectiveDateTime.spec.ts new file mode 100644 index 000000000..1268197f5 --- /dev/null +++ b/ppr-ui/tests/unit/EffectiveDateTime.spec.ts @@ -0,0 +1,68 @@ +import Vue, { nextTick } from 'vue' +import Vuetify from 'vuetify' +import { Wrapper } from '@vue/test-utils' +import { createComponent, getTestId } from './utils' +import { EffectiveDateTime } from '@/components/unitNotes' +import { SharedDatePicker } from '@/components/common' +import { useStore } from '@/store/store' + +Vue.use(Vuetify) +const store = useStore() + +const props = { + content: { + title: 'Effective Date and Time', + description: 'Select the effective date and time for', + sideLabel: 'Effective Date and Time' + }, + validate: false +} + +describe('EffectiveDateTime', () => { + let wrapper: Wrapper + + beforeEach(async () => { + wrapper = createComponent(EffectiveDateTime, props) + }) + + afterEach(() => { + wrapper.destroy() + }) + + it('should render the component', () => { + const EffectiveDateTimeComponent = wrapper.findComponent(EffectiveDateTime) + + expect(EffectiveDateTimeComponent.exists()).toBeTruthy() + expect(EffectiveDateTimeComponent.findComponent(SharedDatePicker).exists()).toBeTruthy() + expect(EffectiveDateTimeComponent.find(getTestId('time-picker-fields')).exists()).toBeTruthy() + expect(EffectiveDateTimeComponent.find(getTestId('date-summary-label')).exists()).toBeFalsy() + + const immediateDate = ( + EffectiveDateTimeComponent.find(getTestId('immediate-date-radio'))).element + + const pastDate = ( + EffectiveDateTimeComponent.find(getTestId('past-date-radio'))).element + + expect(immediateDate.checked).toBeTruthy() + expect(pastDate.checked).toBeFalsy() + }) + + it('should set the Effective and Expiry Date Times', async () => { + const EffectiveDateTimeComponent = wrapper.findComponent(EffectiveDateTime) + + expect(wrapper.vm.effectiveDate).toBeTruthy() + + EffectiveDateTimeComponent.find(getTestId('past-date-radio')).trigger('click') + EffectiveDateTimeComponent.findComponent(SharedDatePicker).vm.$emit('emitDate', '2023-07-01') + expect(wrapper.vm.selectedPastDate).toBeTruthy() + + wrapper.vm.selectHour = '10' + wrapper.vm.selectMinute = '25' + + await Vue.nextTick() + + const dateSummaryLabel = EffectiveDateTimeComponent.find(getTestId('date-summary-label')) + expect(dateSummaryLabel.exists()).toBeTruthy() + expect(dateSummaryLabel.text()).toContain('July 1, 2023 at 10:25 am') + }) +}) diff --git a/ppr-ui/tests/unit/MhrUnitNote.spec.ts b/ppr-ui/tests/unit/MhrUnitNote.spec.ts index 78780cd21..3a7960d89 100644 --- a/ppr-ui/tests/unit/MhrUnitNote.spec.ts +++ b/ppr-ui/tests/unit/MhrUnitNote.spec.ts @@ -3,7 +3,7 @@ import Vuetify from 'vuetify' import { createPinia, setActivePinia } from 'pinia' import { useStore } from '../../src/store/store' import VueRouter from 'vue-router' -import { createLocalVue, mount, shallowMount, Wrapper } from '@vue/test-utils' +import { createLocalVue, mount, Wrapper } from '@vue/test-utils' import mockRouter from './MockRouter' import { MhrUnitNote } from '@/views' @@ -11,7 +11,7 @@ import { RouteNames, UnitNoteDocTypes } from '@/enums' import { getTestId, setupMockUser } from './utils' import { UnitNotesInfo } from '@/resources/unitNotes' import { CertifyInformation, ContactInformation, DocumentId, Remarks } from '@/components/common' -import { UnitNoteAdd, UnitNoteReview, UnitNoteReviewDetailsTable } from '@/components/unitNotes' +import { EffectiveDateTime, UnitNoteAdd, UnitNoteReview, UnitNoteReviewDetailsTable } from '@/components/unitNotes' import { Attention } from '@/components/mhrRegistration/ReviewConfirm' import { StaffPayment } from '@bcrs-shared-components/staff-payment' @@ -90,6 +90,7 @@ describe('MHR Unit Note Filing', () => { expect(UnitNoteReviewComponent.findComponent(UnitNoteReviewDetailsTable)).toBeTruthy() expect(UnitNoteReviewComponent.findComponent(ContactInformation)).toBeTruthy() + expect(UnitNoteReviewComponent.findComponent(EffectiveDateTime)).toBeTruthy() expect(UnitNoteReviewComponent.findComponent(Attention)).toBeTruthy() expect(UnitNoteReviewComponent.findComponent(CertifyInformation)).toBeTruthy() expect(UnitNoteReviewComponent.findComponent(StaffPayment)).toBeTruthy()