@webitel/ui-sdk 0.9.55 → 0.9.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui-sdk.common.js +67 -52
- package/dist/ui-sdk.common.js.map +1 -1
- package/dist/ui-sdk.css +1 -1
- package/dist/ui-sdk.umd.js +67 -52
- package/dist/ui-sdk.umd.js.map +1 -1
- package/dist/ui-sdk.umd.min.js +1 -1
- package/dist/ui-sdk.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/organisms/wt-player/wt-player.vue +20 -5
- package/src/css/components/molecules/wt-datepicker/_variables.scss +2 -2
- package/src/css/components/molecules/wt-datepicker/datepicker-calendar.scss +2 -1
- package/src/css/components/organisms/wt-player/_variables.scss +3 -1
- package/src/locale/ru/ru.js +1 -1
- package/src/locale/ua/ua.js +1 -1
- package/src/modules/QueryFilters/components/__tests__/filter-pagination.spec.js +71 -0
- package/src/modules/QueryFilters/components/__tests__/filter-search.spec.js +23 -28
- package/src/modules/QueryFilters/components/filter-pagination.vue +110 -0
- package/src/modules/QueryFilters/components/filter-search.vue +1 -1
- package/src/modules/QueryFilters/mixins/__tests__/apiFilterMixin.spec.js +15 -14
- package/src/modules/QueryFilters/mixins/__tests__/enumFilterMixin.spec.js +50 -35
- package/src/modules/QueryFilters/mixins/__tests__/sortFilterMixin.spec.js +16 -11
- package/src/modules/QueryFilters/mixins/baseFilterMixin/baseFilterMixin.js +8 -2
- package/src/modules/QueryFilters/mixins/enumFilterMixin.js +11 -9
- package/src/modules/QueryFilters/store/QueryControllerStoreModule.js +60 -0
- package/src/modules/QueryFilters/store/QueryFiltersStoreModule.js +5 -0
- package/src/modules/QueryFilters/store/__tests__/QueryControllerStoreModule.spec.js +42 -0
- package/src/modules/QueryFilters/api/__tests__/defaults.spec.js +0 -18
- package/src/modules/QueryFilters/api/defaults.js +0 -16
- package/src/modules/QueryFilters/mixins/__tests__/paginationFilterMixin.spec.js +0 -74
- package/src/modules/QueryFilters/mixins/__tests__/urlControllerMixin.spec.js +0 -48
- package/src/modules/QueryFilters/mixins/_urlControllerMixin/_urlControllerMixin.js +0 -39
- package/src/modules/QueryFilters/mixins/paginationFilterMixin.js +0 -66
- package/src/modules/QueryFilters/store/queryFilters.js +0 -6
package/package.json
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
<aside class="wt-player">
|
|
3
3
|
<audio
|
|
4
4
|
id="wt-player__player"
|
|
5
|
+
ref="audio"
|
|
5
6
|
:src="src"
|
|
6
7
|
:autoplay="autoplay"
|
|
7
8
|
controls
|
|
8
9
|
v-on="listeners"
|
|
9
10
|
></audio>
|
|
11
|
+
|
|
12
|
+
<!-- The "wt-icon-btn" component is append in to "audio" element by "setCloseIcon" method-->
|
|
10
13
|
<wt-icon-btn
|
|
11
14
|
class="wt-player__close-icon"
|
|
15
|
+
ref="close-icon"
|
|
12
16
|
icon="close"
|
|
13
17
|
@click="$emit('close')"
|
|
14
18
|
></wt-icon-btn>
|
|
@@ -38,6 +42,7 @@ export default {
|
|
|
38
42
|
data: () => ({
|
|
39
43
|
player: null,
|
|
40
44
|
}),
|
|
45
|
+
|
|
41
46
|
watch: {
|
|
42
47
|
src() {
|
|
43
48
|
this.setupDownload();
|
|
@@ -46,9 +51,11 @@ export default {
|
|
|
46
51
|
this.setupDownload();
|
|
47
52
|
},
|
|
48
53
|
},
|
|
54
|
+
|
|
49
55
|
mounted() {
|
|
50
56
|
this.setupPlayer();
|
|
51
57
|
},
|
|
58
|
+
|
|
52
59
|
computed: {
|
|
53
60
|
listeners() {
|
|
54
61
|
return {
|
|
@@ -56,6 +63,7 @@ export default {
|
|
|
56
63
|
};
|
|
57
64
|
},
|
|
58
65
|
},
|
|
66
|
+
|
|
59
67
|
methods: {
|
|
60
68
|
setupPlayer() {
|
|
61
69
|
const baseURL = this.$baseURL || process.env.BASE_URL;
|
|
@@ -73,6 +81,7 @@ export default {
|
|
|
73
81
|
active: this.loop,
|
|
74
82
|
},
|
|
75
83
|
});
|
|
84
|
+
this.appendCloseIcon();
|
|
76
85
|
},
|
|
77
86
|
setupDownload() {
|
|
78
87
|
if (!this.download) this.setupPlayer();
|
|
@@ -82,6 +91,13 @@ export default {
|
|
|
82
91
|
this.player.download = this.download(this.src);
|
|
83
92
|
}
|
|
84
93
|
},
|
|
94
|
+
appendCloseIcon() {
|
|
95
|
+
const plyrControls = this.$refs.audio.plyr?.elements?.controls;
|
|
96
|
+
const closeIcon = this.$refs['close-icon'].$el;
|
|
97
|
+
if (plyrControls) {
|
|
98
|
+
plyrControls.append(closeIcon);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
85
101
|
},
|
|
86
102
|
};
|
|
87
103
|
</script>
|
|
@@ -93,16 +109,15 @@ export default {
|
|
|
93
109
|
@extend %typo-body-md;
|
|
94
110
|
position: sticky;
|
|
95
111
|
bottom: 60px;
|
|
96
|
-
display: flex;
|
|
97
|
-
box-shadow: var(--box-shadow);
|
|
98
|
-
border-radius: var(--border-radius);
|
|
99
112
|
|
|
100
113
|
.plyr {
|
|
101
|
-
|
|
114
|
+
border-radius: var(--border-radius);
|
|
115
|
+
box-shadow: var(--box-shadow);
|
|
102
116
|
}
|
|
103
117
|
|
|
104
118
|
&__close-icon {
|
|
105
|
-
|
|
119
|
+
transform: translate(var(--player-close-icon-transform-translate-x),
|
|
120
|
+
var(--player-close-icon-transform-translate-y));
|
|
106
121
|
}
|
|
107
122
|
|
|
108
123
|
.plyr__control:hover, {
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
--datepicker-width: calc(
|
|
12
12
|
7 * var(--datepicker-cell-size)
|
|
13
13
|
+ 2 * var(--datepicker-calendar-padding)
|
|
14
|
-
+
|
|
14
|
+
+ 8px
|
|
15
15
|
+ 7 * 2 * var(--datepicker-cell-margin)); // 7 cells * 2 sides
|
|
16
16
|
|
|
17
17
|
--datepicker-selected-cell-text-color: var(--main-primary-color);
|
|
18
18
|
--datepicker-selected-cell-bg-color: var(--main-accent-color);
|
|
19
19
|
--datepicker-cell--hover-color: #F9F9F9;
|
|
20
|
-
}
|
|
20
|
+
}
|
|
@@ -53,7 +53,9 @@
|
|
|
53
53
|
@extend %typo-body-lg;
|
|
54
54
|
width: var(--datepicker-cell-size);
|
|
55
55
|
height: var(--datepicker-cell-size);
|
|
56
|
+
margin: 1px;
|
|
56
57
|
padding: 0;
|
|
58
|
+
border: none;
|
|
57
59
|
line-height: var(--datepicker-cell-size);
|
|
58
60
|
transition: var(--transition);
|
|
59
61
|
|
|
@@ -66,7 +68,6 @@
|
|
|
66
68
|
|
|
67
69
|
&.day {
|
|
68
70
|
border-radius: var(--border-radius);
|
|
69
|
-
margin: 1px;
|
|
70
71
|
|
|
71
72
|
&.selected {
|
|
72
73
|
@extend %typo-strong-lg;
|
|
@@ -2,5 +2,7 @@
|
|
|
2
2
|
--plyr-color-main: var(--main-accent-color);
|
|
3
3
|
--plyr-audio-control-color: var(--icon-primary-color);
|
|
4
4
|
// --plyr-control-toggle-checked-background: var(--main-primary-color);
|
|
5
|
-
--player-close-icon-
|
|
5
|
+
--player-close-icon-transform-translate-x: var(--spacing--sm);
|
|
6
|
+
// "-1 * var" for use the negative value of a variable
|
|
7
|
+
--player-close-icon-transform-translate-y: calc(-1 * var(--spacing--md));
|
|
6
8
|
}
|
package/src/locale/ru/ru.js
CHANGED
|
@@ -74,7 +74,7 @@ export default {
|
|
|
74
74
|
name: 'Supervisor Workspace',
|
|
75
75
|
sections: {
|
|
76
76
|
[SupervisorSections.QUEUES]: 'Очереди',
|
|
77
|
-
[SupervisorSections.AGENTS]: '
|
|
77
|
+
[SupervisorSections.AGENTS]: 'Операторы',
|
|
78
78
|
[SupervisorSections.ACTIVE_CALLS]: 'Активные звонки',
|
|
79
79
|
},
|
|
80
80
|
},
|
package/src/locale/ua/ua.js
CHANGED
|
@@ -74,7 +74,7 @@ export default {
|
|
|
74
74
|
name: 'Supervisor Workspace',
|
|
75
75
|
sections: {
|
|
76
76
|
[SupervisorSections.QUEUES]: 'Черги',
|
|
77
|
-
[SupervisorSections.AGENTS]: '
|
|
77
|
+
[SupervisorSections.AGENTS]: 'Оператори',
|
|
78
78
|
[SupervisorSections.ACTIVE_CALLS]: 'Активні дзвінки',
|
|
79
79
|
},
|
|
80
80
|
},
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import BaseFilterSchema from '../../classes/BaseFilterSchema';
|
|
3
|
+
import baseFilterMixin from '../../mixins/baseFilterMixin/baseFilterMixin';
|
|
4
|
+
import FilterPagination from '../filter-pagination.vue';
|
|
5
|
+
|
|
6
|
+
const pageDefaultValue = 1;
|
|
7
|
+
const page = 2;
|
|
8
|
+
const size = 20;
|
|
9
|
+
|
|
10
|
+
const pageFilterSchema = new BaseFilterSchema({ value: page, defaultValue: pageDefaultValue });
|
|
11
|
+
const sizeFilterSchema = new BaseFilterSchema({ value: size });
|
|
12
|
+
|
|
13
|
+
describe('Pagination filter mixin', () => {
|
|
14
|
+
const setValue = jest.fn();
|
|
15
|
+
const setValueToQuery = jest.fn();
|
|
16
|
+
const getValueFromQuery = jest.fn(({ filterQuery }) => (filterQuery === 'page' ? page : size));
|
|
17
|
+
|
|
18
|
+
let wrapper;
|
|
19
|
+
|
|
20
|
+
jest.spyOn(baseFilterMixin.methods, 'setValue').mockImplementation(setValue);
|
|
21
|
+
jest.spyOn(baseFilterMixin.methods, 'setValueToQuery').mockImplementation(setValueToQuery);
|
|
22
|
+
jest.spyOn(baseFilterMixin.methods, 'getValueFromQuery').mockImplementation(getValueFromQuery);
|
|
23
|
+
|
|
24
|
+
const computed = {
|
|
25
|
+
pageFilterSchema() { return pageFilterSchema; },
|
|
26
|
+
sizeFilterSchema() { return sizeFilterSchema; },
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
setValue.mockClear();
|
|
31
|
+
setValueToQuery.mockClear();
|
|
32
|
+
getValueFromQuery.mockClear();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('Correctly sets value from $route query', async () => {
|
|
36
|
+
wrapper = shallowMount(FilterPagination, {
|
|
37
|
+
computed,
|
|
38
|
+
});
|
|
39
|
+
expect(setValue).toHaveBeenNthCalledWith(1, { filter: 'page', value: page });
|
|
40
|
+
expect(setValue).toHaveBeenNthCalledWith(2, { filter: 'size', value: size });
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('At "prev" page, changes query and emits event', async () => {
|
|
44
|
+
wrapper = shallowMount(FilterPagination, { computed });
|
|
45
|
+
wrapper.vm.prev();
|
|
46
|
+
expect(wrapper.emitted().input).toBeTruthy();
|
|
47
|
+
expect(setValue).toHaveBeenLastCalledWith({ filter: 'page', value: page - 1 });
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('At "next" page, changes query and emits event', async () => {
|
|
51
|
+
wrapper = shallowMount(FilterPagination, { computed });
|
|
52
|
+
wrapper.vm.next();
|
|
53
|
+
expect(wrapper.emitted().input).toBeTruthy();
|
|
54
|
+
expect(setValue).toHaveBeenLastCalledWith({ filter: 'page', value: page + 1 });
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('At "resetPage" method, changes query and emits event', async () => {
|
|
58
|
+
wrapper = shallowMount(FilterPagination, { computed });
|
|
59
|
+
wrapper.vm.resetPage();
|
|
60
|
+
expect(wrapper.emitted().input).toBeTruthy();
|
|
61
|
+
expect(setValue).toHaveBeenLastCalledWith({ filter: 'page', value: pageDefaultValue });
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('At "sizeChange", changes query and emits event', async () => {
|
|
65
|
+
const newSize = 40;
|
|
66
|
+
wrapper = shallowMount(FilterPagination, { computed });
|
|
67
|
+
wrapper.vm.sizeChange(newSize);
|
|
68
|
+
expect(wrapper.emitted().input).toBeTruthy();
|
|
69
|
+
expect(setValue).toHaveBeenLastCalledWith({ filter: 'size', value: newSize });
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -1,49 +1,44 @@
|
|
|
1
|
-
import { shallowMount
|
|
2
|
-
import Vuex from 'vuex';
|
|
3
|
-
import VueRouter from 'vue-router';
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
4
2
|
import SearchFilter from '../filter-search.vue';
|
|
5
3
|
import BaseFilterSchema from '../../classes/BaseFilterSchema';
|
|
6
4
|
import baseFilterMixin from '../../mixins/baseFilterMixin/baseFilterMixin';
|
|
7
5
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
6
|
+
const namespace = 'jest';
|
|
7
|
+
const filterQuery = 'jest';
|
|
8
|
+
const filterSchema = new BaseFilterSchema();
|
|
9
|
+
const searchValue = 'jest-search';
|
|
12
10
|
|
|
13
11
|
describe('Search Filter', () => {
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const store = new Vuex.Store({
|
|
18
|
-
modules: {
|
|
19
|
-
[namespace]: {
|
|
20
|
-
namespaced: true,
|
|
21
|
-
state: {
|
|
22
|
-
[filterQuery]: filterSchema,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
});
|
|
12
|
+
const setValue = jest.fn();
|
|
13
|
+
const setValueToQuery = jest.fn();
|
|
14
|
+
const getValueFromQuery = jest.fn(() => searchValue);
|
|
27
15
|
|
|
28
16
|
const mountOptions = {
|
|
29
|
-
localVue,
|
|
30
|
-
store,
|
|
31
|
-
router,
|
|
32
17
|
propsData: {
|
|
33
18
|
namespace,
|
|
34
19
|
filterQuery,
|
|
35
20
|
},
|
|
21
|
+
computed: {
|
|
22
|
+
filterSchema() { return filterSchema; },
|
|
23
|
+
},
|
|
36
24
|
};
|
|
25
|
+
|
|
26
|
+
jest.spyOn(baseFilterMixin.methods, 'setValue').mockImplementation(setValue);
|
|
27
|
+
jest.spyOn(baseFilterMixin.methods, 'setValueToQuery').mockImplementation(setValueToQuery);
|
|
28
|
+
jest.spyOn(baseFilterMixin.methods, 'getValueFromQuery').mockImplementation(getValueFromQuery);
|
|
29
|
+
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
setValue.mockClear();
|
|
32
|
+
setValueToQuery.mockClear();
|
|
33
|
+
getValueFromQuery.mockClear();
|
|
34
|
+
});
|
|
35
|
+
|
|
37
36
|
it('renders a component', () => {
|
|
38
37
|
const wrapper = shallowMount(SearchFilter, mountOptions);
|
|
39
38
|
expect(wrapper.exists()).toBe(true);
|
|
40
39
|
});
|
|
41
40
|
it('initial restoreValue() triggers setValue() method', async () => {
|
|
42
|
-
const search = 'jest';
|
|
43
|
-
await router.replace({ query: { [filterQuery]: search } });
|
|
44
|
-
const setValueMock = jest.fn();
|
|
45
|
-
jest.spyOn(baseFilterMixin.methods, 'setValue').mockImplementationOnce(setValueMock);
|
|
46
41
|
shallowMount(SearchFilter, mountOptions);
|
|
47
|
-
expect(
|
|
42
|
+
expect(setValue).toHaveBeenCalledWith({ filter: filterQuery, value: searchValue });
|
|
48
43
|
});
|
|
49
44
|
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<wt-pagination
|
|
3
|
+
:next="isNext"
|
|
4
|
+
:prev="isPrev"
|
|
5
|
+
:value="sizeFilterSchema.value"
|
|
6
|
+
debounce
|
|
7
|
+
@change="sizeChange"
|
|
8
|
+
@next="next"
|
|
9
|
+
@prev="prev"
|
|
10
|
+
></wt-pagination>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
import getNamespacedState from '../../../store/helpers/getNamespacedState';
|
|
15
|
+
import baseFilterMixin from '../mixins/baseFilterMixin/baseFilterMixin';
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
name: 'filter-pagination',
|
|
19
|
+
mixins: [baseFilterMixin],
|
|
20
|
+
props: {
|
|
21
|
+
isNext: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: true,
|
|
24
|
+
},
|
|
25
|
+
pageFilterQuery: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: 'page',
|
|
28
|
+
},
|
|
29
|
+
sizeFilterQuery: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: 'size',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
computed: {
|
|
36
|
+
pageFilterSchema() {
|
|
37
|
+
if (!this.$store) throw new Error('Vuex is required for page filter binding');
|
|
38
|
+
return getNamespacedState(this.$store.state, this.namespace)[this.pageFilterQuery];
|
|
39
|
+
},
|
|
40
|
+
sizeFilterSchema() {
|
|
41
|
+
if (!this.$store) throw new Error('Vuex is required for size filter binding');
|
|
42
|
+
return getNamespacedState(this.$store.state, this.namespace)[this.sizeFilterQuery];
|
|
43
|
+
},
|
|
44
|
+
isPrev() {
|
|
45
|
+
return this.page > 1;
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
methods: {
|
|
50
|
+
restore() {
|
|
51
|
+
this.restorePage();
|
|
52
|
+
this.restoreSize();
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
restorePage() {
|
|
56
|
+
const value = +this.getValueFromQuery({ filterQuery: this.pageFilterQuery });
|
|
57
|
+
if (value) this.setValue({ filter: this.pageFilterQuery, value });
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
restoreSize() {
|
|
61
|
+
const value = +this.getValueFromQuery({ filterQuery: this.sizeFilterQuery });
|
|
62
|
+
if (value) this.setValue({ filter: this.sizeFilterQuery, value });
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
next() {
|
|
66
|
+
this.$emit('input');
|
|
67
|
+
const value = this.pageFilterSchema.value + 1;
|
|
68
|
+
this.setValue({ filter: this.pageFilterQuery, value });
|
|
69
|
+
this.setValueToQuery({
|
|
70
|
+
filterQuery: this.pageFilterQuery,
|
|
71
|
+
value,
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
prev() {
|
|
76
|
+
this.$emit('input');
|
|
77
|
+
const value = this.pageFilterSchema.value - 1;
|
|
78
|
+
this.setValue({ filter: this.pageFilterQuery, value });
|
|
79
|
+
this.setValueToQuery({
|
|
80
|
+
filterQuery: this.pageFilterQuery,
|
|
81
|
+
value,
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
resetPage() {
|
|
86
|
+
this.$emit('input');
|
|
87
|
+
const value = this.pageFilterSchema.defaultValue;
|
|
88
|
+
this.setValue({ filter: this.pageFilterQuery, value });
|
|
89
|
+
this.setValueToQuery({
|
|
90
|
+
filterQuery: this.pageFilterQuery,
|
|
91
|
+
value,
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
sizeChange(value) {
|
|
96
|
+
this.$emit('input');
|
|
97
|
+
this.setValue({ filter: this.sizeFilterQuery, value });
|
|
98
|
+
this.setValueToQuery({
|
|
99
|
+
filterQuery: this.sizeFilterQuery,
|
|
100
|
+
value,
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<style scoped>
|
|
109
|
+
|
|
110
|
+
</style>
|
|
@@ -1,47 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import VueRouter from 'vue-router';
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
3
2
|
import ApiFilterSchema from '../../classes/ApiFilterSchema';
|
|
4
3
|
import apiFilterMixin from '../apiFilterMixin';
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
localVue.use(VueRouter);
|
|
8
|
-
const router = new VueRouter();
|
|
5
|
+
const filterQuery = 'team';
|
|
9
6
|
const team = ['1', '2'];
|
|
10
7
|
const filterSchema = new ApiFilterSchema();
|
|
11
8
|
|
|
12
9
|
describe('API filter mixin', () => {
|
|
13
10
|
const setValue = jest.fn();
|
|
11
|
+
const setValueToQuery = jest.fn();
|
|
12
|
+
const getValueFromQuery = jest.fn(() => team);
|
|
13
|
+
|
|
14
14
|
const Component = {
|
|
15
15
|
render() {},
|
|
16
16
|
mixins: [apiFilterMixin],
|
|
17
17
|
data: () => ({
|
|
18
|
-
filterQuery
|
|
18
|
+
filterQuery,
|
|
19
19
|
}),
|
|
20
20
|
computed: {
|
|
21
21
|
filterSchema() { return filterSchema; },
|
|
22
22
|
},
|
|
23
|
-
methods: {
|
|
23
|
+
methods: {
|
|
24
|
+
setValue,
|
|
25
|
+
setValueToQuery,
|
|
26
|
+
getValueFromQuery,
|
|
27
|
+
},
|
|
24
28
|
};
|
|
25
29
|
|
|
26
30
|
beforeEach(() => {
|
|
27
31
|
setValue.mockClear();
|
|
28
|
-
|
|
32
|
+
setValueToQuery.mockClear();
|
|
33
|
+
getValueFromQuery.mockClear();
|
|
29
34
|
});
|
|
30
35
|
|
|
31
36
|
it('Correctly sets value from $route query', async () => {
|
|
32
|
-
await router.replace({ query: { team } });
|
|
33
37
|
const wrapper = shallowMount(Component, {
|
|
34
|
-
localVue,
|
|
35
|
-
router,
|
|
36
38
|
});
|
|
37
39
|
expect(setValue).toHaveBeenCalledWith({ filter: 'team', value: [{ id: team[0] }, { id: team[1] }] });
|
|
38
40
|
});
|
|
39
41
|
|
|
40
42
|
it('Sets empty array value if $route query is empty', async () => {
|
|
43
|
+
getValueFromQuery.mockImplementationOnce(() => []);
|
|
41
44
|
const wrapper = shallowMount(Component, {
|
|
42
|
-
|
|
43
|
-
router,
|
|
44
|
-
data: () => ({ filterQuery: 'queue' }),
|
|
45
|
+
data: () => ({ filterQuery }),
|
|
45
46
|
});
|
|
46
47
|
expect(setValue).not.toHaveBeenCalled();
|
|
47
48
|
});
|
|
@@ -1,69 +1,84 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import EnumFilterSchema from '../../classes/EnumFilterSchema';
|
|
3
3
|
import enumFilterMixin from '../enumFilterMixin';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const filterQuery = 'direction';
|
|
6
|
+
const options = [
|
|
7
|
+
{
|
|
6
8
|
name: 'Inbound',
|
|
7
9
|
value: 'inbound',
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
+
}, {
|
|
10
11
|
name: 'Outbound',
|
|
11
12
|
value: 'outbound',
|
|
12
|
-
}
|
|
13
|
+
},
|
|
14
|
+
];
|
|
13
15
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const
|
|
16
|
+
const queryValue = options[0].value;
|
|
17
|
+
|
|
18
|
+
const filterSchema = new EnumFilterSchema({
|
|
19
|
+
options,
|
|
20
|
+
storedProp: 'value',
|
|
21
|
+
});
|
|
17
22
|
|
|
18
23
|
describe('Enum filter mixin', () => {
|
|
19
24
|
const setValue = jest.fn();
|
|
25
|
+
const setValueToQuery = jest.fn();
|
|
26
|
+
const getValueFromQuery = jest.fn(() => queryValue);
|
|
27
|
+
|
|
20
28
|
const Component = {
|
|
21
29
|
render() {
|
|
22
30
|
},
|
|
23
31
|
mixins: [enumFilterMixin],
|
|
24
32
|
data: () => ({
|
|
25
|
-
filterQuery
|
|
26
|
-
storedProp: 'value',
|
|
27
|
-
options,
|
|
33
|
+
filterQuery,
|
|
28
34
|
}),
|
|
29
|
-
|
|
35
|
+
computed: {
|
|
36
|
+
filterSchema() { return filterSchema; },
|
|
37
|
+
},
|
|
38
|
+
methods: {
|
|
39
|
+
setValue,
|
|
40
|
+
setValueToQuery,
|
|
41
|
+
getValueFromQuery,
|
|
42
|
+
},
|
|
30
43
|
};
|
|
31
44
|
|
|
32
45
|
beforeEach(() => {
|
|
33
46
|
setValue.mockClear();
|
|
34
|
-
|
|
47
|
+
setValueToQuery.mockClear();
|
|
48
|
+
getValueFromQuery.mockClear();
|
|
35
49
|
});
|
|
36
50
|
|
|
37
51
|
it('Correctly sets value from $route query', async () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
router,
|
|
42
|
-
});
|
|
43
|
-
await wrapper.vm.$nextTick();
|
|
44
|
-
expect(setValue).toHaveBeenCalledWith({ filter: 'direction', value: options[0] });
|
|
52
|
+
const wrapper = shallowMount(Component, {});
|
|
53
|
+
expect(setValue)
|
|
54
|
+
.toHaveBeenCalledWith({ filter: filterQuery, value: options[0] });
|
|
45
55
|
});
|
|
46
56
|
|
|
47
57
|
it('Sets empty array value if $route query is empty', async () => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
58
|
+
getValueFromQuery.mockImplementationOnce(() => []);
|
|
59
|
+
|
|
60
|
+
shallowMount(Component, {});
|
|
52
61
|
expect(setValue).not.toHaveBeenCalled();
|
|
53
62
|
});
|
|
54
63
|
|
|
55
64
|
it('Attaches locales to options, if they have "locale" key', async () => {
|
|
56
|
-
const options = [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
const options = [
|
|
66
|
+
{
|
|
67
|
+
locale: 'jest.locale',
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
const expectedOptions = [
|
|
71
|
+
{
|
|
72
|
+
locale: options[0].locale,
|
|
73
|
+
name: options[0].locale,
|
|
74
|
+
},
|
|
75
|
+
];
|
|
63
76
|
const wrapper = shallowMount(Component, {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
computed: {
|
|
78
|
+
options() {
|
|
79
|
+
return options;
|
|
80
|
+
},
|
|
81
|
+
},
|
|
67
82
|
});
|
|
68
83
|
expect(wrapper.vm.localizedOptions).toEqual(expectedOptions);
|
|
69
84
|
});
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { shallowMount
|
|
2
|
-
import VueRouter from 'vue-router';
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
3
2
|
import sortFilterMixin from '../sortFilterMixin';
|
|
4
3
|
|
|
5
|
-
const localVue = createLocalVue();
|
|
6
|
-
localVue.use(VueRouter);
|
|
7
|
-
const router = new VueRouter();
|
|
8
|
-
|
|
9
4
|
const headers = [{
|
|
10
5
|
value: 'queue',
|
|
11
6
|
show: true,
|
|
@@ -30,27 +25,37 @@ const sortedHeaders = [{
|
|
|
30
25
|
field: 'online',
|
|
31
26
|
}];
|
|
32
27
|
|
|
28
|
+
const queryValue = '+queue';
|
|
29
|
+
|
|
33
30
|
describe('Sort filter mixin', () => {
|
|
34
31
|
const setHeaders = jest.fn();
|
|
32
|
+
const setValueToQuery = jest.fn();
|
|
33
|
+
const getValueFromQuery = jest.fn(() => queryValue);
|
|
34
|
+
|
|
35
35
|
const Component = {
|
|
36
36
|
render() {},
|
|
37
37
|
mixins: [sortFilterMixin],
|
|
38
38
|
data: () => ({ headers }),
|
|
39
|
-
methods: {
|
|
39
|
+
methods: {
|
|
40
|
+
setHeaders,
|
|
41
|
+
setValueToQuery,
|
|
42
|
+
getValueFromQuery,
|
|
43
|
+
},
|
|
40
44
|
};
|
|
41
45
|
|
|
42
46
|
beforeEach(() => {
|
|
43
|
-
|
|
47
|
+
setHeaders.mockClear();
|
|
48
|
+
setValueToQuery.mockClear();
|
|
49
|
+
getValueFromQuery.mockClear();
|
|
44
50
|
});
|
|
45
51
|
|
|
46
52
|
it('Correctly sets value from $route query', async () => {
|
|
47
|
-
|
|
48
|
-
const wrapper = shallowMount(Component, { localVue, router });
|
|
53
|
+
const wrapper = shallowMount(Component);
|
|
49
54
|
expect(setHeaders).toHaveBeenCalledWith(sortedHeaders);
|
|
50
55
|
});
|
|
51
56
|
|
|
52
57
|
it('After "sort" trigger, header column sort value changes properly', () => {
|
|
53
|
-
const wrapper = shallowMount(Component
|
|
58
|
+
const wrapper = shallowMount(Component);
|
|
54
59
|
const queue = wrapper.vm.headers.find((header) => header.value === 'queue');
|
|
55
60
|
wrapper.vm.sort(queue);
|
|
56
61
|
expect(setHeaders).toHaveBeenCalledWith(sortedHeaders);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import _urlControllerMixin from '../_urlControllerMixin/_urlControllerMixin';
|
|
2
1
|
import getNamespacedState from '../../../../store/helpers/getNamespacedState';
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
|
-
mixins: [_urlControllerMixin],
|
|
6
4
|
props: {
|
|
7
5
|
namespace: {
|
|
8
6
|
type: String,
|
|
@@ -30,5 +28,13 @@ export default {
|
|
|
30
28
|
if (!this.$store) throw new Error('Vuex is required for default setValue() baseFilterMixin method');
|
|
31
29
|
return this.$store.dispatch(`${this.namespace}/SET_FILTER`, payload);
|
|
32
30
|
},
|
|
31
|
+
setValueToQuery(payload) {
|
|
32
|
+
if (!this.$store) throw new Error('Vuex is required for default setValueToQuery() baseFilterMixin method');
|
|
33
|
+
return this.$store.dispatch(`${this.namespace}/SET_VALUE_TO_QUERY`, payload);
|
|
34
|
+
},
|
|
35
|
+
getValueFromQuery(payload) {
|
|
36
|
+
if (!this.$store) throw new Error('Vuex is required for default getValueFromQuery() baseFilterMixin method');
|
|
37
|
+
return this.$store.dispatch(`${this.namespace}/GET_VALUE_FROM_QUERY`, payload);
|
|
38
|
+
},
|
|
33
39
|
},
|
|
34
40
|
};
|