-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added element ids - updated LEAR business duplicate check - added foreign business duplicate check - misc cleanup - added test suite (WIP)
- Loading branch information
Severin Beauvais
committed
Jan 17, 2024
1 parent
87fc3f9
commit 9b3623f
Showing
13 changed files
with
220 additions
and
34 deletions.
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
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,181 @@ | ||
import Vue from 'vue' | ||
import Vuetify from 'vuetify' | ||
import { createPinia, setActivePinia } from 'pinia' | ||
import { useStore } from '@/store/store' | ||
import { mount } from '@vue/test-utils' | ||
import flushPromises from 'flush-promises' | ||
import LegalServices from '@/services/legal-services' | ||
import AmalgamatingBusinesses from '@/components/Amalgamation/AmalgamatingBusinesses.vue' | ||
import { AmlRoles, AmlTypes } from '@/enums/amalgamationEnums' | ||
|
||
const vuetify = new Vuetify({}) | ||
setActivePinia(createPinia()) | ||
const store = useStore() | ||
|
||
// mock services function | ||
// vi.spyOn((LegalServices as any), 'updateFiling').mockImplementation(() => {}) | ||
|
||
describe('Amalgamating Businesses - add amalgamating business', () => { | ||
let wrapper: any | ||
|
||
beforeEach(() => { | ||
// initial state | ||
store.stateModel.tombstone.keycloakRoles = [] | ||
store.stateModel.amalgamation.amalgamatingBusinesses = [] | ||
|
||
wrapper = mount(AmalgamatingBusinesses, { vuetify }) | ||
}) | ||
|
||
afterEach(() => { | ||
wrapper.destroy() | ||
}) | ||
|
||
it('conditionally renders the amalgamating business panel', async () => { | ||
}) | ||
|
||
it('saves an amalgamating business', async () => { | ||
}) | ||
|
||
it('saves an amalgamating business', async () => { | ||
}) | ||
|
||
it('doesn\'t add a duplicate amalgamating business', async () => { | ||
}) | ||
}) | ||
|
||
describe('Amalgamating Businesses - add amalgamating foreign business', () => { | ||
let wrapper: any | ||
|
||
beforeEach(() => { | ||
// initial state | ||
store.stateModel.tombstone.keycloakRoles = ['staff'] | ||
store.stateModel.amalgamation.amalgamatingBusinesses = [] | ||
|
||
wrapper = mount(AmalgamatingBusinesses, { vuetify }) | ||
}) | ||
|
||
afterEach(() => { | ||
wrapper.destroy() | ||
}) | ||
|
||
it('conditionally renders the foreign business panel', async () => { | ||
// verify panel not yet rendered | ||
expect(wrapper.find('#add-foreign-business-panel').exists()).toBe(false) | ||
|
||
// verify Add buttons are enabled | ||
const addAmalgamatingButton = wrapper.find('#add-amalgamating-business-button') | ||
const addForeignButton = wrapper.find('#add-foreign-business-button') | ||
expect(addAmalgamatingButton.classes()).not.toContain('v-btn--disabled') | ||
expect(addForeignButton.classes()).not.toContain('v-btn--disabled') | ||
|
||
// verify Add Foreign button and click it | ||
expect(addForeignButton.text()).toBe('Add an Amalgamating Foreign Business') | ||
await addForeignButton.trigger('click') | ||
|
||
// verify Add buttons are now disabled | ||
expect(addAmalgamatingButton.classes()).toContain('v-btn--disabled') | ||
expect(addForeignButton.classes()).toContain('v-btn--disabled') | ||
|
||
// verify panel is now rendered | ||
expect(wrapper.find('#add-foreign-business-panel').exists()).toBe(true) | ||
|
||
// verify Save button | ||
const saveButton = wrapper.find('#save-foreign-business-button') | ||
expect(saveButton.text()).toBe('Add') | ||
|
||
// verify Cancel button and click it | ||
const cancelButton = wrapper.find('#cancel-foreign-business-button') | ||
expect(cancelButton.text()).toBe('Cancel') | ||
await cancelButton.trigger('click') | ||
|
||
// verify panel is no longer rendered | ||
expect(wrapper.find('#add-foreign-business-panel').exists()).toBe(false) | ||
}) | ||
|
||
it('saves a foreign business', async () => { | ||
// open panel | ||
await wrapper.setData({ | ||
isAddingAmalgamatingForeignBusiness: true | ||
}) | ||
|
||
// simulate form data | ||
await wrapper.setData({ | ||
isCan: true, | ||
jurisdiction: { text: 'BC', value: 'CA' }, | ||
legalName: 'Foreign Business', | ||
corpNumber: 'ABC-123' | ||
}) | ||
|
||
// simulate Save button action | ||
wrapper.vm.saveAmalgamatingForeignBusiness() | ||
|
||
// verify validation | ||
expect(wrapper.vm.isForeignBusinessValid).toBe(true) | ||
|
||
// verify data | ||
expect(store.stateModel.amalgamation.amalgamatingBusinesses.length).toBe(1) | ||
const business = store.stateModel.amalgamation.amalgamatingBusinesses[0] as any | ||
expect(business.type).toBe(AmlTypes.FOREIGN) | ||
expect(business.role).toBe(AmlRoles.AMALGAMATING) | ||
expect(business.foreignJurisdiction).toEqual({ country: 'CA', region: 'BC' }) | ||
expect(business.legalName).toBe('Foreign Business') | ||
expect(business.corpNumber).toBe('ABC-123') | ||
|
||
// verify panel is now closed | ||
expect(wrapper.vm.isAddingAmalgamatingForeignBusiness).toBe(false) | ||
}) | ||
|
||
it('doesn\'t add a duplicate foreign business', async () => { | ||
// pre-populate a foreign business | ||
store.stateModel.amalgamation.amalgamatingBusinesses = [ | ||
{ | ||
type: AmlTypes.FOREIGN, | ||
role: AmlRoles.AMALGAMATING, | ||
foreignJurisdiction: { country: 'CA', region: 'BC' }, | ||
legalName: 'Foreign Business', | ||
corpNumber: 'ABC-123' | ||
} | ||
] | ||
expect(store.stateModel.amalgamation.amalgamatingBusinesses.length).toBe(1) | ||
|
||
// open panel | ||
await wrapper.setData({ | ||
isAddingAmalgamatingForeignBusiness: true | ||
}) | ||
|
||
// simulate form data | ||
await wrapper.setData({ | ||
isCan: true, | ||
jurisdiction: { text: 'BC', value: 'CA' }, | ||
legalName: 'Foreign Business', | ||
corpNumber: 'ABC-123' | ||
}) | ||
|
||
// verify snackbar is not displayed | ||
expect(wrapper.vm.snackbar).toBe(false) | ||
|
||
// simulate Save button action | ||
wrapper.vm.saveAmalgamatingForeignBusiness() | ||
|
||
// verify snackbar is displayed | ||
expect(wrapper.vm.snackbar).toBe(true) | ||
|
||
// verify data | ||
expect(store.stateModel.amalgamation.amalgamatingBusinesses.length).toBe(1) | ||
|
||
// verify panel is still open | ||
expect(wrapper.vm.isAddingAmalgamatingForeignBusiness).toBe(true) | ||
}) | ||
}) | ||
|
||
describe.skip('Amalgamating Businesses - foreign business form', () => { | ||
let wrapper: any | ||
|
||
beforeEach(() => { | ||
wrapper = mount(AmalgamatingBusinesses, { vuetify }) | ||
}) | ||
|
||
afterEach(() => { | ||
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
Oops, something went wrong.