Skip to content

Commit

Permalink
15018 Fix max business start date (#505)
Browse files Browse the repository at this point in the history
* - app version = 4.4.5

* - fixed startDateMin
- fixed startDateMax
- added unit tests
  • Loading branch information
severinbeauvais authored Jun 14, 2023
1 parent cf66add commit a3673d6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 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": "4.4.4",
"version": "4.4.5",
"private": true,
"appName": "Edit UI",
"sbcName": "SBC Common Components",
Expand Down
12 changes: 6 additions & 6 deletions src/components/common/YourCompany/BusinessStartDate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
title="Start Date"
nudge-right="80"
nudge-top="15"
:minDate="minDate"
:maxDate="maxDate"
:minDate="startDateMin"
:maxDate="startDateMax"
:editLabel="getEditLabel"
:editedLabel="getEditedLabel"
@emitDate="onOkClicked($event)"
Expand Down Expand Up @@ -216,22 +216,22 @@ export default class BusinessStartDate extends Mixins(CommonMixin, DateMixin) {
}
/** The minimum start date that can be entered (up to 10 years before reg date). */
get minDate (): string {
get startDateMin (): string {
// no min date for staff
if (this.isRoleStaff) return null
const date = this.apiToDate(this.getBusinessFoundingDateTime)
date.setFullYear(date.getUTCFullYear() - 10)
date.setFullYear(date.getFullYear() - 10)
return this.dateToYyyyMmDd(date)
}
/** The maximum start date that can be entered (up to 90 days after reg date). */
get maxDate (): string {
get startDateMax (): string {
// no max date for conversion
if (this.isFirmConversionFiling) return null
const date = this.apiToDate(this.getBusinessFoundingDateTime)
date.setDate(date.getUTCDate() + 90)
date.setDate(date.getDate() + 90)
return this.dateToYyyyMmDd(date)
}
Expand Down
16 changes: 15 additions & 1 deletion tests/unit/BusinessStartDate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Business Start Date', () => {
let wrapper: any

beforeEach(async () => {
store.stateModel.businessInformation.foundingDate = '2021-07-01T00:00:00.000000+00:00'
store.stateModel.businessInformation.foundingDate = '2021-07-01T12:00:00.000000+00:00'
store.stateModel.tombstone.entityType = CorpTypeCd.SOLE_PROP
wrapper = mount(BusinessStartDate, { vuetify, localVue, router })
await flushPromises()
Expand Down Expand Up @@ -87,4 +87,18 @@ describe('Business Start Date', () => {
expect(wrapper.find('.v-chip__content').text()).toBe('Corrected')
expect(wrapper.find('#start-undo-btn').text()).toBe('Undo')
})

it('has correct minimum and maximum dates for a staff user ', () => {
store.setKeycloakRoles(['staff'])

expect(wrapper.vm.startDateMin).toBe(null) // no minimum date
expect(wrapper.vm.startDateMax).toBe('2021-09-29') // 90 days after founding date
})

it('has correct minimum and maximum dates for a regular user', () => {
store.setKeycloakRoles([])

expect(wrapper.vm.startDateMin).toBe('2011-07-01') // 10 years before founding date
expect(wrapper.vm.startDateMax).toBe('2021-09-29') // 90 days after founding date
})
})

0 comments on commit a3673d6

Please sign in to comment.