From 54d6e234d75d0d996e12dda378cad29698945486 Mon Sep 17 00:00:00 2001 From: Orel Ben Neriah Date: Wed, 10 May 2023 12:14:35 -0700 Subject: [PATCH 1/3] Adds mapping of API status to UI status --- .../src/components/tables/common/TableRow.vue | 2 +- ppr-ui/src/composables/useRegistration.ts | 19 +++++-------------- ppr-ui/src/resources/statusTypes.ts | 15 ++++++++++++++- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/ppr-ui/src/components/tables/common/TableRow.vue b/ppr-ui/src/components/tables/common/TableRow.vue index ac0bb768a..6aa101dea 100644 --- a/ppr-ui/src/components/tables/common/TableRow.vue +++ b/ppr-ui/src/components/tables/common/TableRow.vue @@ -137,7 +137,7 @@ >
{{ isMhrTransfer(item) ? - 'Completed' : getStatusDescription(item.statusType) }} + 'Completed' : getStatusDescription(item.statusType, isChild, isPpr) }}

{{ isPpr ? '* Draft Amendment' : '* Draft Changes' }}

diff --git a/ppr-ui/src/composables/useRegistration.ts b/ppr-ui/src/composables/useRegistration.ts index befe3954e..9e5095611 100644 --- a/ppr-ui/src/composables/useRegistration.ts +++ b/ppr-ui/src/composables/useRegistration.ts @@ -1,5 +1,5 @@ import { reactive, toRefs } from '@vue/composition-api' -import { MhStatusTypes, StatusTypes } from '@/resources' +import { MhrAPIToUIStatusTypesMap, PprAPIToUIStatusTypesMap } from '@/resources' import { APIAmendmentTypes, APIRegistrationTypes, @@ -42,21 +42,12 @@ export const useRegistration = (setSort: RegistrationSortIF) => { } } - const getStatusDescription = (status: APIStatusTypes | MhApiStatusTypes): string => { + const getStatusDescription = (status: APIStatusTypes | MhApiStatusTypes, + isChild: boolean, isPpr: boolean): string => { if (!status) return UIStatusTypes.DRAFT if (status === MhApiStatusTypes.FROZEN) return MhUIStatusTypes.ACTIVE - - for (const statusType of StatusTypes) { - if (statusType.value === status) { - return statusType.text - } - } - - for (const mhStatusType of MhStatusTypes) { - if (mhStatusType.value === status) { - return mhStatusType.text - } - } + if (isChild && (status === MhApiStatusTypes.HISTORICAL || status === MhApiStatusTypes.EXEMPT)) return '' + return isPpr ? PprAPIToUIStatusTypesMap[status] : MhrAPIToUIStatusTypesMap[status] } const getRegisteringName = (name: string): string => { diff --git a/ppr-ui/src/resources/statusTypes.ts b/ppr-ui/src/resources/statusTypes.ts index d0e637585..4f6f87dfc 100644 --- a/ppr-ui/src/resources/statusTypes.ts +++ b/ppr-ui/src/resources/statusTypes.ts @@ -7,7 +7,6 @@ export const StatusTypes = [ }, { value: APIStatusTypes.ACTIVE, - mhrValue: APIStatusTypes.MHR_ACTIVE, text: UIStatusTypes.ACTIVE }, { @@ -38,3 +37,17 @@ export const MhStatusTypes = [ text: MhUIStatusTypes.HISTORICAL } ] + +export const PprAPIToUIStatusTypesMap = { + [APIStatusTypes.DRAFT]: UIStatusTypes.DRAFT, + [APIStatusTypes.ACTIVE]: UIStatusTypes.ACTIVE, + [APIStatusTypes.EXPIRED]: UIStatusTypes.EXPIRED, + [APIStatusTypes.DISCHARGED]: UIStatusTypes.DISCHARGED +} + +export const MhrAPIToUIStatusTypesMap = { + [MhApiStatusTypes.DRAFT]: MhUIStatusTypes.DRAFT, + [MhApiStatusTypes.ACTIVE]: MhUIStatusTypes.ACTIVE, + [MhApiStatusTypes.EXEMPT]: MhUIStatusTypes.EXEMPT, + [MhApiStatusTypes.HISTORICAL]: MhUIStatusTypes.HISTORICAL +} From 794f2255f34f819d1778547c103659a5cd9ecb09 Mon Sep 17 00:00:00 2001 From: Orel Ben Neriah Date: Wed, 10 May 2023 12:16:18 -0700 Subject: [PATCH 2/3] Sets hasDraft to false as drafts don't have drafts --- .../src/composables/mhrRegistration/useNewMhrRegistration.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ppr-ui/src/composables/mhrRegistration/useNewMhrRegistration.ts b/ppr-ui/src/composables/mhrRegistration/useNewMhrRegistration.ts index b6f9cb37f..bf94c7856 100644 --- a/ppr-ui/src/composables/mhrRegistration/useNewMhrRegistration.ts +++ b/ppr-ui/src/composables/mhrRegistration/useNewMhrRegistration.ts @@ -360,10 +360,10 @@ export const useNewMhrRegistration = () => { createDateTime: draft.createDateTime, error: draft.error, registrationDescription: draft.registrationDescription, - hasDraft: sortOptions?.status === APIStatusTypes.DRAFT, + hasDraft: false, ownerNames: '', path: draft.path, - statusType: APIStatusTypes.DRAFT, + statusType: MhApiStatusTypes.DRAFT, username: '', documentId: draft.draftNumber } From 98266cc237b9fd53a6badbaecfdfcc6b9ef2f18b Mon Sep 17 00:00:00 2001 From: Orel Ben Neriah Date: Wed, 10 May 2023 12:25:13 -0700 Subject: [PATCH 3/3] Updates tests and adds children status display test --- ppr-ui/tests/unit/TableRow.spec.ts | 51 ++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/ppr-ui/tests/unit/TableRow.spec.ts b/ppr-ui/tests/unit/TableRow.spec.ts index e9cfa9576..c47e9c8dd 100644 --- a/ppr-ui/tests/unit/TableRow.spec.ts +++ b/ppr-ui/tests/unit/TableRow.spec.ts @@ -159,7 +159,7 @@ describe('TableRow tests', () => { expect(rowData.at(1).find(btnExpTxt).exists()).toBe(false) } // status type - expect(rowData.at(3).text()).toContain(wrapper.vm.getStatusDescription(baseReg.statusType)) + expect(rowData.at(3).text()).toContain(wrapper.vm.getStatusDescription(baseReg.statusType, false, true)) // expire days if ([APIStatusTypes.DISCHARGED, APIStatusTypes.EXPIRED].includes(baseReg.statusType as APIStatusTypes)) { expect(rowData.at(8).text()).toContain('—') @@ -216,7 +216,7 @@ describe('TableRow tests', () => { // submitted date expect(rowData.at(2).text()).toBe('Not Registered') // status type - expect(rowData.at(3).text()).toContain(wrapper.vm.getStatusDescription(baseReg.statusType)) + expect(rowData.at(3).text()).toContain(wrapper.vm.getStatusDescription(baseReg.statusType, isChild, true)) // expire days if (isChild) expect(rowData.at(8).text()).toEqual('') else expect(rowData.at(8).text()).toBe('N/A') @@ -432,7 +432,7 @@ describe('Mhr TableRow tests', () => { expect(rowData.at(1).find(btnExpTxt).exists()).toBe(false) } // status type - expect(rowData.at(3).text()).toContain(wrapper.vm.getStatusDescription(baseReg.statusType)) + expect(rowData.at(3).text()).toContain(wrapper.vm.getStatusDescription(baseReg.statusType, isChild, false)) // expire days expect(rowData.at(8).text()).toContain(wrapper.vm.showExpireDays(baseReg)) // action btn @@ -524,10 +524,7 @@ describe('Mhr TableRow tests', () => { { ...mockedMhRegistration, statusType: MhApiStatusTypes.FROZEN } ] - for (let i = 0; i < registrations.length; i++) { - // both below are the same variable, but typed differently - const reg = registrations[i] as MhRegistrationSummaryIF - + for (const reg of registrations) { await wrapper.setProps({ setItem: reg }) @@ -556,4 +553,44 @@ describe('Mhr TableRow tests', () => { } } }) + + it('displays the correct status for all mhStatusTypes as children', async () => { + const registrations: (MhRegistrationSummaryIF)[] = [ + { ...mockedMhRegistration, statusType: MhApiStatusTypes.EXEMPT }, + { ...mockedMhRegistration, statusType: MhApiStatusTypes.HISTORICAL }, + { ...mockedMhRegistration, statusType: MhApiStatusTypes.ACTIVE }, + { ...mockedMhRegistration, statusType: MhApiStatusTypes.DRAFT }, + { ...mockedMhRegistration, statusType: MhApiStatusTypes.FROZEN } + ] + + for (const reg of registrations) { + await wrapper.setProps({ + setItem: reg, + setChild: true + }) + + expect(wrapper.vm.item).toEqual(reg) + const rowData = wrapper.findAll(tableRow + ' td') + expect(rowData.exists()).toBe(true) + switch (reg.statusType) { + case MhApiStatusTypes.ACTIVE: + expect(rowData.at(3).text()).toContain(MhUIStatusTypes.ACTIVE) + break + case MhApiStatusTypes.DRAFT: + expect(rowData.at(3).text()).toContain(MhUIStatusTypes.DRAFT) + break + case MhApiStatusTypes.EXEMPT: + expect(rowData.at(3).text()).toContain('') + break + case MhApiStatusTypes.FROZEN: + expect(rowData.at(3).text()).toContain(MhUIStatusTypes.ACTIVE) + break + case MhApiStatusTypes.HISTORICAL: + expect(rowData.at(3).text()).toContain('') + break + default: + fail('No/Unknown MhStatusType') + } + } + }) })