Skip to content

Commit

Permalink
- added check for pay-error class (#176)
Browse files Browse the repository at this point in the history
- combined pending status blocks
- replaced array filter with find
- very minor cleanup
- created new test file for template-first tests (very incomplete)
  • Loading branch information
severinbeauvais authored Jan 13, 2021
1 parent cc0f20e commit 459c80b
Show file tree
Hide file tree
Showing 4 changed files with 242 additions and 17 deletions.
5 changes: 1 addition & 4 deletions src/components/Dashboard/FilingHistoryList/CompletedIa.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
<p>Return to your Manage Businesses dashboard to access your business and file changes.</p>

<div class="to-dashboard-container">
<v-btn
color="primary"
@click.native.stop="returnToDashboard()"
>
<v-btn color="primary" @click.native.stop="returnToDashboard()">
<span>Return to Dashboard</span>
</v-btn>
</div>
Expand Down
18 changes: 9 additions & 9 deletions src/components/Dashboard/TodoList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@
class="align-items-top todo-item"
v-for="(task, index) in orderBy(taskItems, 'order')"
:key="index"
:class="{ 'disabled': !task.enabled, 'pay-error': isPayError(task) }"
:class="{
'disabled': !task.enabled,
'pay-error': isStatusDraft(task) && isPayError(task)
}"
>
<v-expansion-panel-header class="no-dropdown-icon">
<div class="list-item">
<div class="todo-label">
<h3 class="list-item__title">{{task.title}}
<v-btn v-if="(isTypeCorrection(task) || isTypeAlteration(task)) && isStatusDraft(task)"
<v-btn v-if="isStatusDraft(task) && (isTypeCorrection(task) || isTypeAlteration(task))"
class="expand-btn ml-0"
outlined
color="red"
Expand Down Expand Up @@ -400,12 +403,9 @@
</div>
</template>

<template v-else-if="isStatusPending(task) && isPayMethodOnlineBanking(task)">
<payment-pending-online-banking :filing=task />
</template>

<template v-else-if="isStatusPending(task)">
<payment-pending />
<payment-pending-online-banking v-if="isPayMethodOnlineBanking(task)" :filing=task />
<payment-pending v-else />
</template>

<template v-else-if="isStatusError(task)">
Expand Down Expand Up @@ -549,10 +549,10 @@ export default {
// If there are any draft/pending/error/paid/correction tasks, emit this event to the parent component.
// This indicates that a new filing cannot be started because this item has to be completed first.
this.$emit('has-blocker-task',
this.taskItems.filter(item => {
this.taskItems.find(item => {
return (this.isStatusDraft(item) || this.isStatusPending(item) || this.isStatusError(item) ||
this.isStatusPaid(item) || this.isTypeCorrection(item) || this.isTypeAlteration(item))
}).length > 0
}) !== undefined
)
},
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/TodoList.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ Vue.use(Vuelidate)
const vuetify = new Vuetify({})
const store = getVuexStore()

// Boilerplate to prevent the complaint "[Vuetify] Unable to locate target [data-app]"
const app: HTMLDivElement = document.createElement('div')
app.setAttribute('data-app', 'true')
document.body.append(app)
// Prevent the warning "[Vuetify] Unable to locate target [data-app]"
document.body.setAttribute('data-app', 'true')

describe('TodoList - UI', () => {
beforeAll(() => {
Expand Down
230 changes: 230 additions & 0 deletions tests/unit/TodoList2.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
//
// This file differs from TodoList.spec.ts in that it tests "backwards" from the HTML,
// instead of working "forwards" from the data.
//

import Vue from 'vue'
import Vuetify from 'vuetify'
// import Vue2Filters from 'vue2-filters'
import Vuelidate from 'vuelidate'
import { mount } from '@vue/test-utils'
import { getVuexStore } from '@/store'
import TodoList from '@/components/Dashboard/TodoList.vue'

// suppress "Avoid mutating a prop directly" warnings
// ref: https://github.com/vuejs/vue-test-utils/issues/532
Vue.config.silent = true

Vue.use(Vuetify)
// Vue.use(Vue2Filters) // not sure if this is needed?
Vue.use(Vuelidate)

const vuetify = new Vuetify({})
const store = getVuexStore()

xdescribe('TodoList - common expansion panel header tests', () => {
beforeAll(() => {
sessionStorage.clear()
sessionStorage.setItem('BUSINESS_ID', 'CP0001191')
store.state.entityType = 'CP'
})

it('handles empty data', async () => {
// init store
store.state.tasks = []

const wrapper = mount(TodoList, { store, vuetify })
const vm = wrapper.vm as any
await Vue.nextTick()

expect(vm.$el.querySelectorAll('.todo-item').length).toEqual(0)
expect(vm.$el.querySelector('.no-results')).toBeDefined()
expect(vm.$el.querySelector('.no-results').textContent).toContain('You don\'t have anything to do yet')

wrapper.destroy()
})

it('displays disabled task', async () => {
// NB: this should only be NEW tasks (ie, blocked by another task)
// verify class
// verify disabled actions
// verify title

})

it('displays draft task with pay error', async () => {
// verify class
// verify red top border
// verify title
// verify sub-title
// verify details expand-btn
})

it('displays draft correction without comments', async () => {
// verify title
// verify sub-title
// verify details expand-btn
// verify no resume button
// verify no delete draft button
})

it('displays draft correction with comments', async () => {
// verify title
// verify sub-title
// verify details expand-btn
// verify comments "button"
// verify no resume button
// verify no delete draft button
})

it('displays draft correction as staff', async () => {
// verify resume button
// verify delete draft button
})

it('displays draft alteration without comments', async () => {
// verify title
// verify sub-title
// verify detaild expand-btn
// verify no resume button
// verify no delete draft button
})

it('displays draft alteration with comments', async () => {
// verify title
// verify sub-title
// verify details expand-btn
// verify comments "button"
// verify no resume button
// verify no delete draft button
})

it('displays draft alteration as staff', async () => {
// verify resume button
// verify delete draft button
})

it('displays new task with subtitle', async () => {
// verify title
// verify sub-title
// verify no details expand-btn
})

it('displays new task without subtitle', async () => {
// verify title
// verify no sub-title
// verify no details expand-btn
})

it('displays draft IA for numbered company', async () => {
// verify title
// verify sub-title
// verify no details expand-btn
// verify "incorporate a numbered company" button
})

it('displays draft IA for named business', async () => {
// verify title
// verify sub-title
// verify details expand-btn
// verify "incorporate using this nr" button
})

it('displays correction-pending correction', async () => {
// verify title
// verify sub-title
// verify comments "button"
// verify no action buttons
})

it('displays correction-pending alteration', async () => {
// verify title
// verify sub-title
// verify comments "button"
// verify no action buttons
})

it('displays pending task in process', async () => {
// verify title
// verify sub-title
// verify no details expand-btn
// verify loading button
})

it('displays pending task with online banking pay method', async () => {
// verify title
// verify sub-title
// verify details expand-btn
})

it('displays pending task with other pay method', async () => {
// verify title
// verify sub-title
// verify details expand-btn
})

it('displays error task in process', async () => {
// verify title
// verify sub-title
// verify no details expand-btn
// verify loading button
})

it('displays error task', async () => {
// verify title
// verify sub-title
// verify details expand-btn
})

it('displays paid task in process', async () => {
// verify title
// verify sub-title
// verify no details expand-btn
// verify loading button
})

it('displays paid task', async () => {
// verify title
// verify sub-title
// verify details expand-btn
})
})

xdescribe('TodoList - common actions list tests', () => {
})

xdescribe('TodoList - common expansion panel content tests', () => {
})

xdescribe('TodoList - tests specific to Benefit Companies', () => {
beforeAll(() => {
sessionStorage.clear()
sessionStorage.setItem('BUSINESS_ID', 'BC0007291')
store.state.entityType = 'BEN'
})

it('displays new AR header/checkbox', async () => {
// verify title
// verify bcorps-ar-subtitle
// verify no subtitle
// verify enable-checkbox
// verify no details expand-btn
// verify date subtitle
})
})

xdescribe('TodoList - tests specific to Incorporation Applications', () => {
beforeAll(() => {
sessionStorage.clear()
sessionStorage.setItem('TEMP_REG_NUMBER', 'TaAbBcC123')
store.state.entityType = 'BEN'
})
//
// TODO: numbered vs named
//
})

xdescribe('TodoList - tests specific to Name Requests', () => {
// this functionality is current disabled in the code
// FUTURE: implement appropriate unit tests here
})

0 comments on commit 459c80b

Please sign in to comment.