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

Does not show exempt and historical children + Code clean up #1330

Merged
merged 3 commits into from
May 11, 2023
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/components/tables/common/TableRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
>
<div v-if="!isChild || isDraft(item) || !isPpr">
{{ isMhrTransfer(item) ?
'Completed' : getStatusDescription(item.statusType) }}
'Completed' : getStatusDescription(item.statusType, isChild, isPpr) }}
<p v-if="!isChild && item.hasDraft" class="ma-0">
<i>{{ isPpr ? '* Draft Amendment' : '* Draft Changes' }}</i>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
19 changes: 5 additions & 14 deletions ppr-ui/src/composables/useRegistration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { reactive, toRefs } from '@vue/composition-api'
import { MhStatusTypes, StatusTypes } from '@/resources'
import { MhrAPIToUIStatusTypesMap, PprAPIToUIStatusTypesMap } from '@/resources'
import {
APIAmendmentTypes,
APIRegistrationTypes,
Expand Down Expand Up @@ -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 => {
dimak1 marked this conversation as resolved.
Show resolved Hide resolved
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 => {
Expand Down
15 changes: 14 additions & 1 deletion ppr-ui/src/resources/statusTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const StatusTypes = [
},
{
value: APIStatusTypes.ACTIVE,
mhrValue: APIStatusTypes.MHR_ACTIVE,
text: UIStatusTypes.ACTIVE
},
{
Expand Down Expand Up @@ -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
}
cameron-eyds marked this conversation as resolved.
Show resolved Hide resolved
51 changes: 44 additions & 7 deletions ppr-ui/tests/unit/TableRow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('—')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
})
Expand Down Expand Up @@ -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')
}
}
})
})