TT#31801 List Company Hours Times

What has been done:
- TT#31810, CallForwarding: Implement api requests
- TT#32002, CallForwarding: Implement store
- TT#32001, CallForwarding: Implement UI component
- TT#32003, CallForwarding: Create test

Change-Id: I2c858ea73bde7ec8a71127dd48d3e8de6121fd37
changes/60/18760/15
raxelsen 8 years ago
parent 57a26ca298
commit f345683357

@ -1,6 +1,7 @@
import _ from 'lodash';
import Vue from 'vue';
import { i18n } from '../i18n';
import { getJsonBody } from './utils';
let rowCountAssumption = 1000;
@ -54,8 +55,10 @@ export function getTimesets(id) {
} else {
return Promise.resolve(result);
}
}).then(result => {
resolve(getJsonBody(result.body)._embedded['ngcp:cftimesets']);
}).then((result) => {
let response = getJsonBody(result.body)._embedded || [];
let timesets = response['ngcp:cftimesets'] || [];
resolve(timesets);
}).catch(err => {
reject(err);
});
@ -375,3 +378,123 @@ export function moveDestinationDown(options) {
});
});
}
export function getDaysFromRange(options) {
let fromDay = options.from;
let toDay = options.to;
let wdayMap = {
1: i18n.t('pages.callForward.times.sunday'),
2: i18n.t('pages.callForward.times.monday'),
3: i18n.t('pages.callForward.times.tuesday'),
4: i18n.t('pages.callForward.times.wednesday'),
5: i18n.t('pages.callForward.times.thursday'),
6: i18n.t('pages.callForward.times.friday'),
7: i18n.t('pages.callForward.times.saturday')
};
let days = [];
while (fromDay < toDay) {
days.push({ name: wdayMap[fromDay], number: fromDay });
fromDay++;
};
return days;
}
export function getHoursFromRange(options) {
let fromMinute = options.hasMinute ? options.fromMinute : '00';
let toMinute = options.hasMinute ? options.toMinute + 1 : '00';
toMinute = !toMinute ? fromMinute + 1 : toMinute;
let hours = [];
if (options.hasMinute) {
while (options.fromHour < options.toHour) {
hours.push({
from: `${options.fromHour}:${fromMinute}`,
to: `${options.fromHour}:${toMinute}`
});
options.fromHour++;
};
} else {
hours.push({
from: `${options.fromHour}:${fromMinute}`,
to: `${options.toHour}:${toMinute}`
});
}
return hours;
}
export function convertTimesetToWeekdays(options) {
let times = [];
let counter = 0;
let timesetIsCompatible = false;
let timesetHasDuplicate = false;
let timesetExists = false;
let timesetHasReverse = false;
options.timesets.forEach((timeset) => {
let timesetNameMatches = timeset.name === options.timesetName;
if (counter === 0 && timesetNameMatches) {
timeset.times.forEach((time) => {
let days = [];
let hours = [];
let fromDay = parseInt(time.wday.split('-')[0]);
let toDay = time.wday.split('-')[1] ? parseInt(time.wday.split('-')[1]) + 1 : fromDay + 1;
let fromHour = parseInt(time.hour.split('-')[0]);
let toHour = time.hour.split('-')[1] ? parseInt(time.hour.split('-')[1]) + 1 : fromHour + 1;
let fromMinute = time.minute ? parseInt(time.minute.split('-')[0]) : undefined;
let toMinute = (time.minute && time.minute.split('-')[1]) ? parseInt(time.minute.split('-')[1]) : undefined;
let isCompatible = time.mday || time.month || time.year || !time.wday || !time.hour;
let isReverse = fromDay > toDay || fromHour > toHour || fromMinute > toMinute;
if (isCompatible) {
timesetIsCompatible = false;
return;
} else if (isReverse) {
timesetHasReverse = true;
return;
} else {
hours = getHoursFromRange({ hasMinute: !!time.minute,
fromHour: fromHour, toHour: toHour,
fromMinute: fromMinute, toMinute: toMinute });
days = getDaysFromRange({ from: fromDay, to: toDay });
days.forEach(day => {
hours.forEach(hour => {
times.push({
weekday: day.name,
from: hour.from,
to: hour.to,
wday: time.wday,
hour: time.hour,
minute: time.minute
});
});
});
timesetIsCompatible = true;
}
});
timesetExists = true;
counter++;
} else if (timesetNameMatches) {
timesetHasDuplicate = true;
return;
}
});
return {
times: times,
timesetIsCompatible: timesetIsCompatible,
timesetExists: timesetExists,
timesetHasReverse: timesetHasReverse,
timesetHasDuplicate: timesetHasDuplicate
};
}
export function loadTimesetTimes(options) {
return new Promise((resolve, reject)=> {
Promise.resolve().then(() => {
return getTimesets(options.subscriberId);
}).then((timesets) => {
let times = convertTimesetToWeekdays({ timesets: timesets, timesetName: options.timeset});
return times;
}).then((times) => {
resolve(times);
}).catch((err) => {
reject(err);
});
});
}

@ -1,29 +1,29 @@
<template>
<csc-page :title="$t('pages.callForward.titles.afterHours')">
<csc-call-forward timeset="After Hours" :destinations="destinations">
</csc-call-forward>
<csc-call-forward-destinations timeset="After Hours" :destinations="destinations">
</csc-call-forward-destinations>
</csc-page>
</template>
<script>
import { mapState } from 'vuex'
import CscPage from '../../CscPage'
import CscCallForward from './CscCallForward'
import CscCallForwardDestinations from './CscCallForwardDestinations'
export default {
data () {
return {}
},
components: {
CscPage,
CscCallForward
CscCallForwardDestinations
},
created() {
this.$store.dispatch('callForward/loadAfterHoursEverybodyDestinations');
},
computed: {
...mapState('callForward', {
destinations: 'afterHoursEverybodyDestinations'
})
...mapState('callForward', [
'destinations'
])
}
}
</script>

@ -1,29 +1,29 @@
<template>
<csc-page :title="$t('pages.callForward.titles.always')">
<csc-call-forward timeset="null" :destinations="destinations">
</csc-call-forward>
<csc-call-forward-destinations timeset="null" :destinations="destinations">
</csc-call-forward-destinations>
</csc-page>
</template>
<script>
import { mapState } from 'vuex'
import CscPage from '../../CscPage'
import CscCallForward from './CscCallForward'
import CscCallForwardDestinations from './CscCallForwardDestinations'
export default {
data () {
return {}
},
components: {
CscPage,
CscCallForward
CscCallForwardDestinations
},
created() {
this.$store.dispatch('callForward/loadAlwaysEverybodyDestinations');
},
computed: {
...mapState('callForward', {
destinations: 'alwaysEverybodyDestinations'
})
...mapState('callForward', [
'destinations'
])
}
}
</script>

@ -1,29 +1,80 @@
<template>
<csc-page :title="$t('pages.callForward.titles.companyHours')">
<csc-call-forward timeset="Company Hours" :destinations="destinations">
</csc-call-forward>
<div v-if="timesetIsCompatible && !timesetHasReverse && !timesetHasDuplicate && timesetExists">
<csc-call-forward-times :times="timesetTimes"></csc-call-forward-times>
<csc-call-forward-destinations timeset="Company Hours" :destinations="destinations">
</csc-call-forward-destinations>
</div>
<div v-else-if="timesetHasReverse && timesetExists">
<q-alert color="red"
icon="date_range"
enter="bounceInLeft"
leave="bounceOutRight"
appear>
{{ $t('pages.callForward.times.companyHoursReverse') }}
</q-alert>
</div>
<div v-else-if="timesetHasDuplicate && timesetExists">
<q-alert color="red"
icon="date_range"
enter="bounceInLeft"
leave="bounceOutRight"
appear>
{{ $t('pages.callForward.times.companyHoursDuplicate') }}
</q-alert>
</div>
<div v-else-if="!timesetIsCompatible && timesetExists">
<q-alert color="red"
icon="date_range"
enter="bounceInLeft"
leave="bounceOutRight"
appear>
{{ $t('pages.callForward.times.companyHoursIncompatible') }}
</q-alert>
</div>
<div v-else>
<q-alert color="warning"
icon="date_range"
enter="bounceInLeft"
leave="bounceOutRight"
appear>
{{ $t('pages.callForward.times.companyHoursNotDefined') }}
</q-alert>
</div>
</csc-page>
</template>
<script>
import { mapState } from 'vuex'
import { QAlert } from 'quasar-framework'
import CscPage from '../../CscPage'
import CscCallForward from './CscCallForward'
import CscCallForwardDestinations from './CscCallForwardDestinations'
import CscCallForwardTimes from './CscCallForwardTimes'
export default {
data () {
return {}
},
components: {
CscPage,
CscCallForward
CscCallForwardDestinations,
CscCallForwardTimes,
QAlert
},
created() {
this.$store.dispatch('callForward/loadCompanyHoursEverybodyDestinations');
this.$store.dispatch('callForward/loadTimesetTimes', {
timeset: 'Company Hours'
});
},
computed: {
...mapState('callForward', {
destinations: 'companyHoursEverybodyDestinations'
})
...mapState('callForward', [
'destinations',
'timesetTimes',
'timesetIsCompatible',
'timesetHasReverse',
'timesetHasDuplicate',
'timesetExists'
])
}
}
</script>

@ -29,7 +29,7 @@
import CscDestinations from './CscDestinations'
import { QCard } from 'quasar-framework'
export default {
name: 'csc-call-forward',
name: 'csc-call-forward-destinations',
props: [
'timeset',
'destinations'

@ -0,0 +1,64 @@
<template>
<q-field class="time-field">
<div class="row no-wrap">
<q-input class="col-8"
v-model="weekday"
readonly />
<q-datetime
class="col-2"
color="primary"
v-model="from"
align="right"
type="time"
format24h
readonly />
<q-datetime
class="col-2"
color="primary"
v-model="to"
align="right"
type="time"
format24h
readonly />
</div>
</q-field>
</template>
<script>
import { QField, QInput, QDatetime, date } from 'quasar-framework'
export default {
name: 'csc-call-forward-time',
props: [
'time'
],
data () {
return {
}
},
components: {
QField,
QInput,
QDatetime
},
computed: {
weekday() {
return this.time.weekday;
},
from() {
return date.buildDate({
hours: this.time.from.split(':')[0],
minutes: this.time.from.split(':')[1]
});
},
to() {
return date.buildDate({
hours: this.time.to.split(':')[0],
minutes: this.time.to.split(':')[1]
});
}
}
}
</script>
<style lang="stylus">
</style>

@ -0,0 +1,83 @@
<template>
<q-card class="times-card">
<q-card-title class="times-title">
Times
</q-card-title>
<q-card-main>
<div class="row no-wrap">
<p class="col-8 ">{{ $t('pages.callForward.times.weekday') }}</p>
<p class="col-2 hour-label">{{ $t('pages.callForward.times.from') }}</p>
<p class="col-2 hour-label">{{ $t('pages.callForward.times.to') }}</p</p>
</div>
<csc-call-forward-time v-if="times.length > 0" v-for="(time, index) in times" :time="time">
</csc-call-forward-time>
</q-card-main>
<q-card-actions>
<q-field v-if="!addFormEnabled">
<q-btn color="primary"
class="add-time"
icon="fa-plus" flat
@click="enableAddForm()">{{ $t('pages.callForward.times.addTimeButton') }}</q-btn>
</q-field>
</q-card-actions>
</q-card>
</template>
<script>
import numberFormat from '../../../filters/number-format'
import CscCallForwardTime from './CscCallForwardTime'
import { mapState } from 'vuex'
import { QCard, QCardTitle, QCardMain, QCardActions,
QField, QBtn } from 'quasar-framework'
export default {
name: 'csc-call-forward-times',
props: [
'times'
],
data () {
return {
addFormEnabled: false
}
},
components: {
CscCallForwardTime,
QCard,
QCardTitle,
QCardMain,
QCardActions,
QField,
QBtn
},
methods: {
enableAddForm() {
console.log('enableAddForm()');
}
}
}
</script>
<style lang="stylus">
@import '~variables'
.times-title
color $primary
padding-left 5px
padding-bottom 8px
.times-card
padding 0 15px
.q-field
margin 5px 0
.q-card-actions
padding-top 0
padding-left 10px
.q-card-main
padding-bottom 8px
.add-time
margin-left 14px
.row
p
font-size 0.9 rem
color $secondary
margin-bottom 0
.hour-label
text-align right
</style>

@ -149,7 +149,25 @@
"addErrorMessage": "An error occured while trying to add the destination. Please try again.",
"addInputError": "Input a valid number or subscriber name",
"timeout": "Timeout",
"destination": "Destination"
"destination": "Destination",
"times": {
"noTimeSet": "no time set",
"addTimeButton": "Add Time",
"companyHoursIncompatible": "The Company Hours timeset contains incompatible values.",
"companyHoursNotDefined": "The Company Hours timeset is not defined.",
"companyHoursDuplicate": "More than one Company Hours timeset exists.",
"companyHoursReverse": "The Company Hours timeset contain reverse order of values.",
"weekday": "Weekday",
"from": "From",
"to": "To",
"monday": "Monday",
"tuesday": "Tuesday",
"wednesday": "Wednesday",
"thursday": "Thursday",
"friday": "Friday",
"saturday": "Saturday",
"sunday": "Sunday"
}
},
"home": {
"title": "Home",

@ -1,6 +1,9 @@
'use strict';
import _ from 'lodash'; import { getSourcesets, getDestinationsets,
import _ from 'lodash';
import { getSourcesets,
getDestinationsets,
getTimesets,
getMappings,
loadEverybodyDestinations,
@ -10,7 +13,8 @@ import _ from 'lodash'; import { getSourcesets, getDestinationsets,
addDestinationToExistingGroup,
changePositionOfDestination,
moveDestinationUp,
moveDestinationDown } from '../api/call-forward';
moveDestinationDown,
loadTimesetTimes } from '../api/call-forward';
const DestinationState = {
button: 'button',
@ -26,17 +30,7 @@ export default {
sourcesets: null,
timesets: null,
destinationsets: null,
alwaysEverybodyDestinations: {
online: [],
busy: [],
offline: []
},
companyHoursEverybodyDestinations: {
online: [],
busy: [],
offline: []
},
afterHoursEverybodyDestinations: {
destinations: {
online: [],
busy: [],
offline: []
@ -58,7 +52,12 @@ export default {
destination: '',
priority: 1,
timeout: ''
}
},
timesetTimes: [],
timesetIsCompatible: false,
timesetExists: true,
timesetHasReverse: false,
timesetHasDuplicate: false
},
getters: {
hasFaxCapability(state, getters, rootState, rootGetters) {
@ -79,21 +78,11 @@ export default {
getDestinationsetId(state) {
return state.destinationsetId;
},
getCompanyHoursId(state) {
getTimesetId(state) {
let timeset;
for (let group in state.companyHoursEverybodyDestinations) {
for (let group in state.destinations) {
if (!timeset) {
timeset = _.find(state.companyHoursEverybodyDestinations[group], (o) => {
return o.timesetId > 0;
});
};
};
return timeset ? timeset.timesetId : null;
},
getAfterHoursId(state) {
let timeset;
for (let group in state.afterHoursEverybodyDestinations) { if (!timeset) {
timeset = _.find(state.afterHoursEverybodyDestinations[group], (o) => {
timeset = _.find(state.destinations[group], (o) => {
return o.timesetId > 0;
});
};
@ -111,17 +100,8 @@ export default {
loadTimesets(state, result) {
state.timesets = result;
},
loadDestinationsets(state, result) {
state.destinationsets = result;
},
loadAlwaysEverybodyDestinations(state, result) {
state.alwaysEverybodyDestinations = result;
},
loadCompanyHoursEverybodyDestinations(state, result) {
state.companyHoursEverybodyDestinations = result;
},
loadAfterHoursEverybodyDestinations(state, result) {
state.afterHoursEverybodyDestinations = result;
loadDestinations(state, result) {
state.destinations = result;
},
setActiveForm(state, value) {
state.activeForm = value;
@ -196,6 +176,21 @@ export default {
removeDestinationFailed(state, error) {
state.removeDestinationState = DestinationState.failed;
state.removeDestinationError = error;
},
loadTimesetTimes(state, result) {
state.timesetTimes = result;
},
setTimesetIsCompatible(state, value) {
state.timesetIsCompatible = value;
},
setTimesetExists(state, value) {
state.timesetExists = value;
},
setTimesetHasReverse(state, value) {
state.timesetHasReverse = value;
},
setTimesetHasDuplicate(state, value) {
state.timesetHasDuplicate = value;
}
},
actions: {
@ -244,9 +239,9 @@ export default {
loadEverybodyDestinations({
subscriberId: localStorage.getItem('subscriberId'),
timeset: null
}).then((result)=>{
context.commit('loadAlwaysEverybodyDestinations', result);
})
}).then((result)=>{
context.commit('loadDestinations', result);
});
});
},
loadCompanyHoursEverybodyDestinations(context) {
@ -254,9 +249,9 @@ export default {
loadEverybodyDestinations({
subscriberId: localStorage.getItem('subscriberId'),
timeset: 'Company Hours'
}).then((result)=>{
context.commit('loadCompanyHoursEverybodyDestinations', result);
})
}).then((result)=>{
context.commit('loadDestinations', result);
});
});
},
loadAfterHoursEverybodyDestinations(context) {
@ -264,9 +259,9 @@ export default {
loadEverybodyDestinations({
subscriberId: localStorage.getItem('subscriberId'),
timeset: 'After Hours'
}).then((result)=>{
context.commit('loadAfterHoursEverybodyDestinations', result);
})
}).then((result)=>{
context.commit('loadDestinations', result);
});
});
},
deleteDestinationFromDestinationset(context, options) {
@ -297,10 +292,9 @@ export default {
let updatedOptions;
let type = context.getters.getFormType;
let timeset = null;
if (options.timeset === 'Company Hours') {
timeset = context.getters.getCompanyHoursId;
} else if (options.timeset === 'After Hours') {
timeset = context.getters.getAfterHoursId;
if (options.timeset === 'Company Hours' ||
options.timeset === 'After Hours') {
timeset = context.getters.getTimesetId;
};
context.commit('addDestinationRequesting');
if (type !== 'number') {
@ -412,6 +406,18 @@ export default {
},
resetDestinationState(context) {
context.commit('resetDestinationState');
},
loadTimesetTimes(context, options) {
loadTimesetTimes({
timeset: options.timeset,
subscriberId: context.getters.getSubscriberId
}).then((result) => {
context.commit('loadTimesetTimes', result.times);
context.commit('setTimesetIsCompatible', result.timesetIsCompatible);
context.commit('setTimesetExists', result.timesetExists);
context.commit('setTimesetHasReverse', result.timesetHasReverse);
context.commit('setTimesetHasDuplicate', result.timesetHasDuplicate);
});
}
}
};

@ -6,7 +6,10 @@ import VueResource from 'vue-resource';
import { getMappings, getSourcesets, getTimesets,
getDestinationsets, getDestinationsetById,
deleteDestinationFromDestinationset,
addDestinationToDestinationset } from '../../src/api/call-forward';
addDestinationToDestinationset,
convertTimesetToWeekdays,
getHoursFromRange,
getDaysFromRange } from '../../src/api/call-forward';
import { assert } from 'chai';
Vue.use(VueResource);
@ -386,4 +389,270 @@ describe('CallForward', function(){
});
});
it('should convert timeset with days and hours, and no minutes, to weekdays', function(){
let options = {
timesetName: "Company Hours",
timesets: [{
id: 1,
name: "Company Hours",
subscriber_id: 309,
times: [{
hour: "6-8",
mday: null,
minute: null,
month: null,
wday: "1-2",
year: null
}]
}]
};
let convertedData = {
times: [
{
from: "6:00",
hour: "6-8",
minute: null,
to: "9:00",
wday: "1-2",
weekday: "Sunday"
},
{
from: "6:00",
hour: "6-8",
minute: null,
to: "9:00",
wday: "1-2",
weekday: "Monday"
}
],
timesetExists: true,
timesetHasDuplicate: false,
timesetHasReverse: false,
timesetIsCompatible: true
};
assert.deepEqual(convertTimesetToWeekdays(options), convertedData);
});
it('should convert timeset with days, hours and minutes to weekdays', function(){
let options = {
timesetName: "Company Hours",
timesets: [{
id: 1,
name: "Company Hours",
subscriber_id: 309,
times: [{
hour: "6-8",
mday: null,
minute: "0-30",
month: null,
wday: "1-2",
year: null
}]
}]
};
let convertedData = {
times: [
{
from: "6:0",
hour: "6-8",
minute: "0-30",
to: "6:31",
wday: "1-2",
weekday: "Sunday"
},
{
from: "7:0",
hour: "6-8",
minute: "0-30",
to: "7:31",
wday: "1-2",
weekday: "Sunday"
},
{
from: "8:0",
hour: "6-8",
minute: "0-30",
to: "8:31",
wday: "1-2",
weekday: "Sunday"
},
{
from: "6:0",
hour: "6-8",
minute: "0-30",
to: "6:31",
wday: "1-2",
weekday: "Monday"
},
{
from: "7:0",
hour: "6-8",
minute: "0-30",
to: "7:31",
wday: "1-2",
weekday: "Monday"
},
{
from: "8:0",
hour: "6-8",
minute: "0-30",
to: "8:31",
wday: "1-2",
weekday: "Monday"
}
],
timesetExists: true,
timesetHasDuplicate: false,
timesetHasReverse: false,
timesetIsCompatible: true
};
assert.deepEqual(convertTimesetToWeekdays(options), convertedData);
});
it('should correctly convert timeset with single day, hour and minute', function(){
let options = {
timesetName: "Company Hours",
timesets: [{
id: 1,
name: "Company Hours",
subscriber_id: 309,
times: [{
hour: "6",
mday: null,
minute: "0",
month: null,
wday: "1",
year: null
}]
}]
};
let convertedData = {
times: [
{
from: "6:0",
hour: "6",
minute: "0",
to: "6:1",
wday: "1",
weekday: "Sunday"
}
],
timesetExists: true,
timesetHasDuplicate: false,
timesetHasReverse: false,
timesetIsCompatible: true
};
assert.deepEqual(convertTimesetToWeekdays(options), convertedData);
});
it('should attempt to convert timeset with year, returning compatibility error', function(){
let options = {
timesetName: "Company Hours",
timesets: [{
id: 1,
name: "Company Hours",
subscriber_id: 309,
times: [{
hour: "6-8",
mday: null,
minute: null,
month: null,
wday: "1-2",
year: "2018"
}]
}]
};
let timesetIsCompatible = false;
assert.equal(convertTimesetToWeekdays(options).timesetIsCompatible, timesetIsCompatible);
});
it('should attempt to convert timeset with reverse range, returning compatibility error', function(){
let options = {
timesetName: "Company Hours",
timesets: [
{
id: 1,
name: "Company Hours",
subscriber_id: 309,
times: [{
hour: "8-6",
mday: null,
minute: null,
month: null,
wday: "1-2",
year: null
}]
}
]
};
let timesetHasReverse = true;
assert.equal(convertTimesetToWeekdays(options).timesetHasReverse, timesetHasReverse);
});
it('should attempt to convert duplicate timesets, returning compatibility error', function(){
let options = {
timesetName: "Company Hours",
timesets: [
{
id: 1,
name: "Company Hours",
subscriber_id: 309,
times: [{
hour: "8-6",
mday: null,
minute: null,
month: null,
wday: "1-2",
year: null
}]
},
{
id: 3,
name: "Company Hours",
subscriber_id: 309,
times: [{
hour: "8-14",
mday: null,
minute: null,
month: null,
wday: "1-4",
year: null
}]
}
]
};
let timesetHasDuplicate = true;
assert.equal(convertTimesetToWeekdays(options).timesetHasDuplicate, timesetHasDuplicate);
});
it('should attempt to convert empty timesets, returning error declaring that timeset is undefined', function(){
let options = {
timesetName: "Company Hours",
timesets: []
};
let timesetExists = false;
assert.equal(convertTimesetToWeekdays(options).timesetExists, timesetExists);
});
});

@ -6,12 +6,16 @@ import { assert } from 'chai';
describe('CallForward', function(){
it('should load always everybody destinations', function(){
it('should load always type destinations', function(){
let state = {
alwaysEverybodyDestinations: [
]
destinations: {
online: [],
busy: [],
offline: []
}
};
let data = {
online: [],
busy: [],
offline: [{
destinations: [{
@ -30,87 +34,23 @@ describe('CallForward', function(){
}],
id: 3,
name: "csc_destinationset_1"
}],
online: []
}]
};
CallForwardModule.mutations.loadAlwaysEverybodyDestinations(state, data);
assert.deepEqual(state.alwaysEverybodyDestinations, data);
CallForwardModule.mutations.loadDestinations(state, data);
assert.deepEqual(state.destinations, data);
});
it(' should reset destination form', function() {
it('should load timeset times', function(){
let state = {
conversations: [
]
};
let data = {
announcement_id: null,
destination: '',
priority: 1,
timeout: ''
};
CallForwardModule.mutations.resetFormState(state);
assert.deepEqual(state.form, data);
it('should load company hours everybody destinations', function(){
let state = {
companyHoursEverybodyDestinations: [
]
};
let data = {
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"
}],
online: []
};
CallForwardModule.mutations.loadCompanyHoursEverybodyDestinations(state, data);
assert.deepEqual(state.companyHoursEverybodyDestinations, data);
});
it('should load after hours everybody destinations', function(){
let state = {
afterHoursEverybodyDestinations: [
]
};
let data = {
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"
}],
online: []
};
CallForwardModule.mutations.loadAfterHoursEverybodyDestinations(state, data);
assert.deepEqual(state.afterHoursEverybodyDestinations, data);
timesetTimes: []
};
let data = [
{ weekday: "Monday", from: "8", to: "16" },
{ weekday: "Tuesday", from: "8", to: "16" },
{ weekday: "Wednesday", from: "8", to: "16" }
]
CallForwardModule.mutations.loadTimesetTimes(state, data);
assert.equal(state.timesetTimes, data);
});
});

Loading…
Cancel
Save