Skip to content

Commit

Permalink
Fix validation in Home Owner Transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
dimak1 committed Jul 3, 2024
1 parent 015089c commit 251a585
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ppr-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ppr-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ppr-ui",
"version": "3.2.30",
"version": "3.2.31",
"private": true,
"appName": "Assets UI",
"sbcName": "SBC Common Components",
Expand Down
2 changes: 1 addition & 1 deletion ppr-ui/src/composables/mhrRegistration/useHomeOwners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export function useHomeOwners (isMhrTransfer: boolean = false, isMhrCorrection:
const hasNoGroups = [HomeTenancyTypes.SOLE, HomeTenancyTypes.JOINT].includes(getHomeTenancyType()) ||
groups.length === 0

return !hasNoGroups || !groups || groups.length >= 2 ||
return hasNoGroups || !groups || groups.length >= 2 ||
(!showGroups.value && groups.length === 1)
}

Expand Down
46 changes: 45 additions & 1 deletion ppr-ui/tests/unit/MhrTransferHomeOwners.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,54 @@ import {
} from '@/enums'
import { DeathCertificate, SupportingDocuments } from '@/components/mhrTransfers'
import { transferSupportingDocuments, transfersErrors, MixedRolesErrors } from '@/resources'
import { useNewMhrRegistration } from '@/composables'
import { useHomeOwners, useNewMhrRegistration } from '@/composables'

const store = useStore()

describe('useHomeOwners composable', () => {
it('test hasMinimumGroups', async () => {

// setup owners structure where 3 groups of sole owners were removed
// and one owner was added
const homeOwnerGroups: MhrRegistrationHomeOwnerGroupIF[] = [
{
groupId: 1,
interest: 'Undivided',
interestDenominator: 2,
interestNumerator: 1,
owners: [mockedRemovedPerson],
type: HomeTenancyTypes.SOLE,
action: ActionTypes.REMOVED
},
{
groupId: 2,
interest: 'Undivided',
interestDenominator: 2,
interestNumerator: 1,
owners: [mockedRemovedPerson],
type: HomeTenancyTypes.SOLE,
action: ActionTypes.REMOVED
},
{
groupId: 3,
owners: [mockedAddedPerson],
type: HomeTenancyTypes.SOLE,
action: ActionTypes.ADDED
}
]

await store.setMhrTransferHomeOwnerGroups(homeOwnerGroups)
await store.setMhrTransferType({ transferType: ApiTransferTypes.SALE_OR_GIFT } as TransferTypeSelectIF)

const useHomeOwnersComposable = useHomeOwners(true)
useHomeOwnersComposable.setShowGroups(true)

const { hasMinimumGroups } = useHomeOwnersComposable

expect(hasMinimumGroups()).toBe(true)
})
})

describe('Home Owners', () => {
let wrapper

Expand Down

0 comments on commit 251a585

Please sign in to comment.