Skip to content

Commit

Permalink
- updated Staff Payment unit tests
Browse files Browse the repository at this point in the history
- refactored Directors unit tests to not use setTimeout()
- fixed filing save tests (missing 'get tasks')
- cleaned up other unit tests
- added Detail Comment autofocus prop
- display app version on startup to console
- removed obsolete hard-coded entity type (code still not in use)
- ensures comments are sorted by timestamp
  • Loading branch information
severinbeauvais committed Feb 20, 2020
1 parent 899d106 commit 07935ca
Show file tree
Hide file tree
Showing 29 changed files with 444 additions and 358 deletions.
22 changes: 15 additions & 7 deletions src/components/Dashboard/FilingHistoryList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
</template>
<v-list dense>
<v-list-item-group color="primary">
<!-- NB: this menu item is disabled in current release -->
<v-list-item disabled>
<v-list-item-icon>
<v-icon>mdi-file-document-edit-outline</v-icon>
Expand Down Expand Up @@ -162,8 +163,8 @@
v-if="isRoleStaff"
@click.stop="showCommentDialog(item.filingId)"
>
<span>Add Detail Comment</span>
</v-btn>
<span>Add Detail Comment</span>
</v-btn>
</div>
<div>
<!-- the detail comments list-->
Expand Down Expand Up @@ -344,7 +345,7 @@ export default {
}],
paperOnly: false,
isCorrected: filing.header.isCorrected || false,
comments: this.flattenComments(filing.header.comments)
comments: this.flattenAndSortComments(filing.header.comments)
}
this.filedItems.push(item)
} else {
Expand Down Expand Up @@ -388,7 +389,7 @@ export default {
status: filing.header.status,
paperOnly: false,
isCorrected: filing.header.isCorrected || false,
comments: this.flattenComments(filing.header.comments)
comments: this.flattenAndSortComments(filing.header.comments)
}
this.filedItems.push(item)
} else {
Expand Down Expand Up @@ -429,13 +430,20 @@ export default {
}],
paperOnly: true,
isCorrected: filing.header.isCorrected || false,
comments: this.flattenComments(filing.header.comments)
comments: this.flattenAndSortComments(filing.header.comments)
}
this.filedItems.push(item)
},
flattenComments (comments: any): Array<any> {
return (comments && comments.length > 0) ? comments.map(c => c.comment) : []
flattenAndSortComments (comments: any): Array<any> {
if (comments && comments.length > 0) {
// first use map to change comment.comment to comment
const mapped: Array<any> = comments.map(c => c.comment)
// then sort newest to oldest
const sorted = mapped.sort((a, b) => new Date(a.timestamp) < new Date(b.timestamp) ? 1 : -1)
return sorted
}
return []
},
typeToTitle (type: string, agmYear: string = null): string {
Expand Down
7 changes: 6 additions & 1 deletion src/components/common/DetailComment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
outlined
auto-grow
rows="5"
id="detail-comment-textfield"
id="detail-comment-textarea"
:counter="MAXLENGTH"
:rules="rules"
:value="value"
:label="label"
:autofocus="autofocus"
@input="emitInput($event)"
/>
</v-card>
Expand Down Expand Up @@ -46,6 +47,10 @@ export default class DetailComment extends Vue {
@Prop({ default: '' })
private label: string
/** Autofocus passed into this component. */
@Prop({ default: false })
private autofocus: boolean
/**
* Called when prop changes (ie, v-model is updated by parent).
* This method is debounced to prevent excessive validation.
Expand Down
11 changes: 10 additions & 1 deletion src/components/dialogs/AddCommentDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<detail-comment
ref="detailComment"
v-model="comment"
autofocus
label="Add a Detail Comment that will appear on the ledger for this entity"
@valid="detailCommentValid=$event"
/>
Expand Down Expand Up @@ -53,7 +54,7 @@ export default class AddCommentDialog extends Vue {
/** Prop to display the dialog. */
@Prop() private dialog: boolean
/** Prop to display the dialog. */
/** Prop to provide the Filing ID. */
@Prop() private filingId: number
/** Prop to provide attachment selector. */
Expand Down Expand Up @@ -92,6 +93,14 @@ export default class AddCommentDialog extends Vue {
private async save (): Promise<void> {
// prevent double saving
if (this.saving) return
// ensure we have a Filing ID
if (!this.filingId) {
// eslint-disable-next-line no-console
console.error('save() error - missing filing ID')
return
}
this.saving = true
const data = {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/config-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default {
* fetch config from environment and API
*/
fetchConfig () {
const { name, version } = require('../../package.json')
console.info(`This is ${name} v${version}`)

const origin = window.location.origin
const vueAppPath = process.env.VUE_APP_PATH

Expand Down
16 changes: 7 additions & 9 deletions src/utils/sleep.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
export default {
/**
* Method that "sleeps" for specified timeout. Must be called from async method.
* @param ms Delay to sleep, in milliseconds.
* @returns A promise to await upon.
*/
sleep (ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms))
}
/**
* Function that "sleeps" for specified timeout. Must be called from async method.
* @param ms Delay to sleep, in milliseconds.
* @returns A promise to await upon.
*/
export function sleep (ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms))
}
5 changes: 2 additions & 3 deletions src/views/AnnualReport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,7 @@ export default {
if (this.agmDate) return this.agmDate
// if filing is in past year then use last day in that year
if (this.ARFilingYear < this.currentYear) return `${this.ARFilingYear}-12-31`
// otherwise use current date
// (should never happen because either we should have an AGM Date or filing should be in past year)
// otherwise use current date (BCOMP only - should never happen for COOP)
return this.currentDate
},
Expand Down Expand Up @@ -455,7 +454,7 @@ export default {
}
// NB: filing id of 0 means "new AR"
// otherwise it's a draft AR filing id
this.filingId = this.$route.params.id
this.filingId = +this.$route.params.id // number
// if tombstone data isn't set, route to home
if (!this.entityIncNo || !this.ARFilingYear || (this.filingId === undefined)) {
Expand Down
6 changes: 2 additions & 4 deletions src/views/Correction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export default {
}
}
// NB: this is the id of the filing to correct
const origFilingId = this.$route.params.id
const origFilingId = +this.$route.params.id // number
// if required data isn't set, route to home
if (!this.entityIncNo || (origFilingId === undefined) || (origFilingId <= 0)) {
Expand Down Expand Up @@ -606,9 +606,7 @@ export default {
}
}
if (setting === 'add' && !added) {
// TODO: remove hard-coded entity type when fee codes are available from Pay team
// this.filingData.push({ filingTypeCode: filing, entityType: this.entityType })
this.filingData.push({ filingTypeCode: filing, entityType: EntityTypes.BCOMP })
this.filingData.push({ filingTypeCode: filing, entityType: this.entityType })
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/StandaloneDirectorsFiling.vue
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ export default {
// NB: filing id of 0 means "new"
// otherwise it's a draft filing id
this.filingId = this.$route.params.id
this.filingId = +this.$route.params.id // number
// if tombstone data isn't set, route to home
if (!this.entityIncNo || (this.filingId === undefined)) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/StandaloneOfficeAddressFiling.vue
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export default {
// NB: filing id of 0 means "new"
// otherwise it's a draft filing id
this.filingId = this.$route.params.id
this.filingId = +this.$route.params.id // number
// if tombstone data isn't set, route to home
if (!this.entityIncNo || (this.filingId === undefined)) {
Expand Down
13 changes: 5 additions & 8 deletions tests/unit/AGMDate.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Vue from 'vue'
import Vuetify from 'vuetify'
import Vuelidate from 'vuelidate'
import { mount } from '@vue/test-utils'
import flushPromises from 'flush-promises'
import { mount, Wrapper } from '@vue/test-utils'

import store from '@/store/store'
import AgmDate from '@/components/AnnualReport/AGMDate.vue'
Expand All @@ -27,10 +26,10 @@ Vue.use(Vuelidate)
const vuetify = new Vuetify({})

describe('AgmDate', () => {
let wrapper
let vm
let wrapper: Wrapper<AgmDate>
let vm: any

beforeEach(async () => {
beforeEach(() => {
// init store
store.state.entityIncNo = 'CP0001191'
store.state.currentDate = '2019-07-15'
Expand All @@ -39,9 +38,7 @@ describe('AgmDate', () => {
store.state.lastAnnualReportDate = '2018-07-15'

wrapper = mount(AgmDate, { store, vuetify })
vm = wrapper.vm as any

await flushPromises()
vm = wrapper.vm
})

afterEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/AddressListSm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { EntityTypes } from '@/enums'
Vue.use(Vuetify)
Vue.use(Vuelidate)

let vuetify = new Vuetify({})
const vuetify = new Vuetify({})

describe('AddressListSm', () => {
it('handles empty data', done => {
Expand Down
Loading

0 comments on commit 07935ca

Please sign in to comment.