TT#103201 Close call forwarding condition popups if opening other popups or menus

Change-Id: Ie523cc0bb7de3c36564f45060a1bd8e2f92f852d
pull/4/head
Hans-Peter Herzog 5 years ago
parent e4c421e1d9
commit 239466fcb5

@ -1,5 +1,5 @@
const fs = require('fs-extra') const fs = require('fs-extra')
let extend = undefined let extend
/** /**
* The .babelrc file has been created to assist Jest for transpiling. * The .babelrc file has been created to assist Jest for transpiling.
@ -7,12 +7,12 @@ let extend = undefined
*/ */
if (fs.existsSync('./.babelrc')) { if (fs.existsSync('./.babelrc')) {
extend = './.babelrc' extend = './.babelrc'
} }
module.exports = { module.exports = {
presets: [ presets: [
'@quasar/babel-preset-app' '@quasar/babel-preset-app'
], ],
extends: extend extends: extend
} }

@ -1,5 +1,7 @@
<template> <template>
<q-popup-proxy> <q-popup-proxy
@before-show="$store.commit('callForwarding/popupShow', null)"
>
<q-list <q-list
v-bind="$attrs" v-bind="$attrs"
class="bg-dark" class="bg-dark"

@ -0,0 +1,66 @@
<template>
<q-popup-proxy
ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
v-on="$listeners"
>
<slot />
</q-popup-proxy>
</template>
<script>
import _ from 'lodash'
import {
v4
} from 'uuid'
import {
mapState,
mapMutations
} from 'vuex'
export default {
name: 'CscCfConditionPopup',
data () {
return {
popupId: _.kebabCase(this.$options.name) + '-' + v4()
}
},
computed: {
...mapState('callForwarding', [
'popupCurrent'
])
},
watch: {
popupCurrent (id) {
if (id === null || this.popupId !== id) {
this.close()
}
}
},
methods: {
...mapMutations('callForwarding', [
'popupShow'
]),
beforeShow () {
this.closed = false
this.popupShow(this.popupId)
},
close () {
this.closed = true
this.$refs.popup.hide()
this.$emit('close')
},
reOpen () {
if (!this.closed) {
this.$refs.popup.hide()
this.$nextTick(() => {
this.$refs.popup.show()
this.$emit('open')
})
}
}
}
}
</script>

@ -1,10 +1,6 @@
<template> <template>
<q-popup-proxy <csc-cf-condition-popup
ref="popup" ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
> >
<csc-cf-group-condition-menu <csc-cf-group-condition-menu
v-if="internalStep === 'menu'" v-if="internalStep === 'menu'"
@ -111,11 +107,10 @@
:destination-set="destinationSet" :destination-set="destinationSet"
:source-set="sourceSet" :source-set="sourceSet"
:time-set="timeSet" :time-set="timeSet"
@navigate="navigate"
@back="internalStep='menu'" @back="internalStep='menu'"
@close="closePopup" @close="closePopup"
/> />
</q-popup-proxy> </csc-cf-condition-popup>
</template> </template>
<script> <script>
@ -126,9 +121,11 @@ import CscCfGroupConditionDate from 'components/call-forwarding/CscCfGroupCondit
import CscCfGroupConditionDateRange from 'components/call-forwarding/CscCfGroupConditionDateRange' import CscCfGroupConditionDateRange from 'components/call-forwarding/CscCfGroupConditionDateRange'
import CscCfGroupConditionWeekdays from 'components/call-forwarding/CscCfGroupConditionWeekdays' import CscCfGroupConditionWeekdays from 'components/call-forwarding/CscCfGroupConditionWeekdays'
import CscCfGroupConditionOfficeHours from 'components/call-forwarding/CscCfGroupConditionOfficeHours' import CscCfGroupConditionOfficeHours from 'components/call-forwarding/CscCfGroupConditionOfficeHours'
import CscCfConditionPopup from 'components/call-forwarding/CscCfConditionPopup'
export default { export default {
name: 'CscCfConditionPopupAll', name: 'CscCfConditionPopupAll',
components: { components: {
CscCfConditionPopup,
CscCfGroupConditionOfficeHours, CscCfGroupConditionOfficeHours,
CscCfGroupConditionWeekdays, CscCfGroupConditionWeekdays,
CscCfGroupConditionDateRange, CscCfGroupConditionDateRange,
@ -161,41 +158,18 @@ export default {
}, },
data () { data () {
return { return {
closed: false, internalStep: this.step
internalStep: this.step,
selectedSourceSet: null
} }
}, },
watch: { watch: {
internalStep () { internalStep () {
if (!this.closed) { this.$refs.popup.reOpen()
this.$refs.popup.hide()
this.$nextTick(() => {
this.$refs.popup.show()
})
}
} }
}, },
methods: { methods: {
beforeShow () {
this.closed = false
},
closePopup () { closePopup () {
this.closed = true
this.internalStep = 'menu' this.internalStep = 'menu'
this.$refs.popup.hide() this.$refs.popup.close()
},
openPopup () {
if (!this.closed) {
this.$refs.popup.hide()
this.$nextTick(() => {
this.$refs.popup.show()
})
}
},
navigate (step) {
this.internalStep = step
this.openPopup()
} }
} }
} }

@ -1,10 +1,6 @@
<template> <template>
<q-popup-proxy <csc-cf-condition-popup
ref="popup" ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
> >
<csc-cf-group-condition-source-set-create <csc-cf-group-condition-source-set-create
v-if="internalStep === 'call-from'" v-if="internalStep === 'call-from'"
@ -36,15 +32,17 @@
@create="internalStep='call-from'" @create="internalStep='call-from'"
@close="closePopup" @close="closePopup"
/> />
</q-popup-proxy> </csc-cf-condition-popup>
</template> </template>
<script> <script>
import CscCfGroupConditionSourceSetCreate from 'components/call-forwarding/CscCfGroupConditionSourceSetCreate' import CscCfGroupConditionSourceSetCreate from 'components/call-forwarding/CscCfGroupConditionSourceSetCreate'
import CscCfGroupConditionSourceSetSelect from 'components/call-forwarding/CscCfGroupConditionSourceSetSelect' import CscCfGroupConditionSourceSetSelect from 'components/call-forwarding/CscCfGroupConditionSourceSetSelect'
import CscCfConditionPopup from 'components/call-forwarding/CscCfConditionPopup'
export default { export default {
name: 'CscCfConditionPopupCallFrom', name: 'CscCfConditionPopupCallFrom',
components: { components: {
CscCfConditionPopup,
CscCfGroupConditionSourceSetSelect, CscCfGroupConditionSourceSetSelect,
CscCfGroupConditionSourceSetCreate CscCfGroupConditionSourceSetCreate
}, },
@ -74,22 +72,13 @@ export default {
}, },
watch: { watch: {
internalStep () { internalStep () {
if (!this.closed) { this.$refs.popup.reOpen()
this.$refs.popup.hide()
this.$nextTick(() => {
this.$refs.popup.show()
})
}
} }
}, },
methods: { methods: {
beforeShow () {
this.closed = false
},
closePopup () { closePopup () {
this.closed = true
this.internalStep = 'call-from' this.internalStep = 'call-from'
this.$refs.popup.hide() this.$refs.popup.close()
} }
} }
} }

@ -1,10 +1,6 @@
<template> <template>
<q-popup-proxy <csc-cf-condition-popup
ref="popup" ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
> >
<csc-cf-group-condition-source-set-create <csc-cf-group-condition-source-set-create
v-if="internalStep === 'call-not-from'" v-if="internalStep === 'call-not-from'"
@ -36,15 +32,17 @@
@create="internalStep='call-not-from'" @create="internalStep='call-not-from'"
@close="closePopup" @close="closePopup"
/> />
</q-popup-proxy> </csc-cf-condition-popup>
</template> </template>
<script> <script>
import CscCfGroupConditionSourceSetCreate from 'components/call-forwarding/CscCfGroupConditionSourceSetCreate' import CscCfGroupConditionSourceSetCreate from 'components/call-forwarding/CscCfGroupConditionSourceSetCreate'
import CscCfGroupConditionSourceSetSelect from 'components/call-forwarding/CscCfGroupConditionSourceSetSelect' import CscCfGroupConditionSourceSetSelect from 'components/call-forwarding/CscCfGroupConditionSourceSetSelect'
import CscCfConditionPopup from 'components/call-forwarding/CscCfConditionPopup'
export default { export default {
name: 'CscCfConditionPopupCallNotFrom', name: 'CscCfConditionPopupCallNotFrom',
components: { components: {
CscCfConditionPopup,
CscCfGroupConditionSourceSetSelect, CscCfGroupConditionSourceSetSelect,
CscCfGroupConditionSourceSetCreate CscCfGroupConditionSourceSetCreate
}, },
@ -74,22 +72,13 @@ export default {
}, },
watch: { watch: {
internalStep () { internalStep () {
if (!this.closed) { this.$refs.popup.reOpen()
this.$refs.popup.hide()
this.$nextTick(() => {
this.$refs.popup.show()
})
}
} }
}, },
methods: { methods: {
beforeShow () {
this.closed = false
},
closePopup () { closePopup () {
this.closed = true
this.internalStep = 'call-not-from' this.internalStep = 'call-not-from'
this.$refs.popup.hide() this.$refs.popup.close()
} }
} }
} }

@ -1,10 +1,6 @@
<template> <template>
<q-popup-proxy <csc-cf-condition-popup
ref="popup" ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
> >
<csc-cf-group-condition-date <csc-cf-group-condition-date
:mapping="mapping" :mapping="mapping"
@ -14,14 +10,16 @@
:delete-button="true" :delete-button="true"
@close="closePopup" @close="closePopup"
/> />
</q-popup-proxy> </csc-cf-condition-popup>
</template> </template>
<script> <script>
import CscCfGroupConditionDate from 'components/call-forwarding/CscCfGroupConditionDate' import CscCfGroupConditionDate from 'components/call-forwarding/CscCfGroupConditionDate'
import CscCfConditionPopup from 'components/call-forwarding/CscCfConditionPopup'
export default { export default {
name: 'CscCfConditionPopupDate', name: 'CscCfConditionPopupDate',
components: { components: {
CscCfConditionPopup,
CscCfGroupConditionDate CscCfGroupConditionDate
}, },
props: { props: {
@ -43,12 +41,8 @@ export default {
} }
}, },
methods: { methods: {
beforeShow () {
this.closed = false
},
closePopup () { closePopup () {
this.closed = true this.$refs.popup.close()
this.$refs.popup.hide()
} }
} }
} }

@ -1,10 +1,6 @@
<template> <template>
<q-popup-proxy <csc-cf-condition-popup
ref="popup" ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
> >
<csc-cf-group-condition-date-range <csc-cf-group-condition-date-range
:mapping="mapping" :mapping="mapping"
@ -14,14 +10,16 @@
:delete-button="true" :delete-button="true"
@close="closePopup" @close="closePopup"
/> />
</q-popup-proxy> </csc-cf-condition-popup>
</template> </template>
<script> <script>
import CscCfGroupConditionDateRange from 'components/call-forwarding/CscCfGroupConditionDateRange' import CscCfGroupConditionDateRange from 'components/call-forwarding/CscCfGroupConditionDateRange'
import CscCfConditionPopup from 'components/call-forwarding/CscCfConditionPopup'
export default { export default {
name: 'CscCfConditionPopupDateRange', name: 'CscCfConditionPopupDateRange',
components: { components: {
CscCfConditionPopup,
CscCfGroupConditionDateRange CscCfGroupConditionDateRange
}, },
props: { props: {
@ -43,12 +41,8 @@ export default {
} }
}, },
methods: { methods: {
beforeShow () {
this.closed = false
},
closePopup () { closePopup () {
this.closed = true this.$refs.popup.close()
this.$refs.popup.hide()
} }
} }
} }

@ -1,10 +1,6 @@
<template> <template>
<q-popup-proxy <csc-cf-condition-popup
ref="popup" ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
> >
<csc-cf-group-condition-office-hours <csc-cf-group-condition-office-hours
:mapping="mapping" :mapping="mapping"
@ -14,14 +10,16 @@
:delete-button="true" :delete-button="true"
@close="closePopup" @close="closePopup"
/> />
</q-popup-proxy> </csc-cf-condition-popup>
</template> </template>
<script> <script>
import CscCfGroupConditionOfficeHours from 'components/call-forwarding/CscCfGroupConditionOfficeHours' import CscCfGroupConditionOfficeHours from 'components/call-forwarding/CscCfGroupConditionOfficeHours'
import CscCfConditionPopup from 'components/call-forwarding/CscCfConditionPopup'
export default { export default {
name: 'CscCfConditionPopupOfficeHours', name: 'CscCfConditionPopupOfficeHours',
components: { components: {
CscCfConditionPopup,
CscCfGroupConditionOfficeHours CscCfGroupConditionOfficeHours
}, },
props: { props: {
@ -43,12 +41,8 @@ export default {
} }
}, },
methods: { methods: {
beforeShow () {
this.closed = false
},
closePopup () { closePopup () {
this.closed = true this.$refs.popup.close()
this.$refs.popup.hide()
} }
} }
} }

@ -1,10 +1,6 @@
<template> <template>
<q-popup-proxy <csc-cf-condition-popup
ref="popup" ref="popup"
persistent
anchor="bottom middle"
self="top middle"
@before-show="beforeShow"
> >
<csc-cf-group-condition-weekdays <csc-cf-group-condition-weekdays
:mapping="mapping" :mapping="mapping"
@ -14,14 +10,16 @@
:delete-button="true" :delete-button="true"
@close="closePopup" @close="closePopup"
/> />
</q-popup-proxy> </csc-cf-condition-popup>
</template> </template>
<script> <script>
import CscCfGroupConditionWeekdays from 'components/call-forwarding/CscCfGroupConditionWeekdays' import CscCfGroupConditionWeekdays from 'components/call-forwarding/CscCfGroupConditionWeekdays'
import CscCfConditionPopup from 'components/call-forwarding/CscCfConditionPopup'
export default { export default {
name: 'CscCfConditionPopupWeekdays', name: 'CscCfConditionPopupWeekdays',
components: { components: {
CscCfConditionPopup,
CscCfGroupConditionWeekdays CscCfGroupConditionWeekdays
}, },
props: { props: {
@ -43,12 +41,8 @@ export default {
} }
}, },
methods: { methods: {
beforeShow () {
this.closed = false
},
closePopup () { closePopup () {
this.closed = true this.$refs.popup.close()
this.$refs.popup.hide()
} }
} }
} }

@ -32,6 +32,7 @@
<q-popup-edit <q-popup-edit
v-model="changedDestinationTimeout" v-model="changedDestinationTimeout"
buttons buttons
@before-show="$store.commit('callForwarding/popupShow', null)"
@save="updateRingTimeoutEvent()" @save="updateRingTimeoutEvent()"
> >
<csc-input <csc-input
@ -67,6 +68,7 @@
<q-popup-edit <q-popup-edit
v-model="changedDestinationTimeout" v-model="changedDestinationTimeout"
buttons buttons
@before-show="$store.commit('callForwarding/popupShow', null)"
@save="updateDestinationTimeoutEvent({ @save="updateDestinationTimeoutEvent({
destinationTimeout: changedDestinationTimeout, destinationTimeout: changedDestinationTimeout,
destinationIndex: destinationIndex - 1, destinationIndex: destinationIndex - 1,
@ -152,6 +154,7 @@
<q-popup-edit <q-popup-edit
v-model="changedDestination" v-model="changedDestination"
buttons buttons
@before-show="$store.commit('callForwarding/popupShow', null)"
@save="updateDestinationEvent({ @save="updateDestinationEvent({
destination: changedDestination, destination: changedDestination,
destinationIndex: destinationIndex, destinationIndex: destinationIndex,

@ -27,3 +27,7 @@ export function dataSucceeded (state, res) {
state.mappings = res.mappings state.mappings = res.mappings
} }
} }
export function popupShow (state, popupId) {
state.popupCurrent = popupId
}

@ -15,6 +15,7 @@ export default function () {
sourceSets: null, sourceSets: null,
sourceSetMap: {}, sourceSetMap: {},
timeSets: null, timeSets: null,
timeSetMap: {} timeSetMap: {},
popupCurrent: null
} }
} }

@ -1,310 +1,309 @@
'use strict'; 'use strict'
import Vue from 'vue'; import Vue from 'vue'
import VueResource from 'vue-resource'; import VueResource from 'vue-resource'
import { import {
enableIncomingCallBlocking, enableIncomingCallBlocking,
disableIncomingCallBlocking, disableIncomingCallBlocking,
getIncomingCallBlocking, getIncomingCallBlocking,
addNumberToIncomingList, addNumberToIncomingList,
editNumberFromIncomingList, editNumberFromIncomingList,
removeNumberFromIncomingList, removeNumberFromIncomingList,
enableOutgoingCallBlocking, enableOutgoingCallBlocking,
disableOutgoingCallBlocking, disableOutgoingCallBlocking,
getOutgoingCallBlocking, getOutgoingCallBlocking,
addNumberToOutgoingList, addNumberToOutgoingList,
editNumberFromOutgoingList, editNumberFromOutgoingList,
removeNumberFromOutgoingList removeNumberFromOutgoingList
} from '../../src/api/call-blocking'; } from '../../src/api/call-blocking'
import { assert } from 'chai'; import { assert } from 'chai'
Vue.use(VueResource); Vue.use(VueResource)
describe('CallBlocking', function(){ describe('CallBlocking', function () {
var subscriberId = 123
var subscriberId = 123; beforeEach(function () {
Vue.http.interceptors = []
})
beforeEach(function(){ describe('Incoming', function () {
Vue.http.interceptors = []; it('should enable call blocking for incoming calls', function (done) {
}); Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
assert.equal(request.body[0].op, 'replace')
assert.equal(request.body[0].path, '/block_in_mode')
assert.equal(request.body[0].value, true)
next(request.respondWith('', {
status: 204
}))
})
enableIncomingCallBlocking(subscriberId).then(() => {
done()
}).catch((err) => {
done(err)
})
})
describe('Incoming', function(){ it('should disable call blocking for incoming calls', function (done) {
it('should enable call blocking for incoming calls', function(done) { Vue.http.interceptors.unshift((request, next) => {
Vue.http.interceptors.unshift((request, next)=>{ assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.body[0].op, 'replace')
assert.equal(request.body[0].op, 'replace'); assert.equal(request.body[0].path, '/block_in_mode')
assert.equal(request.body[0].path, '/block_in_mode'); assert.equal(request.body[0].value, false)
assert.equal(request.body[0].value, true); next(request.respondWith('', {
next(request.respondWith('', { status: 204
status: 204 }))
})); })
}); disableIncomingCallBlocking(subscriberId).then(() => {
enableIncomingCallBlocking(subscriberId).then(()=>{ done()
done(); }).catch((err) => {
}).catch((err)=>{ done(err)
done(err); })
}); })
});
it('should disable call blocking for incoming calls', function(done) { it('should get all data regarding incoming call blocking', function (done) {
Vue.http.interceptors.unshift((request, next)=>{ var list = [
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); '0123456789',
assert.equal(request.body[0].op, 'replace'); '0987654321'
assert.equal(request.body[0].path, '/block_in_mode'); ]
assert.equal(request.body[0].value, false); Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith('', { assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
status: 204 next(request.respondWith(JSON.stringify({
})); block_in_list: list,
}); block_in_mode: true
disableIncomingCallBlocking(subscriberId).then(()=>{ }), {
done(); status: 200
}).catch((err)=>{ }))
done(err); })
}); getIncomingCallBlocking(subscriberId).then((result) => {
}); assert.deepEqual(result.list, list)
assert.equal(result.enabled, true)
done()
}).catch((err) => {
done(err)
})
})
it('should get all data regarding incoming call blocking', function(done){ it('should add a new number to incoming call blocking list', function (done) {
var list = [ var number = '0987654321'
"0123456789", var list = [
"0987654321" '0123456789'
]; ]
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
next(request.respondWith(JSON.stringify({ if (request.method === 'GET') {
"block_in_list" : list, next(request.respondWith(JSON.stringify({
"block_in_mode" : true block_in_list: list
}), { }), {
status: 200 status: 200
})); }))
}); } else if (request.method === 'PUT') {
getIncomingCallBlocking(subscriberId).then((result)=>{ assert.deepEqual(request.body.block_in_list, [].concat([number], list))
assert.deepEqual(result.list, list); next(request.respondWith('', {
assert.equal(result.enabled, true); status: 200
done(); }))
}).catch((err)=>{ }
done(err); })
}); addNumberToIncomingList(subscriberId, number).then((result) => {
}); done()
}).catch((err) => {
done(err)
})
})
it('should add a new number to incoming call blocking list', function(done){ it('should edit a number from incoming call blocking list', function (done) {
var number = '0987654321'; var number = '0987654321'
var list = [ var list = [
"0123456789" '0123456789'
]; ]
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if(request.method === 'GET') { if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
"block_in_list" : list block_in_list: list
}), { }), {
status: 200 status: 200
})); }))
} else if(request.method === 'PUT') { } else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_in_list, [].concat([number], list)); assert.deepEqual(request.body.block_in_list, [number])
next(request.respondWith('', { next(request.respondWith('', {
status: 200 status: 200
})); }))
} }
}); })
addNumberToIncomingList(subscriberId, number).then((result)=>{ editNumberFromIncomingList(subscriberId, 0, number).then((result) => {
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should edit a number from incoming call blocking list', function(done){ it('should remove a number from incoming call blocking list', function (done) {
var number = '0987654321'; var number = '0987654321'
var list = [ var list = [
"0123456789" '0123456789'
]; ]
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if(request.method === 'GET') { if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
"block_in_list" : list block_in_list: [].concat([number]).concat(list)
}), { }), {
status: 200 status: 200
})); }))
} else if(request.method === 'PUT') { } else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_in_list, [number]); assert.deepEqual(request.body.block_in_list, list)
next(request.respondWith('', { next(request.respondWith('', {
status: 200 status: 200
})); }))
} }
}); })
editNumberFromIncomingList(subscriberId, 0, number).then((result)=>{ removeNumberFromIncomingList(subscriberId, 0, number).then((result) => {
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
})
it('should remove a number from incoming call blocking list', function(done){ describe('Outgoing', function () {
var number = '0987654321'; it('should enable call blocking for outgoing calls', function (done) {
var list = [ Vue.http.interceptors.unshift((request, next) => {
"0123456789" assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
]; assert.equal(request.body[0].op, 'replace')
Vue.http.interceptors.unshift((request, next)=>{ assert.equal(request.body[0].path, '/block_out_mode')
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.body[0].value, true)
if(request.method === 'GET') { next(request.respondWith('', {
next(request.respondWith(JSON.stringify({ status: 204
"block_in_list" : [].concat([number]).concat(list) }))
}), { })
status: 200 enableOutgoingCallBlocking(subscriberId).then(() => {
})); done()
} else if(request.method === 'PUT') { }).catch((err) => {
assert.deepEqual(request.body.block_in_list, list); done(err)
next(request.respondWith('', { })
status: 200 })
}));
}
});
removeNumberFromIncomingList(subscriberId, 0, number).then((result)=>{
done();
}).catch((err)=>{
done(err);
});
});
});
describe('Outgoing', function(){ it('should disable call blocking for outgoing calls', function (done) {
it('should enable call blocking for outgoing calls', function(done) { Vue.http.interceptors.unshift((request, next) => {
Vue.http.interceptors.unshift((request, next)=>{ assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.body[0].op, 'replace')
assert.equal(request.body[0].op, 'replace'); assert.equal(request.body[0].path, '/block_out_mode')
assert.equal(request.body[0].path, '/block_out_mode'); assert.equal(request.body[0].value, false)
assert.equal(request.body[0].value, true); next(request.respondWith('', {
next(request.respondWith('', { status: 204
status: 204 }))
})); })
}); disableOutgoingCallBlocking(subscriberId).then(() => {
enableOutgoingCallBlocking(subscriberId).then(()=>{ done()
done(); }).catch((err) => {
}).catch((err)=>{ done(err)
done(err); })
}); })
});
it('should disable call blocking for outgoing calls', function(done) { it('should get all data regarding outgoing call blocking', function (done) {
Vue.http.interceptors.unshift((request, next)=>{ var list = [
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); '0123456789',
assert.equal(request.body[0].op, 'replace'); '0987654321'
assert.equal(request.body[0].path, '/block_out_mode'); ]
assert.equal(request.body[0].value, false); Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith('', { assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
status: 204 next(request.respondWith(JSON.stringify({
})); block_out_list: list,
}); block_out_mode: true
disableOutgoingCallBlocking(subscriberId).then(()=>{ }), {
done(); status: 200
}).catch((err)=>{ }))
done(err); })
}); getOutgoingCallBlocking(subscriberId).then((result) => {
}); assert.deepEqual(result.list, list)
assert.equal(result.enabled, true)
done()
}).catch((err) => {
done(err)
})
})
it('should get all data regarding outgoing call blocking', function(done){ it('should add a new number to outgoing call blocking list', function (done) {
var list = [ var number = '0987654321'
"0123456789", var list = [
"0987654321" '0123456789'
]; ]
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
next(request.respondWith(JSON.stringify({ if (request.method === 'GET') {
"block_out_list" : list, next(request.respondWith(JSON.stringify({
"block_out_mode" : true block_out_list: list
}), { }), {
status: 200 status: 200
})); }))
}); } else if (request.method === 'PUT') {
getOutgoingCallBlocking(subscriberId).then((result)=>{ assert.deepEqual(request.body.block_out_list, [].concat([number], list))
assert.deepEqual(result.list, list); next(request.respondWith('', {
assert.equal(result.enabled, true); status: 200
done(); }))
}).catch((err)=>{ }
done(err); })
}); addNumberToOutgoingList(subscriberId, number).then((result) => {
}); done()
}).catch((err) => {
done(err)
})
})
it('should add a new number to outgoing call blocking list', function(done){ it('should edit a number from outgoing call blocking list', function (done) {
var number = '0987654321'; var number = '0987654321'
var list = [ var list = [
"0123456789" '0123456789'
]; ]
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if(request.method === 'GET') { if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
"block_out_list" : list block_out_list: list
}), { }), {
status: 200 status: 200
})); }))
} else if(request.method === 'PUT') { } else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_out_list, [].concat([number], list)); assert.deepEqual(request.body.block_out_list, [number])
next(request.respondWith('', { next(request.respondWith('', {
status: 200 status: 200
})); }))
} }
}); })
addNumberToOutgoingList(subscriberId, number).then((result)=>{ editNumberFromOutgoingList(subscriberId, 0, number).then((result) => {
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
it('should edit a number from outgoing call blocking list', function(done){ it('should remove a number from outgoing call blocking list', function (done) {
var number = '0987654321'; var number = '0987654321'
var list = [ var list = [
"0123456789" '0123456789'
]; ]
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId); assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId)
if(request.method === 'GET') { if (request.method === 'GET') {
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
"block_out_list" : list block_out_list: [].concat([number]).concat(list)
}), { }), {
status: 200 status: 200
})); }))
} else if(request.method === 'PUT') { } else if (request.method === 'PUT') {
assert.deepEqual(request.body.block_out_list, [number]); assert.deepEqual(request.body.block_out_list, list)
next(request.respondWith('', { next(request.respondWith('', {
status: 200 status: 200
})); }))
} }
}); })
editNumberFromOutgoingList(subscriberId, 0, number).then((result)=>{ removeNumberFromOutgoingList(subscriberId, 0).then(() => {
done(); done()
}).catch((err)=>{ }).catch((err) => {
done(err); done(err)
}); })
}); })
})
it('should remove a number from outgoing call blocking list', function(done){ })
var number = '0987654321';
var list = [
"0123456789"
];
Vue.http.interceptors.unshift((request, next)=>{
assert.equal(request.url, 'api/subscriberpreferences/' + subscriberId);
if(request.method === 'GET') {
next(request.respondWith(JSON.stringify({
"block_out_list" : [].concat([number]).concat(list)
}), {
status: 200
}));
} else if(request.method === 'PUT') {
assert.deepEqual(request.body.block_out_list, list);
next(request.respondWith('', {
status: 200
}));
}
});
removeNumberFromOutgoingList(subscriberId, 0).then(()=>{
done();
}).catch((err)=>{
done(err);
});
});
});
});

File diff suppressed because it is too large Load Diff

@ -1,97 +1,94 @@
'use strict'; 'use strict'
import Vue from 'vue'; import Vue from 'vue'
import VueResource from 'vue-resource'; import VueResource from 'vue-resource'
import crypto from 'crypto-browserify' import crypto from 'crypto-browserify'
import { getConversations } from '../../src/api/conversations'; import { getConversations } from '../../src/api/conversations'
import { assert } from 'chai'; import { assert } from 'chai'
Vue.use(VueResource); Vue.use(VueResource)
describe('Conversations', function(){ describe('Conversations', function () {
const subscriberId = 123
const subscriberId = 123; it('should get all data regarding conversations', function (done) {
const innerData = [{
_links: {
collection: {
href: '/api/conversations/'
},
curies: {
href: 'http://purl.org/sipwise/ngcp-api/#rel-{rel}',
name: 'ngcp',
templated: true
},
'ngcp:conversations': {
href: '/api/conversations/1?type=voicemail'
},
'ngcp:voicemailrecordings': {
href: '/api/voicemailrecordings/1'
},
'ngcp:voicemails': {
href: '/api/voicemails/1'
},
profile: {
href: 'http://purl.org/sipwise/ngcp-api/'
},
self: {
href: '/api/conversations/1?type=voicemail'
}
},
call_id: 'kp55kEGtNp',
callee: '43993006',
caller: '43993006',
context: 'voicemailcaller_unavail',
direction: 'in',
duration: '15',
filename: 'voicemail-0.wav',
folder: 'Old',
id: 1,
start_time: '2017-12-07 16:22:04',
type: 'voicemail',
voicemail_subscriber_id: 235
}]
it('should get all data regarding conversations', function(done){ const data = {
_embedded: {
'ngcp:conversations': innerData
},
total_count: 1
}
let innerData = [{ const innerDataTransformed = {
"_links" : { items: [{
"collection": { call_id: 'kp55kEGtNp',
"href": "/api/conversations/" callee: '43993006',
}, caller: '43993006',
"curies": { context: 'voicemailcaller_unavail',
"href": "http://purl.org/sipwise/ngcp-api/#rel-{rel}", direction: 'in',
"name": "ngcp", duration: '15',
"templated": true filename: 'voicemail-0.wav',
}, folder: 'Old',
"ngcp:conversations": { id: 1,
"href": "/api/conversations/1?type=voicemail" start_time: '2017-12-07 16:22:04',
}, type: 'voicemail',
"ngcp:voicemailrecordings": { voicemail_subscriber_id: 235
"href": "/api/voicemailrecordings/1" }],
}, lastPage: 1
"ngcp:voicemails": { }
"href": "/api/voicemails/1"
},
"profile": {
"href": "http://purl.org/sipwise/ngcp-api/"
},
"self": {
"href": "/api/conversations/1?type=voicemail"
}
},
"call_id": "kp55kEGtNp",
"callee": "43993006",
"caller": "43993006",
"context": "voicemailcaller_unavail",
"direction": "in",
"duration": "15",
"filename": "voicemail-0.wav",
"folder": "Old",
"id": 1,
"start_time": "2017-12-07 16:22:04",
"type": "voicemail",
"voicemail_subscriber_id": 235
}];
let data = { Vue.http.interceptors = []
"_embedded": { Vue.http.interceptors.unshift((request, next) => {
"ngcp:conversations": innerData next(request.respondWith(JSON.stringify(data), {
}, status: 200
total_count: 1 }))
}; })
getConversations(subscriberId).then((result) => {
let innerDataTransformed = { assert.deepEqual(result, innerDataTransformed)
items: [{ done()
"call_id": "kp55kEGtNp", }).catch((err) => {
"callee": "43993006", done(err)
"caller": "43993006", })
"context": "voicemailcaller_unavail", })
"direction": "in", })
"duration": "15",
"filename": "voicemail-0.wav",
"folder": "Old",
"id": 1,
"start_time": "2017-12-07 16:22:04",
"type": "voicemail",
"voicemail_subscriber_id": 235
}],
lastPage: 1
};
Vue.http.interceptors = [];
Vue.http.interceptors.unshift((request, next)=>{
next(request.respondWith(JSON.stringify(data), {
status: 200
}));
});
getConversations(subscriberId).then((result)=>{
assert.deepEqual(result, innerDataTransformed);
done();
}).catch((err)=>{
done(err);
});
});
});

@ -1,196 +1,192 @@
'use strict'; 'use strict'
import Vue from 'vue'; import Vue from 'vue'
import VueResource from 'vue-resource'; import VueResource from 'vue-resource'
import { import {
getFieldList getFieldList
} from '../../src/api/common'; } from '../../src/api/common'
import { import {
getSpeedDialsById, getSpeedDialsById,
getUnassignedSlots getUnassignedSlots
} from '../../src/api/speed-dial'; } from '../../src/api/speed-dial'
import { assert } from 'chai'; import { assert } from 'chai'
import { i18n } from '../../src/i18n'; import { i18n } from '../../src/i18n'
Vue.use(VueResource); Vue.use(VueResource)
describe('SpeedDial', function(){ describe('SpeedDial', function () {
const subscriberId = 123
const subscriberId = 123; it('should get list of subscriber specific speed dials', function (done) {
const data = {
_links: {
collection: {
href: '/api/speeddials/'
},
curies: {
href: 'http://purl.org/sipwise/ngcp-api/#rel-{rel}',
name: 'ngcp',
templated: true
},
'ngcp:journal': [
{
href: '/api/speeddials/323/journal/'
}
],
'ngcp:speeddials': [
{
href: '/api/speeddials/323'
}
],
'ngcp:subscribers': [
{
href: '/api/subscribers/323'
}
],
profile: {
href: 'http://purl.org/sipwise/ngcp-api/'
},
self: {
href: '/api/speeddials/323'
}
},
speeddials: [
{
destination: 'sip:439965050@192.168.178.23',
slot: '*9'
},
{
destination: 'sip:22222222@192.168.178.23',
slot: '*0'
},
{
destination: 'sip:43665522@192.168.178.23',
slot: '*3'
}
]
}
it('should get list of subscriber specific speed dials', function(done){ const fieldList = [
{
destination: 'sip:22222222@192.168.178.23',
slot: '*0'
},
{
destination: 'sip:43665522@192.168.178.23',
slot: '*3'
},
{
destination: 'sip:439965050@192.168.178.23',
slot: '*9'
}
]
let data = { Vue.http.interceptors = []
"_links" : { Vue.http.interceptors.unshift((request, next) => {
"collection" : { next(request.respondWith(JSON.stringify(data), {
"href" : "/api/speeddials/" status: 200
}, }))
"curies" : { })
"href" : "http://purl.org/sipwise/ngcp-api/#rel-{rel}", getSpeedDialsById(subscriberId).then((result) => {
"name" : "ngcp", assert.deepEqual(result, fieldList)
"templated" : true done()
}, }).catch((err) => {
"ngcp:journal" : [ done(err)
{ })
"href" : "/api/speeddials/323/journal/" })
}
],
"ngcp:speeddials" : [
{
"href" : "/api/speeddials/323"
}
],
"ngcp:subscribers" : [
{
"href" : "/api/subscribers/323"
}
],
"profile" : {
"href" : "http://purl.org/sipwise/ngcp-api/"
},
"self" : {
"href" : "/api/speeddials/323"
}
},
"speeddials" : [
{
"destination" : "sip:439965050@192.168.178.23",
"slot" : "*9"
},
{
"destination" : "sip:22222222@192.168.178.23",
"slot" : "*0"
},
{
"destination" : "sip:43665522@192.168.178.23",
"slot" : "*3"
}
]
};
let fieldList = [ it('should get list of unassigned speed dial slots', function (done) {
{ const data = {
"destination" : "sip:22222222@192.168.178.23", _links: {
"slot" : "*0" collection: {
}, href: '/api/speeddials/'
{ },
"destination" : "sip:43665522@192.168.178.23", curies: {
"slot" : "*3" href: 'http://purl.org/sipwise/ngcp-api/#rel-{rel}',
}, name: 'ngcp',
{ templated: true
"destination" : "sip:439965050@192.168.178.23", },
"slot" : "*9" 'ngcp:journal': [
} {
]; href: '/api/speeddials/323/journal/'
}
],
'ngcp:speeddials': [
{
href: '/api/speeddials/323'
}
],
'ngcp:subscribers': [
{
href: '/api/subscribers/323'
}
],
profile: {
href: 'http://purl.org/sipwise/ngcp-api/'
},
self: {
href: '/api/speeddials/323'
}
},
speeddials: [
{
destination: 'sip:439965050@192.168.178.23',
slot: '*9'
},
{
destination: 'sip:22222222@192.168.178.23',
slot: '*0'
},
{
destination: 'sip:43665522@192.168.178.23',
slot: '*3'
}
]
}
Vue.http.interceptors = []; const slotOptions = [
Vue.http.interceptors.unshift((request, next)=>{ {
next(request.respondWith(JSON.stringify(data), { label: i18n.t('speedDial.slot').concat(' *1'),
status: 200 value: '*1'
})); },
}); {
getSpeedDialsById(subscriberId).then((result)=>{ label: i18n.t('speedDial.slot').concat(' *2'),
assert.deepEqual(result, fieldList); value: '*2'
done(); },
}).catch((err)=>{ {
done(err); label: i18n.t('speedDial.slot').concat(' *4'),
}); value: '*4'
}); },
{
label: i18n.t('speedDial.slot').concat(' *5'),
value: '*5'
},
{
label: i18n.t('speedDial.slot').concat(' *6'),
value: '*6'
},
{
label: i18n.t('speedDial.slot').concat(' *7'),
value: '*7'
},
{
label: i18n.t('speedDial.slot').concat(' *8'),
value: '*8'
}
]
it('should get list of unassigned speed dial slots', function(done){ Vue.http.interceptors = []
Vue.http.interceptors.unshift((request, next) => {
let data = { next(request.respondWith(JSON.stringify(data), {
"_links" : { status: 200
"collection" : { }))
"href" : "/api/speeddials/" })
}, getUnassignedSlots(subscriberId).then((result) => {
"curies" : { assert.deepEqual(result, slotOptions)
"href" : "http://purl.org/sipwise/ngcp-api/#rel-{rel}", done()
"name" : "ngcp", }).catch((err) => {
"templated" : true done(err)
}, })
"ngcp:journal" : [ })
{ })
"href" : "/api/speeddials/323/journal/"
}
],
"ngcp:speeddials" : [
{
"href" : "/api/speeddials/323"
}
],
"ngcp:subscribers" : [
{
"href" : "/api/subscribers/323"
}
],
"profile" : {
"href" : "http://purl.org/sipwise/ngcp-api/"
},
"self" : {
"href" : "/api/speeddials/323"
}
},
"speeddials" : [
{
"destination" : "sip:439965050@192.168.178.23",
"slot" : "*9"
},
{
"destination" : "sip:22222222@192.168.178.23",
"slot" : "*0"
},
{
"destination" : "sip:43665522@192.168.178.23",
"slot" : "*3"
}
]
};
let slotOptions = [
{
"label" : i18n.t('speedDial.slot').concat(" *1"),
"value" : "*1"
},
{
"label" : i18n.t('speedDial.slot').concat(" *2"),
"value" : "*2"
},
{
"label" : i18n.t('speedDial.slot').concat(" *4"),
"value" : "*4"
},
{
"label" : i18n.t('speedDial.slot').concat(" *5"),
"value" : "*5"
},
{
"label" : i18n.t('speedDial.slot').concat(" *6"),
"value" : "*6"
},
{
"label" : i18n.t('speedDial.slot').concat(" *7"),
"value" : "*7"
},
{
"label" : i18n.t('speedDial.slot').concat(" *8"),
"value" : "*8"
}
];
Vue.http.interceptors = [];
Vue.http.interceptors.unshift((request, next)=>{
next(request.respondWith(JSON.stringify(data), {
status: 200
}));
});
getUnassignedSlots(subscriberId).then((result)=>{
assert.deepEqual(result, slotOptions);
done();
}).catch((err)=>{
done(err);
});
});
});

@ -1,52 +1,51 @@
'use strict'; 'use strict'
import Vue from 'vue'; import Vue from 'vue'
import VueResource from 'vue-resource'; import VueResource from 'vue-resource'
import { getPreferences } from '../../src/api/subscriber'; import { getPreferences } from '../../src/api/subscriber'
import { assert } from 'chai'; import { assert } from 'chai'
Vue.use(VueResource); Vue.use(VueResource)
describe('Subscriber', function(){ describe('Subscriber', function () {
const subscriberId = 123
const subscriberId = 123; it('should get all subscriber preferences', function (done) {
Vue.http.interceptors = []
Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify({
block_in_mode: false,
clir: false
}), {
status: 200
}))
})
getPreferences(subscriberId).then((result) => {
assert.property(result, 'block_in_mode')
assert.isFalse(result.block_in_mode)
assert.property(result, 'clir')
assert.isFalse(result.clir)
done()
}).catch((err) => {
done(err)
})
})
it('should get all subscriber preferences', function(done) { it('should handle a 403 Forbidden while requesting the preferences', function (done) {
Vue.http.interceptors = []; Vue.http.interceptors = []
Vue.http.interceptors.unshift((request, next)=>{ Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify({ next(request.respondWith(JSON.stringify({
block_in_mode: false, message: '403 Forbidden'
clir: false }), {
}), { status: 403
status: 200 }))
})); })
}); getPreferences(subscriberId).then(() => {
getPreferences(subscriberId).then((result)=>{ done(new Error('Test failed'))
assert.property(result, 'block_in_mode'); }).catch((err) => {
assert.isFalse(result.block_in_mode); assert.equal(err.status, 403)
assert.property(result, 'clir'); done()
assert.isFalse(result.clir); })
done(); })
}).catch((err)=>{ })
done(err);
});
});
it('should handle a 403 Forbidden while requesting the preferences', function(done) {
Vue.http.interceptors = [];
Vue.http.interceptors.unshift((request, next)=>{
next(request.respondWith(JSON.stringify({
message: '403 Forbidden'
}), {
status: 403
}));
});
getPreferences(subscriberId).then(()=>{
done(new Error('Test failed'));
}).catch((err)=>{
assert.equal(err.status, 403);
done();
});
});
});

@ -1,152 +1,147 @@
'use strict'; 'use strict'
import Vue from 'vue'; import Vue from 'vue'
import VueResource from 'vue-resource'; import VueResource from 'vue-resource'
import { import {
get, get,
getList getList
} from '../../src/api/common'; } from '../../src/api/common'
import { import {
getVoiceboxSettings, getVoiceboxSettings,
getVoiceboxGreetingByType getVoiceboxGreetingByType
} from '../../src/api/voicebox'; } from '../../src/api/voicebox'
import { assert } from 'chai'; import { assert } from 'chai'
Vue.use(VueResource); Vue.use(VueResource)
describe('Voicebox', function() { describe('Voicebox', function () {
const subscriberId = 123
const subscriberId = 123;
it('should get subscriber\'s voicebox settings', function (done) {
it('should get subscriber\'s voicebox settings', function(done) { const data = {
_links: {
let data = { collection: {
"_links" : { href: '/api/voicemailsettings/'
"collection" : { },
"href" : "/api/voicemailsettings/" curies: {
}, href: 'http://purl.org/sipwise/ngcp-api/#rel-{rel}',
"curies" : { name: 'ngcp',
"href" : "http://purl.org/sipwise/ngcp-api/#rel-{rel}", templated: true
"name" : "ngcp", },
"templated" : true 'ngcp:journal': [
}, {
"ngcp:journal" : [ href: '/api/voicemailsettings/123/journal/'
{ }
"href" : "/api/voicemailsettings/123/journal/" ],
} 'ngcp:subscribers': [
], {
"ngcp:subscribers" : [ href: '/api/subscribers/123'
{ }
"href" : "/api/subscribers/123" ],
} profile: {
], href: 'http://purl.org/sipwise/ngcp-api/'
"profile" : { },
"href" : "http://purl.org/sipwise/ngcp-api/" self: {
}, href: '/api/voicemailsettings/123'
"self" : { }
"href" : "/api/voicemailsettings/123" },
} attach: true,
}, delete: false,
"attach" : true, email: '',
"delete" : false, id: 123,
"email" : "", pin: '1234',
"id" : 123, sms_number: ''
"pin" : "1234", }
"sms_number" : ""
}; const settings = {
attach: true,
let settings = { delete: false,
"attach" : true, email: '',
"delete" : false, id: 123,
"email" : "", pin: '1234',
"id" : 123, sms_number: ''
"pin" : "1234", }
"sms_number" : ""
}; Vue.http.interceptors = []
Vue.http.interceptors.unshift((request, next) => {
Vue.http.interceptors = []; next(request.respondWith(JSON.stringify(data), {
Vue.http.interceptors.unshift((request, next) => { status: 200
next(request.respondWith(JSON.stringify(data), { }))
status: 200 })
})); getVoiceboxSettings(subscriberId).then((result) => {
}); assert.deepEqual(result, settings)
getVoiceboxSettings(subscriberId).then((result) => { done()
assert.deepEqual(result, settings); }).catch((err) => {
done(); done(err)
}).catch((err) => { })
done(err); })
});
}); it('should get subscriber\'s busy greeting', function (done) {
const data = {
it('should get subscriber\'s busy greeting', function(done) { _embedded: {
'ngcp:voicemailgreetings': [
let data = { {
"_embedded" : { dir: 'busy',
"ngcp:voicemailgreetings" : [ id: 1,
{ subscriber_id: 123
"dir" : "busy", }
"id" : 1, ]
"subscriber_id" : 123 },
} total_count: 1
] }
},
"total_count" : 1 const greeting = {
}; dir: 'busy',
id: 1,
let greeting = { subscriber_id: 123
"dir" : "busy", }
"id" : 1,
"subscriber_id" : 123 Vue.http.interceptors = []
}; Vue.http.interceptors.unshift((request, next) => {
next(request.respondWith(JSON.stringify(data), {
Vue.http.interceptors = []; status: 200
Vue.http.interceptors.unshift((request, next) => { }))
next(request.respondWith(JSON.stringify(data), { })
status: 200 getVoiceboxGreetingByType({ id: subscriberId, type: 'busy' }).then((result) => {
})); assert.deepEqual(result.items[0], greeting)
}); done()
getVoiceboxGreetingByType({id: subscriberId, type: 'busy'}).then((result) => { }).catch((err) => {
assert.deepEqual(result.items[0], greeting); done(err)
done(); })
}).catch((err) => { })
done(err);
}); it('should get subscriber\'s unavailable greeting', function (done) {
}); const data = {
_embedded: {
it('should get subscriber\'s unavailable greeting', function(done) { 'ngcp:voicemailgreetings': [
{
let data = { dir: 'unavail',
"_embedded" : { id: 1,
"ngcp:voicemailgreetings" : [ subscriber_id: 123
{ }
"dir" : "unavail", ]
"id" : 1, },
"subscriber_id" : 123 total_count: 1
} }
]
}, const greeting = {
"total_count" : 1 dir: 'unavail',
}; id: 1,
subscriber_id: 123
let greeting = { }
"dir" : "unavail",
"id" : 1, Vue.http.interceptors = []
"subscriber_id" : 123 Vue.http.interceptors.unshift((request, next) => {
}; next(request.respondWith(JSON.stringify(data), {
status: 200
Vue.http.interceptors = []; }))
Vue.http.interceptors.unshift((request, next) => { })
next(request.respondWith(JSON.stringify(data), { getVoiceboxGreetingByType({ id: subscriberId, type: 'unavail' }).then((result) => {
status: 200 assert.deepEqual(result.items[0], greeting)
})); done()
}); }).catch((err) => {
getVoiceboxGreetingByType({id: subscriberId, type: 'unavail'}).then((result) => { done(err)
assert.deepEqual(result.items[0], greeting); })
done(); })
}).catch((err) => { })
done(err);
});
});
});

@ -1,13 +1,12 @@
import Vue from 'vue' import Vue from 'vue'
import Login from '../../src/components/Login.vue' import Login from '../../src/components/Login.vue'
import { assert } from 'chai'; import { assert } from 'chai'
describe('Login', function() { describe('Login', function () {
it('should initialize with default data', function () {
it('should initialize with default data', function(){ var defaultData = Login.data()
var defaultData = Login.data(); assert.equal(defaultData.username, '')
assert.equal(defaultData.username, ''); assert.equal(defaultData.password, '')
assert.equal(defaultData.password, ''); })
}); })
});

@ -1,65 +1,62 @@
'use strict'; 'use strict'
import CallBlockingModule from '../../src/store/call-blocking'; import CallBlockingModule from '../../src/store/call-blocking'
import { assert } from 'chai'; import { assert } from 'chai'
describe('CallBlocking', function(){ describe('CallBlocking', function () {
describe('Incoming', function () {
describe('Incoming', function(){ it('should enable list', function () {
var state = {}
it('should enable list', function(){ CallBlockingModule.mutations.toggleSucceeded(state, true)
var state = {}; assert.equal(state.enabled, true)
CallBlockingModule.mutations.toggleSucceeded(state, true); })
assert.equal(state.enabled, true);
}); it('should disable list', function () {
var state = {}
it('should disable list', function(){ CallBlockingModule.mutations.toggleSucceeded(state, false)
var state = {}; assert.equal(state.enabled, false)
CallBlockingModule.mutations.toggleSucceeded(state, false); })
assert.equal(state.enabled, false);
}); it('should load list and flag', function () {
var state = {}
it('should load list and flag', function(){ var list = [
var state = {}; '0123456789',
var list = [ '0987654321'
'0123456789', ]
'0987654321' CallBlockingModule.mutations.numberListSucceeded(state, {
]; enabled: true,
CallBlockingModule.mutations.numberListSucceeded(state, { list: list
enabled: true, })
list: list assert.equal(state.enabled, true)
}); assert.deepEqual(state.list, list)
assert.equal(state.enabled, true); })
assert.deepEqual(state.list, list); })
});
}); describe('Outgoing', function () {
it('should enable list', function () {
describe('Outgoing', function(){ var state = {}
CallBlockingModule.mutations.toggleSucceeded(state, true)
it('should enable list', function(){ assert.equal(state.enabled, true)
var state = {}; })
CallBlockingModule.mutations.toggleSucceeded(state, true);
assert.equal(state.enabled, true); it('should disable list', function () {
}); var state = {}
CallBlockingModule.mutations.toggleSucceeded(state, false)
it('should disable list', function(){ assert.equal(state.enabled, false)
var state = {}; })
CallBlockingModule.mutations.toggleSucceeded(state, false);
assert.equal(state.enabled, false); it('should load list and flag', function () {
}); var state = {}
var list = [
it('should load list and flag', function(){ '0123456789',
var state = {}; '0987654321'
var list = [ ]
'0123456789', CallBlockingModule.mutations.numberListSucceeded(state, {
'0987654321' enabled: true,
]; list: list
CallBlockingModule.mutations.numberListSucceeded(state, { })
enabled: true, assert.equal(state.enabled, true)
list: list assert.deepEqual(state.list, list)
}); })
assert.equal(state.enabled, true); })
assert.deepEqual(state.list, list); })
});
});
});

@ -1,63 +1,61 @@
'use strict'; 'use strict'
import CallForwardModule from '../../src/store/call-forward'; import CallForwardModule from '../../src/store/call-forward'
import { assert } from 'chai'; import { assert } from 'chai'
describe('CallForward', function(){ describe('CallForward', function () {
it('should load always type destinations', function () {
const state = {
destinations: {
online: [],
busy: [],
offline: []
}
}
const data = {
online: [],
busy: [],
offline: [{
destinations: [{
announcement_id: null,
destination: 'sip:3333@192.168.178.23',
priority: 1,
simple_destination: '3333',
timeout: 60
},
{
announcement_id: null,
destination: 'sip:2222@192.168.178.23',
priority: 1,
simple_destination: '2222',
timeout: 300
}],
id: 3,
name: 'csc_destinationset_1'
}]
}
CallForwardModule.mutations.loadDestinations(state, data)
assert.deepEqual(state.destinations, data)
})
it('should load always type destinations', function(){ it('should load timeset times', function () {
let state = { const state = {
destinations: { timesetTimes: []
online: [], }
busy: [], const result = {
offline: [] times: [
} { weekday: 'Monday', from: '8', to: '16' },
}; { weekday: 'Tuesday', from: '8', to: '16' },
let data = { { weekday: 'Wednesday', from: '8', to: '16' }
online: [], ],
busy: [], timesetIsCompatible: null,
offline: [{ timesetExists: null,
destinations: [{ timesetHasReverse: null,
"announcement_id": null, timesetHasDuplicate: null,
"destination": "sip:3333@192.168.178.23", timesetId: null
"priority": 1, }
"simple_destination": "3333", CallForwardModule.mutations.loadTimesSucceeded(state, result)
"timeout": 60 assert.equal(state.timesetTimes, result.times)
}, })
{ })
"announcement_id": null,
"destination": "sip:2222@192.168.178.23",
"priority": 1,
"simple_destination": "2222",
"timeout": 300
}],
id: 3,
name: "csc_destinationset_1"
}]
};
CallForwardModule.mutations.loadDestinations(state, data);
assert.deepEqual(state.destinations, data);
});
it('should load timeset times', function(){
let state = {
timesetTimes: []
};
let result = {
times: [
{ weekday: "Monday", from: "8", to: "16" },
{ weekday: "Tuesday", from: "8", to: "16" },
{ weekday: "Wednesday", from: "8", to: "16" }
],
timesetIsCompatible: null,
timesetExists: null,
timesetHasReverse: null,
timesetHasDuplicate: null,
timesetId: null
}
CallForwardModule.mutations.loadTimesSucceeded(state, result);
assert.equal(state.timesetTimes, result.times);
});
});

@ -1,98 +1,89 @@
'use strict'; 'use strict'
import ConferenceModule from '../../src/store/conference'; import ConferenceModule from '../../src/store/conference'
import { assert } from 'chai'; import { assert } from 'chai'
describe('Conference', function(){ describe('Conference', function () {
it('should add a participant id to the store if not already stored', () => {
it('should add a participant id to the store if not already stored', () => { const state = {
let state = { participants: []
participants: [] }
}; const participant = {
const participant = { getId: () => {
getId: () => { return '123456789'
return '123456789'; }
} }
}; ConferenceModule.mutations.participantJoined(state, participant)
ConferenceModule.mutations.participantJoined(state, participant); assert.include(state.participants, participant.getId())
assert.include(state.participants, participant.getId()); })
}); it('should not add a participant id to the store if already stored', () => {
const state = {
it('should not add a participant id to the store if already stored', () => { participants: ['123456789']
let state = { }
participants: ['123456789'] const participant = {
}; getId: () => {
const participant = { return '123456789'
getId: () => { }
return '123456789'; }
} ConferenceModule.mutations.participantJoined(state, participant)
}; assert.equal(state.participants.length, 1)
ConferenceModule.mutations.participantJoined(state, participant); })
assert.equal(state.participants.length, 1);
it('should remove a participant id from the store', () => {
}); const state = {
participants: ['123456789']
it('should remove a participant id from the store', () => { }
let state = { const participant = {
participants: ['123456789'] getId: () => {
}; return '123456789'
const participant = { }
getId: () => { }
return '123456789'; ConferenceModule.mutations.participantLeft(state, participant)
} assert.notInclude(state.participants, participant.getId())
}; })
ConferenceModule.mutations.participantLeft(state, participant);
assert.notInclude(state.participants, participant.getId()); it('should remove a participant mediastream from the store', () => {
const state = {
}); remoteMediaStreams: {
123456789: '123456789'
it('should remove a participant mediastream from the store', () => { }
let state = { }
remoteMediaStreams: { const participantId = '123456789'
123456789: '123456789'
} ConferenceModule.mutations.removeRemoteMedia(state, participantId)
}; assert.notExists(state.remoteMediaStreams[participantId])
const participantId = '123456789'; })
ConferenceModule.mutations.removeRemoteMedia(state, participantId); it('should store the selected remote participant as selected', () => {
assert.notExists(state.remoteMediaStreams[participantId]); const state = {
selectedParticipant: null
}); }
const participantId = '123456789'
it('should store the selected remote participant as selected', () => {
let state = { ConferenceModule.mutations.setSelectedParticipant(state, participantId)
selectedParticipant: null assert.equal(state.selectedParticipant, participantId)
}; })
const participantId = '123456789';
it('should store the local participant as selected if current selected participant leaves', () => {
ConferenceModule.mutations.setSelectedParticipant(state, participantId); const state = {
assert.equal(state.selectedParticipant, participantId); selectedParticipant: '123456789',
participants: []
}); }
const participantId = '123456789'
it('should store the local participant as selected if current selected participant leaves', () => {
let state = { ConferenceModule.mutations.setSelectedParticipant(state, participantId)
selectedParticipant: '123456789', assert.equal(state.selectedParticipant, 'local')
participants: [] })
};
const participantId = '123456789'; it('should reset the selected participant when conference ends', () => {
const state = {
ConferenceModule.mutations.setSelectedParticipant(state, participantId); selectedParticipant: 'local',
assert.equal(state.selectedParticipant, 'local'); joinState: false
}
});
ConferenceModule.mutations.setSelectedParticipant(state)
it('should reset the selected participant when conference ends', () => { assert.equal(state.selectedParticipant, null)
let state = { })
selectedParticipant: 'local', })
joinState: false
};
ConferenceModule.mutations.setSelectedParticipant(state);
assert.equal(state.selectedParticipant, null);
});
});

@ -1,154 +1,152 @@
'use strict'; 'use strict'
import ConversationsModule from '../../src/store/conversations/conversations'; import ConversationsModule from '../../src/store/conversations/conversations'
import { assert } from 'chai'; import { assert } from 'chai'
describe('Conversations', function(){ describe('Conversations', function () {
it('should load next page of items', function () {
const resultItems = []
const state = {
items: [
{
call_id: '8fe2fa2f-84bc-48be-977d-84984aa5cc29',
call_type: 'call',
callee: '43993006',
caller: '43993004',
currency: '',
customer_cost: 0,
direction: 'out',
duration: '0:00:00',
id: 85,
rating_status: 'ok',
start_time: '2018-06-21 14:50:00.687',
status: 'noanswer',
total_customer_cost: 0,
type: 'call',
_links: {
}
}
]
}
const data = {
items: [
{
call_id: '8fe2fa2f-84bc-48be-977d-84984aa5cc29',
call_type: 'call',
callee: '43993006',
caller: '43993004',
currency: '',
customer_cost: 0,
direction: 'out',
duration: '0:00:00',
id: 85,
rating_status: 'ok',
start_time: '2018-06-21 14:50:00.687',
status: 'noanswer',
total_customer_cost: 0,
type: 'call',
_links: {
}
}
],
lastPage: 1
}
resultItems.push(state.items[0])
resultItems.push(data.items[0])
ConversationsModule.mutations.nextPageSucceeded(state, data)
assert.deepEqual(state.items, resultItems)
})
it('should load next page of items', function(){ it('should load reloaded items', function () {
let resultItems = []; const state = {
let state = { items: [
items: [ {
{ call_id: '8fe2fa2f-84bc-48be-977d-84984aa5cc29',
call_id: "8fe2fa2f-84bc-48be-977d-84984aa5cc29", call_type: 'call',
call_type: "call", callee: '43993006',
callee: "43993006", caller: '43993004',
caller: "43993004", currency: '',
currency: "", customer_cost: 0,
customer_cost: 0, direction: 'out',
direction: "out", duration: '0:00:00',
duration: "0:00:00", id: 85,
id: 85, rating_status: 'ok',
rating_status: "ok", start_time: '2018-06-21 14:50:00.687',
start_time: "2018-06-21 14:50:00.687", status: 'noanswer',
status: "noanswer", total_customer_cost: 0,
total_customer_cost: 0, type: 'call',
type: "call", _links: {
_links: { }
} }
} ]
] }
}; const data = {
let data = { items: [
items: [ {
{ call_id: 'd2212956-46cc-4f9d-805d-cf2b5f572726',
call_id: "8fe2fa2f-84bc-48be-977d-84984aa5cc29", call_type: 'call',
call_type: "call", callee: '43993007',
callee: "43993006", caller: '43993004',
caller: "43993004", currency: '',
currency: "", customer_cost: 0,
customer_cost: 0, direction: 'out',
direction: "out", duration: '0:00:00',
duration: "0:00:00", id: 87,
id: 85, rating_status: 'ok',
rating_status: "ok", start_time: '2018-06-21 15:02:41.762',
start_time: "2018-06-21 14:50:00.687", status: 'noanswer',
status: "noanswer", total_customer_cost: 0,
total_customer_cost: 0, type: 'call',
type: "call", _links: {
_links: { }
} },
} {
], call_id: '8fe2fa2f-84bc-48be-977d-84984aa5cc29',
lastPage: 1 call_type: 'call',
}; callee: '43993006',
resultItems.push(state.items[0]); caller: '43993004',
resultItems.push(data.items[0]); currency: '',
ConversationsModule.mutations.nextPageSucceeded(state, data); customer_cost: 0,
assert.deepEqual(state.items, resultItems); direction: 'out',
}); duration: '0:00:00',
id: 85,
rating_status: 'ok',
start_time: '2018-06-21 14:50:00.687',
status: 'noanswer',
total_customer_cost: 0,
type: 'call',
_links: {
}
}
],
lastPage: 1
}
ConversationsModule.mutations.reloadItemsSucceeded(state, data)
assert.deepEqual(state.items, data.items)
})
it('should load reloaded items', function(){ it('should load blocked numbers and mode', function () {
let state = { const state = {
items: [ blockedNumbersIncoming: new Set(),
{ blockedModeIncoming: null,
call_id: "8fe2fa2f-84bc-48be-977d-84984aa5cc29", blockedNumbersOutgoing: new Set(),
call_type: "call", blockedModeOutgoing: null
callee: "43993006", }
caller: "43993004", const options = {
currency: "", blockAnonymous: undefined,
customer_cost: 0, enabled: undefined,
direction: "out", list: [
duration: "0:00:00", '123456',
id: 85, '555555'
rating_status: "ok", ]
start_time: "2018-06-21 14:50:00.687", }
status: "noanswer", const listSet = new Set(['123456', '555555'])
total_customer_cost: 0, ConversationsModule.mutations.blockedIncomingSucceeded(state, options)
type: "call", ConversationsModule.mutations.blockedOutgoingSucceeded(state, options)
_links: { assert.deepEqual(state.blockedNumbersIncoming, listSet)
} assert.equal(state.blockedModeIncoming, 'blacklist')
} assert.deepEqual(state.blockedNumbersOutgoing, listSet)
] assert.equal(state.blockedModeOutgoing, 'blacklist')
}; })
let data = { })
items: [
{
call_id: "d2212956-46cc-4f9d-805d-cf2b5f572726",
call_type: "call",
callee: "43993007",
caller: "43993004",
currency: "",
customer_cost: 0,
direction: "out",
duration: "0:00:00",
id: 87,
rating_status: "ok",
start_time: "2018-06-21 15:02:41.762",
status: "noanswer",
total_customer_cost: 0,
type: "call",
_links: {
}
},
{
call_id: "8fe2fa2f-84bc-48be-977d-84984aa5cc29",
call_type: "call",
callee: "43993006",
caller: "43993004",
currency: "",
customer_cost: 0,
direction: "out",
duration: "0:00:00",
id: 85,
rating_status: "ok",
start_time: "2018-06-21 14:50:00.687",
status: "noanswer",
total_customer_cost: 0,
type: "call",
_links: {
}
}
],
lastPage: 1
};
ConversationsModule.mutations.reloadItemsSucceeded(state, data);
assert.deepEqual(state.items, data.items);
});
it('should load blocked numbers and mode', function(){
let state = {
blockedNumbersIncoming: new Set(),
blockedModeIncoming: null,
blockedNumbersOutgoing: new Set(),
blockedModeOutgoing: null
};
let options = {
blockAnonymous: undefined,
enabled: undefined,
list: [
"123456",
"555555"
]
};
let listSet = new Set(["123456", "555555"]);
ConversationsModule.mutations.blockedIncomingSucceeded(state, options);
ConversationsModule.mutations.blockedOutgoingSucceeded(state, options);
assert.deepEqual(state.blockedNumbersIncoming, listSet);
assert.equal(state.blockedModeIncoming, 'blacklist');
assert.deepEqual(state.blockedNumbersOutgoing, listSet);
assert.equal(state.blockedModeOutgoing, 'blacklist');
});
});

@ -1,72 +1,70 @@
'use strict'; 'use strict'
import PbxConfig from '../../src/store/pbx-config'; import PbxConfig from '../../src/store/pbx-config'
import { assert } from 'chai'; import { assert } from 'chai'
describe('PBX Configuration Store', () => { describe('PBX Configuration Store', () => {
it('should list all PBX Groups', () => {
it('should list all PBX Groups', () => { const state = {}
let state = {}; const data = {
let data = { pilot: {},
pilot: {}, seats: {
seats: { 2: {
2: { id: 2,
id: 2, pbx_group_ids: []
pbx_group_ids: [] },
}, 3:
3:
{ {
id: 3, id: 3,
pbx_group_ids: [] pbx_group_ids: []
}
},
lastPage: 1,
groups: {
4: {
id: 4,
display_name: 'Marketing'
} }
}, },
numbers: [ lastPage: 1,
{ groups: {
id: 6 4: {
}, id: 4,
{ display_name: 'Marketing'
id: 7 }
} },
] numbers: [
}; {
PbxConfig.mutations.listSucceeded(state, data); id: 6
assert.equal(state.seats, data.seats); },
assert.equal(state.groups, data.groups); {
assert.deepEqual(state.numbers, data.numbers); id: 7
}); }
]
it('should list all Sound Sets', () => { }
let state = {}; PbxConfig.mutations.listSucceeded(state, data)
let data = { assert.equal(state.seats, data.seats)
items: [ assert.equal(state.groups, data.groups)
{ assert.deepEqual(state.numbers, data.numbers)
contract_defaults: true, })
customer_id: null,
description: 'Set description 1',
groups: [],
id: 15,
name: 'Set 1'
},
{
contract_defaults: false,
customer_id: null,
description: 'Set description 2',
groups: [],
id: 17,
name: 'Set 2'
}
]
};
PbxConfig.mutations.listSoundSetsSucceeded(state, data);
assert.equal(state.soundSets[15], data.items[0]);
assert.equal(state.soundSets[17], data.items[1]);
});
}); it('should list all Sound Sets', () => {
const state = {}
const data = {
items: [
{
contract_defaults: true,
customer_id: null,
description: 'Set description 1',
groups: [],
id: 15,
name: 'Set 1'
},
{
contract_defaults: false,
customer_id: null,
description: 'Set description 2',
groups: [],
id: 17,
name: 'Set 2'
}
]
}
PbxConfig.mutations.listSoundSetsSucceeded(state, data)
assert.equal(state.soundSets[15], data.items[0])
assert.equal(state.soundSets[17], data.items[1])
})
})

@ -1,27 +1,25 @@
'use strict'; 'use strict'
import SpeedDialModule from '../../src/store/speed-dial'; import SpeedDialModule from '../../src/store/speed-dial'
import { assert } from 'chai'; import { assert } from 'chai'
describe('SpeedDial', function(){ describe('SpeedDial', function () {
it('should load all assigned speed dial slots', function () {
it('should load all assigned speed dial slots', function(){ const state = {
let state = { assignedSlots: []
assignedSlots: [] }
}; const data = [
let data = [ {
{ destination: 'sip:111111@192.168.178.23',
destination: "sip:111111@192.168.178.23", slot: '*1'
slot: "*1" },
}, {
{ destination: 'sip:333333@192.168.178.23',
destination: "sip:333333@192.168.178.23", slot: '*3'
slot: "*3" }
} ]
]; SpeedDialModule.mutations.speedDialSucceeded(state, data)
SpeedDialModule.mutations.speedDialSucceeded(state, data); assert.deepEqual(state.assignedSlots, data)
assert.deepEqual(state.assignedSlots, data); })
}); })
});

@ -1,17 +1,16 @@
'use strict'; 'use strict'
import UserModule from '../../src/store/user'; import UserModule from '../../src/store/user'
import { assert } from 'chai'; import { assert } from 'chai'
describe('UserModule', ()=>{ describe('UserModule', () => {
it('should login', () => {
it('should login', ()=>{ var state = {}
var state = {}; UserModule.mutations.loginSucceeded(state, {
UserModule.mutations.loginSucceeded(state, { jwt: 'abc123',
jwt: 'abc123', subscriberId: 123
subscriberId: 123 })
}); assert.equal(state.jwt, 'abc123')
assert.equal(state.jwt, 'abc123'); assert.equal(state.subscriberId, '123')
assert.equal(state.subscriberId, '123'); })
}); })
});

@ -1,107 +1,104 @@
'use strict'; 'use strict'
import VoiceboxModule from '../../src/store/voicebox'; import VoiceboxModule from '../../src/store/voicebox'
import localeEn from 'src/i18n/en.json' import localeEn from 'src/i18n/en.json'
import { i18n } from '../../src/i18n'; import { i18n } from '../../src/i18n'
import { assert } from 'chai'; import { assert } from 'chai'
describe('Voicebox', function(){ describe('Voicebox', function () {
it('should load all voicebox settings into store', function () {
const state = {
voiceboxSettingDelete: false,
voiceboxSettingAttach: false,
voiceboxSettingPin: '',
voiceboxSettingEmail: ''
}
const settings = {
attach: true,
delete: false,
email: '',
id: 123,
pin: 1234,
sms_number: ''
}
VoiceboxModule.mutations.loadSettingsSucceeded(state, settings)
assert.equal(state.voiceboxSettingDelete, settings.delete)
assert.equal(state.voiceboxSettingAttach, settings.attach)
assert.equal(state.voiceboxSettingEmail, settings.email)
assert.equal(state.voiceboxSettingPin, settings.pin)
})
it('should load all voicebox settings into store', function(){ it('should load all busy greeting id into store', function () {
let state = { const state = {
voiceboxSettingDelete: false, busyGreetingId: null
voiceboxSettingAttach: false, }
voiceboxSettingPin: '', const greetings = [
voiceboxSettingEmail: '', {
}; id: 1
let settings = { }
attach: true, ]
delete: false, VoiceboxModule.mutations.loadBusyGreetingSucceeded(state, greetings)
email: '', assert.deepEqual(state.busyGreetingId, greetings[0].id)
id: 123, })
pin: 1234,
sms_number: ''
};
VoiceboxModule.mutations.loadSettingsSucceeded(state, settings);
assert.equal(state.voiceboxSettingDelete, settings.delete);
assert.equal(state.voiceboxSettingAttach, settings.attach);
assert.equal(state.voiceboxSettingEmail, settings.email);
assert.equal(state.voiceboxSettingPin, settings.pin);
}); it('should load busy greeting id into store', function () {
const state = {
busyGreetingId: null
}
const greetings = [
{
id: 1
}
]
VoiceboxModule.mutations.loadBusyGreetingSucceeded(state, greetings)
assert.deepEqual(state.busyGreetingId, greetings[0].id)
})
it('should load all busy greeting id into store', function(){ it('should load unavailable greeting id into store', function () {
let state = { const state = {
busyGreetingId: null unavailGreetingId: null
}; }
let greetings = [ const greetings = [
{ {
id: 1 id: 1
} }
]; ]
VoiceboxModule.mutations.loadBusyGreetingSucceeded(state, greetings); VoiceboxModule.mutations.loadUnavailGreetingSucceeded(state, greetings)
assert.deepEqual(state.busyGreetingId, greetings[0].id); assert.deepEqual(state.unavailGreetingId, greetings[0].id)
}); })
it('should load busy greeting id into store', function(){ it('should load busy greeting url into store', function () {
let state = { const state = {
busyGreetingId: null playBusyGreetingUrl: null
}; }
let greetings = [ const url = 'blob:https://1.2.3.4/6341147c-3ed2-4112-876b-331e834a4821'
{ VoiceboxModule.mutations.playBusyGreetingSucceeded(state, url)
id: 1 assert.deepEqual(state.playBusyGreetingUrl, url)
} })
];
VoiceboxModule.mutations.loadBusyGreetingSucceeded(state, greetings);
assert.deepEqual(state.busyGreetingId, greetings[0].id);
});
it('should load unavailable greeting id into store', function(){ it('should load unavailable greeting id into store', function () {
let state = { const state = {
unavailGreetingId: null playUnavailGreetingUrl: null
}; }
let greetings = [ const url = 'blob:https://1.2.3.4/6341147c-3ed2-4112-876b-331e834a4821'
{ VoiceboxModule.mutations.playUnavailGreetingSucceeded(state, url)
id: 1 assert.deepEqual(state.playUnavailGreetingUrl, url)
} })
];
VoiceboxModule.mutations.loadUnavailGreetingSucceeded(state, greetings);
assert.deepEqual(state.unavailGreetingId, greetings[0].id);
});
it('should load busy greeting url into store', function(){ it('should get right label for busy greeting to indicate if it\'s custom or default', function () {
let state = { const state = {
playBusyGreetingUrl: null busyGreetingId: null
}; }
let url = "blob:https://1.2.3.4/6341147c-3ed2-4112-876b-331e834a4821"; const getterObject = VoiceboxModule.getters.busyGreetingLabel(state)
VoiceboxModule.mutations.playBusyGreetingSucceeded(state, url); assert.equal(getterObject, i18n.t('voicebox.label.defaultSoundActive'))
assert.deepEqual(state.playBusyGreetingUrl, url); })
});
it('should load unavailable greeting id into store', function(){ it('should get right label for unavailable greeting to indicate if it\'s custom or default', function () {
let state = { const state = {
playUnavailGreetingUrl: null unavailGreetingId: 1
}; }
let url = "blob:https://1.2.3.4/6341147c-3ed2-4112-876b-331e834a4821"; const getterObject = VoiceboxModule.getters.unavailGreetingLabel(state)
VoiceboxModule.mutations.playUnavailGreetingSucceeded(state, url); assert.equal(getterObject, i18n.t('voicebox.label.customSoundActive'))
assert.deepEqual(state.playUnavailGreetingUrl, url); })
}); })
it('should get right label for busy greeting to indicate if it\'s custom or default', function(){
let state = {
busyGreetingId: null
};
let getterObject = VoiceboxModule.getters.busyGreetingLabel(state);
assert.equal(getterObject, i18n.t('voicebox.label.defaultSoundActive'));
});
it('should get right label for unavailable greeting to indicate if it\'s custom or default', function(){
let state = {
unavailGreetingId: 1
};
let getterObject = VoiceboxModule.getters.unavailGreetingLabel(state);
assert.equal(getterObject, i18n.t('voicebox.label.customSoundActive'));
});
});

@ -1,74 +1,72 @@
'use strict'; 'use strict'
import { assert } from 'chai'; import { assert } from 'chai'
import { isYesterday, isToday, isWithinLastWeek } from '../../src/helpers/date-helper' import { isYesterday, isToday, isWithinLastWeek } from '../../src/helpers/date-helper'
describe('Date helper', function() { describe('Date helper', function () {
it('should check whether a given date is yesterday or not', function () {
const today = new Date('2000-01-01 00:00:00')
const beforeYesterday = new Date('1999-12-30 00:00:00')
const tomorrow = new Date('2000-01-02 00:00:00')
it('should check whether a given date is yesterday or not', function() { const yesterday1 = new Date('1999-12-31 00:00:00')
let today = new Date('2000-01-01 00:00:00'); const yesterday2 = new Date('1999-12-31 14:00:00')
let beforeYesterday = new Date('1999-12-30 00:00:00'); const yesterday3 = new Date('1999-12-31 23:59:59')
let tomorrow = new Date('2000-01-02 00:00:00');
let yesterday1 = new Date('1999-12-31 00:00:00'); assert.isTrue(isYesterday(yesterday1, today))
let yesterday2 = new Date('1999-12-31 14:00:00'); assert.isTrue(isYesterday(yesterday2, today))
let yesterday3 = new Date('1999-12-31 23:59:59'); assert.isTrue(isYesterday(yesterday3, today))
assert.isTrue(isYesterday(yesterday1, today)); assert.isFalse(isYesterday(beforeYesterday, today))
assert.isTrue(isYesterday(yesterday2, today)); assert.isFalse(isYesterday(today, today))
assert.isTrue(isYesterday(yesterday3, today)); assert.isFalse(isYesterday(tomorrow, today))
})
assert.isFalse(isYesterday(beforeYesterday, today)); it('should check whether a given date is today or not', function () {
assert.isFalse(isYesterday(today, today)); const today = new Date('2000-01-01 00:00:00')
assert.isFalse(isYesterday(tomorrow, today)); const yesterday = new Date('1999-12-31 00:00:00')
}); const beforeYesterday = new Date('1999-12-30 00:00:00')
const tomorrow = new Date('2000-01-02 00:00:00')
const afterTomorrow = new Date('2000-01-03 00:00:00')
it('should check whether a given date is today or not', function() { const today1 = new Date('2000-01-01 00:00:00')
let today = new Date('2000-01-01 00:00:00'); const today2 = new Date('2000-01-01 14:00:00')
let yesterday = new Date('1999-12-31 00:00:00'); const today3 = new Date('2000-01-01 23:59:59')
let beforeYesterday = new Date('1999-12-30 00:00:00');
let tomorrow = new Date('2000-01-02 00:00:00');
let afterTomorrow = new Date('2000-01-03 00:00:00');
let today1 = new Date('2000-01-01 00:00:00'); assert.isTrue(isToday(today, today))
let today2 = new Date('2000-01-01 14:00:00'); assert.isTrue(isToday(today1, today))
let today3 = new Date('2000-01-01 23:59:59'); assert.isTrue(isToday(today2, today))
assert.isTrue(isToday(today3, today))
assert.isTrue(isToday(today, today)); assert.isFalse(isToday(beforeYesterday, today))
assert.isTrue(isToday(today1, today)); assert.isFalse(isToday(yesterday, today))
assert.isTrue(isToday(today2, today)); assert.isFalse(isToday(tomorrow, today))
assert.isTrue(isToday(today3, today)); assert.isFalse(isToday(afterTomorrow, today))
})
assert.isFalse(isToday(beforeYesterday, today)); it('should check whether a given date is within last week or not', function () {
assert.isFalse(isToday(yesterday, today)); const today = new Date('2000-01-01 00:00:00')
assert.isFalse(isToday(tomorrow, today)); const validDay1 = new Date('1999-12-31 00:00:00')
assert.isFalse(isToday(afterTomorrow, today)); const validDay2 = new Date('1999-12-30 00:00:00')
}); const validDay3 = new Date('1999-12-29 00:00:00')
const validDay4 = new Date('1999-12-28 00:00:00')
const validDay5 = new Date('1999-12-27 00:00:00')
const validDay6 = new Date('1999-12-26 00:00:00')
it('should check whether a given date is within last week or not', function(){ const invalidDay1 = new Date('1999-12-25 00:00:00')
const invalidDay2 = new Date('1999-12-24 00:00:00')
const invalidDay3 = new Date('1999-12-23 00:00:00')
let today = new Date('2000-01-01 00:00:00'); assert.isTrue(isWithinLastWeek(validDay1, today))
let validDay1 = new Date('1999-12-31 00:00:00'); assert.isTrue(isWithinLastWeek(validDay2, today))
let validDay2 = new Date('1999-12-30 00:00:00'); assert.isTrue(isWithinLastWeek(validDay3, today))
let validDay3 = new Date('1999-12-29 00:00:00'); assert.isTrue(isWithinLastWeek(validDay4, today))
let validDay4 = new Date('1999-12-28 00:00:00'); assert.isTrue(isWithinLastWeek(validDay5, today))
let validDay5 = new Date('1999-12-27 00:00:00'); assert.isTrue(isWithinLastWeek(validDay6, today))
let validDay6 = new Date('1999-12-26 00:00:00');
let invalidDay1 = new Date('1999-12-25 00:00:00'); assert.isFalse(isWithinLastWeek(today, today))
let invalidDay2 = new Date('1999-12-24 00:00:00'); assert.isFalse(isWithinLastWeek(invalidDay1, today))
let invalidDay3 = new Date('1999-12-23 00:00:00'); assert.isFalse(isWithinLastWeek(invalidDay2, today))
assert.isFalse(isWithinLastWeek(invalidDay3, today))
assert.isTrue(isWithinLastWeek(validDay1, today)); })
assert.isTrue(isWithinLastWeek(validDay2, today)); })
assert.isTrue(isWithinLastWeek(validDay3, today));
assert.isTrue(isWithinLastWeek(validDay4, today));
assert.isTrue(isWithinLastWeek(validDay5, today));
assert.isTrue(isWithinLastWeek(validDay6, today));
assert.isFalse(isWithinLastWeek(today, today));
assert.isFalse(isWithinLastWeek(invalidDay1, today));
assert.isFalse(isWithinLastWeek(invalidDay2, today));
assert.isFalse(isWithinLastWeek(invalidDay3, today));
});
});

@ -1,44 +1,42 @@
'use strict'; 'use strict'
import { assert } from 'chai'; import { assert } from 'chai'
import numberFormat from '../../src/filters/number-format'; import numberFormat, { normalizeDestination } from '../../src/filters/number-format'
import { normalizeDestination } from '../../src/filters/number-format';
const numbers = { const numbers = {
valid1: '43993004', valid1: '43993004',
invalid1: '43993004+', invalid1: '43993004+',
invalid2: 'a43993004', invalid2: 'a43993004'
}; }
const sipUris = { const sipUris = {
valid1: 'sip:43993004@sipwise.com', valid1: 'sip:43993004@sipwise.com',
invalid1: 'sip:a43993004@sipwise.com' invalid1: 'sip:a43993004@sipwise.com'
}; }
const destinations = { const destinations = {
voiceMail: 'sip:vmu@voicebox.local', voiceMail: 'sip:vmu@voicebox.local',
fax2Mail: 'sip:@fax2mail.local', fax2Mail: 'sip:@fax2mail.local',
managerSecretary: 'sip:@managersecretary.local', managerSecretary: 'sip:@managersecretary.local',
app: 'sip:app@app.local', app: 'sip:app@app.local',
customHours: 'sip:custom-hours@app.local', customHours: 'sip:custom-hours@app.local',
conference: 'sip:@conference.local', conference: 'sip:@conference.local',
number: 'sip:43993004@sipwise.com' number: 'sip:43993004@sipwise.com'
}; }
describe('NumberFormatFilter', function() { describe('NumberFormatFilter', function () {
it('should format a number or sip uri', function () {
assert.equal(numberFormat(sipUris.valid1), numbers.valid1)
assert.equal(numberFormat(sipUris.invalid1), numbers.invalid2)
})
it('should format a number or sip uri', function(){ it('should format a call forward destination', function () {
assert.equal(numberFormat(sipUris.valid1), numbers.valid1); assert.equal(normalizeDestination(destinations.voiceMail), 'Voicebox')
assert.equal(numberFormat(sipUris.invalid1), numbers.invalid2); assert.equal(normalizeDestination(destinations.fax2Mail), 'Fax2Mail')
}); assert.equal(normalizeDestination(destinations.managerSecretary), 'Manager Secretary')
assert.equal(normalizeDestination(destinations.app), 'App')
it('should format a call forward destination', function(){ assert.equal(normalizeDestination(destinations.customHours), 'Custom Announcement')
assert.equal(normalizeDestination(destinations.voiceMail), 'Voicebox'); assert.equal(normalizeDestination(destinations.conference), 'Conference')
assert.equal(normalizeDestination(destinations.fax2Mail), 'Fax2Mail'); assert.equal(normalizeDestination(destinations.number), numbers.valid1)
assert.equal(normalizeDestination(destinations.managerSecretary), 'Manager Secretary'); })
assert.equal(normalizeDestination(destinations.app), 'App'); })
assert.equal(normalizeDestination(destinations.customHours), 'Custom Announcement');
assert.equal(normalizeDestination(destinations.conference), 'Conference');
assert.equal(normalizeDestination(destinations.number), numbers.valid1);
});
});

@ -1,61 +1,57 @@
'use strict'; 'use strict'
import { assert } from 'chai'; import { assert } from 'chai'
import { import {
userInfo, userInfo,
customMacAddress customMacAddress
} from '../../src/helpers/validation' } from '../../src/helpers/validation'
describe('Userinfo validation helper', function() { describe('Userinfo validation helper', function () {
it('should validate userinfo consisting of phone number and country code', function () {
it('should validate userinfo consisting of phone number and country code', function() { const input = '+439988776655'
let input = "+439988776655"; assert.isTrue(userInfo(input))
assert.isTrue(userInfo(input)); })
});
it('should validate userinfo with parameter', function () {
it('should validate userinfo with parameter', function() { const input = '+358-555-1234567;postd=pp22'
let input = "+358-555-1234567;postd=pp22"; assert.isTrue(userInfo(input))
assert.isTrue(userInfo(input)); })
});
it('should validate userinfo consisting of subscriber username', function () {
it('should validate userinfo consisting of subscriber username', function() { const input = 'alice'
let input = "alice"; assert.isTrue(userInfo(input))
assert.isTrue(userInfo(input)); })
});
it('should not validate invalid userinfo characters', function () {
it('should not validate invalid userinfo characters', function() { const input = 'al)<e'
let input = "al)<e"; assert.isFalse(userInfo(input))
assert.isFalse(userInfo(input)); })
}); })
}); describe('Custom mac address validation helper', function () {
it('should validate mac address separated by colon', function () {
describe('Custom mac address validation helper', function() { const input = '13:14:5f:cD:42:5f'
assert.isTrue(customMacAddress(input))
it('should validate mac address separated by colon', function() { })
let input = "13:14:5f:cD:42:5f";
assert.isTrue(customMacAddress(input)); it('should validate mac address separated by hyphen', function () {
}); const input = '13-14-5f-cD-42-5f'
assert.isTrue(customMacAddress(input))
it('should validate mac address separated by hyphen', function() { })
let input = "13-14-5f-cD-42-5f";
assert.isTrue(customMacAddress(input)); it('should validate mac address without separator', function () {
}); const input = '13145fcD425f'
assert.isTrue(customMacAddress(input))
it('should validate mac address without separator', function() { })
let input = "13145fcD425f";
assert.isTrue(customMacAddress(input)); it('should not validate mac address with mixed separator', function () {
}); const input = '13:14:5f:cD:42-5f'
assert.isFalse(customMacAddress(input))
it('should not validate mac address with mixed separator', function() { })
let input = "13:14:5f:cD:42-5f";
assert.isFalse(customMacAddress(input)); it('should not validate mac address when invalid', function () {
}); const input = 'k183p1r23411'
assert.isFalse(customMacAddress(input))
it('should not validate mac address when invalid', function() { })
let input = "k183p1r23411"; })
assert.isFalse(customMacAddress(input));
});
});

@ -1,12 +1,12 @@
<template> <template>
<div></div> <div />
</template> </template>
<script> <script>
export default { export default {
data () { data () {
return {} return {}
} }
} }
</script> </script>

@ -1,18 +1,18 @@
<template> <template>
<!-- Configure "view" prop for QLayout --> <!-- Configure "view" prop for QLayout -->
<q-layout> <q-layout>
<q-toolbar slot="header"> <q-toolbar slot="header">
<!-- opens drawer below <!-- opens drawer below
<button class="hide-on-drawer-visible" @click="$refs.drawer.open()"> <button class="hide-on-drawer-visible" @click="$refs.drawer.open()">
<i>menu</i> <i>menu</i>
</button> </button>
--> -->
<q-toolbar-title> <q-toolbar-title>
Title Title
</q-toolbar-title> </q-toolbar-title>
</q-toolbar> </q-toolbar>
<!-- Navigation Tabs <!-- Navigation Tabs
<q-tabs slot="navigation"> <q-tabs slot="navigation">
<q-route-tab slot="title" icon="view_quilt" to="/layout/about" replace hide="icon" label="About" /> <q-route-tab slot="title" icon="view_quilt" to="/layout/about" replace hide="icon" label="About" />
<q-route-tab slot="title" icon="view_day" to="/layout/toolbar" replace hide="icon" label="Toolbar" /> <q-route-tab slot="title" icon="view_day" to="/layout/toolbar" replace hide="icon" label="Toolbar" />
@ -21,7 +21,7 @@
</q-tabs> </q-tabs>
--> -->
<!-- Left Side Panel <!-- Left Side Panel
<div slot="left"> <div slot="left">
<q-list no-border link inset-delimiter> <q-list no-border link inset-delimiter>
<q-list-header>Essential Links</q-list-header> <q-list-header>Essential Links</q-list-header>
@ -45,27 +45,27 @@
</div> </div>
--> -->
<!-- Right Side Panel <!-- Right Side Panel
<div slot="right"> <div slot="right">
... ...
</div> </div>
--> -->
<router-view /> <router-view />
<!-- Footer <!-- Footer
<q-toolbar slot="footer"> <q-toolbar slot="footer">
... ...
</q-toolbar> </q-toolbar>
--> -->
</q-layout> </q-layout>
</template> </template>
<script> <script>
export default { export default {
data () { data () {
return {} return {}
} }
} }
</script> </script>

@ -1,15 +1,15 @@
<template> <template>
<!-- if you want automatic padding use "layout-padding" class --> <!-- if you want automatic padding use "layout-padding" class -->
<div class="layout-padding"> <div class="layout-padding">
<!-- your content --> <!-- your content -->
</div> </div>
</template> </template>
<script> <script>
export default { export default {
data () { data () {
return {} return {}
} }
} }
</script> </script>

@ -1,24 +1,29 @@
<template> <template>
<div> <div>
<p class="textContent">{{ input }}</p> <p class="textContent">
<span>{{ counter }}</span> {{ input }}
<q-btn id="mybutton" @click="increment()"></q-btn> </p>
</div> <span>{{ counter }}</span>
<q-btn
id="mybutton"
@click="increment()"
/>
</div>
</template> </template>
<script> <script>
export default { export default {
name: 'QBUTTON', name: 'QBUTTON',
data () { data () {
return { return {
counter: 0, counter: 0,
input: 'rocket muffin' input: 'rocket muffin'
} }
}, },
methods: { methods: {
increment () { increment () {
this.counter++ this.counter++
} }
} }
} }
</script> </script>

@ -47,6 +47,6 @@ Object.keys(originalExpect).forEach(key => (global.expect[key] = originalExpect[
*/ */
// do this to make sure we don't get multiple hits from both webpacks when running SSR // do this to make sure we don't get multiple hits from both webpacks when running SSR
setTimeout(()=>{ setTimeout(() => {
// do nothing // do nothing
}, 1) }, 1)

@ -6,65 +6,65 @@ import VueRouter from 'vue-router'
import Quasar, { Cookies } from 'quasar' import Quasar, { Cookies } from 'quasar'
const mockSsrContext = () => { const mockSsrContext = () => {
return { return {
req: { req: {
headers: {} headers: {}
}, },
res: { res: {
setHeader: () => undefined setHeader: () => undefined
} }
} }
} }
// https://eddyerburgh.me/mock-vuex-in-vue-unit-tests // https://eddyerburgh.me/mock-vuex-in-vue-unit-tests
export const mountQuasar = (component, options = {}) => { export const mountQuasar = (component, options = {}) => {
const localVue = createLocalVue() const localVue = createLocalVue()
const app = {} const app = {}
localVue.use(Vuex) localVue.use(Vuex)
localVue.use(VueRouter) localVue.use(VueRouter)
localVue.use(Quasar) localVue.use(Quasar)
const store = new Vuex.Store({}) const store = new Vuex.Store({})
const router = new VueRouter() const router = new VueRouter()
if (options) { if (options) {
const ssrContext = options.ssr ? mockSsrContext() : null const ssrContext = options.ssr ? mockSsrContext() : null
if (options.cookies) { if (options.cookies) {
const cookieStorage = ssrContext ? Cookies.parseSSR(ssrContext) : Cookies const cookieStorage = ssrContext ? Cookies.parseSSR(ssrContext) : Cookies
const cookies = options.cookies const cookies = options.cookies
Object.keys(cookies).forEach(key => { Object.keys(cookies).forEach(key => {
cookieStorage.set(key, cookies[key]) cookieStorage.set(key, cookies[key])
}) })
} }
if (options.plugins) { if (options.plugins) {
options.plugins.forEach(plugin => { options.plugins.forEach(plugin => {
plugin({ app, store, router, Vue: localVue, ssrContext }) plugin({ app, store, router, Vue: localVue, ssrContext })
}) })
} }
} }
// mock vue-i18n // mock vue-i18n
const $t = () => {} const $t = () => {}
const $tc = () => {} const $tc = () => {}
const $n = () => {} const $n = () => {}
const $d = () => {} const $d = () => {}
return shallowMount(component, { return shallowMount(component, {
localVue: localVue, localVue: localVue,
store, store,
router, router,
mocks: { $t, $tc, $n, $d }, mocks: { $t, $tc, $n, $d },
// Injections for Components with a QPage root Element // Injections for Components with a QPage root Element
provide: { provide: {
pageContainer: true, pageContainer: true,
layout: { layout: {
header: {}, header: {},
right: {}, right: {},
footer: {}, footer: {},
left: {} left: {}
} }
} }
}) })
} }

Loading…
Cancel
Save