Skip to content

Commit

Permalink
- app version = 5.8.5 (#643)
Browse files Browse the repository at this point in the history
- now save auth info instead of just email (so we don't have to re-fetch it later)
- updated unit tests

Co-authored-by: Severin Beauvais <severin.beauvais@gov.bc.ca>
  • Loading branch information
severinbeauvais and Severin Beauvais authored Feb 1, 2024
1 parent c66c186 commit 267c612
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 69 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-create-ui",
"version": "5.8.4",
"version": "5.8.5",
"private": true,
"appName": "Create UI",
"sbcName": "SBC Common Components",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Amalgamation/AmalgamatingBusinesses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ export default class AmalgamatingBusinesses extends Mixins(AmalgamationMixin, Co
role: AmlRoles.AMALGAMATING,
identifier: business.businessInfo.identifier,
name: business.businessInfo.legalName,
email: business.authInfo.contacts[0].email,
authInfo: business.authInfo,
legalType: business.businessInfo.legalType,
addresses: business.addresses,
isNotInGoodStanding: (business.businessInfo.goodStanding === false),
Expand Down
2 changes: 1 addition & 1 deletion src/components/Amalgamation/BusinessTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default class BusinessTable extends Mixins(AmalgamationMixin) {
}
email (item: AmalgamatingBusinessIF): string {
if (item?.type === AmlTypes.LEAR) return item.email
if (item?.type === AmlTypes.LEAR) return item.authInfo?.contacts[0]?.email
return null // should never happen
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Amalgamation/BusinessTableSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default class BusinessTableSummary extends Vue {
}
email (item: AmalgamatingBusinessIF): string {
if (item?.type === AmlTypes.LEAR) return item.email
if (item?.type === AmlTypes.LEAR) return item.authInfo?.contacts[0]?.email
return null // should never happen
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RegisteredRecordsAddressesIF } from '@/interfaces'
import { AuthInformationIF, RegisteredRecordsAddressesIF } from '@/interfaces'
import { AmlStatuses, AmalgamationTypes, AmlRoles, AmlTypes } from '@/enums'
import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module'

Expand All @@ -12,7 +12,7 @@ interface AmalgamatingLearIF {

// properties for UI only:
name?: string
email?: string
authInfo?: AuthInformationIF
legalType?: CorpTypeCd
addresses?: RegisteredRecordsAddressesIF
status?: AmlStatuses // computed status (base on business rules)
Expand Down
34 changes: 19 additions & 15 deletions src/mixins/amalgamation-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
AmlRoles, AmlStatuses, AmlTypes, EntityStates, FilingStatus, RestorationTypes, RoleTypes
} from '@/enums'
import {
AmalgamatingBusinessIF, ContactPointIF, EmptyNameRequest, NameRequestIF, NameTranslationIF,
OrgPersonIF, PeopleAndRoleIF, RegisteredRecordsAddressesIF, ShareClassIF
AmalgamatingBusinessIF, ContactPointIF, EmptyContactPoint, EmptyNameRequest, NameRequestIF,
NameTranslationIF, OrgPersonIF, PeopleAndRoleIF, RegisteredRecordsAddressesIF, ShareClassIF
} from '@/interfaces'
import { CorrectNameOptions } from '@bcrs-shared-components/enums/'
import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module'
Expand Down Expand Up @@ -216,6 +216,7 @@ export default class AmalgamationMixin extends Vue {
/**
* Fetches the business' auth information, business info, addresses, first task, and first filing.
* @param identifier The business identifier.
* @returns An object of business information sub-objects, some of which may be null.
*/
async fetchAmalgamatingBusinessInfo (identifier: string): Promise<any> {
// Make all API calls concurrently without rejection.
Expand Down Expand Up @@ -309,7 +310,7 @@ export default class AmalgamationMixin extends Vue {
role: item.role, // amalgamating or holding
identifier: tingBusiness.businessInfo.identifier,
name: tingBusiness.businessInfo.legalName,
email: tingBusiness.authInfo?.contacts[0].email,
authInfo: tingBusiness.authInfo,
legalType: tingBusiness.businessInfo.legalType,
addresses: tingBusiness.addresses,
isNotInGoodStanding: (tingBusiness.businessInfo.goodStanding === false),
Expand Down Expand Up @@ -344,21 +345,19 @@ export default class AmalgamationMixin extends Vue {
throw new Error('updatePrepopulatedData(): invalid business')
}

// first, fetch new directors/share structure/auth info
// NB - business addresses have already been fetched
// first, fetch directors and share structure
// NB - addresses and auth info have already been fetched
// NB - make all API calls concurrently without rejection
// NB - if any call failed, that item will be null
const [ directors, shareStructure, authInfo ] =
const [ directors, shareStructure ] =
await Promise.allSettled([
LegalServices.fetchDirectors(business.identifier),
LegalServices.fetchShareStructure(business.identifier),
AuthServices.fetchAuthInfo(business.identifier)
LegalServices.fetchShareStructure(business.identifier)
]).then(results => results.map((result: any) => result.value || null))

// check for errors before changing anything
if (!directors) throw new Error('Unable to fetch directors')
if (!shareStructure) throw new Error('Unable to fetch share structure')
if (!authInfo) throw new Error('Unable to fetch auth info')

// unset previous holding/primary business, if any
const previous = this.getAmalgamatingBusinesses.find((b: AmalgamatingBusinessIF) =>
Expand Down Expand Up @@ -388,12 +387,17 @@ export default class AmalgamationMixin extends Vue {
// overwrite business contact -- only when user has marked new holding/primary business,
// otherwise leave existing data from restored draft
if (isNew) {
this.setBusinessContact({
email: authInfo.contacts[0].email,
confirmEmail: authInfo.contacts[0].email,
phone: authInfo.contacts[0].phone,
extension: authInfo.contacts[0].extension
})
if (business.authInfo?.contacts[0]) {
this.setBusinessContact({
email: business.authInfo.contacts[0].email,
confirmEmail: business.authInfo.contacts[0].email,
phone: business.authInfo.contacts[0].phone,
extension: business.authInfo.contacts[0].extension
})
} else {
// safety check - clear old business contact
this.setBusinessContact({ ...EmptyContactPoint })
}
}

// set new resulting business name and type
Expand Down
2 changes: 1 addition & 1 deletion src/mixins/filing-template-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export default class FilingTemplateMixin extends Mixins(AmalgamationMixin, DateM
// (eg, became historical) since the last draft save.
const holdingPrimary = await this.refetchAmalgamatingBusinessesInfo()
// If there's a holding or primary business, fetch its data and update the prepopulated data.
// This will overwrite office addresses, directors and share structure from above.
// This will overwrite office addresses, directors and share structure that were set above.
if (holdingPrimary) await this.updatePrepopulatedData(holdingPrimary)
}

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/AmalgamatingBusinesses.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,9 @@ describe('Amalgamating Businesses - add amalgamating business', () => {
expect(business.role).toBe(AmlRoles.AMALGAMATING)
expect(business.identifier).toBe('BC1234567')
expect(business.name).toBe('My BC Business')
expect(business.email).toBe('email@example.com')
expect(business.authInfo.contacts[0].email).toBe('email@example.com')
expect(business.legalType).toBe(CorpTypeCd.BC_COMPANY)
expect(business.address.streetAddress).toBe('123 Main St')
expect(business.addresses.registeredOffice.mailingAddress.streetAddress).toBe('123 Main St')
expect(business.isNotInGoodStanding).toBe(false)
expect(business.isFrozen).toBe(false)
expect(business.isFutureEffective).toBe(false)
Expand Down
53 changes: 32 additions & 21 deletions tests/unit/BusinessTable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@ describe('Business Table - display', () => {
type: AmlTypes.LEAR,
identifier: 'BC1111111',
name: 'My BC Limited Company',
email: 'bc1111111@example.com',
address: {
streetAddress: '123 Main St',
addressCity: 'Victoria',
addressCountry: 'CA',
postalCode: 'V8V 8V8'
authInfo: { contacts: [ { email: 'bc1111111@example.com' } ] },
addresses: {
registeredOffice: {
mailingAddress: {
streetAddress: '123 Main St',
addressCity: 'Victoria',
addressCountry: 'CA',
postalCode: 'V8V 8V8'
}
}
},
legalType: CorpTypeCd.BC_COMPANY,
expectedBusinessType: 'BC Limited Company',
Expand All @@ -62,12 +66,16 @@ describe('Business Table - display', () => {
type: AmlTypes.LEAR,
identifier: 'BC1111111',
name: 'My BC Limited Company',
email: 'bc1111111@example.com',
address: {
streetAddress: '123 Main St',
addressCity: 'Victoria',
addressCountry: 'CA',
postalCode: 'V8V 8V8'
authInfo: { contacts: [ { email: 'bc1111111@example.com' } ] },
addresses: {
registeredOffice: {
mailingAddress: {
streetAddress: '123 Main St',
addressCity: 'Victoria',
addressCountry: 'CA',
postalCode: 'V8V 8V8'
}
}
},
legalType: CorpTypeCd.BC_COMPANY,
expectedBusinessType: 'BC Limited Company',
Expand All @@ -79,7 +87,7 @@ describe('Business Table - display', () => {
type: AmlTypes.LEAR,
identifier: 'BC2222222',
name: 'My Benefit Company',
email: 'bc2222222@example.com',
authInfo: { contacts: [ { email: 'bc2222222@example.com' } ] },
address: undefined,
legalType: CorpTypeCd.BENEFIT_COMPANY,
expectedBusinessType: 'BC Benefit Company',
Expand Down Expand Up @@ -156,15 +164,15 @@ describe('Business Table - display', () => {

if ((business.type === AmlTypes.LEAR)) {
expect(td.at(0).text()).toContain(business.name)
expect(td.at(0).text()).toContain(business.email)
expect(td.at(0).text()).toContain(business.authInfo.contacts[0].email)

expect(td.at(1).text()).toContain(business.expectedBusinessType)

if (business.address) {
expect(td.at(2).text()).toContain(business.address.streetAddress)
expect(td.at(2).text()).toContain(business.address.addressCity)
if (business.addresses) {
expect(td.at(2).text()).toContain(business.addresses.registeredOffice.mailingAddress.streetAddress)
expect(td.at(2).text()).toContain(business.addresses.registeredOffice.mailingAddress.addressCity)
expect(td.at(2).text()).toContain('Canada')
expect(td.at(2).text()).toContain(business.address.postalCode)
expect(td.at(2).text()).toContain(business.addresses.registeredOffice.mailingAddress.postalCode)
} else {
expect(td.at(2).text()).toBe('Affiliate to view')
}
Expand All @@ -181,7 +189,10 @@ describe('Business Table - display', () => {

expect(td.at(4).exists()).toBe(true) // see separate BusinessTableStatus tests

expect(td.at(5).find('.v-btn').exists()).toBe(true)
if (business.role === AmlRoles.AMALGAMATING) {
// button only exists on amalgamating businesses (not holding or primary)
expect(td.at(5).find('.v-btn').exists()).toBe(true)
}
}

if ((business.type === AmlTypes.FOREIGN)) {
Expand Down Expand Up @@ -243,12 +254,12 @@ describe('Business Table - validity', () => {
amalgamatingBusinesses: [
// both of these will be status "OK"
{
address: {},
addresses: {},
legalType: CorpTypeCd.BC_COMPANY,
type: AmlTypes.LEAR
},
{
address: {},
addresses: {},
legalType: CorpTypeCd.BC_COMPANY,
type: AmlTypes.LEAR
}
Expand Down
44 changes: 26 additions & 18 deletions tests/unit/BusinessTableSummary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ describe('Business Table Summary', () => {
type: AmlTypes.LEAR,
identifier: 'BC1111111',
name: 'Test Business 1',
email: 'bc1111111@example.com',
address: {
streetAddress: '123 Main St',
addressCity: 'Victoria',
addressCountry: 'CA',
postalCode: 'V8V 8V8'
authInfo: { contacts: [ { email: 'bc1111111@example.com' } ] },
addresses: {
registeredOffice: {
mailingAddress: {
streetAddress: '123 Main St',
addressCity: 'Victoria',
addressCountry: 'CA',
postalCode: 'V8V 8V8'
}
}
},
role: AmlRoles.PRIMARY
},
Expand All @@ -55,12 +59,16 @@ describe('Business Table Summary', () => {
type: AmlTypes.LEAR,
identifier: 'BC1111111',
name: 'Test Business 1',
email: 'bc1111111@example.com',
address: {
streetAddress: '123 Main St',
addressCity: 'Victoria',
addressCountry: 'CA',
postalCode: 'V8V 8V8'
authInfo: { contacts: [ { email: 'bc1111111@example.com' } ] },
addresses: {
registeredOffice: {
mailingAddress: {
streetAddress: '123 Main St',
addressCity: 'Victoria',
addressCountry: 'CA',
postalCode: 'V8V 8V8'
}
}
},
role: AmlRoles.HOLDING
},
Expand All @@ -70,7 +78,7 @@ describe('Business Table Summary', () => {
type: AmlTypes.LEAR,
identifier: 'BC2222222',
name: 'Test Business 2',
email: 'bc2222222@example.com',
authInfo: { contacts: [ { email: 'bc2222222@example.com' } ] },
address: undefined,
role: AmlRoles.AMALGAMATING
},
Expand Down Expand Up @@ -134,13 +142,13 @@ describe('Business Table Summary', () => {

if ((business.type === AmlTypes.LEAR)) {
expect(td.at(0).text()).toContain(business.name)
expect(td.at(0).text()).toContain(business.email)
expect(td.at(0).text()).toContain(business.authInfo.contacts[0].email)

if (business.address) {
expect(td.at(1).text()).toContain(business.address.streetAddress)
expect(td.at(1).text()).toContain(business.address.addressCity)
if (business.addresses) {
expect(td.at(1).text()).toContain(business.addresses.registeredOffice.mailingAddress.streetAddress)
expect(td.at(1).text()).toContain(business.addresses.registeredOffice.mailingAddress.addressCity)
expect(td.at(1).text()).toContain('Canada')
expect(td.at(1).text()).toContain(business.address.postalCode)
expect(td.at(1).text()).toContain(business.addresses.registeredOffice.mailingAddress.postalCode)
} else {
expect(td.at(1).text()).toBe('Affiliate to view')
}
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/amalgamation-mixin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ describe('Amalgamation Mixin - rules', () => {
store.setKeycloakRoles([])

// verify rule
expect(wrapper.vm.notAffiliated({ type: AmlTypes.LEAR, address: null })).toBe(AmlStatuses.ERROR_NOT_AFFILIATED)
expect(wrapper.vm.notAffiliated({ type: AmlTypes.LEAR, addresses: null })).toBe(AmlStatuses.ERROR_NOT_AFFILIATED)

// verify staff only
store.setKeycloakRoles(['staff'])
expect(wrapper.vm.notAffiliated({ type: AmlTypes.LEAR, address: null })).toBeNull()
expect(wrapper.vm.notAffiliated({ type: AmlTypes.LEAR, addresses: null })).toBeNull()
store.setKeycloakRoles([])

// verify not LEAR only
expect(wrapper.vm.notAffiliated({ type: AmlTypes.FOREIGN, address: null })).toBeNull()
expect(wrapper.vm.notAffiliated({ type: AmlTypes.FOREIGN, addresses: null })).toBeNull()

// verify address exists only
expect(wrapper.vm.notAffiliated({ type: AmlTypes.LEAR, address: {} })).toBeNull()
expect(wrapper.vm.notAffiliated({ type: AmlTypes.LEAR, addresses: {} })).toBeNull()
})

it('correctly evaluates "notHistorical" rule', () => {
Expand Down

0 comments on commit 267c612

Please sign in to comment.