diff --git a/package-lock.json b/package-lock.json index 95ecbe14e..2fdfa7614 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "business-create-ui", - "version": "5.6.27", + "version": "5.6.28", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "business-create-ui", - "version": "5.6.27", + "version": "5.6.28", "dependencies": { "@babel/compat-data": "^7.21.5", "@bcrs-shared-components/approval-type": "1.0.19", diff --git a/package.json b/package.json index 54e8c6700..9eeaa7e10 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "business-create-ui", - "version": "5.6.27", + "version": "5.6.28", "private": true, "appName": "Create UI", "sbcName": "SBC Common Components", diff --git a/src/components/Amalgamation/BusinessTable.vue b/src/components/Amalgamation/BusinessTable.vue index d8b5d983f..c3ee5f27c 100644 --- a/src/components/Amalgamation/BusinessTable.vue +++ b/src/components/Amalgamation/BusinessTable.vue @@ -151,7 +151,7 @@ export default class BusinessTable extends Mixins(AmalgamationMixin) { const fj = (item?.type === AmlTypes.FOREIGN) && item.foreignJurisdiction if (fj?.country) { const country = getName(fj.country) - const region = fj.region + const region = (fj.region === 'FEDERAL' ? 'Federal' : fj.region) if (region) return `${region}, ${country}` return country } diff --git a/src/components/Amalgamation/BusinessTableSummary.vue b/src/components/Amalgamation/BusinessTableSummary.vue index 1b47295c7..0edd728b4 100644 --- a/src/components/Amalgamation/BusinessTableSummary.vue +++ b/src/components/Amalgamation/BusinessTableSummary.vue @@ -11,7 +11,7 @@ - +

No businesses added

diff --git a/tests/unit/BusinessStatus.spec.ts b/tests/unit/BusinessStatus.spec.ts new file mode 100644 index 000000000..06ed88de7 --- /dev/null +++ b/tests/unit/BusinessStatus.spec.ts @@ -0,0 +1,111 @@ +import { AmlStatuses } from '@/enums' +import { wrapperFactory } from '../vitest-wrapper-factory' +import BusinessStatus from '@/components/Amalgamation/BusinessStatus.vue' + +describe('Business Status', () => { + const tests = [ + { + label: 'OK', + status: AmlStatuses.OK, + tooltip: 'The currently selected BC Registries account has access to this business.' + }, + { + label: 'Error CCC Mismatch', + status: AmlStatuses.ERROR_CCC_MISMATCH, + tooltip: 'A BC Community Contribution Company must amalgamate to form a new BC Community' + }, + { + label: 'Error Foreign', + status: AmlStatuses.ERROR_FOREIGN, + tooltip: 'A foreign corporation cannot be amalgamated except by Registries staff.' + }, + { + label: 'Error Foreign Horizontal', + status: AmlStatuses.ERROR_FOREIGN_HORIZONTAL, + tooltip: 'A foreign company (including an Extraprovincial Company) cannot be part of a Short' + }, + { + label: 'Error Foreign Unlimited', + status: AmlStatuses.ERROR_FOREIGN_UNLIMITED, + tooltip: 'A foreign corporation must not amalgamate with a limited company and continue as' + }, + { + label: 'Error Foreign Unlimited 2', + status: AmlStatuses.ERROR_FOREIGN_UNLIMITED2, + tooltip: 'A BC Company cannot amalgamate with an existing foreign corporation to form a BC' + }, + { + label: 'Error Foreign Unlimited 3', + status: AmlStatuses.ERROR_FOREIGN_UNLIMITED3, + tooltip: 'A BC Company cannot amalgamate with a foreign company to form a BC Unlimited' + }, + { + label: 'Error Future Effective Filing', + status: AmlStatuses.ERROR_FUTURE_EFFECTIVE_FILING, + tooltip: 'This business has a future effective filing. It cannot be part of an amalgamation' + }, + { + label: 'Error Historical', + status: AmlStatuses.ERROR_HISTORICAL, + tooltip: 'This business is historical. It cannot be part of an amalgamation.' + }, + { + label: 'Error Limited Restoration', + status: AmlStatuses.ERROR_LIMITED_RESTORATION, + tooltip: 'This business is under limited restoration. It cannot be part of an amalgamation' + }, + { + label: 'Error Need BC Company', + status: AmlStatuses.ERROR_NEED_BC_COMPANY, + tooltip: 'You must add at least one BC company.' + }, + { + label: 'Error Not Affiliated', + status: AmlStatuses.ERROR_NOT_AFFILIATED, + tooltip: 'This business is not affiliated with the currently selected BC Registries account.' + }, + { + label: 'Error Not In Good Standing', + status: AmlStatuses.ERROR_NOT_IN_GOOD_STANDING, + tooltip: 'This business is not in good standing. This filing cannot be submitted until all' + }, + { + label: 'Error XPRO ULC CCC', + status: AmlStatuses.ERROR_XPRO_ULC_CCC, + tooltip: 'An Extraprovincial Company cannot amalgamate to form a new BC Unlimited Liability' + } + ] + + it('has the expected number of tests', () => { + expect(tests.length).toBe(14) + }) + + for (const test of tests) { + it(`correctly displays status "${test.label}"`, () => { + const wrapper = wrapperFactory(BusinessStatus, { status: test.status }) + + const div = wrapper.find('.business-status') + expect(div.exists()).toBe(true) + + // verify icon + if (test.status === AmlStatuses.OK) { + expect(div.find('.v-icon.mdi-check').exists()).toBe(true) + } else { + expect(div.find('.v-icon.mdi-alert').exists()).toBe(true) + } + + // verify text + if (test.status === AmlStatuses.OK) { + expect(div.text()).toContain('Ready') + } else { + expect(div.text()).toContain('Attention Required') + } + + // verify tooltip + // (can't verify v-tooltip text directly because it's attached outside this component) + expect((wrapper.vm as any).tooltip).toContain(test.tooltip) + + wrapper.destroy() + }) + } +}) diff --git a/tests/unit/BusinessTable.spec.ts b/tests/unit/BusinessTable.spec.ts new file mode 100644 index 000000000..4d8d00d31 --- /dev/null +++ b/tests/unit/BusinessTable.spec.ts @@ -0,0 +1,169 @@ +import { AmlRoles, AmlTypes } from '@/enums' +import { wrapperFactory } from '../vitest-wrapper-factory' +import BusinessTable from '@/components/Amalgamation/BusinessTable.vue' +import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module' + +describe('Business Table', () => { + it('displays correctly when there are no amalgamating businesses', () => { + const wrapper = wrapperFactory( + BusinessTable, + null, + { + amalgamation: { + amalgamatingBusinesses: [] + } + } + ) + + const table = wrapper.find('#business-table') + expect(table.exists()).toBe(true) + + // verify table headers + const th = table.findAll('thead tr > th') + expect(th.length).toBe(6) + expect(th.at(0).text()).toBe('Business Name') + expect(th.at(1).text()).toBe('Business Type') + expect(th.at(2).text()).toBe('Mailing Address') + expect(th.at(3).text()).toBe('Role') + expect(th.at(4).text()).toBe('Status') + expect(th.at(5).text()).toBe('Action') + + // verify table data + const td = table.findAll('tbody tr > td') + expect(td.length).toBe(1) + expect(td.at(0).attributes('colspan')).toBe('6') + expect(td.at(0).text()).toBe('No businesses added') + + wrapper.destroy() + }) + + const amalgamatingBusinesses = [ + { + label: 'BC Limited holding business', + 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' + }, + legalType: CorpTypeCd.BC_COMPANY, + expectedBusinessType: 'BC Limited Company', + role: AmlRoles.HOLDING + }, + { + label: 'Benefit Company amalgamating business with no address', + type: AmlTypes.LEAR, + identifier: 'BC2222222', + name: 'My Benefit Company', + email: 'bc2222222@example.com', + address: undefined, + legalType: CorpTypeCd.BENEFIT_COMPANY, + expectedBusinessType: 'BC Benefit Company', + role: AmlRoles.AMALGAMATING + }, + { + label: 'foreign business in Federal jurisdiction', + type: AmlTypes.FOREIGN, + corpNumber: 'CA-3333333', + legalName: 'My Federal Business', + expectedBusinessType: 'Foreign', + foreignJurisdiction: { + country: 'CA', + region: 'FEDERAL' + }, + expectedJurisdiction: 'Federal, Canada', + role: AmlRoles.AMALGAMATING + }, + { + label: 'foreign business in USA jurisdiction', + type: AmlTypes.FOREIGN, + corpNumber: 'US-4444444', + legalName: 'My USA Business', + expectedBusinessType: 'Foreign', + foreignJurisdiction: { + country: 'US' + }, + expectedJurisdiction: 'United States of America', + role: AmlRoles.AMALGAMATING + } + ] + + for (const business of amalgamatingBusinesses) { + it(`displays correctly when there is a ${business.label}`, () => { + const wrapper = wrapperFactory( + BusinessTable, + null, + { + amalgamation: { + amalgamatingBusinesses: [ business ] + } + } + ) + + const table = wrapper.find('#business-table') + expect(table.exists()).toBe(true) + + // verify table headers + const th = table.findAll('thead tr > th') + expect(th.length).toBe(6) + expect(th.at(0).text()).toBe('Business Name') + expect(th.at(1).text()).toBe('Business Type') + expect(th.at(2).text()).toBe('Mailing Address') + expect(th.at(3).text()).toBe('Role') + expect(th.at(4).text()).toBe('Status') + expect(th.at(5).text()).toBe('Action') + + // verify table data + const td = table.findAll('tbody tr > td') + expect(td.length).toBe(6) + expect(td.at(0).classes('business-name')).toBe(true) + expect(td.at(1).classes('business-type')).toBe(true) + expect(td.at(2).classes('business-address')).toBe(true) + expect(td.at(3).classes('business-role')).toBe(true) + expect(td.at(4).classes('business-status')).toBe(true) + expect(td.at(5).classes('business-actions')).toBe(true) + + if ((business.type === AmlTypes.LEAR)) { + expect(td.at(0).text()).toContain(business.name) + expect(td.at(0).text()).toContain(business.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) + expect(td.at(2).text()).toContain('Canada') + expect(td.at(2).text()).toContain(business.address.postalCode) + } else { + expect(td.at(2).text()).toBe('Affiliate to view') + } + + if (business.role === AmlRoles.AMALGAMATING) { + expect(td.at(3).text()).toBe('Amalgamating Business') + } + if (business.role === AmlRoles.HOLDING) { + expect(td.at(3).text()).toBe('Holding Company') + } + + expect(td.at(4).exists()).toBe(true) // see separate BusinessTableStatus tests + + expect(td.at(5).find('.v-btn').exists()).toBe(true) + } + + if ((business.type === AmlTypes.FOREIGN)) { + expect(td.at(0).text()).toBe(business.legalName) + expect(td.at(1).text()).toBe(business.expectedBusinessType) + expect(td.at(2).text()).toBe(business.expectedJurisdiction) + expect(td.at(3).text()).toBe('Amalgamating Business') + expect(td.at(4).exists()).toBe(true) // see separate BusinessTableStatus tests + expect(td.at(5).find('.v-btn').exists()).toBe(true) + } + + wrapper.destroy() + }) + } +}) diff --git a/tests/unit/BusinessTableSummary.spec.ts b/tests/unit/BusinessTableSummary.spec.ts new file mode 100644 index 000000000..6f5cf1048 --- /dev/null +++ b/tests/unit/BusinessTableSummary.spec.ts @@ -0,0 +1,141 @@ +import { AmlRoles, AmlTypes } from '@/enums' +import { wrapperFactory } from '../vitest-wrapper-factory' +import BusinessTableSummary from '@/components/Amalgamation/BusinessTableSummary.vue' + +describe('Business Table Summary', () => { + it('displays correctly when there are no amalgamating businesses', () => { + const wrapper = wrapperFactory( + BusinessTableSummary, + null, + { + amalgamation: { + amalgamatingBusinesses: [] + } + } + ) + + const bts = wrapper.find('#business-table-summary') + expect(bts.exists()).toBe(true) + + // verify table headers + const th = bts.findAll('thead tr > th') + expect(th.length).toBe(3) + expect(th.at(0).text()).toBe('Business Name') + expect(th.at(1).text()).toBe('Mailing Address') + expect(th.at(2).text()).toBe('Role') + + // verify table data + const td = bts.findAll('tbody tr > td') + expect(td.length).toBe(1) + expect(td.at(0).attributes('colspan')).toBe('3') + expect(td.at(0).text()).toBe('No businesses added') + + wrapper.destroy() + }) + + const amalgamatingBusinesses = [ + { + label: 'LEAR holding business', + 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' + }, + role: AmlRoles.HOLDING + }, + { + label: 'LEAR amalgamating business with no address', + type: AmlTypes.LEAR, + identifier: 'BC2222222', + name: 'Test Business 2', + email: 'bc2222222@example.com', + address: undefined, + role: AmlRoles.AMALGAMATING + }, + { + label: 'foreign business in Federal jurisdiction', + type: AmlTypes.FOREIGN, + corpNumber: 'CA-3333333', + legalName: 'Test Business 3', + foreignJurisdiction: { + country: 'CA', + region: 'FEDERAL' + }, + expectedJurisdiction: 'Federal, Canada', + role: AmlRoles.AMALGAMATING + }, + { + label: 'foreign business in USA jurisdiction', + type: AmlTypes.FOREIGN, + corpNumber: 'US-4444444', + legalName: 'Test Business 4', + foreignJurisdiction: { + country: 'US' + }, + expectedJurisdiction: 'United States of America', + role: AmlRoles.AMALGAMATING + } + ] + + for (const business of amalgamatingBusinesses) { + it(`displays correctly when there is a ${business.label}`, () => { + const wrapper = wrapperFactory( + BusinessTableSummary, + null, + { + amalgamation: { + amalgamatingBusinesses: [ business ] + } + } + ) + + const bts = wrapper.find('#business-table-summary') + expect(bts.exists()).toBe(true) + + // verify table headers + const th = bts.findAll('thead tr > th') + expect(th.length).toBe(3) + expect(th.at(0).text()).toBe('Business Name') + expect(th.at(1).text()).toBe('Mailing Address') + expect(th.at(2).text()).toBe('Role') + + // verify table data + const td = bts.findAll('tbody tr > td') + expect(td.length).toBe(3) + + if ((business.type === AmlTypes.LEAR)) { + expect(td.at(0).text()).toContain(business.name) + expect(td.at(0).text()).toContain(business.email) + + if (business.address) { + expect(td.at(1).text()).toContain(business.address.streetAddress) + expect(td.at(1).text()).toContain(business.address.addressCity) + expect(td.at(1).text()).toContain('Canada') + expect(td.at(1).text()).toContain(business.address.postalCode) + } else { + expect(td.at(1).text()).toBe('Affiliate to view') + } + + if (business.role === AmlRoles.AMALGAMATING) { + expect(td.at(2).text()).toBe('Amalgamating Business') + } + if (business.role === AmlRoles.HOLDING) { + expect(td.at(2).text()).toBe('Holding Company') + } + } + + if ((business.type === AmlTypes.FOREIGN)) { + expect(td.at(0).text()).toBe(business.legalName) + expect(td.at(1).text()).toBe(business.expectedJurisdiction) + expect(td.at(2).text()).toBe('Amalgamating Business') + } + + wrapper.destroy() + }) + } +})