Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QS: Transfer Unit Testing #1951

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})
})
}
Loading