Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

18641 Business table unit tests #615

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.6.27",
"version": "5.6.28",
"private": true,
"appName": "Create UI",
"sbcName": "SBC Common Components",
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 @@ -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
}
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 @@ -11,7 +11,7 @@

<tbody>
<tr v-if="!getAmalgamatingBusinesses.length">
<td colspan="6">
<td colspan="3">
<p class="text-center mb-0">
No businesses added
</p>
Expand Down
111 changes: 111 additions & 0 deletions tests/unit/BusinessStatus.spec.ts
Original file line number Diff line number Diff line change
@@ -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)
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in case we delete or add a status and forget to update these tests.


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()
})
}
})
169 changes: 169 additions & 0 deletions tests/unit/BusinessTable.spec.ts
Original file line number Diff line number Diff line change
@@ -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()
})
}
})
Loading
Loading