Skip to content

Commit

Permalink
QS: Transfer Unit Testing (bcgov#1951)
Browse files Browse the repository at this point in the history
* QS: Transfer Unit Testing

* preserve content white space
  • Loading branch information
cameron-eyds authored Jun 25, 2024
1 parent bb3d0ed commit 1f35151
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ppr-ui/src/utils/validation-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export function normalizeObject (convertObject: any): any {
convertObject = omitBy(convertObject, overSome([isNil, isNaN, isEmpty])) // lodash function to remove empty properties
// this logic normalizes all string properties(values) are converted to uppercased and spaces are removed.
Object.entries(convertObject).forEach(([key, value]) => {
if (typeof value === 'string') convertObject[key] = value?.toUpperCase().replaceAll(' ', '').trim()
if (typeof value === 'string') convertObject[key] = value?.toUpperCase().trim()
})
return convertObject
}
Expand Down
2 changes: 1 addition & 1 deletion ppr-ui/src/views/mhrInformation/MhrInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@
</v-expand-transition>
<p
v-if="disableRoleBaseTransfer"
class="mt-9"
class="manufacturer-mismatch-text mt-9"
>
<span class="font-weight-bold">Note:</span> You cannot register an ownership transfer or change
because the home does not have a sole owner whose name matches your manufacturer’s name. Transfers can
Expand Down
80 changes: 76 additions & 4 deletions ppr-ui/tests/unit/MhrInformationQsTransfers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ import { defaultFlagSet } from '@/utils'
import { mockMhrTransferCurrentHomeOwner } from './test-data'
import { createComponent, mapMhrTypeToProductCode, setupCurrentHomeOwners, setupMockUser } from './utils'
import { HomeOwners, MhrInformation } from '@/views'
import { MhrSubTypes, ProductCode, RouteNames } from '@/enums'
import { MhApiFrozenDocumentTypes, MhApiStatusTypes, MhrSubTypes, ProductCode, RouteNames } from '@/enums'
import { nextTick } from 'vue'
import { LienAlert } from '@/components/common'
import { TransferType } from '@/components/mhrTransfers'
import { HomeOwnersTable } from '@/components/mhrRegistration'
import { useStore } from '@/store/store'
import { beforeAll } from 'vitest'
import { afterEach, beforeAll } from 'vitest'
import { useUserAccess } from '@/composables'
import flushPromises from 'flush-promises'


const store = useStore()

//TODO: Work in progress to test the variations between QS Type in Transfers
Expand Down Expand Up @@ -48,6 +47,12 @@ for (const subProduct of subProducts) {
await nextTick()
})

afterEach(async () => {
store.setLienType('')
store.setMhrStatusType(null)
store.setMhrFrozenDocumentType(null)
})

it('renders and displays the Mhr Information View for this QS type', async () => {
// Verify Base Wrapper
expect(wrapper.findComponent(MhrInformation).exists()).toBe(true)
Expand All @@ -71,8 +76,75 @@ for (const subProduct of subProducts) {
})

it('renders change owners button conditionally', async () => {
// enable transfers based on role
const isNotDealer = subProduct !== MhrSubTypes.DEALERS
wrapper.vm.enableRoleBasedTransfer = isNotDealer
await nextTick()

expect(wrapper.find('#home-owners-header').exists()).toBe(true)
expect(wrapper.vm.enableHomeOwnerChanges).toBe(isNotDealer)
expect(wrapper.find('#home-owners-change-btn').exists()).toBe(isNotDealer)
})

it('renders Lien Alert', async () => {
store.setLienType('mockLienType')
await nextTick()

expect(wrapper.find('#home-owners-header').exists()).toBe(true)
expect(wrapper.vm.enableHomeOwnerChanges).toBe(true)
expect(wrapper.find('#home-owners-change-btn').exists()).toBe(true)
// Verify disabled Home Owners Change btn
expect(wrapper.find('#home-owners-change-btn').attributes().disabled).toBeDefined()
})

it('verify frozen state due to affe filing', async () => {
store.setMhrStatusType(MhApiStatusTypes.FROZEN)
store.setMhrFrozenDocumentType(MhApiFrozenDocumentTypes.TRANS_AFFIDAVIT)
await nextTick()

// Verify showTransfer type
expect(wrapper.vm.showTransferType).toBe(false)

// Verify in-progress-filing messaging due to affe
expect(wrapper.vm.showInProgressMsg).toBe(true)

// Verify disabled Home Owners Change btn
expect(wrapper.find('#home-owners-change-btn').attributes().disabled).toBeDefined()
})

it('verify role based transfer messaging and button states', async () => {
const isManufacturer = subProduct === MhrSubTypes.MANUFACTURER
// enable transfers based on role
wrapper.vm.enableRoleBasedTransfer = subProduct !== MhrSubTypes.DEALERS
wrapper.vm.disableRoleBaseTransfer = isManufacturer
await nextTick()

// Verify showTransfer type
expect(wrapper.vm.showTransferType).toBe(false)

// Verify Mismatch text
expect(wrapper.find('.manufacturer-mismatch-text').exists()).toBe(isManufacturer)

// Role based tests
switch (subProduct) {
case MhrSubTypes.DEALERS:
expect(wrapper.find('#home-owners-change-btn').exists()).toBe(false)
break;
case MhrSubTypes.MANUFACTURER:
expect(wrapper.find('#home-owners-change-btn').attributes().disabled).toBeDefined()
// Verify Mismatch text content
expect(wrapper.find('.manufacturer-mismatch-text').text()).toContain('You cannot register an ownership ' +
'transfer or change because the home does not have a sole owner whose name matches your manufacturer’s' +
' name')
break;
case MhrSubTypes.LAWYERS_NOTARIES:
expect(wrapper.find('#home-owners-change-btn').attributes().disabled).toBeUndefined()
wrapper.find('#home-owners-change-btn').trigger('click')
await nextTick()
break;
}

// Verify showTransfer type
expect(wrapper.vm.showTransferType).toBe(subProduct === MhrSubTypes.LAWYERS_NOTARIES)
})
})
}

0 comments on commit 1f35151

Please sign in to comment.