Skip to content

Commit

Permalink
Merge pull request #370 from lewischenstudio/13079
Browse files Browse the repository at this point in the history
13079 Resolution Dates Collab Pre-existing Conditions for BEN IA correction filings
  • Loading branch information
lewischenstudio authored Sep 1, 2022
2 parents 5923920 + a6ea3ad commit f69a9f5
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 26 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-edit-ui",
"version": "3.7.0",
"version": "3.7.1",
"private": true,
"appName": "Edit UI",
"sbcName": "SBC Common Components",
Expand Down
3 changes: 2 additions & 1 deletion src/components/Alteration/Articles/Articles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<div
class="section-container"
v-if="getBusinessInformation.hasRestrictions"
v-if="getBusinessInformation.hasRestrictions || isBenCorrectionFiling"
:class="{'invalid-section': invalidCompanyProvisions}">
<CompanyProvisions
class="sub-section"
Expand Down Expand Up @@ -59,6 +59,7 @@ export default class Articles extends Mixins(CommonMixin) {
@Getter getHasRightsOrRestrictions!: boolean
@Getter getIsResolutionDatesValid!: boolean
@Getter getComponentValidate!: boolean
@Getter isBenCorrectionFiling!: boolean
// Global actions
@Action setProvisionsRemoved!: ActionBindingIF
Expand Down
2 changes: 1 addition & 1 deletion src/components/Alteration/Articles/CompanyProvisions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<v-col class="pr-0 pl-0 pt-0" cols="3">
<label class="define-company-provisions-title">Pre-existing<br>Company Provisions</label>
<v-chip v-if="hasProvisionsRemovedPropsChanged" x-small label color="primary" text-color="white">
CHANGED
{{ editedLabel }}
</v-chip>
</v-col>
<v-col id="none-of-provisions-apply-text" cols="7" class="pt-0 pl-0 info-text" v-if="provisionsRemoved">
Expand Down
61 changes: 43 additions & 18 deletions src/components/Alteration/Articles/ResolutionDates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
<label>
<span :class="{'error-text': !getIsResolutionDatesValid}">Resolution or<br>Court Order Dates</span>
</label>
<v-chip
v-if="haveNewResolutionDates && isBenCorrectionFiling"
id="corrected-lbl"
x-small label
color="primary"
text-color="white"
>
Corrected
</v-chip>
</v-col>

<v-col :cols="isEditMode ? '7' : '8'">
Expand All @@ -25,20 +34,20 @@

<v-col cols="2" class="align-right" v-if="isEditMode && !isAdding">
<v-btn id="add-resolution-date"
class="add-btn"
text color="primary"
:disabled="haveAddedDates"
@click="isAdding = true"
class="add-btn"
text color="primary"
:disabled="haveAddedDates"
@click="isAdding = true"
>
<v-icon small>mdi-plus</v-icon>
<span>Add</span>
<v-icon small>{{ addBtnIcon }}</v-icon>
<span>{{ addBtnLabel }}</span>
</v-btn>
</v-col>
<v-col cols="2" class="align-right" v-else-if="isAdding">
<v-btn id="close-resolution-date"
class="close-btn"
text color="primary"
@click="isAdding = false"
class="close-btn"
text color="primary"
@click="isAdding = false"
>
<v-icon small>mdi-close</v-icon>
<span>Cancel</span>
Expand All @@ -52,17 +61,17 @@
<v-col cols="7">
<ul class="resolution-date-list info-text pl-0 mt-2">
<li v-for="(date, index) in addedDates"
:key="`newResolutionDate-${index}`"
:key="`newResolutionDate-${index}`"
>
<strong class="mr-2">{{date}}</strong>
<v-btn v-if="isEditMode"
id="remove-resolution-date"
class="remove-btn mt-n1"
text color="primary"
@click="onRemove(index)"
id="remove-resolution-date"
class="remove-btn mt-n1"
text color="primary"
@click="onRemove(index)"
>
<v-icon small>mdi-delete</v-icon>
<span>Remove</span>
<v-icon small>{{ removeBtnIcon }}</v-icon>
<span>{{ removeBtnLabel }}</span>
</v-btn>
</li>
</ul>
Expand Down Expand Up @@ -140,10 +149,10 @@ export default class ResolutionDates extends Mixins(CommonMixin) {
// Global getters
@Getter getBusinessFoundingDate!: string
@Getter getCurrentDate!: string
@Getter hasShareStructureChanged!: boolean
@Getter getHasOriginalRightsOrRestrictions!: boolean
@Getter haveNewResolutionDates!: boolean
@Getter getIsResolutionDatesValid!: boolean
@Getter isSummaryMode!: boolean
@Getter isBenCorrectionFiling!: boolean
// Global setter
@Action setValidComponent!: ActionBindingIF
Expand All @@ -160,6 +169,22 @@ export default class ResolutionDates extends Mixins(CommonMixin) {
return (this.previousDates?.length > 0)
}
get addBtnIcon (): string {
return this.isBenCorrectionFiling ? 'mdi-pencil' : 'mdi-plus'
}
get addBtnLabel (): string {
return this.isBenCorrectionFiling ? 'Correct' : 'Add'
}
get removeBtnIcon (): string {
return this.isBenCorrectionFiling ? 'mdi-undo' : 'mdi-delete'
}
get removeBtnLabel (): string {
return this.isBenCorrectionFiling ? 'Undo' : 'Remove'
}
/** Called to add a new date. */
onDateEmitted (date: string): void {
if (date) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ export interface CorrectionInformationIF {
resolutionDates?: string[]
}
startDate?: string // YYYY-MM-DD
provisionsRemoved?: boolean
}
6 changes: 5 additions & 1 deletion src/mixins/filing-template-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ export default class FilingTemplateMixin extends Mixins(DateMixin, EnumMixin) {
if (this.isBenCorrectionFiling) {
filing.correction.nameTranslations = isDraft ? this.getNameTranslations : this.prepareNameTranslations()
filing.correction.shareStructure = {
shareClasses: isDraft ? this.getShareClasses : this.prepareShareClasses()
shareClasses: isDraft ? this.getShareClasses : this.prepareShareClasses(),
resolutionDates: this.getNewResolutionDates
}
filing.correction.provisionsRemoved = this.areProvisionsRemoved
}

// add in data specific to firm corrections
Expand Down Expand Up @@ -592,6 +594,8 @@ export default class FilingTemplateMixin extends Mixins(DateMixin, EnumMixin) {
this.setNewResolutionDates(cloneDeep(
filing.correction.shareStructure?.resolutionDates || []
))
// store Provisions Removed
this.setProvisionsRemoved(filing.correction.provisionsRemoved || false)
}

// store Certify State
Expand Down
4 changes: 3 additions & 1 deletion src/store/getters/state-getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,9 @@ export const hasCorrectionDataChanged = (state: StateIF): boolean => {
haveNameTranslationsChanged(state) ||
haveOfficeAddressesChanged(state) ||
havePeopleAndRolesChanged(state) ||
hasShareStructureChanged(state)
hasShareStructureChanged(state) ||
areProvisionsRemoved(state) ||
haveNewResolutionDates(state)
)
}

Expand Down
6 changes: 5 additions & 1 deletion src/views/Correction/BenCorrection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

<ShareStructures class="mt-10" />

<Articles class="mt-10" />

<Detail
class="mt-10"
sectionNumber="1."
Expand All @@ -48,6 +50,7 @@
<script lang="ts">
import { Component, Emit, Mixins, Prop, Watch } from 'vue-property-decorator'
import { Action } from 'vuex-class'
import { Articles } from '@/components/Alteration/'
import { CertifySection, Detail, PeopleAndRoles, ShareStructures, StaffPayment, YourCompany }
from '@/components/common/'
import { CommonMixin, DateMixin, FeeMixin, FilingTemplateMixin } from '@/mixins/'
Expand All @@ -62,7 +65,8 @@ import { BenefitCompanyStatementResource } from '@/resources/Correction/'
PeopleAndRoles,
ShareStructures,
StaffPayment,
YourCompany
YourCompany,
Articles
}
})
export default class BenCorrection extends Mixins(CommonMixin, DateMixin, FeeMixin, FilingTemplateMixin) {
Expand Down
48 changes: 48 additions & 0 deletions tests/unit/Articles.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ const changeCompanyProvisionsButton = '#change-company-provisions'
const undoCompanyProvisions = '#undo-company-provisions'
const companyProvisionsCheckbox = '#cp-checkbox'
const companyProvisionDoneButton = '#company-provisions-done'
const resolutionDatesSection = '#resolution-dates'
const resolutionDatesAddButtonn = '#add-resolution-date'
const resolutionDatesCloseButton = '#close-resolution-date'
const resolutionDatesRemoveButton = '#remove-resolution-date'
const resolutionDatesTextsList = '.resolution-date-list'

describe('Articles component', () => {
it('displays the correct sections', () => {
Expand All @@ -38,6 +43,7 @@ describe('Articles component', () => {
expect(wrapper.find(articlesHeaderIcon).exists()).toBe(true)
expect(wrapper.find(articlesHeaderLabel).text()).toBe('Articles')
expect(wrapper.find(companyProvisionsSection).exists()).toBe(true)
expect(wrapper.find(resolutionDatesSection).exists()).toBe(true)

wrapper.destroy()
})
Expand Down Expand Up @@ -150,4 +156,46 @@ describe('Articles component', () => {

wrapper.destroy()
})

it('shows only Add button when list for the initial state', () => {
const router = mockRouter.mock()
router.push({ name: alterationRoute })
store.state.stateModel.shareStructureStep.resolutionDates = []
const wrapper = mount(Articles, { router, store, vuetify })

expect(wrapper.find(articlesTitle).exists()).toBe(true)
expect(wrapper.find(resolutionDatesAddButtonn).exists()).toBe(true)

wrapper.destroy()
})

it('shows only Close button when Add button is clicked', async () => {
const router = mockRouter.mock()
router.push({ name: alterationRoute })
store.state.stateModel.shareStructureStep.resolutionDates = []
const wrapper = mount(Articles, { router, store, vuetify })

expect(wrapper.find(articlesTitle).exists()).toBe(true)
const addBtn = wrapper.find(resolutionDatesAddButtonn)
await addBtn.trigger('click')

expect(wrapper.find(resolutionDatesCloseButton).exists()).toBe(true)

wrapper.destroy()
})

it('shows only Remove button when the list is not empty', () => {
const router = mockRouter.mock()
router.push({ name: alterationRoute })
store.state.stateModel.shareStructureStep.resolutionDates = ['2022-08-31']
const wrapper = mount(Articles, { router, store, vuetify })

expect(wrapper.find(articlesTitle).exists()).toBe(true)
expect(wrapper.find(resolutionDatesRemoveButton).exists()).toBe(true)
const dates = wrapper.findAll(resolutionDatesTextsList)
expect(dates.exists()).toBe(true)
expect(dates.length).toBe(1)
expect(dates.at(0).text()).toContain('2022-08-31')
wrapper.destroy()
})
})
13 changes: 13 additions & 0 deletions tests/unit/BenCorrection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import sinon from 'sinon'
import { getVuexStore } from '@/store/'
import { shallowMount, createLocalVue } from '@vue/test-utils'
import { axios } from '@/utils/'
import { Articles } from '@/components/Alteration/'
import { CertifySection, Detail, PeopleAndRoles, ShareStructures, StaffPayment, YourCompany }
from '@/components/common/'
import BenCorrection from '@/views/Correction/BenCorrection.vue'
import mockRouter from './MockRouter'

Expand Down Expand Up @@ -156,6 +159,16 @@ describe('Benefit Company Correction component', () => {
expect(wrapper.findComponent(BenCorrection).exists()).toBe(true)
})

it('loads each component', async () => {
expect(wrapper.findComponent(YourCompany).exists()).toBe(true)
expect(wrapper.findComponent(PeopleAndRoles).exists()).toBe(true)
expect(wrapper.findComponent(ShareStructures).exists()).toBe(true)
expect(wrapper.findComponent(Articles).exists()).toBe(true)
expect(wrapper.findComponent(Detail).exists()).toBe(true)
expect(wrapper.findComponent(CertifySection).exists()).toBe(true)
expect(wrapper.findComponent(StaffPayment).exists()).toBe(true)
})

// FUTURE
xit('loads the entity snapshot into the store', async () => {
await wrapper.setProps({ appReady: true })
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/CompanyProvisions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,26 @@ describe('company provisions', () => {

wrapper.destroy()
})

it('displays the Correct button for correction filings', () => {
store.state.stateModel.tombstone.entityType = 'BEN'
store.state.stateModel.tombstone.filingType = 'correction'

const router = mockRouter.mock()
router.push({ name: alterationRouterName })
const wrapper = mount(CompanyProvisions,
{
router,
vuetify,
store,
propsData: { provisionsRemoved: false }
})

const addBtn = wrapper.find('#change-company-provisions')
expect(addBtn.exists()).toBe(true)
expect(addBtn.text()).toBe('Correct')
expect(addBtn.find('.v-icon.mdi-pencil').exists()).toBe(true)

wrapper.destroy()
})
})
32 changes: 32 additions & 0 deletions tests/unit/ResolutionDates.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,38 @@ describe('Resolution Dates component - edit mode', () => {

wrapper.destroy()
})

it('displays the Correct button for correction filings', () => {
store.state.stateModel.tombstone.entityType = 'BEN'
store.state.stateModel.tombstone.filingType = 'correction'
store.state.stateModel.shareStructureStep.shareClasses = shareClasses
store.state.stateModel.shareStructureStep.resolutionDates = addedDates

const wrapper = wrapperFactory()

const addBtn = wrapper.find('#add-resolution-date')
expect(addBtn.exists()).toBe(true)
expect(addBtn.text()).toBe('Correct')
expect(addBtn.find('.v-icon.mdi-pencil').exists()).toBe(true)

wrapper.destroy()
})

it('displays the Undo button for correction filings', async () => {
store.state.stateModel.tombstone.entityType = 'BEN'
store.state.stateModel.tombstone.filingType = 'correction'
store.state.stateModel.shareStructureStep.shareClasses = shareClasses
store.state.stateModel.shareStructureStep.resolutionDates = addedDates

const wrapper = wrapperFactory({ addedDates: ['2021-03-17'] })

const removeBtn = wrapper.find('#remove-resolution-date')
expect(removeBtn.exists()).toBe(true)
expect(removeBtn.text()).toBe('Undo')
expect(removeBtn.find('.v-icon.mdi-undo').exists()).toBe(true)

wrapper.destroy()
})
})

describe('Resolution Dates component - review mode', () => {
Expand Down

0 comments on commit f69a9f5

Please sign in to comment.