diff --git a/package-lock.json b/package-lock.json index ef5af5d8..5f449f9a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "business-edit-ui", - "version": "4.10.4", + "version": "4.10.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "business-edit-ui", - "version": "4.10.4", + "version": "4.10.5", "dependencies": { "@babel/compat-data": "^7.21.5", "@bcrs-shared-components/action-chip": "1.1.5", diff --git a/package.json b/package.json index 537aee0b..1e4598e9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/common/YourCompany/ChangeBusinessType.vue b/src/components/common/YourCompany/ChangeBusinessType.vue index 4eb18f96..aa844ed6 100644 --- a/src/components/common/YourCompany/ChangeBusinessType.vue +++ b/src/components/common/YourCompany/ChangeBusinessType.vue @@ -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. */ @@ -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 diff --git a/src/store/store.ts b/src/store/store.ts index 98dfae6d..81ad2ab6 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -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 }, @@ -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 }, @@ -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]) }, diff --git a/tests/unit/ChangeBusinessType.spec.ts b/tests/unit/ChangeBusinessType.spec.ts index 19e78e75..864e2fb9 100644 --- a/tests/unit/ChangeBusinessType.spec.ts +++ b/tests/unit/ChangeBusinessType.spec.ts @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/tests/unit/utils.ts b/tests/unit/utils.ts index 077cc482..51b92f19 100644 --- a/tests/unit/utils.ts +++ b/tests/unit/utils.ts @@ -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] }