Skip to content

Commit

Permalink
18369 agm extension evaluation (#573)
Browse files Browse the repository at this point in the history
* 18369 agm evaluation component setup

* 18369 agm evaluation component setup

* 18369 added logic to agm extension evaluation component and unit testing

* removed unnecessary data from agmExtensionEvaluation

* removed rootStore values since unused

* removed unused pinia

* misc edit

* added yellow evaluation box unit test

* fixed expected value

* removed redundant testing in yellow-box verification

* added idea for template conditionals in the component

* rearranged data variables in the conditionals

* removed now unused props

* misc fix

* added new testing for agm extension evaluation

* removed Text string variables from AgmExtension.vue

* fized testing error

* fixed silly typo
  • Loading branch information
PaulGarewal authored Nov 14, 2023
1 parent d0c8c19 commit a7f7a20
Show file tree
Hide file tree
Showing 4 changed files with 259 additions and 12 deletions.
40 changes: 37 additions & 3 deletions src/components/AgmExtension/AgmExtensionEvaluation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<template #content>
<v-card
v-if="!data.isEligible"
outlined
class="message-box rounded-0 mt-6 mx-6"
>
Expand All @@ -33,7 +34,7 @@
cols="12"
sm="9"
>
{{ data.agmYear || '' }}
{{ data.agmYear }}
</v-col>
</v-row>

Expand All @@ -51,7 +52,21 @@
cols="12"
sm="9"
>
{{ data.extensionDuration || 'Unknown' }}
<template v-if="!data.isEligible">
<template v-if="data.alreadyExtended && !data.requestExpired">
The business has reached maximum possible extension for this AGM.
</template>
<template v-else-if="!data.alreadyExtended && data.requestExpired">
The period to request an extension for this AGM has expired.
</template>
<template v-else-if="data.alreadyExtended && data.requestExpired">
The business has reached maximum possible extension for this AGM.
The period to request an extension has expired.
</template>
</template>
<template v-else>
{{ data.extensionDuration }} months
</template>
</v-col>
</v-row>

Expand All @@ -69,7 +84,21 @@
cols="12"
sm="9"
>
{{ data.agmDueDate || 'Unknown' }}
<template v-if="!data.isEligible">
<template v-if="data.alreadyExtended && !data.requestExpired">
The due date for this AGM cannot be set since extension has already been requested.
</template>
<template v-else-if="!data.alreadyExtended && data.requestExpired">
The due date for this AGM cannot be set since the request for extension has expired.
</template>
<template v-else-if="data.alreadyExtended && data.requestExpired">
The due date for this AGM cannot be set since extension has already been requested and the request
for extension has expired.
</template>
</template>
<template v-else>
{{ dueDateString }}
</template>
</v-col>
</v-row>
</template>
Expand All @@ -80,6 +109,7 @@
import { Component, Prop, Vue } from 'vue-property-decorator'
import { VcardTemplate } from '@/components/common'
import { AgmExtEvalIF } from '@/interfaces'
import { DateUtilities } from '@/services'
@Component({
components: {
Expand All @@ -88,5 +118,9 @@ import { AgmExtEvalIF } from '@/interfaces'
})
export default class AgmExtensionEvaluation extends Vue {
@Prop({ required: true }) readonly data!: AgmExtEvalIF
get dueDateString (): string {
return (DateUtilities.formatYyyyMmDd(this.data.agmDueDate))
}
}
</script>
4 changes: 4 additions & 0 deletions src/interfaces/agm-ext-eval-interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** Object that stores AGM Extension evaluation fields. */
export interface AgmExtEvalIF {
alreadyExtended: boolean
requestExpired: boolean
isGoodStanding: boolean
incorporationDate: Date
isFirstAgm: boolean
Expand All @@ -15,6 +17,8 @@ export interface AgmExtEvalIF {

/** An empty AGM Extension Evaluation object. Note: don't assign this - make a copy instead. */
export const EmptyAgmExtEval: AgmExtEvalIF = {
alreadyExtended: null,
requestExpired: null,
isGoodStanding: null,
incorporationDate: null,
isFirstAgm: null,
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/AgmExtension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ describe('AGM Extension view', () => {
incorporationDate: new Date('2000-01-01T08:00:00.000Z'),
isEligible: true,
isFirstAgm: null,
isGoodStanding: true
isGoodStanding: true,
alreadyExtended: null,
requestExpired: null
},
business: {
foundingDate: '2000-01-01T08:00:00.000+00:00',
Expand Down
223 changes: 215 additions & 8 deletions tests/unit/AgmExtensionEvaluation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import Vue from 'vue'
import Vuetify from 'vuetify'
import { mount } from '@vue/test-utils'
import { createPinia, setActivePinia } from 'pinia'
import { useRootStore } from '@/stores'
import AgmExtensionEvaluation from '@/components/AgmExtension/AgmExtensionEvaluation.vue'

Vue.use(Vuetify)

const vuetify = new Vuetify({})
setActivePinia(createPinia())
const rootStore = useRootStore()

describe('ExtensionRequest', () => {
describe('ExtensionEvaluation', () => {
it('displays normally', () => {
// init store
rootStore.keycloakRoles = ['']

const wrapper = mount(AgmExtensionEvaluation, {
propsData: {
Expand All @@ -36,10 +31,222 @@ describe('ExtensionRequest', () => {
expect(rows.at(0).find('.col-sm-9').text()).toBe('2023')

expect(rows.at(1).find('.col-sm-3').text()).toBe('Duration of Extension')
expect(rows.at(1).find('.col-sm-9').text()).toBe('Unknown')
expect(rows.at(1).find('.col-sm-9').text()).toBe('')

expect(rows.at(2).find('.col-sm-3').text()).toBe('Due date for this AGM')
expect(rows.at(2).find('.col-sm-9').text()).toBe('Unknown')
expect(rows.at(2).find('.col-sm-9').text()).toBe('')

wrapper.destroy()
})

it('is eligible', () => {
// init store

const wrapper = mount(AgmExtensionEvaluation, {
propsData: {
data: {
agmYear: 2023,
isEligible: true,
alreadyExtended: false,
requestExpired: false
}
},
vuetify
})

const rows = wrapper.findAll('.content .row')

expect(rows.at(0).find('.col-sm-9').text()).toBe('2023')

expect(rows.at(1).find('.col-sm-9').text()).toBe('months')

expect(rows.at(2).find('.col-sm-9').text()).toBe('')

wrapper.destroy()
})

it('is eligible, setting the already extended and request expired to true', () => {
// init store

const wrapper = mount(AgmExtensionEvaluation, {
propsData: {
data: {
agmYear: 2023,
isEligible: true,
alreadyExtended: true,
requestExpired: true
}
},
vuetify
})

const rows = wrapper.findAll('.content .row')

expect(rows.at(0).find('.col-sm-9').text()).toBe('2023')

expect(rows.at(1).find('.col-sm-9').text()).toBe('months')

expect(rows.at(2).find('.col-sm-9').text()).toBe('')

wrapper.destroy()
})

it('is eligible, setting the already extended to false request expired to true', () => {
// init store

const wrapper = mount(AgmExtensionEvaluation, {
propsData: {
data: {
agmYear: 2023,
isEligible: true,
alreadyExtended: false,
requestExpired: true
}
},
vuetify
})

const rows = wrapper.findAll('.content .row')

expect(rows.at(0).find('.col-sm-9').text()).toBe('2023')

expect(rows.at(1).find('.col-sm-9').text()).toBe('months')

expect(rows.at(2).find('.col-sm-9').text()).toBe('')

wrapper.destroy()
})

it('is eligible, setting the already extended to true and request expired to false', () => {
// init store

const wrapper = mount(AgmExtensionEvaluation, {
propsData: {
data: {
agmYear: 2023,
isEligible: true,
alreadyExtended: true,
requestExpired: false
}
},
vuetify
})

const rows = wrapper.findAll('.content .row')

expect(rows.at(0).find('.col-sm-9').text()).toBe('2023')

expect(rows.at(1).find('.col-sm-9').text()).toBe('months')

expect(rows.at(2).find('.col-sm-9').text()).toBe('')

wrapper.destroy()
})

it('is not eligible - already extended', () => {
// init store

const wrapper = mount(AgmExtensionEvaluation, {
propsData: {
data: {
agmYear: 2023,
isEligible: false,
alreadyExtended: true,
requestExpired: false
}
},
vuetify
})

const rows = wrapper.findAll('.content .row')

expect(rows.at(0).find('.col-sm-9').text()).toBe('2023')

expect(rows.at(1).find('.col-sm-9').text()).toBe(
'The business has reached maximum possible extension for this AGM.')

expect(rows.at(2).find('.col-sm-9').text()).toBe(
'The due date for this AGM cannot be set since extension has already been requested.')

wrapper.destroy()
})

it('is not eligible - request expired', () => {
// init store

const wrapper = mount(AgmExtensionEvaluation, {
propsData: {
data: {
agmYear: 2023,
isEligible: false,
alreadyExtended: false,
requestExpired: true
}
},
vuetify
})

const rows = wrapper.findAll('.content .row')

expect(rows.at(0).find('.col-sm-9').text()).toBe('2023')

expect(rows.at(1).find('.col-sm-9').text()).toBe(
'The period to request an extension for this AGM has expired.')

expect(rows.at(2).find('.col-sm-9').text()).toBe(
'The due date for this AGM cannot be set since the request for extension has expired.')

wrapper.destroy()
})

it('is not eligible - already extended + request expired', () => {
// init store

const wrapper = mount(AgmExtensionEvaluation, {
propsData: {
data: {
agmYear: 2023,
isEligible: false,
alreadyExtended: true,
requestExpired: true
}
},
vuetify
})

const rows = wrapper.findAll('.content .row')

expect(rows.at(0).find('.col-sm-9').text()).toBe('2023')

expect(rows.at(1).find('.col-sm-9').text()).toBe(
'The business has reached maximum possible extension for this AGM. ' +
'The period to request an extension has expired.')

expect(rows.at(2).find('.col-sm-9').text()).toBe(
'The due date for this AGM cannot be set since extension has already been requested ' +
'and the request for extension has expired.')

wrapper.destroy()
})

it('is not eligible yellow-box verification', () => {
// init store

const wrapper = mount(AgmExtensionEvaluation, {
propsData: {
data: {
agmYear: 2023,
isEligible: false,
alreadyExtended: true,
requestExpired: true
}
},
vuetify
})

const yellowEvalBox = wrapper.find('.message-box')

expect(yellowEvalBox.exists()).toBe(true)

wrapper.destroy()
})
Expand Down

0 comments on commit a7f7a20

Please sign in to comment.