Skip to content

Commit

Permalink
22479 Added special handling for cont in entity types (#582)
Browse files Browse the repository at this point in the history
* - app version = 4.10.5
- convert cont in entity type to regular entity type for v-select, etc
- convert regular entity type to cont in type to prevent equivalent-type changes

* - added a unit test

---------

Co-authored-by: Severin Beauvais <[email protected]>
  • Loading branch information
severinbeauvais and Severin Beauvais authored Aug 2, 2024
1 parent 82f952b commit f46a197
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 12 deletions.
4 changes: 2 additions & 2 deletions 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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "business-edit-ui",
"version": "4.10.4",
"version": "4.10.5",
"private": true,
"appName": "Edit UI",
"sbcName": "SBC Common Components",
Expand Down
31 changes: 30 additions & 1 deletion src/components/common/YourCompany/ChangeBusinessType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,19 @@ export default class ChangeBusinessType extends Mixins(CommonMixin) {
/** Define the entity type locally once the value has been populated in the store. */
@Watch('getEntityType')
private initializeEntityType (): void {
this.selectedEntityType = this.getEntityType
/** Converts type to regular entity type. */
function convertToRegularEntityType (type: CorpTypeCd): CorpTypeCd {
switch (type) {
case CorpTypeCd.BEN_CONTINUE_IN: return CorpTypeCd.BENEFIT_COMPANY
case CorpTypeCd.CCC_CONTINUE_IN: return CorpTypeCd.BC_CCC
case CorpTypeCd.CONTINUE_IN: return CorpTypeCd.BC_COMPANY
case CorpTypeCd.ULC_CONTINUE_IN: return CorpTypeCd.BC_ULC_COMPANY
default: return type
}
}
// convert types for the v-select, etc
this.selectedEntityType = convertToRegularEntityType(this.getEntityType)
}
/** Clear the articles confirm checkbox whenever the selected entity type changes. */
Expand Down Expand Up @@ -429,6 +441,23 @@ export default class ChangeBusinessType extends Mixins(CommonMixin) {
/** Submit new company type. */
submitTypeChange () {
/** Converts type to continuation in entity type. */
function convertToContinuedInEntityType (type: CorpTypeCd): CorpTypeCd {
switch (type) {
case CorpTypeCd.BENEFIT_COMPANY: return CorpTypeCd.BEN_CONTINUE_IN
case CorpTypeCd.BC_CCC: return CorpTypeCd.CCC_CONTINUE_IN
case CorpTypeCd.BC_COMPANY: return CorpTypeCd.CONTINUE_IN
case CorpTypeCd.BC_ULC_COMPANY: return CorpTypeCd.ULC_CONTINUE_IN
default: return type
}
}
// prevent continuation in entity types from changing to equivalent regular entity types
if (this.getOriginalLegalType === convertToContinuedInEntityType(this.selectedEntityType)) {
this.isEditingType = false
return
}
this.setEntityType(this.selectedEntityType)
this.isEditingType = false
Expand Down
6 changes: 3 additions & 3 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export const useStore = defineStore('store', {
return this.getEntitySnapshot?.businessInfo || null
},

/** The original legal type. */
/** The original legal type (aka entity type). */
getOriginalLegalType (): CorpTypeCd {
return this.getOriginalBusinessInfo?.legalType || null
},
Expand All @@ -166,7 +166,7 @@ export const useStore = defineStore('store', {
return this.getOriginalBusinessInfo?.nrNumber || ''
},

/** The entity type. */
/** The entity type (aka legal type). */
getEntityType (): CorpTypeCd {
return this.stateModel.tombstone.entityType
},
Expand Down Expand Up @@ -846,7 +846,7 @@ export const useStore = defineStore('store', {
return this.stateModel.documentDelivery.documentOptionalEmail
},

/** Checks for a 7 digit pattern to identify a numbered company from the Legal Name. */
/** Checks the Legal Name for a 7 digit pattern to identify a numbered company. */
isNumberedCompany (): boolean {
return RegExp('^\\d{7}$').test(this.getOriginalLegalName?.split(' ')[0])
},
Expand Down
26 changes: 22 additions & 4 deletions tests/unit/ChangeBusinessType.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Change Business Type component', () => {
wrapper.destroy()
})

it('should have tooltip and no correct button for Coop Special Resolution filing', () => {
it('should have tooltip and no correct button for a Coop Special Resolution filing', () => {
store.stateModel.tombstone.entityType = CorpTypeCd.COOP
store.stateModel.tombstone.filingType = FilingTypes.SPECIAL_RESOLUTION
store.resourceModel.changeData = { typeChangeInfo: 'tooltip' } as any
Expand All @@ -60,7 +60,7 @@ describe('Change Business Type component', () => {
wrapper.destroy()
})

it('should have tooltip and no correct button for GP Change filing', () => {
it('should have tooltip and no correct button for a GP Change filing', () => {
store.stateModel.tombstone.entityType = CorpTypeCd.PARTNERSHIP
store.stateModel.tombstone.filingType = FilingTypes.CHANGE_OF_NAME
store.resourceModel.changeData = { typeChangeInfo: 'tooltip' } as any
Expand All @@ -72,7 +72,7 @@ describe('Change Business Type component', () => {
wrapper.destroy()
})

it('should have tooltip and no correct button for GP Conversion filing', () => {
it('should have tooltip and no correct button for a GP Conversion filing', () => {
store.stateModel.tombstone.entityType = CorpTypeCd.PARTNERSHIP
store.stateModel.tombstone.filingType = FilingTypes.CONVERSION
store.resourceModel.changeData = { typeChangeInfo: 'tooltip' } as any
Expand All @@ -85,7 +85,7 @@ describe('Change Business Type component', () => {
wrapper.destroy()
})

it('should have correct button and no tooltip for BC Alteration filing', async () => {
it('should have correct button and no tooltip for a BC Alteration filing', async () => {
mockFeatureFlagsForAlterationChangeBusinessTypes()
store.stateModel.tombstone.entityType = CorpTypeCd.BC_COMPANY
store.stateModel.tombstone.filingType = FilingTypes.ALTERATION
Expand All @@ -103,6 +103,24 @@ describe('Change Business Type component', () => {
vi.clearAllMocks()
})

it('should have correct button and no tooltip for a C Alteration filing', async () => {
mockFeatureFlagsForAlterationChangeBusinessTypes()
store.stateModel.tombstone.entityType = CorpTypeCd.CONTINUE_IN
store.stateModel.tombstone.filingType = FilingTypes.ALTERATION
store.stateModel.entitySnapshot = { businessInfo: { legalType: 'C' } } as any
store.resourceModel.changeData = { typeChangeInfo: null } as any

const wrapper = mount(ChangeBusinessType, { vuetify })

await Vue.nextTick()

expect(wrapper.find('.v-tooltip').exists()).toBe(false)
expect(wrapper.find('#btn-correct-business-type').exists()).toBe(true)

wrapper.destroy()
vi.clearAllMocks()
})

it('should have actions hidden when entityTypeChangedByName is enabled', () => {
store.stateModel.tombstone.entityTypeChangedByName = true
store.stateModel.tombstone.filingType = FilingTypes.ALTERATION
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function mockFeatureFlagsForAlterationChangeBusinessTypes () {
vi.spyOn(util, 'GetFeatureFlag').mockImplementation(
(name) => {
if (name === 'supported-alteration-change-business-types') {
return ['BEN', 'BC', 'CC', 'ULC']
return ['BEN', 'BC', 'CC', 'ULC', 'CBEN', 'C', 'CCC', 'CUL']
} else {
return util.defaultFlagSet[name]
}
Expand Down

0 comments on commit f46a197

Please sign in to comment.