From 810e18b15c688c5166fb8c71554b6be4f891855f Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Tue, 25 Jul 2023 07:31:41 -0700 Subject: [PATCH 1/2] Changes for feature flagging change business types. --- package-lock.json | 4 ++-- package.json | 2 +- .../common/YourCompany/ChangeBusinessType.vue | 19 ++++++++++++++++--- src/utils/feature-flag-utils.ts | 3 ++- tests/unit/ChangeBusinessType.spec.ts | 5 ++++- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index ecf0a52a1..f879fcf34 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "business-edit-ui", - "version": "4.5.1", + "version": "4.5.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "business-edit-ui", - "version": "4.5.1", + "version": "4.5.4", "dependencies": { "@babel/compat-data": "^7.21.5", "@bcrs-shared-components/action-chip": "1.1.5", diff --git a/package.json b/package.json index 06691d419..c9d70f1bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "business-edit-ui", - "version": "4.5.1", + "version": "4.5.4", "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 fb1cd779f..c5bf18129 100644 --- a/src/components/common/YourCompany/ChangeBusinessType.vue +++ b/src/components/common/YourCompany/ChangeBusinessType.vue @@ -184,7 +184,7 @@ Undo { + return this.supportedEntityTypes?.includes(option.value) + }) + } + + get enableEditButton (): boolean { + // Exclude CCC - Originally: isBcCompany || isBcUlcCompany || isBenefitCompany + if (this.getEntitySnapshot?.businessInfo?.legalType === CorpTypeCd.BC_CCC) { + return false + } + return this.supportedEntityTypes?.includes(this.getEntitySnapshot?.businessInfo?.legalType) } get minimumThreeDirectorError (): boolean { diff --git a/src/utils/feature-flag-utils.ts b/src/utils/feature-flag-utils.ts index 7cbb9b605..4d65e9d48 100644 --- a/src/utils/feature-flag-utils.ts +++ b/src/utils/feature-flag-utils.ts @@ -14,7 +14,8 @@ const defaultFlagSet: LDFlagSet = { 'conversion-ui-enabled': false, 'restoration-ui-enabled': false, 'sentry-enable': false, // by default, no sentry logs - 'supported-correction-entities': [] + 'supported-correction-entities': [], + 'supported-alteration-change-business-types': ['BEN', 'BC', 'CC', 'ULC'] } /** diff --git a/tests/unit/ChangeBusinessType.spec.ts b/tests/unit/ChangeBusinessType.spec.ts index 964827bbd..24944cd17 100644 --- a/tests/unit/ChangeBusinessType.spec.ts +++ b/tests/unit/ChangeBusinessType.spec.ts @@ -1,3 +1,4 @@ +import Vue from 'vue' import Vuetify from 'vuetify' import { mount } from '@vue/test-utils' import ChangeBusinessType from '@/components/common/YourCompany/ChangeBusinessType.vue' @@ -81,7 +82,7 @@ describe('Change Business Type component', () => { wrapper.destroy() }) - it('should have correct button and no tooltip for BC Alteration filing', () => { + it('should have correct button and no tooltip for BC Alteration filing', async () => { store.stateModel.tombstone.entityType = CorpTypeCd.BC_COMPANY store.stateModel.tombstone.filingType = FilingTypes.ALTERATION store.stateModel.entitySnapshot = { businessInfo: { legalType: 'BC' } } as any @@ -89,6 +90,8 @@ describe('Change Business Type component', () => { 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) From 3ee4d8578ccc006478d7bd7e104c9da9a90ba744 Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Tue, 25 Jul 2023 12:47:37 -0700 Subject: [PATCH 2/2] Changes from feedback. Mock the feature flags. --- .../common/YourCompany/ChangeBusinessType.vue | 4 ++-- src/utils/feature-flag-utils.ts | 4 ++-- tests/unit/setup.ts | 13 ++++++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/components/common/YourCompany/ChangeBusinessType.vue b/src/components/common/YourCompany/ChangeBusinessType.vue index c5bf18129..d1f25584d 100644 --- a/src/components/common/YourCompany/ChangeBusinessType.vue +++ b/src/components/common/YourCompany/ChangeBusinessType.vue @@ -286,12 +286,12 @@ export default class ChangeBusinessType extends Mixins(CommonMixin) { confirmArticles = false isEditingType = false dropdown: boolean = null - supportedEntityTypes = null + supportedEntityTypes: Array = [] /** Called when component is mounted. */ mounted (): void { this.initializeEntityType() - this.supportedEntityTypes = GetFeatureFlag('supported-alteration-change-business-types') || [] + this.supportedEntityTypes = GetFeatureFlag('supported-alteration-change-business-types') } /** Define the entity type locally once the value has been populated in the store. */ diff --git a/src/utils/feature-flag-utils.ts b/src/utils/feature-flag-utils.ts index 4d65e9d48..b4adf1781 100644 --- a/src/utils/feature-flag-utils.ts +++ b/src/utils/feature-flag-utils.ts @@ -7,7 +7,7 @@ declare const window: any * Default flag values when LD is not available. * Uses "business-edit" project (per LD client id in config). */ -const defaultFlagSet: LDFlagSet = { +export const defaultFlagSet: LDFlagSet = { 'alteration-ui-enabled': false, 'banner-text': '', // by default, there is no banner text 'change-ui-enabled': false, @@ -15,7 +15,7 @@ const defaultFlagSet: LDFlagSet = { 'restoration-ui-enabled': false, 'sentry-enable': false, // by default, no sentry logs 'supported-correction-entities': [], - 'supported-alteration-change-business-types': ['BEN', 'BC', 'CC', 'ULC'] + 'supported-alteration-change-business-types': [] } /** diff --git a/tests/unit/setup.ts b/tests/unit/setup.ts index a4e551065..627baa360 100644 --- a/tests/unit/setup.ts +++ b/tests/unit/setup.ts @@ -1,4 +1,4 @@ -/* This file is to provide the correct setup for the Vue instance. +/* This file is to provide the correct setup for the Vue instance. Also for system wide mocks. * It can save people time when writing tests, as they wont need to figure out * why some of the errors are showing up due to Vue not having the plugins it needs. * See src/main.ts. @@ -10,6 +10,7 @@ import Affix from 'vue-affix' import Vue2Filters from 'vue2-filters' // needed by SbcFeeSummary import Vuetify from 'vuetify' import { TiptapVuetifyPlugin } from 'tiptap-vuetify' +import * as util from '@/utils/' Vue.use(Vuetify) Vue.use(Affix) @@ -28,3 +29,13 @@ Vue.use(TiptapVuetifyPlugin, { // optional, default to 'md' (default vuetify icons before v2.0.0) iconsGroup: 'mdi' }) + +// Mock feature flags for unit tests. +jest.spyOn(util, 'GetFeatureFlag').mockImplementation( + (name) => { + if (name === 'supported-alteration-change-business-types') { + return ['BEN', 'BC', 'CC', 'ULC'] + } else { + return util.defaultFlagSet[name] + } + })