Skip to content

Commit

Permalink
Add unit tests for exempt Mhr Info
Browse files Browse the repository at this point in the history
  • Loading branch information
dimak1 committed Oct 20, 2023
1 parent a355325 commit 3f1b09b
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 12 deletions.
28 changes: 27 additions & 1 deletion ppr-ui/tests/unit/MhrInformation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ import {
mockedUnitNotes5,
mockedPerson2,
mockedExecutor,
mockedAdministrator
mockedAdministrator,
mockedResidentialExemptionOrder,
mockedUnitNotes3
} from './test-data'
import {
CertifyIF,
Expand Down Expand Up @@ -1040,4 +1042,28 @@ describe('Mhr Information', () => {
expect(CautionBoxComponent.find('.v-icon').classes('alert-icon')).toBeTruthy()
expect(CautionBoxComponent.text()).toContain(UnitNotesInfo[UnitNoteDocTypes.NOTICE_OF_TAX_SALE].header)
})

it('should have read only view for exempt MHR (Residential Exemption filed)', async () => {
wrapper = createComponent()

// add unit notes with Residential Exemption
await store.setMhrUnitNotes([mockedResidentialExemptionOrder, ...mockedUnitNotes3])
await store.setAuthRoles([AuthRoles.PPR_STAFF])
wrapper.vm.dataLoaded = true
await nextTick()

expect(wrapper.find(getTestId('correct-into-desc')).exists()).toBeFalsy()
expect(wrapper.find(getTestId('mhr-alert-msg')).exists()).toBeTruthy()
// message for Staff should contain unique text
expect(wrapper.find(getTestId('mhr-alert-msg')).text()).toContain('See Unit Notes for further information')
expect(wrapper.find(HomeOwners).find('#home-owners-change-btn').exists()).toBeFalsy()

// setup Qualified Supplier as Manufacturer
await store.setAuthRoles([AuthRoles.MHR_TRANSFER_SALE])
await store.setUserProductSubscriptionsCodes([ProductCode.MANUFACTURER])
await nextTick()

// message for QS should contain unique text
expect(wrapper.find(getTestId('mhr-alert-msg')).text()).toContain('contact BC Registries staff')
})
})
12 changes: 6 additions & 6 deletions ppr-ui/tests/unit/Tombstone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { AccountInformationIF, FinancingStatementIF, UserInfoIF } from '@/interf
import { mockedFinancingStatementComplete, mockedSelectSecurityAgreement } from './test-data'
import mockRouter from './MockRouter'
import { AuthRoles, ProductCode, RouteNames } from '@/enums'
import { convertDate, pacificDate } from '@/utils'
import { pacificDate } from '@/utils'

Vue.use(Vuetify)

Expand Down Expand Up @@ -150,7 +150,7 @@ describe('Tombstone component', () => {
expect(extraInfo.length).toBe(0)
})

it('renders Tombstone component peoperly for Search', async () => {
it('renders Tombstone component properly for Search', async () => {
wrapper = createComponent(RouteNames.SEARCH)
await nextTick()

Expand All @@ -168,7 +168,7 @@ describe('Tombstone component', () => {
expect(extraInfo.length).toBe(0)
})

it('renders Tombstone component peoperly for New Registration: length-trust', async () => {
it('renders Tombstone component properly for New Registration: length-trust', async () => {
wrapper = createComponent(RouteNames.LENGTH_TRUST)
await nextTick()

Expand All @@ -186,7 +186,7 @@ describe('Tombstone component', () => {
expect(extraInfo.length).toBe(0)
})

it('renders Tombstone component peoperly for New Registration: parties/debtors', async () => {
it('renders Tombstone component properly for New Registration: parties/debtors', async () => {
wrapper = createComponent(RouteNames.ADD_SECUREDPARTIES_AND_DEBTORS)
await nextTick()

Expand All @@ -204,7 +204,7 @@ describe('Tombstone component', () => {
expect(extraInfo.length).toBe(0)
})

it('renders Tombstone component peoperly for New Registration: collateral', async () => {
it('renders Tombstone component properly for New Registration: collateral', async () => {
wrapper = createComponent(RouteNames.ADD_COLLATERAL)
await nextTick()

Expand All @@ -222,7 +222,7 @@ describe('Tombstone component', () => {
expect(extraInfo.length).toBe(0)
})

it('renders Tombstone component peoperly for New Registration: review/confirm', async () => {
it('renders Tombstone component properly for New Registration: review/confirm', async () => {
wrapper = createComponent(RouteNames.REVIEW_CONFIRM)
await nextTick()

Expand Down
21 changes: 19 additions & 2 deletions ppr-ui/tests/unit/TombstoneDischarge.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Libraries
import Vue, { nextTick } from 'vue'
import Vue from 'vue'
import Vuetify from 'vuetify'
import VueRouter from 'vue-router'
import { createPinia, setActivePinia } from 'pinia'
Expand All @@ -12,7 +12,12 @@ import { TombstoneDischarge } from '@/components/tombstone'

// Other
import { FinancingStatementIF } from '@/interfaces'
import { mockedFinancingStatementComplete, mockedMhrInformation, mockedSelectSecurityAgreement } from './test-data'
import {
mockedFinancingStatementComplete,
mockedMhrInformation,
mockedMhrInformationExempt,
mockedSelectSecurityAgreement
} from './test-data'
import mockRouter from './MockRouter'
import { RouteNames } from '@/enums'
import { pacificDate } from '@/utils'
Expand Down Expand Up @@ -191,4 +196,16 @@ describe('TombstoneDischarge component - MHR', () => {
expect(extraInfo.at(0).text()).toContain('Registration Status:')
expect(extraInfo.at(0).text()).toContain('Cancelled')
})

it('should render Tombstone component for Exempt MHR (Residential Exemption unit note)', async () => {
await store.setMhrInformation(mockedMhrInformationExempt)
wrapper = createComponent(RouteNames.MHR_INFORMATION)
const tombstoneDischarge = wrapper.findComponent(TombstoneDischarge)
tombstoneDischarge.vm.isMhrInformation = true
await Vue.nextTick()

expect(tombstoneDischarge.find(tombstoneHeader).text())
.toContain('Manufactured Home Registration Number ' + mockedMhrInformationExempt.mhrNumber)
expect(tombstoneDischarge.find(tombstoneInfo).text()).toContain(mockedMhrInformationExempt.statusType)
})
})
51 changes: 49 additions & 2 deletions ppr-ui/tests/unit/UnitNotePanels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { createPinia, setActivePinia } from 'pinia'
import { useStore } from '../../src/store/store'
import { mount, createLocalVue, Wrapper } from '@vue/test-utils'
import { UnitNoteContentInfo, UnitNoteHeaderInfo, UnitNotePanel, UnitNotePanels } from '../../src/components/unitNotes'
import { UnitNoteDocTypes, UnitNoteStatusTypes } from '../../src/enums'
import { AuthRoles, ProductCode, UnitNoteDocTypes, UnitNoteStatusTypes } from '../../src/enums'
import {
mockedCancelledTaxSaleNote,
mockedNoticeOfRedemption,
mockedResidentialExemptionOrder,
mockedUnitNotes,
mockedUnitNotes2,
mockedUnitNotes3,
Expand All @@ -17,7 +18,7 @@ import {
} from './test-data'
import { BaseAddress } from '@/composables/address'
import { pacificDate, shortPacificDate } from '@/utils'
import { UnitNotesInfo, cancelledWithRedemptionNote } from '@/resources/unitNotes'
import { ResidentialExemptionQSDropDown, ResidentialExemptionStaffDropDown, UnitNotesInfo, cancelledWithRedemptionNote } from '@/resources/unitNotes'

Check warning on line 21 in ppr-ui/tests/unit/UnitNotePanels.spec.ts

View workflow job for this annotation

GitHub Actions / linting (20.5.1)

This line has a length of 149. Maximum allowed is 120
import { CancelUnitNoteIF, UnitNoteIF, UnitNotePanelIF } from '@/interfaces'
import { getTestId } from './utils'
import { useMhrUnitNote } from '@/composables'
Expand Down Expand Up @@ -471,4 +472,50 @@ describe('UnitNotePanels', () => {
`${UnitNotesInfo[UnitNoteDocTypes.NOTICE_OF_TAX_SALE].header} ${cancelledWithRedemptionNote}`
)
})

it('should show correct view for Staff and QS for Residential Exemption note', async () => {
const mixedNotes: UnitNoteIF[] =
[...mockedUnitNotes4, mockedResidentialExemptionOrder]

let wrapper = createComponent(mixedNotes)
wrapper.setProps({ hasResExemption: true })

// set Qualified Supplier role
await store.setAuthRoles([AuthRoles.MHR_TRANSFER_SALE])
await store.setUserProductSubscriptionsCodes([ProductCode.MANUFACTURER])

wrapper.find('#open-unit-notes-btn').trigger('click')
await nextTick()

// check dropdown for Qualified Supplier
expect(wrapper.vm.addUnitNoteDropdown).toBe(ResidentialExemptionQSDropDown)

// set Staff role
await store.setAuthRoles([AuthRoles.STAFF, AuthRoles.PPR_STAFF])

wrapper = createComponent(mixedNotes)
wrapper.setProps({ hasResExemption: true })

wrapper.find('#open-unit-notes-btn').trigger('click')
await nextTick()
await nextTick()

// check dropdown for Staff
expect(wrapper.vm.addUnitNoteDropdown).toBe(ResidentialExemptionStaffDropDown)

const resExemptionPanel = wrapper.findAllComponents(UnitNotePanel).at(1)
expect(resExemptionPanel.find('h3').text()).toBe(UnitNotesInfo[UnitNoteDocTypes.RESIDENTIAL_EXEMPTION_ORDER].header)

// expand Res Exemption panel
resExemptionPanel.find('.unit-note-menu-btn').trigger('click')
await nextTick()
await nextTick()

const resExemptionContentInfo = resExemptionPanel.findComponent(UnitNoteContentInfo)

// check visible and hidden sections of the panel info
expect(resExemptionContentInfo.find(getTestId('effective-date-info')).exists()).toBe(false)
expect(resExemptionContentInfo.find(getTestId('remarks-info')).exists()).toBe(true)
expect(resExemptionContentInfo.find(getTestId('person-giving-notice-info')).exists()).toBe(false)
})
})
14 changes: 13 additions & 1 deletion ppr-ui/tests/unit/test-data/mock-registration-new.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIRegistrationTypes, DraftTypes, UIRegistrationTypes, APIVehicleTypes, ActionTypes } from '@/enums'
import { APIRegistrationTypes, DraftTypes, APIVehicleTypes, ActionTypes, MhApiStatusTypes } from '@/enums'
import {
RegistrationTypesMiscellaneousCC,
RegistrationTypesStandard,
Expand Down Expand Up @@ -448,3 +448,15 @@ export const mockedMhrInformation: MhRegistrationSummaryIF = {
submittingParty: 'ABC SUBMITTING COMPANY',
username: 'BUSINESS REGISTRY TEST 1'
}

export const mockedMhrInformationExempt: MhRegistrationSummaryIF = {
clientReferenceId: 'UT-MHREG-SOLE',
createDateTime: '2023-10-15T09:18:13-07:00',
mhrNumber: '150575',
ownerNames: 'MARY-ANNE BICKNELL',
path: '/mhr/api/v1/registrations/150575',
registrationDescription: 'MANUFACTURED HOME REGISTRATION',
statusType: MhApiStatusTypes.EXEMPT.toLocaleLowerCase(),
submittingParty: 'ABC SUBMITTING COMPANY',
username: 'BUSINESS REGISTRY TEST 1'
}
13 changes: 13 additions & 0 deletions ppr-ui/tests/unit/test-data/mock-unit-notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,16 @@ export const mockedNoticeOfRedemption: CancelUnitNoteIF = {
status: UnitNoteStatusTypes.ACTIVE,
destroyed: false
}

// Residential Exemption - EXRS type
export const mockedResidentialExemptionOrder: UnitNoteIF = {
documentType: UnitNoteDocTypes.RESIDENTIAL_EXEMPTION_ORDER,
documentId: '12345678',
documentRegistrationNumber: '5544332',
documentDescription: UnitNotesInfo[UnitNoteDocTypes.RESIDENTIAL_EXEMPTION_ORDER].header,
createDateTime: '2023-08-20T09:00:00Z',
effectiveDateTime: '2023-08-20T09:00:00Z',
remarks: 'Residential Exemption remarks',
status: UnitNoteStatusTypes.ACTIVE,
destroyed: false
}

0 comments on commit 3f1b09b

Please sign in to comment.