@webitel/ui-sdk 2.0.3-3 → 2.0.4-1
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 +25 -16
- package/dist/ui-sdk.common.js.map +1 -1
- package/dist/ui-sdk.css +1 -1
- package/dist/ui-sdk.umd.js +25 -16
- package/dist/ui-sdk.umd.js.map +1 -1
- package/dist/ui-sdk.umd.min.js +4 -4
- package/dist/ui-sdk.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/wt-context-menu/__tests__/WtContextMenu.spec.js +1 -35
- package/src/components/atoms/wt-context-menu/wt-context-menu.vue +27 -21
- package/src/components/molecules/wt-button-select/__tests__/WtButtonSelect.spec.js +2 -36
- package/src/components/molecules/wt-button-select/wt-button-select.vue +19 -23
- package/src/css/components/atoms/wt-context-menu/_variables.scss +1 -1
- package/src/modules/QueryFilters/components/__tests__/filter-from-to.spec.js +14 -14
- package/src/modules/QueryFilters/components/filter-from-to.vue +0 -1
package/package.json
CHANGED
|
@@ -2,42 +2,8 @@ import { shallowMount } from '@vue/test-utils';
|
|
|
2
2
|
import WtContextMenu from '../wt-context-menu.vue';
|
|
3
3
|
|
|
4
4
|
describe('WtContextMenu', () => {
|
|
5
|
-
const options = ['1', '2'];
|
|
6
|
-
|
|
7
5
|
it('renders a component', () => {
|
|
8
|
-
const wrapper = shallowMount(WtContextMenu);
|
|
6
|
+
const wrapper = shallowMount(WtContextMenu, { propsData: { options: [] } });
|
|
9
7
|
expect(wrapper.classes('wt-context-menu')).toBe(true);
|
|
10
8
|
});
|
|
11
|
-
|
|
12
|
-
it('component is visible by default', () => {
|
|
13
|
-
const wrapper = shallowMount(WtContextMenu);
|
|
14
|
-
expect(wrapper.classes()).not.toContain('wt-context-menu--hidden');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('component is invisible, if "visible" prop = false', () => {
|
|
18
|
-
const wrapper = shallowMount(WtContextMenu, {
|
|
19
|
-
propsData: { visible: false },
|
|
20
|
-
});
|
|
21
|
-
// Here we don't use "isVsisble()" because we hide our elements with "opacity: 0"
|
|
22
|
-
expect(wrapper.classes('wt-context-menu--hidden')).toBe(true);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('correctly display the options length', () => {
|
|
26
|
-
const wrapper = shallowMount(WtContextMenu, {
|
|
27
|
-
propsData: { options },
|
|
28
|
-
});
|
|
29
|
-
expect(wrapper.findAll('.wt-context-menu__option').length).toBe(options.length);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should raise click event, and emit { option, index } when clicked', () => {
|
|
33
|
-
const emittingArgs = { option: '1', index: 0 };
|
|
34
|
-
const wrapper = shallowMount(WtContextMenu, {
|
|
35
|
-
propsData: { options },
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
wrapper.find('.wt-context-menu__option').trigger('click');
|
|
39
|
-
expect(wrapper.emitted().click).toBeTruthy();
|
|
40
|
-
|
|
41
|
-
expect(wrapper.emitted('click')[0][0]).toEqual(emittingArgs);
|
|
42
|
-
});
|
|
43
9
|
});
|
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<v-dropdown
|
|
3
3
|
class="wt-context-menu"
|
|
4
|
-
:
|
|
4
|
+
:shown="visible"
|
|
5
|
+
:triggers="['click', 'touch']"
|
|
6
|
+
placement="bottom-end"
|
|
5
7
|
>
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class="wt-context-menu__option"
|
|
14
|
-
href="#"
|
|
15
|
-
@click.prevent="$emit('click', { option, index })"
|
|
8
|
+
<slot name="activator"></slot>
|
|
9
|
+
<template #popper>
|
|
10
|
+
<ul class="wt-context-menu__menu">
|
|
11
|
+
<li
|
|
12
|
+
class="wt-context-menu__option-wrapper"
|
|
13
|
+
v-for="(option, index) in options"
|
|
14
|
+
:key="index"
|
|
16
15
|
>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
<!-- <a> click.prevent prevents redirect to # -->
|
|
17
|
+
<a
|
|
18
|
+
class="wt-context-menu__option"
|
|
19
|
+
href="#"
|
|
20
|
+
@click.prevent="$emit('click', { option, index })"
|
|
21
|
+
>
|
|
22
|
+
{{ option.text || option }}
|
|
23
|
+
</a>
|
|
24
|
+
</li>
|
|
25
|
+
</ul>
|
|
26
|
+
</template>
|
|
27
|
+
</v-dropdown>
|
|
21
28
|
</template>
|
|
22
29
|
|
|
23
30
|
<script>
|
|
@@ -39,6 +46,10 @@ export default {
|
|
|
39
46
|
|
|
40
47
|
<style lang="scss" scoped>
|
|
41
48
|
.wt-context-menu {
|
|
49
|
+
line-height: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.wt-context-menu__menu {
|
|
42
53
|
@extend %typo-body-2;
|
|
43
54
|
min-width: var(--context-menu-min-width);
|
|
44
55
|
max-width: var(--context-menu-max-width);
|
|
@@ -47,11 +58,6 @@ export default {
|
|
|
47
58
|
box-shadow: var(--box-shadow);
|
|
48
59
|
transition: var(--transition);
|
|
49
60
|
z-index: 1;
|
|
50
|
-
|
|
51
|
-
&--hidden {
|
|
52
|
-
opacity: 0;
|
|
53
|
-
pointer-events: none;
|
|
54
|
-
}
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
.wt-context-menu__option-wrapper {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils';
|
|
1
|
+
import { shallowMount, mount } from '@vue/test-utils';
|
|
2
2
|
import WtSelectButton from '../wt-button-select.vue';
|
|
3
|
-
import WtContextMenu from '../../../atoms/wt-context-menu/wt-context-menu.vue';
|
|
4
3
|
|
|
5
4
|
describe('WtSelectButton', () => {
|
|
6
5
|
it('renders a component', () => {
|
|
@@ -18,41 +17,8 @@ describe('WtSelectButton', () => {
|
|
|
18
17
|
expect(wrapper.find('.wt-button-select__button').text()).toBe(content);
|
|
19
18
|
});
|
|
20
19
|
|
|
21
|
-
it('context-menu is invisible at start', () => {
|
|
22
|
-
const wrapper = shallowMount(WtSelectButton, {
|
|
23
|
-
stubs: { WtContextMenu },
|
|
24
|
-
});
|
|
25
|
-
expect(wrapper.findComponent(WtContextMenu).classes('wt-context-menu--hidden')).toBe(true);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('toggles isOpened, if select-btn is clicked', async () => {
|
|
29
|
-
const wrapper = shallowMount(WtSelectButton, {
|
|
30
|
-
stubs: { WtContextMenu },
|
|
31
|
-
});
|
|
32
|
-
wrapper.find('.wt-button-select__select-btn').vm.$emit('click');
|
|
33
|
-
await wrapper.vm.$nextTick();
|
|
34
|
-
expect(wrapper.findComponent(WtContextMenu).element.classList[1]).toBe(undefined);
|
|
35
|
-
|
|
36
|
-
wrapper.find('.wt-button-select__select-btn').vm.$emit('click');
|
|
37
|
-
await wrapper.vm.$nextTick();
|
|
38
|
-
expect(wrapper.findComponent(WtContextMenu).element.classList[1]).toBe('wt-context-menu--hidden');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('hides context-menu on its click event', async () => {
|
|
42
|
-
const isOpened = true;
|
|
43
|
-
const options = ['1', '2'];
|
|
44
|
-
const wrapper = shallowMount(WtSelectButton, {
|
|
45
|
-
stubs: { WtContextMenu },
|
|
46
|
-
data: () => ({ isOpened }),
|
|
47
|
-
propsData: { options },
|
|
48
|
-
});
|
|
49
|
-
wrapper.findComponent({ name: 'WtContextMenu' }).vm.$emit('click', { option: '1' });
|
|
50
|
-
await wrapper.vm.$nextTick();
|
|
51
|
-
expect(wrapper.findComponent({ name: 'WtContextMenu' }).classes()).toContain('wt-context-menu--hidden');
|
|
52
|
-
});
|
|
53
|
-
|
|
54
20
|
it('should rotate the arrow', () => {
|
|
55
|
-
const wrapper =
|
|
21
|
+
const wrapper = mount(WtSelectButton, {
|
|
56
22
|
data: () => ({
|
|
57
23
|
isOpened: true,
|
|
58
24
|
}),
|
|
@@ -12,26 +12,28 @@
|
|
|
12
12
|
<slot></slot>
|
|
13
13
|
</wt-button>
|
|
14
14
|
|
|
15
|
-
<wt-button
|
|
16
|
-
class="wt-button-select__select-btn"
|
|
17
|
-
v-bind="$attrs"
|
|
18
|
-
:disabled="disabled"
|
|
19
|
-
:loading="false"
|
|
20
|
-
@click="isOpened = !isOpened"
|
|
21
|
-
>
|
|
22
|
-
<wt-icon
|
|
23
|
-
class="wt-button-select__select-arrow"
|
|
24
|
-
:class="{'wt-button-select__select-arrow--active': isOpened}"
|
|
25
|
-
icon="arrow-down"
|
|
26
|
-
:disabled="disabled"
|
|
27
|
-
></wt-icon>
|
|
28
|
-
</wt-button>
|
|
29
|
-
|
|
30
15
|
<wt-context-menu
|
|
31
|
-
:visible="isOpened"
|
|
32
16
|
:options="options"
|
|
17
|
+
:visible="isOpened"
|
|
33
18
|
@click="selectOption"
|
|
34
|
-
|
|
19
|
+
>
|
|
20
|
+
<template v-slot:activator>
|
|
21
|
+
<wt-button
|
|
22
|
+
class="wt-button-select__select-btn"
|
|
23
|
+
v-bind="$attrs"
|
|
24
|
+
:disabled="disabled"
|
|
25
|
+
:loading="false"
|
|
26
|
+
@click="isOpened = !isOpened"
|
|
27
|
+
>
|
|
28
|
+
<wt-icon
|
|
29
|
+
class="wt-button-select__select-arrow"
|
|
30
|
+
:class="{'wt-button-select__select-arrow--active': isOpened}"
|
|
31
|
+
icon="arrow-down"
|
|
32
|
+
:disabled="disabled"
|
|
33
|
+
></wt-icon>
|
|
34
|
+
</wt-button>
|
|
35
|
+
</template>
|
|
36
|
+
</wt-context-menu>
|
|
35
37
|
</div>
|
|
36
38
|
</template>
|
|
37
39
|
|
|
@@ -69,12 +71,6 @@ export default {
|
|
|
69
71
|
display: inline-flex;
|
|
70
72
|
align-items: center;
|
|
71
73
|
gap: var(--button-select-buttons-gap);
|
|
72
|
-
|
|
73
|
-
.wt-context-menu {
|
|
74
|
-
position: absolute;
|
|
75
|
-
top: calc(100% + 1px);
|
|
76
|
-
left: 0;
|
|
77
|
-
}
|
|
78
74
|
}
|
|
79
75
|
|
|
80
76
|
.wt-button-select__button {
|
|
@@ -43,23 +43,23 @@ describe('FilterFromTo Filter', () => {
|
|
|
43
43
|
await router.replace({ query: { [`${filterQuery}From`]: value } });
|
|
44
44
|
const setValueMock = jest.fn();
|
|
45
45
|
jest.spyOn(baseFilterMixin.methods, 'setValue')
|
|
46
|
-
.
|
|
46
|
+
.mockImplementation(setValueMock);
|
|
47
47
|
shallowMount(FilterFromTo, mountOptions);
|
|
48
|
-
expect(setValueMock).
|
|
48
|
+
expect(setValueMock).toHaveBeenNthCalledWith(1, {
|
|
49
49
|
filter: filterQuery,
|
|
50
50
|
value: { to: undefined, from: value },
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
it('initial restoreValue() triggers setValue() method: To case', async () => {
|
|
54
|
+
const value = 10;
|
|
55
|
+
await router.replace({ query: { [`${filterQuery}To`]: value } });
|
|
56
|
+
const setValueMock = jest.fn();
|
|
57
|
+
jest.spyOn(baseFilterMixin.methods, 'setValue')
|
|
58
|
+
.mockImplementation(setValueMock);
|
|
59
|
+
shallowMount(FilterFromTo, mountOptions);
|
|
60
|
+
expect(setValueMock).toHaveBeenNthCalledWith(2, {
|
|
61
|
+
filter: filterQuery,
|
|
62
|
+
value: { to: value, from: undefined },
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
65
|
});
|
|
@@ -71,7 +71,6 @@ export default {
|
|
|
71
71
|
const queryValue = this.$route.query[`${this.filterQuery}To`];
|
|
72
72
|
// this.value.to = +queryValue || to;
|
|
73
73
|
const value = { from: this.value.from, to: +queryValue || to };
|
|
74
|
-
console.info(value);
|
|
75
74
|
this.setValue({ filter: this.filterQuery, value });
|
|
76
75
|
},
|
|
77
76
|
|