Skip to content

Commit

Permalink
Check no person giving notice by default for decal replacement (#1993)
Browse files Browse the repository at this point in the history
Check no person giving notice by default for decal replacement
  • Loading branch information
flutistar authored Jul 26, 2024
1 parent f371920 commit 56e9507
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 11 deletions.
11 changes: 9 additions & 2 deletions ppr-ui/src/components/unitNotes/UnitNoteAdd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</template>

<script lang="ts">
import { computed, defineComponent, reactive, toRefs, watch } from 'vue'
import { computed, defineComponent, reactive, toRefs, watch, onMounted } from 'vue'
import { UnitNotesInfo } from '@/resources/unitNotes'
import { UnitNoteDocTypes } from '@/enums'
import { useStore } from '@/store/store'
Expand Down Expand Up @@ -136,7 +136,7 @@ export default defineComponent({
: personGivingNoticeContent
),
isNoticeOfTaxSale: computed((): boolean => props.docType === UnitNoteDocTypes.NOTICE_OF_TAX_SALE),
hasNoPersonGivingNotice: (getMhrUnitNote.value as UnitNoteIF).hasNoPersonGivingNotice || false,
hasNoPersonGivingNotice: props.docType === UnitNoteDocTypes.DECAL_REPLACEMENT || (getMhrUnitNote.value as UnitNoteIF).hasNoPersonGivingNotice || false,
// Remarks
unitNoteRemarks: (getMhrUnitNote.value as UnitNoteIF).remarks || '',
Expand Down Expand Up @@ -174,6 +174,13 @@ export default defineComponent({
emit('isValid', localState.isUnitNoteValid)
})
onMounted(() => {
if(props.docType === UnitNoteDocTypes.DECAL_REPLACEMENT) {
setValidation(MhrSectVal.UNIT_NOTE_VALID, MhrCompVal.PERSON_GIVING_NOTICE_VALID, localState.hasNoPersonGivingNotice)
handleStoreUpdate('hasNoPersonGivingNotice', localState.hasNoPersonGivingNotice)
}
})
return {
personGivingNoticeContent,
MhrCompVal,
Expand Down
46 changes: 37 additions & 9 deletions ppr-ui/tests/unit/MhrUnitNote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe('MHR Unit Note Filing', async () => {
})

it('should not show field errors when no person giving notice checkbox is checked', async () => {
wrapper = await createUnitNoteComponent(UnitNoteDocTypes.DECAL_REPLACEMENT)
wrapper = await createUnitNoteComponent(UnitNoteDocTypes.PUBLIC_NOTE)

let UnitNoteAddComponent = wrapper.findComponent(UnitNoteAdd)
expect(UnitNoteAddComponent.findAll('.border-error-left').length).toBe(0)
Expand All @@ -210,9 +210,9 @@ describe('MHR Unit Note Filing', async () => {

expect(wrapper.findComponent(UnitNoteReview).exists()).toBeFalsy()

// Asserts error shown before checking the checkbox
expect(UnitNoteAddComponent.findAll('.border-error-left').length).toBe(2)
expect(UnitNoteAddComponent.findAll('.error-text').length).toBe(2)
// Asserts error shown before checking the checkbox(document ID, remarks, contactInfo)
expect(UnitNoteAddComponent.findAll('.border-error-left').length).toBe(3)
expect(UnitNoteAddComponent.findAll('.error-text').length).toBe(3)

const PersonGivingNoticeComponent = UnitNoteAddComponent.findComponent(ContactInformation)

Expand All @@ -228,9 +228,9 @@ describe('MHR Unit Note Filing', async () => {
// Assert contact form is disabled
expect(PersonGivingNoticeComponent.find('#contact-info').exists()).toBeFalsy()

// Asserts error not shown after checking the checkbox (1 error remains from doucment ID)
expect(UnitNoteAddComponent.findAll('.border-error-left').length).toBe(1)
expect(UnitNoteAddComponent.findAll('.error-text').length).toBe(1)
// Asserts error not shown after checking the checkbox (2 error remains from doucment ID and remarks)
expect(UnitNoteAddComponent.findAll('.border-error-left').length).toBe(2)
expect(UnitNoteAddComponent.findAll('.error-text').length).toBe(2)
expect(PersonGivingNoticeComponent.findAll('.error-text').length).toBe(0)

// uncheck the checkbox
Expand All @@ -239,8 +239,8 @@ describe('MHR Unit Note Filing', async () => {
expect(store.getMhrUnitNote.hasNoPersonGivingNotice).toBe(false)

// Asserts error shown after the checkbox is unchecked and form is not disabled
expect(UnitNoteAddComponent.findAll('.border-error-left').length).toBe(2)
expect(UnitNoteAddComponent.findAll('.error-text').length).toBe(2)
expect(UnitNoteAddComponent.findAll('.border-error-left').length).toBe(3)
expect(UnitNoteAddComponent.findAll('.error-text').length).toBe(3)
expect(PersonGivingNoticeComponent.findAll('.error-text').length).toBeGreaterThan(0)
expect(PersonGivingNoticeComponent.find('#contact-info').classes('v-card--disabled')).toBe(false)

Expand Down Expand Up @@ -270,6 +270,34 @@ describe('MHR Unit Note Filing', async () => {
.checked).toBe(true)
})

it('Person Giving Notice should be checked if doctype is decal replacement', async () => {
wrapper = await createUnitNoteComponent(UnitNoteDocTypes.DECAL_REPLACEMENT)

let UnitNoteAddComponent = wrapper.findComponent(UnitNoteAdd)

expect((UnitNoteAddComponent.find('#no-person-giving-notice-checkbox').element as HTMLInputElement)
.checked).toBe(true)
await wrapper.find('#btn-stacked-submit').trigger('click')
await nextTick()

expect(wrapper.findComponent(UnitNoteReview).exists()).toBeFalsy()

// Asserts error shown before checking the checkbox(document ID)
expect(UnitNoteAddComponent.findAll('.border-error-left').length).toBe(1)
expect(UnitNoteAddComponent.findAll('.error-text').length).toBe(1)


await wrapper.findComponent(UnitNoteAdd).vm.$emit('isValid', true)
await wrapper.find('#btn-stacked-submit').trigger('click')
await nextTick()

// should be on the Review & Confirm screen
expect(wrapper.findComponent(UnitNoteReview).exists()).toBeTruthy()

// 'There no Person Giving Notice...' should be shown next to Person Giving Notice
expect(wrapper.find('.no-person-giving-notice').text())
.toBe(hasNoPersonGivingNoticeText)
})
// eslint-disable-next-line max-len
it('should not show EffectiveDate component for Decal Replacement, Public Note, and Confidential Note', async () => {
wrapper = await createUnitNoteComponent(UnitNoteDocTypes.DECAL_REPLACEMENT)
Expand Down

0 comments on commit 56e9507

Please sign in to comment.