Skip to content

Commit

Permalink
20947 - Fix limited restoration to full filing saves or resumes with …
Browse files Browse the repository at this point in the history
…company Name change (#606)

* Fix: limited restoration to full filing incorrectly saves/resumes with NR changes
  • Loading branch information
AimeeGao authored Dec 24, 2024
1 parent fa38f6e commit f7950db
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 7 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.11.12",
"version": "4.11.13",
"private": true,
"appName": "Edit UI",
"sbcName": "SBC Common Components",
Expand Down
27 changes: 23 additions & 4 deletions src/components/common/YourCompany/EntityName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export default class EntityName extends Mixins(CommonMixin, NameRequestMixin) {
@Getter(useStore) isFirmChangeFiling!: boolean
@Getter(useStore) isFirmConversionFiling!: boolean
@Getter(useStore) isLimitedRestorationExtension!: boolean
@Getter(useStore) isLimitedRestorationToFull!: boolean
@Getter(useStore) isNumberedCompany!: boolean
@Getter(useStore) isSpecialResolutionFiling!: boolean
@Getter(useStore) isNameChangedByType!: boolean
Expand Down Expand Up @@ -321,7 +322,9 @@ export default class EntityName extends Mixins(CommonMixin, NameRequestMixin) {
this.hasCompanyNameChanged ||
(
this.hasBusinessNameChanged &&
(this.isAlterationFiling || this.isFirmChangeFiling || this.isSpecialResolutionFiling)
(this.isAlterationFiling || this.isFirmChangeFiling || this.isSpecialResolutionFiling ||
this.isLimitedRestorationToFull
)
)
)
}
Expand All @@ -337,7 +340,9 @@ export default class EntityName extends Mixins(CommonMixin, NameRequestMixin) {
this.hasCompanyNameChanged ||
(
this.hasBusinessNameChanged &&
(this.isAlterationFiling || this.isFirmChangeFiling || this.isSpecialResolutionFiling)
(this.isAlterationFiling || this.isFirmChangeFiling || this.isSpecialResolutionFiling ||
this.isLimitedRestorationToFull
)
)
) &&
!this.isNameChangedByType
Expand Down Expand Up @@ -439,8 +444,22 @@ export default class EntityName extends Mixins(CommonMixin, NameRequestMixin) {
/** Updates UI when correct name options are done. */
nameChangeHandler (isSaved = false): void {
this.hasCompanyNameChanged = this.isNewName
if (isSaved) this.isEditingNames = false
// check if this is a numbered company case:
// 1. no Name Request legal name exists (indicating not using NR)
// 2. business number exists (needed for numbered company name)
const isNumberedName = !this.getNameRequestLegalName && !!this.getBusinessNumber
this.hasCompanyNameChanged = this.isNewName || isNumberedName
if (isSaved) {
this.isEditingNames = false
// set legal name for numbered company to satisfy Legal API requirement
// without this, Legal API will return error when filing restoration with numbered option
if (isNumberedName) {
const numberedName = `${this.getBusinessNumber} B.C. ${this.getUpdatedName}`
this.setNameRequestLegalName(numberedName)
}
}
}
/** Reset company name values to original. */
Expand Down
56 changes: 56 additions & 0 deletions tests/unit/EntityName.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { CorrectionResourceGp } from '@/resources/Correction/GP'
import { CorrectionResourceSp } from '@/resources/Correction/SP'
import { CorrectionResourceUlc } from '@/resources/Correction/ULC'

import { RestorationResourceBc } from '@/resources/LimitedRestorationToFull/BC'

import { SpecialResolutionResourceCp } from '@/resources/SpecialResolution/CP'

import { createPinia, setActivePinia } from 'pinia'
Expand Down Expand Up @@ -398,3 +400,57 @@ describe('Name Changes by Type change', () => {
)
})
})

describe('Name Changes for Limited Restoration to Full', () => {
let wrapper: any

const entitySnapshot = {
businessInfo: {
legalName: 'Mock Original Name',
legalType: CorpTypeCd.BC_COMPANY,
identifier: 'BC0884805'
}
}

beforeEach(() => {
// Set original business Data
store.stateModel.summaryMode = false
store.stateModel.nameRequestLegalName = entitySnapshot.businessInfo.legalName
store.stateModel.entitySnapshot = entitySnapshot as any
store.stateModel.tombstone.filingType = FilingTypes.RESTORATION
store.stateModel.tombstone.entityType = entitySnapshot.businessInfo.legalType
store.stateModel.tombstone.businessId = entitySnapshot.businessInfo.identifier
store.resourceModel = RestorationResourceBc

wrapper = mount(EntityName, {
vuetify,
computed: {
isLimitedRestorationToFull: () => true,
isNameChangedByType: () => false
}
})
})

afterEach(() => {
wrapper.destroy()
})

it('displays Undo button after changing to a numbered company and resuming draft', async () => {
// Initial state
const companyName = wrapper.find('.company-name')
expect(companyName.exists()).toBe(true)
expect(companyName.text()).toBe('Mock Original Name')

// Simulate changing to numbered company
store.stateModel.nameRequestLegalName = null

await wrapper.vm.nameChangeHandler(true)
await Vue.nextTick()

// Verify show the Undo button
const button = wrapper.find('#btn-undo-company-name')
expect(button.exists()).toBe(true)
expect(button.text()).toBe('Undo')
expect(wrapper.vm.shouldShowUndoButton).toBe(true)
})
})

0 comments on commit f7950db

Please sign in to comment.