-
Notifications
You must be signed in to change notification settings - Fork 49
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
|
||
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() | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
}) | ||
} | ||
}) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.