diff --git a/ppr-ui/package-lock.json b/ppr-ui/package-lock.json index 822afb00c..28ecef9fc 100644 --- a/ppr-ui/package-lock.json +++ b/ppr-ui/package-lock.json @@ -1,12 +1,12 @@ { "name": "ppr-ui", - "version": "3.2.21", + "version": "3.2.22", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ppr-ui", - "version": "3.2.21", + "version": "3.2.22", "dependencies": { "@bcrs-shared-components/input-field-date-picker": "^1.0.0", "@lemoncode/fonk": "^1.5.1", diff --git a/ppr-ui/package.json b/ppr-ui/package.json index b846cb703..85da9e300 100644 --- a/ppr-ui/package.json +++ b/ppr-ui/package.json @@ -1,6 +1,6 @@ { "name": "ppr-ui", - "version": "3.2.21", + "version": "3.2.22", "private": true, "appName": "Assets UI", "sbcName": "SBC Common Components", diff --git a/ppr-ui/src/components/common/CollapsibleCard.vue b/ppr-ui/src/components/common/CollapsibleCard.vue new file mode 100644 index 000000000..be8d8ee85 --- /dev/null +++ b/ppr-ui/src/components/common/CollapsibleCard.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/ppr-ui/src/components/common/index.ts b/ppr-ui/src/components/common/index.ts index 85066b28c..456bdfefd 100644 --- a/ppr-ui/src/components/common/index.ts +++ b/ppr-ui/src/components/common/index.ts @@ -38,3 +38,4 @@ export { default as ReviewCard } from './ReviewCard.vue' export { default as LienAlert } from './LienAlert.vue' export { default as UpdatedBadge } from './UpdatedBadge.vue' export { default as StaffPayment } from './StaffPayment.vue' +export { default as CollapsibleCard } from './CollapsibleCard.vue' diff --git a/ppr-ui/src/components/mhrRegistration/HomeOwners/HomeOwnersTable.vue b/ppr-ui/src/components/mhrRegistration/HomeOwners/HomeOwnersTable.vue index f39cb7938..e27223165 100644 --- a/ppr-ui/src/components/mhrRegistration/HomeOwners/HomeOwnersTable.vue +++ b/ppr-ui/src/components/mhrRegistration/HomeOwners/HomeOwnersTable.vue @@ -3,7 +3,7 @@ id="home-owner-table-card" flat rounded - :class="{ 'border-error-left': showTableError }" + :class="{ 'border-error-left': showTableError && !hideTableErrors }" >
+
+ + + + + + +
+ + + + + diff --git a/ppr-ui/src/components/mhrRegistration/HomeOwners/TableGroupHeader.vue b/ppr-ui/src/components/mhrRegistration/HomeOwners/TableGroupHeader.vue index d9f67a121..3d0faedbe 100644 --- a/ppr-ui/src/components/mhrRegistration/HomeOwners/TableGroupHeader.vue +++ b/ppr-ui/src/components/mhrRegistration/HomeOwners/TableGroupHeader.vue @@ -407,7 +407,8 @@ import { FormIF, MhrRegistrationFractionalOwnershipIF, MhrHomeOwnerGroupIF, - MhrRegistrationHomeOwnerIF + MhrRegistrationHomeOwnerIF, + MhrRegistrationHomeOwnerGroupIF } from '@/interfaces/' import { ActionTypes } from '@/enums' import { toTitleCase } from '@/utils' @@ -432,6 +433,10 @@ export default defineComponent({ type: Array as () => MhrRegistrationHomeOwnerIF[], default: () => [] }, + ownerGroups: { + type: Array as () => MhrRegistrationHomeOwnerGroupIF[], + default: () => [] + }, showEditActions: { type: Boolean, default: true @@ -460,7 +465,6 @@ export default defineComponent({ markGroupForRemoval, undoGroupChanges, hasUndefinedGroupInterest, - getTransferOrRegistrationHomeOwnerGroups, getHomeTenancyType, getGroupTenancyType, getCurrentGroupById, @@ -483,13 +487,13 @@ export default defineComponent({ isHomeFractionalOwnershipValid: false, fractionalData: {} as MhrRegistrationFractionalOwnershipIF, group: computed((): MhrHomeOwnerGroupIF => { - return find(getTransferOrRegistrationHomeOwnerGroups(), { groupId: props.groupId }) + return find(props.ownerGroups, { groupId: props.groupId }) }), ownersCount: computed((): number => { return props.owners.filter(owner => owner.action !== ActionTypes.REMOVED && !!owner.ownerId).length }), hasUndefinedInterest: computed((): boolean => { - return hasUndefinedGroupInterest(getTransferOrRegistrationHomeOwnerGroups()) && + return hasUndefinedGroupInterest(props.ownerGroups) && !(localState.group.interestNumerator && localState.group.interestDenominator) }), previousOwnersLabel: computed((): string => { diff --git a/ppr-ui/src/components/mhrRegistration/HomeOwners/index.ts b/ppr-ui/src/components/mhrRegistration/HomeOwners/index.ts index 0f9bb6e17..d9656f61f 100644 --- a/ppr-ui/src/components/mhrRegistration/HomeOwners/index.ts +++ b/ppr-ui/src/components/mhrRegistration/HomeOwners/index.ts @@ -5,3 +5,4 @@ export { default as HomeOwnerGroups } from './HomeOwnerGroups.vue' export { default as TableGroupHeader } from './TableGroupHeader.vue' export { default as FractionalOwnership } from './FractionalOwnership.vue' export { default as HomeOwnersMixedRolesError } from './HomeOwnersMixedRolesError.vue' +export { default as PreviousHomeOwners } from './PreviousHomeOwners.vue' diff --git a/ppr-ui/src/composables/mhrRegistration/useHomeOwners.ts b/ppr-ui/src/composables/mhrRegistration/useHomeOwners.ts index eb0fe1df4..96989f9d7 100644 --- a/ppr-ui/src/composables/mhrRegistration/useHomeOwners.ts +++ b/ppr-ui/src/composables/mhrRegistration/useHomeOwners.ts @@ -42,7 +42,8 @@ export function useHomeOwners (isMhrTransfer: boolean = false, isMhrCorrection: getMhrTransferHomeOwnerGroups, getMhrTransferHomeOwners, getMhrTransferCurrentHomeOwnerGroups, - getMhrTransferType + getMhrTransferType, + isMhrReRegistration } = storeToRefs(useStore()) // Get Transfer or Registration Home Owners @@ -115,7 +116,8 @@ export function useHomeOwners (isMhrTransfer: boolean = false, isMhrCorrection: // Variable to track if owners has a valid combination of Executor/Trustee/Admin (ETA) Owners const hasETA = getTransferOrRegistrationHomeOwnerGroups().some(group => hasExecutorTrusteeAdmin(group)) - const commonCondition = (isMhrTransfer || isMhrCorrection) ? groups.length > 1 : showGroups.value + const commonCondition = + (isMhrTransfer || isMhrCorrection || isMhrReRegistration.value) ? groups.length > 1 : showGroups.value // Special case where a defined Group is orphaned using remove functionality, we want to preserve the Group Type. const isSingleInvalidGroup = !!groups[0]?.interestNumerator && !!groups[0]?.interestDenominator diff --git a/ppr-ui/src/composables/mhrRegistration/useMhrReRegistration.ts b/ppr-ui/src/composables/mhrRegistration/useMhrReRegistration.ts index b57ff5c2d..b07a4a730 100644 --- a/ppr-ui/src/composables/mhrRegistration/useMhrReRegistration.ts +++ b/ppr-ui/src/composables/mhrRegistration/useMhrReRegistration.ts @@ -1,16 +1,28 @@ import { HomeCertificationOptions } from '@/enums' -import { MhRegistrationSummaryIF } from '@/interfaces' +import { MhRegistrationSummaryIF, MhrRegistrationHomeOwnerGroupIF } from '@/interfaces' import { MhrReRegistrationType } from '@/resources' import { useStore } from '@/store/store' import { fetchMhRegistration, getMhrDraft } from '@/utils' import { useNewMhrRegistration } from './useNewMhrRegistration' import { cloneDeep } from 'lodash' import { useMhrInformation } from '../mhrInformation' +import { useHomeOwners } from './useHomeOwners' +import { storeToRefs } from 'pinia' export const useMhrReRegistration = () => { - const { setMhrBaseline, setRegistrationType, setMhrDraftNumber } = useStore() + const { + setMhrBaseline, + setRegistrationType, + setMhrDraftNumber, + setMhrRegistrationHomeOwnerGroups, + setMhrReRegistrationPreviousOwnerGroups, + setMhrReRegistrationPreviousTenancyType, + setMhrNumber, + setMhrStatusType + } = useStore() + + const { getMhrRegistrationHomeOwnerGroups } = storeToRefs(useStore()) - const { setMhrNumber, setMhrStatusType } = useStore() const { parseMhrPermitData } = useMhrInformation() const initMhrReRegistration = async (mhrSummary: MhRegistrationSummaryIF): Promise => @@ -43,6 +55,9 @@ export const useMhrReRegistration = () => { null if (!isDraft) { + // set previous owners to be displayed on Home Owners step of Re-Registration + setupPreviousOwners(data.ownerGroups) + // remove props that should not be pre-populated into Re-Registration data.documentId = '' data.ownerGroups = [] @@ -74,8 +89,27 @@ export const useMhrReRegistration = () => { } } + /** + * Function to setup previous home owners' information for Home Owners step. + * To reuse existing functionality of getHomeTenancyType() we set Mhr Registrations state + * and then capture the Home Tenancy Type. + * + * @param {MhrRegistrationHomeOwnerGroupIF[]} ownerGroups - An array of owner groups. + * @returns {void} + */ + const setupPreviousOwners = (ownerGroups: MhrRegistrationHomeOwnerGroupIF[]): void => { + setMhrRegistrationHomeOwnerGroups(cloneDeep(ownerGroups)) + + const prevOwnersTenancyType: string = useHomeOwners().getHomeTenancyType() + const prevOwnerGroups: MhrRegistrationHomeOwnerGroupIF[] = getMhrRegistrationHomeOwnerGroups.value + + setMhrReRegistrationPreviousTenancyType(prevOwnersTenancyType) + setMhrReRegistrationPreviousOwnerGroups(cloneDeep(prevOwnerGroups)) + } + return { initMhrReRegistration, - initDraftMhrReRegistration + initDraftMhrReRegistration, + setupPreviousOwners } } diff --git a/ppr-ui/src/interfaces/mhr-registration-interfaces/MhrRegistrationIF.ts b/ppr-ui/src/interfaces/mhr-registration-interfaces/MhrRegistrationIF.ts index 43e84698b..6257fdecf 100644 --- a/ppr-ui/src/interfaces/mhr-registration-interfaces/MhrRegistrationIF.ts +++ b/ppr-ui/src/interfaces/mhr-registration-interfaces/MhrRegistrationIF.ts @@ -26,10 +26,10 @@ export interface NewMhrRegistrationApiIF { documentId?: string documentType?: string mhrNumber?: string - registrationType?: APIRegistrationTypes, + registrationType?: APIRegistrationTypes clientReferenceId?: string declaredValue?: string - submittingParty: SubmittingPartyIF, + submittingParty: SubmittingPartyIF ownerGroups: MhrRegistrationHomeOwnerGroupIF[] location: MhrRegistrationHomeLocationIF description: MhrRegistrationDescriptionIF diff --git a/ppr-ui/src/interfaces/store-interfaces/state-model-interface.ts b/ppr-ui/src/interfaces/store-interfaces/state-model-interface.ts index 14ad4543f..7539bdffc 100644 --- a/ppr-ui/src/interfaces/store-interfaces/state-model-interface.ts +++ b/ppr-ui/src/interfaces/store-interfaces/state-model-interface.ts @@ -33,7 +33,8 @@ import { ExemptionValidationIF, StaffPaymentIF, MhrTransportPermitIF, - AddEditSaNoticeIF + AddEditSaNoticeIF, + MhrRegistrationHomeOwnerGroupIF } from '@/interfaces' import { UnitNoteIF } from '@/interfaces/unit-note-interfaces/unit-note-interface' @@ -42,7 +43,7 @@ export interface StateModelIF { accountInformation: AccountInformationIF accountProductSubscriptions: AccountProductSubscriptionIF userProductSubscriptions: Array - userProductSubscriptionsCodes: Array, + userProductSubscriptionsCodes: Array authorization: AuthorizationIF certifyInformation: CertifyIF folioOrReferenceNumber: string @@ -90,6 +91,8 @@ export interface StateModelIF { userInfo: UserInfoIF mhrInformation: MhRegistrationSummaryIF mhrRegistration: MhrRegistrationIF + mhrReRegistrationPreviousOwnerGroups?: MhrRegistrationHomeOwnerGroupIF[] + mhrReRegistrationPreviousTenancyType?: string mhrBaseline?: MhrRegistrationIF mhrUnitNotes?: Array mhrUnitNote: UnitNoteRegistrationIF // used for Unit Note filing/registration @@ -102,7 +105,7 @@ export interface StateModelIF { mhrValidationState?: MhrValidationStateIF mhrValidationManufacturerState?: MhrValidationManufacturerStateIF mhrTransfer: MhrTransferIF - mhrInfoValidationState: mhrInfoValidationStateIF, + mhrInfoValidationState: mhrInfoValidationStateIF mhrTransportPermit: MhrTransportPermitIF mhrOriginalTransportPermit?: MhrTransportPermitIF // original Transport Permit filing when working with Amendments } diff --git a/ppr-ui/src/store/state/state-model.ts b/ppr-ui/src/store/state/state-model.ts index 9f51a6747..81375a800 100644 --- a/ppr-ui/src/store/state/state-model.ts +++ b/ppr-ui/src/store/state/state-model.ts @@ -168,7 +168,7 @@ export const stateModel: StateModelIF = { permitRegistrationNumber: '', permitStatus: null, permitLandStatusConfirmation: null -}, + }, // Manufactured Home Registration State mhrRegistration: { draftNumber: '', @@ -253,6 +253,7 @@ export const stateModel: StateModelIF = { otherRemarks: '' } }, + // Manufactured Home Registration baseline (Corrections/Amendments) mhrBaseline: null, // Mhr Transport Permit @@ -468,7 +469,7 @@ export const stateModel: StateModelIF = { region: null, country: null, postalCode: '' - }, + } }, isRequirementsConfirmed: false, authorization: { diff --git a/ppr-ui/src/store/store.ts b/ppr-ui/src/store/store.ts index a035877b0..947ff0ae4 100644 --- a/ppr-ui/src/store/store.ts +++ b/ppr-ui/src/store/store.ts @@ -240,10 +240,6 @@ export const useStore = defineStore('assetsStore', () => { APIRegistrationTypes.MHR_PUBLIC_AMENDMENT ].includes(state.value.registration?.registrationType?.registrationTypeAPI) }) - const isMhrReRegistration = computed(() => { - return isRoleStaffReg.value && - state.value.registration?.registrationType?.registrationTypeAPI === APIRegistrationTypes.MHR_RE_REGISTRATION - }) const isMhrStaffRegistration = computed(() => { return isMhrRegistration.value && isRoleStaff.value }) @@ -711,6 +707,18 @@ export const useStore = defineStore('assetsStore', () => { return state.value.mhrUnitNoteValidationState }) + // Re-Registration Getters + const isMhrReRegistration = computed(() => { + return isRoleStaffReg.value && + state.value.registration?.registrationType?.registrationTypeAPI === APIRegistrationTypes.MHR_RE_REGISTRATION + }) + const getMhrReRegistrationPreviousOwnerGroups = computed((): MhrRegistrationHomeOwnerGroupIF[] => { + return state.value.mhrReRegistrationPreviousOwnerGroups + }) + const getMhrReRegistrationPreviousTenancyType = computed((): string => { + return state.value.mhrReRegistrationPreviousTenancyType + }) + /** MHR Getters **/ const getMhrInfoValidation = computed(() => { return state.value.mhrInfoValidationState @@ -1282,6 +1290,15 @@ export const useStore = defineStore('assetsStore', () => { state.value.registrationTable.baseMhRegs = baseRegs } + // MHR Re-Registration + function setMhrReRegistrationPreviousOwnerGroups (ownerGroups: MhrRegistrationHomeOwnerGroupIF[]) { + state.value.mhrReRegistrationPreviousOwnerGroups = ownerGroups + } + + function setMhrReRegistrationPreviousTenancyType (tenancyType: string) { + state.value.mhrReRegistrationPreviousTenancyType = tenancyType + } + // MHR Information function setMhrNumber (mhrNumber: string) { state.value.mhrInformation.mhrNumber = mhrNumber @@ -1551,7 +1568,6 @@ export const useStore = defineStore('assetsStore', () => { getRegistrationNumber, getRegistrationType, isMhrRegistration, - isMhrReRegistration, isMhrStaffRegistration, isMhrManufacturerRegistration, isMhrRegistrationReviewValid, @@ -1559,6 +1575,11 @@ export const useStore = defineStore('assetsStore', () => { getRegistrationOther, getRegistration, + // Re-Registration Getters + isMhrReRegistration, + getMhrReRegistrationPreviousOwnerGroups, + getMhrReRegistrationPreviousTenancyType, + // Search getters getSearchResults, getManufacturedHomeSearchResults, @@ -1769,6 +1790,10 @@ export const useStore = defineStore('assetsStore', () => { setMhrTableHistory, setMhrRegistrationOwnLand, + // MHR Re-Registration + setMhrReRegistrationPreviousOwnerGroups, + setMhrReRegistrationPreviousTenancyType, + // MHR Information setMhrNumber, setMhrInformation, diff --git a/ppr-ui/src/views/newMhrRegistration/HomeOwners.vue b/ppr-ui/src/views/newMhrRegistration/HomeOwners.vue index e4d2db4ef..63f532afb 100644 --- a/ppr-ui/src/views/newMhrRegistration/HomeOwners.vue +++ b/ppr-ui/src/views/newMhrRegistration/HomeOwners.vue @@ -416,6 +416,8 @@ />
+ + @@ -423,6 +425,7 @@ import { computed, defineComponent, onBeforeMount, reactive, toRefs, watch } from 'vue' import { useStore } from '@/store/store' import { AddEditHomeOwner, HomeOwnersTable } from '@/components/mhrRegistration/HomeOwners' +import PreviousHomeOwners from '@/components/mhrRegistration/HomeOwners/PreviousHomeOwners.vue' import { BaseDialog } from '@/components/dialogs' import { SimpleHelpToggle } from '@/components/common' import { @@ -430,11 +433,12 @@ import { useMhrCorrections, useMhrInformation, useMhrValidations, + useNavigation, useTransferOwners } from '@/composables' import { MhrRegistrationHomeOwnerGroupIF } from '@/interfaces' -import { ActionTypes } from '@/enums' +import { ActionTypes, RouteNames } from '@/enums' import { transfersErrors } from '@/resources' import { formatCurrency } from '@/utils' @@ -446,7 +450,8 @@ export default defineComponent({ AddEditHomeOwner, BaseDialog, HomeOwnersTable, - SimpleHelpToggle + SimpleHelpToggle, + PreviousHomeOwners }, props: { isMhrTransfer: { @@ -466,6 +471,7 @@ export default defineComponent({ setup (props, context) { const { isRoleStaff, + isMhrReRegistration, getMhrTransferHomeOwnerGroups, getMhrTransferCurrentHomeOwnerGroups, getMhrRegistrationValidationModel, @@ -475,6 +481,8 @@ export default defineComponent({ getMhrTransferDeclaredValue } = storeToRefs(useStore()) + const { isRouteName } = useNavigation() + const { getUiTransferType, isFrozenMhrDueToUnitNote @@ -587,7 +595,11 @@ export default defineComponent({ }), changesRequired: computed((): boolean => { return props.validateTransfer && !hasUnsavedChanges.value - }) + }), + showPreviousHomeOwners: computed((): boolean => + // show only for Mhr Re-Registration flow on Home Owners step + isMhrReRegistration.value && isRouteName(RouteNames.HOME_OWNERS) + ) }) const hideShowRemovedOwners = (forceShow: boolean = false): void => { diff --git a/ppr-ui/tests/unit/MhrInformation.spec.ts b/ppr-ui/tests/unit/MhrInformation.spec.ts index 20347e745..e3e3382e6 100644 --- a/ppr-ui/tests/unit/MhrInformation.spec.ts +++ b/ppr-ui/tests/unit/MhrInformation.spec.ts @@ -26,7 +26,7 @@ import { ProductType, ProductStatus } from '@/enums' -import { HomeOwnersTable } from '@/components/mhrRegistration/HomeOwners' +import { HomeOwnersTable, PreviousHomeOwners } from '@/components/mhrRegistration/HomeOwners' import { createComponent, getTestId } from './utils' import { mockedAddedPerson, @@ -157,6 +157,8 @@ describe('Mhr Information', async () => { expect(wrapper.findComponent(TransferType).exists()).toBe(false) expect(wrapper.findComponent(HomeOwners).exists()).toBeTruthy() + expect(wrapper.findComponent(HomeOwners).findComponent(PreviousHomeOwners).exists()).toBeFalsy() + const homeOwnersTable = wrapper.findComponent(HomeOwnersTable) expect(homeOwnersTable.exists()).toBeTruthy() expect(homeOwnersTable.text()).toContain(mockMhrTransferCurrentHomeOwner.owners[0].organizationName) @@ -955,6 +957,7 @@ describe('Mhr Information', async () => { const homeOwnersComponent = wrapper.findComponent(HomeOwners) await store.setMhrTransferHomeOwnerGroups(homeOwnerGroup) expect(homeOwnersComponent.findComponent(HomeOwnersTable).exists()).toBeTruthy() + expect(homeOwnersComponent.findComponent(PreviousHomeOwners).exists()).toBeFalsy() // check owners are in table expect(homeOwnersComponent.vm.getHomeOwners.length).toBe(2) diff --git a/ppr-ui/tests/unit/MhrRegistration.spec.ts b/ppr-ui/tests/unit/MhrRegistration.spec.ts index 189695fc4..cf3d6d6c1 100644 --- a/ppr-ui/tests/unit/MhrRegistration.spec.ts +++ b/ppr-ui/tests/unit/MhrRegistration.spec.ts @@ -7,16 +7,18 @@ import { ButtonFooter } from '@/components/common' import { Stepper, StickyContainer } from '@/components/common' import { MhrCorrectionStaff, MhrReRegistrationType, MhrRegistrationType } from '@/resources' import { defaultFlagSet } from '@/utils' -import { AuthRoles, MhApiStatusTypes, RouteNames } from '@/enums' -import { mockMhrReRegistration, mockedManufacturerAuthRoles, mockedMhrRegistration } from './test-data' +import { AuthRoles, HomeTenancyTypes, MhApiStatusTypes, RouteNames } from '@/enums' +import { mockMhrReRegistration, mockedManufacturerAuthRoles, mockedMhrRegistration, mockedPerson } from './test-data' import { createComponent, getTestId } from './utils' -import { useNewMhrRegistration } from '@/composables' +import { useMhrReRegistration, useNewMhrRegistration } from '@/composables' import { nextTick } from 'vue' import CautionBox from '@/components/common/CautionBox.vue' import HomeOwnersTable from '@/components/mhrRegistration/HomeOwners/HomeOwnersTable.vue' import SubmittingParty from '@/views/newMhrRegistration/SubmittingParty.vue' import HomeLocation from '@/views/newMhrRegistration/HomeLocation.vue' import HomeOwners from '@/views/newMhrRegistration/HomeOwners.vue' +import { MhrRegistrationHomeOwnerGroupIF } from '@/interfaces' +import { PreviousHomeOwners } from '@/components/mhrRegistration' const store = useStore() @@ -116,6 +118,8 @@ describe('Mhr Re-Registration', () => { }) await nextTick() + const homeOwnerGroup = [{ groupId: 1, owners: [mockedPerson] }] as MhrRegistrationHomeOwnerGroupIF[] + useMhrReRegistration().setupPreviousOwners(homeOwnerGroup) useNewMhrRegistration().initDraftOrCurrentMhr(mockMhrReRegistration as any, false) await nextTick() @@ -123,7 +127,6 @@ describe('Mhr Re-Registration', () => { }) it('renders and displays the Mhr Re-Registration View', async () => { - expect(wrapper.findComponent(MhrRegistration).exists()).toBe(true) expect(wrapper.find('#re-registration-header h1').text()).toBe(MhrReRegistrationType.registrationTypeUI) expect(wrapper.vm.$route.name).toBe(RouteNames.SUBMITTING_PARTY) @@ -138,6 +141,19 @@ describe('Mhr Re-Registration', () => { expect(homeOwnersTable.find(getTestId('no-data-msg')).exists()).toBe(true) // should not have owners for Re-Reg expect(wrapper.findComponent(HomeOwners).findComponent(CautionBox).exists()).toBe(false) + // Previous Home Owners + const prevOwnersCard = wrapper.findComponent(PreviousHomeOwners) + expect(prevOwnersCard.exists()).toBe(true) + expect(prevOwnersCard.find(getTestId('card-header-label')).text()).toBe('Previous Home Owners') + expect(prevOwnersCard.find(getTestId('card-toggle-label')).text()).toBe('Hide Previous Owners') + expect(prevOwnersCard.find(getTestId('home-owner-tenancy-type')).text()).toContain(HomeTenancyTypes.SOLE) + expect(prevOwnersCard.findComponent(HomeOwnersTable).exists()).toBe(true) + + const homeOwnersTableText = prevOwnersCard.findComponent(HomeOwnersTable).text() + expect(homeOwnersTableText).toContain(mockedPerson.individualName.first) + expect(homeOwnersTableText).toContain(mockedPerson.phoneNumber) + expect(homeOwnersTableText).toContain(mockedPerson.address.street) + // Go to Home Location step wrapper.findComponent(Stepper).findAll('.step').at(3).trigger('click') await nextTick() diff --git a/ppr-ui/tests/unit/MhrTransferHomeOwners.spec.ts b/ppr-ui/tests/unit/MhrTransferHomeOwners.spec.ts index f3423aa20..1c534fc68 100644 --- a/ppr-ui/tests/unit/MhrTransferHomeOwners.spec.ts +++ b/ppr-ui/tests/unit/MhrTransferHomeOwners.spec.ts @@ -7,7 +7,8 @@ import { HomeOwnersTable, HomeOwnerGroups, TableGroupHeader, - HomeOwnerRoles + HomeOwnerRoles, + PreviousHomeOwners } from '@/components/mhrRegistration/HomeOwners' import { InfoChip, InputFieldDatePicker, SimpleHelpToggle } from '@/components/common' import { @@ -121,6 +122,7 @@ describe('Home Owners', () => { expect(wrapper.findComponent(AddEditHomeOwner).exists()).toBeFalsy() // Hidden by default expect(wrapper.findComponent(HomeOwnersTable).exists()).toBeTruthy() expect(wrapper.findComponent(SimpleHelpToggle).exists()).toBeFalsy() // Verify it doesn't render in Transfers + expect(wrapper.findComponent(PreviousHomeOwners).exists()).toBeFalsy() }) it('renders Add Edit Home Owner and its sub components', async () => { @@ -1099,6 +1101,7 @@ describe('Home Owners', () => { await selectTransferType(ApiTransferTypes.TO_EXECUTOR_PROBATE_WILL) const homeOwners = wrapper.findComponent(HomeOwners) + expect(homeOwners.findComponent(PreviousHomeOwners).exists()).toBeFalsy() await homeOwners.find(getTestId('table-delete-btn')).trigger('click') // error should not be shown when removing one out of two Executors in the group expect(homeOwners.find(getTestId('invalid-group-msg')).exists()).toBeFalsy() diff --git a/ppr-ui/tests/unit/common-components/CollapsibleCard.spec.ts b/ppr-ui/tests/unit/common-components/CollapsibleCard.spec.ts new file mode 100644 index 000000000..b657dd54f --- /dev/null +++ b/ppr-ui/tests/unit/common-components/CollapsibleCard.spec.ts @@ -0,0 +1,44 @@ +import CollapsibleCard from '@/components/common/CollapsibleCard.vue' +import { getTestId } from '../utils' +import { mount } from '@vue/test-utils' +import { nextTick } from 'vue' + +describe('CollapsibleCard', () => { + let wrapper: any + + const HEADER_LABEL = 'Main Header Label' + const TOGGLE_LABEL = 'Toggle Label' + + beforeEach(async () => { + wrapper = mount(CollapsibleCard, { + props: { + headerLabel: HEADER_LABEL, + toggleLabel: TOGGLE_LABEL + }, + slots: { + infoSlot: '
Info Content
', + mainSlot: '
Main Content
' + } + }) + }) + + it('renders component with props', async () => { + const collapsibleCard = wrapper.findComponent(CollapsibleCard) + expect(collapsibleCard.exists()).toBe(true) + expect(collapsibleCard.find(getTestId('card-header-label')).text()).toBe(HEADER_LABEL) + expect(collapsibleCard.find(getTestId('card-toggle-label')).text()).toBe('Hide ' + TOGGLE_LABEL) + + const cardSlots = collapsibleCard.find(getTestId('card-slots')) + + expect(cardSlots.exists()).toBe(true) + expect(cardSlots.text()).toContain('Info Content') + expect(cardSlots.text()).toContain('Main Content') + + // collapse the card and slots + collapsibleCard.vm.toggleCardOpen() + await nextTick() + + expect(collapsibleCard.find(getTestId('card-slots')).exists()).toBe(false) + expect(collapsibleCard.find(getTestId('card-toggle-label')).text()).toBe('Show ' + TOGGLE_LABEL) + }) +})