Skip to content

Commit

Permalink
17178 - Alteration - Feature flag - Change Business Types (#520)
Browse files Browse the repository at this point in the history
* Changes for feature flagging change business types.

* Changes from feedback. Mock the feature flags.
  • Loading branch information
seeker25 authored Jul 25, 2023
1 parent e972438 commit c3b5106
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 10 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.5.2",
"version": "4.5.3",
"private": true,
"appName": "Edit UI",
"sbcName": "SBC Common Components",
Expand Down
19 changes: 16 additions & 3 deletions src/components/common/YourCompany/ChangeBusinessType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
<span>Undo</span>
</v-btn>
<v-btn
v-else-if="isBcCompany || isBcUlcCompany || isBenefitCompany"
v-else-if="enableEditButton"
id="btn-correct-business-type"
text
color="primary"
Expand Down Expand Up @@ -247,7 +247,7 @@ import { BcRegContacts } from '@/components/common/'
import { CommonMixin } from '@/mixins/'
import { CorpTypeCd, GetCorpFullDescription } from '@bcrs-shared-components/corp-type-module/'
import { ActionBindingIF, EntitySnapshotIF, EntityTypeOption, ResourceIF } from '@/interfaces/'
import { ResourceUtilities } from '@/utils'
import { GetFeatureFlag, ResourceUtilities } from '@/utils'
import { useStore } from '@/store/store'
@Component({
Expand Down Expand Up @@ -287,10 +287,12 @@ export default class ChangeBusinessType extends Mixins(CommonMixin) {
confirmArticles = false
isEditingType = false
dropdown: boolean = null
supportedEntityTypes: Array<string> = []
/** Called when component is mounted. */
mounted (): void {
this.initializeEntityType()
this.supportedEntityTypes = GetFeatureFlag('supported-alteration-change-business-types')
}
/** Define the entity type locally once the value has been populated in the store. */
Expand Down Expand Up @@ -318,7 +320,18 @@ export default class ChangeBusinessType extends Mixins(CommonMixin) {
/** Entity type options based on the company type */
get entityTypeOptions (): EntityTypeOption[] {
return this.getResource.changeData?.entityTypeOptions || []
const entityTypeOptions = this.getResource.changeData?.entityTypeOptions || []
return entityTypeOptions.filter((option: EntityTypeOption) => {
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 {
Expand Down
5 changes: 3 additions & 2 deletions src/utils/feature-flag-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ 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,
'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': []
}

/**
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/ChangeBusinessType.spec.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -81,14 +82,16 @@ 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
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)

Expand Down
13 changes: 12 additions & 1 deletion tests/unit/setup.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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)
Expand All @@ -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]
}
})

0 comments on commit c3b5106

Please sign in to comment.