Skip to content

Commit

Permalink
19458 - do not show/edit directors (bcgov#648)
Browse files Browse the repository at this point in the history
* 19458 - do not show/edit directors

* 19458 - add unit tests

* 19458 - add filtered person list

* 19458 - update package version

* 19458 - update function logic, fix lint error

* 19458 - update package version
  • Loading branch information
ketaki-deodhar authored and JazzarKarim committed Feb 23, 2024
1 parent 16c0c9b commit 6f173ec
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 4 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.11",
"version": "5.8.12",
"private": true,
"appName": "Create UI",
"sbcName": "SBC Common Components",
Expand Down
14 changes: 13 additions & 1 deletion src/components/common/ListPeopleAndRoles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@

<!-- List Content -->
<v-row
v-for="(orgPerson, index1) in personList"
v-for="(orgPerson, index1) in filteredPersonList"
:key="index1"
class="people-roles-content"
no-gutters
Expand Down Expand Up @@ -258,6 +258,7 @@ export default class ListPeopleAndRoles extends Mixins(CommonMixin) {
@Prop({ default: true }) readonly showDeliveryAddressColumn!: boolean
@Prop({ default: true }) readonly showRolesColumn!: boolean
@Prop({ default: false }) readonly showEmailColumn!: boolean
@Prop({ default: true }) readonly showDirectors!: boolean
@Getter(useStore) getAddPeopleAndRoleStep!: PeopleAndRoleIF
@Getter(useStore) getShowErrors!: boolean
Expand All @@ -276,6 +277,17 @@ export default class ListPeopleAndRoles extends Mixins(CommonMixin) {
// Local properties
protected activeIndex: number // is NaN for new org/person
/**
* PersonList is filtered by RoleType.
*/
get filteredPersonList (): Array<OrgPersonIF> {
if (!this.showDirectors) {
return this.personList.filter(person => !this.isDirector(person))
} else {
return this.personList
}
}
get tableHeaders (): Array<string> {
const headers = ['Name', 'Mailing Address']
if (this.showDeliveryAddressColumn) headers.push('Delivery Address')
Expand Down
1 change: 1 addition & 0 deletions src/components/common/PeopleAndRoles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
<ListPeopleAndRoles
:isSummary="false"
:disabled="showOrgPersonForm"
:showDirectors="getPeopleAndRolesResource.showDirectors"
@editPerson="onEditPerson($event)"
@removePerson="onRemovePerson($event)"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface PeopleAndRolesResourceIF {
blurb2?: string | Array<string>
addIncorporator?: boolean
addPerson?: boolean
showDirectors?: boolean
addOrganization?: boolean
addBusiness?: boolean
rules: Array<RuleIF>
Expand Down
1 change: 1 addition & 0 deletions src/resources/AmalgamationShort/BC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const AmalgamationShortResourceBc: AmalgamationResourceIF = {
blurb: 'Add the Completing Party to this application',
helpSection: null,
addPerson: false,
showDirectors: false,
rules: [
{
id: RuleIds.NUM_COMPLETING_PARTY,
Expand Down
1 change: 1 addition & 0 deletions src/resources/AmalgamationShort/BEN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const AmalgamationShortResourceBen: AmalgamationResourceIF = {
blurb: 'Add the Completing Party to this application',
helpSection: null,
addPerson: false,
showDirectors: false,
rules: [
{
id: RuleIds.NUM_COMPLETING_PARTY,
Expand Down
1 change: 1 addition & 0 deletions src/resources/AmalgamationShort/CC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const AmalgamationShortResourceCc: AmalgamationResourceIF = {
blurb: 'Add the Completing Party to this application',
helpSection: null,
addPerson: false,
showDirectors: false,
rules: [
{
id: RuleIds.NUM_COMPLETING_PARTY,
Expand Down
1 change: 1 addition & 0 deletions src/resources/AmalgamationShort/ULC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const AmalgamationShortResourceUlc: AmalgamationResourceIF = {
blurb: 'Add the Completing Party to this application',
helpSection: null,
addPerson: false,
showDirectors: false,
rules: [
{
id: RuleIds.NUM_COMPLETING_PARTY,
Expand Down
106 changes: 106 additions & 0 deletions tests/unit/ListPeopleAndRoles.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,3 +467,109 @@ describe('List People And Roles component - BEN restoration', () => {
expect(wrapper.find('.people-roles-content').exists()).toBe(true)
})
})

describe('List People And Roles component - Short form amalgamation', () => {
let wrapper: any

const mockPersonList = [
{
officer: {
id: 0,
firstName: 'Jon',
lastName: 'Doe',
middleName: 'D',
organizationName: '',
partyType: 'person',
email: '[email protected]'
},
roles: [
{ roleType: 'Completing Party', appointmentDate: '2020-03-30' }
],
mailingAddress: {
streetAddress: '123 Fake Street',
streetAddressAdditional: '',
addressCity: 'Victoria',
addressRegion: 'BC',
postalCode: 'V8Z 5C6',
addressCountry: 'CA'
}
},
{
officer: {
id: 1,
firstName: '',
lastName: '',
middleName: '',
organizationName: 'Sysco Foods Company',
partyType: 'organization'
},
roles: [
{ roleType: 'Director', appointmentDate: '2020-03-30' }
],
mailingAddress: {
streetAddress: '123 Fake Street',
streetAddressAdditional: '',
addressCity: 'Victoria',
addressRegion: 'BC',
postalCode: 'V8Z 5C6',
addressCountry: 'CA'
},
deliveryAddress: {
streetAddress: '123 Fake Street',
streetAddressAdditional: '',
addressCity: 'Victoria',
addressRegion: 'BC',
postalCode: 'V8Z 5C6',
addressCountry: 'CA'
}
}
]

beforeAll(() => {
store.stateModel.entityType = CorpTypeCd.BENEFIT_COMPANY
store.stateModel.tombstone.filingType = FilingTypes.AMALGAMATION_APPLICATION
})

afterEach(() => {
wrapper.destroy()
})

it('does not show the peoples/roles list if there is no data to display', () => {
wrapper = shallowWrapperFactory(
ListPeopleAndRoles,
null,
{ addPeopleAndRoleStep: { orgPeople: [] } }
)

expect(wrapper.findAll('.people-roles-content').length).toEqual(0)
expect(wrapper.find('.people-roles-header').exists()).toBe(false)
expect(wrapper.find('.people-roles-content').exists()).toBe(false)
})

it('displays correct number of peoples/roles list - showDirectors set to false', () => {
wrapper = shallowWrapperFactory(
ListPeopleAndRoles,
{
showDirectors: false
},
{
addPeopleAndRoleStep: { orgPeople: mockPersonList }
}
)

expect(wrapper.findAll('.people-roles-content').length).toEqual(1)
expect(wrapper.find('.people-roles-content').exists()).toBe(true)
})

it('displays correct number of peoples/roles list - showDirectors default value (true)', () => {
wrapper = shallowWrapperFactory(
ListPeopleAndRoles,
null,
{ addPeopleAndRoleStep: { orgPeople: mockPersonList } }
)

expect(wrapper.findAll('.people-roles-content').length).toEqual(2)
expect(wrapper.find('.people-roles-header').exists()).toBe(true)
expect(wrapper.find('.people-roles-content').exists()).toBe(true)
})
})

0 comments on commit 6f173ec

Please sign in to comment.