@webitel/ui-sdk 26.8.75 → 26.8.76
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/{clients-BmeOR90W.js → clients-oFIeYM2J.js} +66 -79
- package/dist/{components-C-ri6OSQ.js → components-BG2hOYak.js} +11 -11
- package/dist/{enums-BvonmHq2.js → enums-B_9ZBu01.js} +2 -2
- package/dist/ui-sdk.css +1 -1
- package/dist/ui-sdk.js +3 -3
- package/dist/ui-sdk.umd.cjs +574 -574
- package/dist/{useValidation-0JwQGpLM.js → useValidation-CEed9cxY.js} +1 -1
- package/dist/{utils-CzBdLnFt.js → utils-BZHq8qMH.js} +1 -1
- package/dist/wt-action-bar-D74sgDCk.js +94 -0
- package/dist/{wt-button-D-nFhi1f.js → wt-button-CVjzcwNg.js} +2 -2
- package/dist/{wt-chat-emoji-CLhgb02d.js → wt-chat-emoji-CP1IO0Z_.js} +4 -4
- package/dist/{wt-datepicker-DCa23hYx.js → wt-datepicker-BgjjbOMX.js} +2 -2
- package/dist/{wt-display-chip-items-B7QLz9QM.js → wt-display-chip-items-BcuWCOui.js} +2 -2
- package/dist/{wt-dual-panel-D-LChluY.js → wt-dual-panel-Cs_Yzfxt.js} +1 -1
- package/dist/{wt-expansion-card-CToBA1fy.js → wt-expansion-card-BT586Mul.js} +1 -1
- package/dist/{wt-expansion-panel-af2t3VrM.js → wt-expansion-panel-kZmHSvPU.js} +1 -1
- package/dist/{wt-icon-WyFAGc4t.js → wt-icon-CAn_j3EL.js} +1 -1
- package/dist/{wt-icon-action-DYBTs3Mf.js → wt-icon-action-DJzm0kEk.js} +1 -1
- package/dist/{wt-icon-btn-BfhuUt8-.js → wt-icon-btn-BL0OfOZM.js} +1 -1
- package/dist/{wt-notifications-bar-CvKwuTEg.js → wt-notifications-bar-DZUTZhZy.js} +2 -2
- package/dist/{wt-player-B2etfN5v.js → wt-player-DbQuCEZb.js} +3 -3
- package/dist/{wt-screen-recordings-action-CepB2pqh.js → wt-screen-recordings-action-CVHZAWjl.js} +1 -1
- package/dist/{wt-search-bar-B4YkhgIB.js → wt-search-bar-DosqJLXT.js} +1 -1
- package/dist/{wt-send-message-popup-BhZ7K_Vs.js → wt-send-message-popup-B59bhE16.js} +2 -2
- package/dist/{wt-status-select-ELI7j73g.js → wt-status-select-Dnv9tj7o.js} +1 -1
- package/dist/{wt-timepicker-C3v9Cp2e.js → wt-timepicker-B4MOaSEZ.js} +2 -2
- package/dist/{wt-toast-DxQBRGm2.js → wt-toast-DJJg7o3S.js} +2 -2
- package/dist/{wt-tree-table-C5sxm-Eb.js → wt-tree-table-D-Jzijlk.js} +1 -1
- package/dist/{wt-type-extension-value-input-gQGgxMcJ.js → wt-type-extension-value-input-BEfx2uDx.js} +3 -3
- package/dist/{wt-vidstack-player-B37Mdf0u.js → wt-vidstack-player-efSk6APE.js} +4 -4
- package/package.json +1 -1
- package/src/components/transitions/__tests__/ExpandTransition.spec.js +15 -0
- package/src/components/transitions/__tests__/WtReplaceTransition.spec.js +66 -0
- package/src/components/transitions/__tests__/WtTransition.spec.js +35 -0
- package/src/components/wt-action-bar/WtActionBarActionsOrder.js +1 -1
- package/src/components/wt-action-bar/__tests__/WtActionBar.spec.js +121 -0
- package/src/components/wt-action-bar/wt-action-bar.vue +57 -33
- package/src/components/wt-app-header/__tests__/WtAppNavigator.spec.js +65 -4
- package/src/components/wt-app-header/__tests__/WtHeaderActions.spec.js +81 -2
- package/src/components/wt-avatar/__tests__/WtAvatar.spec.js +111 -0
- package/src/components/wt-badge/__tests__/WtBadge.spec.js +80 -0
- package/src/components/wt-badge-new/__tests__/WtBadge.spec.js +61 -0
- package/src/components/wt-breadcrumb/__tests__/WtBreadcrumb.spec.js +117 -0
- package/src/components/wt-button-select/__tests__/WtButtonSelect.spec.js +37 -5
- package/src/components/wt-call-media-metric/__tests__/WtCallMediaMetric.spec.js +84 -0
- package/src/components/wt-card/__tests__/WtCard.spec.js +20 -0
- package/src/components/wt-checkbox/__tests__/WtCheckbox.spec.js +63 -0
- package/src/components/wt-chip/__tests__/WtChip.spec.js +32 -0
- package/src/components/wt-confirm-dialog/__tests__/WtConfirmDialog.spec.js +92 -0
- package/src/components/wt-context-menu/__tests__/WtContextMenu.spec.js +146 -1
- package/src/components/wt-copy-action/__tests__/WtCopyAction.spec.js +57 -0
- package/src/components/wt-datepicker/__tests__/WtDatepicker.spec.js +53 -0
- package/src/components/wt-datetime-text/__tests__/WtDatetimeText.spec.js +49 -0
- package/src/components/wt-divider/__tests__/WtDivider.spec.js +30 -0
- package/src/components/wt-dual-panel/__tests__/WtDualPanel.spec.js +120 -0
- package/src/components/wt-dummy/__tests__/WtDummy.spec.js +63 -1
- package/src/components/wt-empty/__tests__/WtEmpty.spec.js +84 -0
- package/src/components/wt-error-page/__tests__/WtErrorPage.spec.js +60 -0
- package/src/components/wt-expansion-card/__tests__/WtExpansionCard.spec.js +63 -0
- package/src/components/wt-expansion-panel/__tests__/WtExpansionPanel.spec.js +48 -9
- package/src/components/wt-filters-panel-wrapper/__tests__/WtFiltersPanelWrapper.spec.js +81 -10
- package/src/components/wt-hint/__tests__/WtHint.spec.js +44 -1
- package/src/components/wt-icon/__tests__/WtIcon.spec.js +29 -0
- package/src/components/wt-icon-action/__tests__/WtIconAction.spec.js +79 -0
- package/src/components/wt-icon-action/wt-icon-action.vue +1 -1
- package/src/components/wt-icon-btn/__tests__/WtIconBtn.spec.js +46 -0
- package/src/components/wt-image/__tests__/WtImage.spec.js +83 -0
- package/src/components/wt-indicator/__tests__/WtIndicator.spec.js +23 -0
- package/src/components/wt-input-number/__tests__/WtInputNumber.spec.js +77 -0
- package/src/components/wt-input-text/__tests__/WtInputText.spec.js +85 -0
- package/src/components/wt-intersection-observer/__tests__/WtIntersectionObserver.spec.js +24 -3
- package/src/components/wt-item-link/__tests__/WtItemLink.spec.js +93 -1
- package/src/components/wt-label/__tests__/WtLabel.spec.js +49 -1
- package/src/components/wt-load-bar/__tests__/WtLoadBar.spec.js +49 -0
- package/src/components/wt-loader/__tests__/WtLoader.spec.js +26 -1
- package/src/components/wt-logo/__tests__/WtLogo.spec.js +55 -0
- package/src/components/wt-menubar/__tests__/WtMenubar.spec.js +30 -0
- package/src/components/wt-message/__tests__/WtMessage.spec.js +46 -0
- package/src/components/wt-multi-select/__tests__/WtMultiSelect.spec.js +106 -0
- package/src/components/wt-page-header/__tests__/WtPageHeader.spec.js +111 -0
- package/src/components/wt-password/__tests__/WtPassword.spec.js +107 -0
- package/src/components/wt-popover/__tests__/WtPopover.spec.js +73 -0
- package/src/components/wt-progress-bar/__tests__/WtProgressBar.spec.js +34 -0
- package/src/components/wt-radio/__tests__/WtRadio.spec.js +45 -0
- package/src/components/wt-rounded-action/__tests__/WtRoundedAction.spec.js +48 -0
- package/src/components/wt-search-bar/__tests__/WtSearchBar.spec.js +74 -13
- package/src/components/wt-single-select/__tests__/WtSingleSelect.spec.js +117 -0
- package/src/components/wt-slider/__tests__/WtSlider.spec.js +100 -0
- package/src/components/wt-stepper/__tests__/WtStepper.spec.js +105 -0
- package/src/components/wt-switcher/__tests__/WtSwitcher.spec.js +47 -0
- package/src/components/wt-table/__tests__/WtTable.spec.js +237 -0
- package/src/components/wt-table-actions/__tests__/WtTableActions.spec.js +153 -1
- package/src/components/wt-table-column-select/__tests__/WtTableColumnSelect.spec.js +147 -0
- package/src/components/wt-tabs/__tests__/WtTabs.spec.js +55 -0
- package/src/components/wt-textarea/__tests__/WtTextarea.spec.js +49 -0
- package/src/components/wt-time-input/__tests__/WtTimeInput.spec.js +29 -0
- package/src/components/wt-tree/__tests__/WtTree.spec.js +126 -2
- package/src/components/wt-tree-line/__tests__/WtTreeLine.spec.js +205 -0
- package/src/components/wt-tree-table/__tests__/WtTreeTable.spec.js +155 -0
- package/src/components/wt-tree-table-row/__tests__/WtTreeTableRow.spec.js +176 -0
- package/src/components/wt-vidstack-player/__tests__/WtVidstackPlayer.spec.js +82 -0
- package/src/enums/IconAction/{IconAction.enum.js → IconAction.ts} +4 -2
- package/src/enums/index.ts +1 -1
- package/src/modules/ObjectPermissions/components/_internal/permissions-tab-content.vue +1 -1
- package/types/.tsbuildinfo +1 -1
- package/types/components/wt-action-bar/wt-action-bar.vue.d.ts +349 -105
- package/types/components/wt-datetime-text/__tests__/WtDatetimeText.spec.d.ts +1 -0
- package/types/components/wt-divider/__tests__/WtDivider.spec.d.ts +1 -0
- package/types/components/wt-dual-panel/__tests__/WtDualPanel.spec.d.ts +1 -0
- package/types/components/wt-empty/__tests__/WtEmpty.spec.d.ts +1 -0
- package/types/components/wt-error-page/__tests__/WtErrorPage.spec.d.ts +1 -0
- package/types/components/wt-expansion-card/__tests__/WtExpansionCard.spec.d.ts +1 -0
- package/types/components/wt-image/__tests__/WtImage.spec.d.ts +1 -0
- package/types/components/wt-input-number/__tests__/WtInputNumber.spec.d.ts +1 -0
- package/types/components/wt-input-text/__tests__/WtInputText.spec.d.ts +1 -0
- package/types/components/wt-logo/__tests__/WtLogo.spec.d.ts +1 -0
- package/types/components/wt-menubar/__tests__/WtMenubar.spec.d.ts +1 -0
- package/types/components/wt-message/__tests__/WtMessage.spec.d.ts +1 -0
- package/types/components/wt-multi-select/__tests__/WtMultiSelect.spec.d.ts +1 -0
- package/types/components/wt-page-header/__tests__/WtPageHeader.spec.d.ts +1 -0
- package/types/components/wt-password/__tests__/WtPassword.spec.d.ts +1 -0
- package/types/components/wt-popover/__tests__/WtPopover.spec.d.ts +1 -0
- package/types/components/wt-single-select/__tests__/WtSingleSelect.spec.d.ts +1 -0
- package/types/components/wt-slider/__tests__/WtSlider.spec.d.ts +1 -0
- package/types/components/wt-stepper/__tests__/WtStepper.spec.d.ts +1 -0
- package/types/components/wt-table/__tests__/WtTable.spec.d.ts +1 -0
- package/types/components/wt-tree-line/__tests__/WtTreeLine.spec.d.ts +1 -0
- package/types/components/wt-tree-table/__tests__/WtTreeTable.spec.d.ts +1 -0
- package/types/components/wt-tree-table-row/__tests__/WtTreeTableRow.spec.d.ts +1 -0
- package/types/components/wt-vidstack-player/__tests__/WtVidstackPlayer.spec.d.ts +1 -0
- package/types/enums/IconAction/IconAction.d.ts +31 -0
- package/types/enums/index.d.ts +1 -1
- package/dist/wt-action-bar-D4wDtBqb.js +0 -87
- package/src/components/wt-action-bar/__tests__/wt-action-bar.spec.js +0 -10
- package/src/components/wt-avatar/__tests__/wt-avatar.spec.js +0 -10
- package/src/components/wt-badge/__tests__/wt-badge.spec.js +0 -10
- package/src/components/wt-breadcrumb/__tests__/wt-breadcrumb.spec.js +0 -14
- package/src/components/wt-dual-panel/__tests__/WtDualPanel.js +0 -62
- package/src/components/wt-empty/__tests__/wt-empty.spec.js +0 -10
- package/src/components/wt-error-page/__tests__/wt-error-page.spec.js +0 -30
- package/src/components/wt-image/__tests__/wt-image.spec.js +0 -10
- package/src/components/wt-logo/__tests__/wt-logo.spec.js +0 -10
- package/src/components/wt-page-header/__tests__/wt-page-header.spec.js +0 -10
- package/src/components/wt-stepper/__tests__/WtStepper.spec.vue.js +0 -19
- package/types/enums/IconAction/IconAction.enum.d.ts +0 -30
- /package/types/components/{wt-action-bar/__tests__/wt-action-bar.spec.d.ts → transitions/__tests__/WtReplaceTransition.spec.d.ts} +0 -0
- /package/types/components/{wt-avatar/__tests__/wt-avatar.spec.d.ts → transitions/__tests__/WtTransition.spec.d.ts} +0 -0
- /package/types/components/{wt-badge/__tests__/wt-badge.spec.d.ts → wt-action-bar/__tests__/WtActionBar.spec.d.ts} +0 -0
- /package/types/components/{wt-breadcrumb/__tests__/wt-breadcrumb.spec.d.ts → wt-avatar/__tests__/WtAvatar.spec.d.ts} +0 -0
- /package/types/components/{wt-empty/__tests__/wt-empty.spec.d.ts → wt-badge/__tests__/WtBadge.spec.d.ts} +0 -0
- /package/types/components/{wt-dual-panel/__tests__/WtDualPanel.d.ts → wt-badge-new/__tests__/WtBadge.spec.d.ts} +0 -0
- /package/types/components/{wt-error-page/__tests__/wt-error-page.spec.d.ts → wt-breadcrumb/__tests__/WtBreadcrumb.spec.d.ts} +0 -0
- /package/types/components/{wt-image/__tests__/wt-image.spec.d.ts → wt-call-media-metric/__tests__/WtCallMediaMetric.spec.d.ts} +0 -0
- /package/types/components/{wt-logo/__tests__/wt-logo.spec.d.ts → wt-card/__tests__/WtCard.spec.d.ts} +0 -0
- /package/types/components/{wt-page-header/__tests__/wt-page-header.spec.d.ts → wt-confirm-dialog/__tests__/WtConfirmDialog.spec.d.ts} +0 -0
- /package/types/components/{wt-stepper/__tests__/WtStepper.spec.vue.d.ts → wt-copy-action/__tests__/WtCopyAction.spec.d.ts} +0 -0
|
@@ -1,14 +1,138 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
2
|
|
|
3
|
+
import { WtTreeMode } from '../types/WtTreeMode';
|
|
3
4
|
import WtTree from '../wt-tree.vue';
|
|
4
5
|
|
|
6
|
+
const data = [
|
|
7
|
+
{
|
|
8
|
+
label: 'Parent 1',
|
|
9
|
+
children: [
|
|
10
|
+
{
|
|
11
|
+
label: 'Child 1.1',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
label: 'Child 1.2',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: 'Parent 2',
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
|
|
5
23
|
describe('WtTree', () => {
|
|
6
24
|
it('renders a component', () => {
|
|
7
25
|
const wrapper = shallowMount(WtTree, {
|
|
8
|
-
|
|
9
|
-
|
|
26
|
+
props: {
|
|
27
|
+
data: [],
|
|
10
28
|
},
|
|
11
29
|
});
|
|
12
30
|
expect(wrapper.classes('wt-tree')).toBe(true);
|
|
13
31
|
});
|
|
32
|
+
|
|
33
|
+
it('renders a wt-tree-line per top-level item in tree mode by default', () => {
|
|
34
|
+
const wrapper = shallowMount(WtTree, {
|
|
35
|
+
props: {
|
|
36
|
+
data,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
expect(
|
|
40
|
+
wrapper.findAllComponents({
|
|
41
|
+
name: 'wt-tree-line',
|
|
42
|
+
}).length,
|
|
43
|
+
).toBe(data.length);
|
|
44
|
+
expect(wrapper.find('.wt-tree__list-content').exists()).toBe(false);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('forwards update:modelValue from a tree-line up', async () => {
|
|
48
|
+
const wrapper = shallowMount(WtTree, {
|
|
49
|
+
props: {
|
|
50
|
+
data,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
await wrapper
|
|
54
|
+
.findComponent({
|
|
55
|
+
name: 'wt-tree-line',
|
|
56
|
+
})
|
|
57
|
+
.vm.$emit('update:modelValue', data[0]);
|
|
58
|
+
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([
|
|
59
|
+
data[0],
|
|
60
|
+
]);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('renders a flattened list of all nested items in list mode', () => {
|
|
64
|
+
const wrapper = shallowMount(WtTree, {
|
|
65
|
+
props: {
|
|
66
|
+
data,
|
|
67
|
+
mode: WtTreeMode.List,
|
|
68
|
+
itemLabel: 'label',
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
const labels = wrapper.findAll('.wt-tree__label');
|
|
72
|
+
expect(labels.length).toBe(4);
|
|
73
|
+
expect(labels.map((l) => l.text())).toEqual([
|
|
74
|
+
'Parent 1',
|
|
75
|
+
'Child 1.1',
|
|
76
|
+
'Child 1.2',
|
|
77
|
+
'Parent 2',
|
|
78
|
+
]);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('emits update:modelValue when a list item is clicked', async () => {
|
|
82
|
+
const wrapper = shallowMount(WtTree, {
|
|
83
|
+
props: {
|
|
84
|
+
data,
|
|
85
|
+
mode: WtTreeMode.List,
|
|
86
|
+
itemLabel: 'label',
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
await wrapper.findAll('.wt-tree__label')[1].trigger('click');
|
|
90
|
+
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([
|
|
91
|
+
data[0].children[0],
|
|
92
|
+
]);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('marks the selected list item as active', () => {
|
|
96
|
+
const wrapper = shallowMount(WtTree, {
|
|
97
|
+
props: {
|
|
98
|
+
data,
|
|
99
|
+
mode: WtTreeMode.List,
|
|
100
|
+
itemLabel: 'label',
|
|
101
|
+
modelValue: data[1],
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
const wrappers = wrapper.findAll('.wt-tree__label-wrapper');
|
|
105
|
+
expect(wrappers.at(-1).classes()).toContain('active');
|
|
106
|
+
expect(wrappers[0].classes()).not.toContain('active');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('uses itemData to compare/select values when provided', async () => {
|
|
110
|
+
const keyedData = [
|
|
111
|
+
{
|
|
112
|
+
id: 'a',
|
|
113
|
+
label: 'A',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: 'b',
|
|
117
|
+
label: 'B',
|
|
118
|
+
},
|
|
119
|
+
];
|
|
120
|
+
const wrapper = shallowMount(WtTree, {
|
|
121
|
+
props: {
|
|
122
|
+
data: keyedData,
|
|
123
|
+
mode: WtTreeMode.List,
|
|
124
|
+
itemLabel: 'label',
|
|
125
|
+
itemData: 'id',
|
|
126
|
+
modelValue: 'b',
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
expect(
|
|
130
|
+
wrapper.findAll('.wt-tree__label-wrapper').at(-1).classes(),
|
|
131
|
+
).toContain('active');
|
|
132
|
+
|
|
133
|
+
await wrapper.findAll('.wt-tree__label')[0].trigger('click');
|
|
134
|
+
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([
|
|
135
|
+
'a',
|
|
136
|
+
]);
|
|
137
|
+
});
|
|
14
138
|
});
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { mount, shallowMount } from '@vue/test-utils';
|
|
2
|
+
|
|
3
|
+
import WtTreeLine from '../wt-tree-line.vue';
|
|
4
|
+
|
|
5
|
+
const leaf = {
|
|
6
|
+
label: 'Leaf',
|
|
7
|
+
};
|
|
8
|
+
const parent = {
|
|
9
|
+
label: 'Parent',
|
|
10
|
+
children: [
|
|
11
|
+
{
|
|
12
|
+
label: 'Child 1',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: 'Child 2',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
describe('WtTreeLine', () => {
|
|
21
|
+
it('renders a component', () => {
|
|
22
|
+
const wrapper = shallowMount(WtTreeLine, {
|
|
23
|
+
props: {
|
|
24
|
+
data: leaf,
|
|
25
|
+
modelValue: null,
|
|
26
|
+
itemLabel: 'label',
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
expect(wrapper.find('.wt-tree-line').exists()).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('renders the item label', () => {
|
|
33
|
+
const wrapper = shallowMount(WtTreeLine, {
|
|
34
|
+
props: {
|
|
35
|
+
data: leaf,
|
|
36
|
+
modelValue: null,
|
|
37
|
+
itemLabel: 'label',
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
expect(wrapper.find('.wt-tree-line__label').text()).toBe('Leaf');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('does not render an expand toggle for a leaf node', () => {
|
|
44
|
+
const wrapper = shallowMount(WtTreeLine, {
|
|
45
|
+
props: {
|
|
46
|
+
data: leaf,
|
|
47
|
+
modelValue: null,
|
|
48
|
+
itemLabel: 'label',
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
expect(
|
|
52
|
+
wrapper
|
|
53
|
+
.findComponent({
|
|
54
|
+
name: 'wt-icon-btn',
|
|
55
|
+
})
|
|
56
|
+
.exists(),
|
|
57
|
+
).toBe(false);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('renders an expand toggle for a node with children', () => {
|
|
61
|
+
const wrapper = shallowMount(WtTreeLine, {
|
|
62
|
+
props: {
|
|
63
|
+
data: parent,
|
|
64
|
+
modelValue: null,
|
|
65
|
+
itemLabel: 'label',
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
expect(
|
|
69
|
+
wrapper
|
|
70
|
+
.findComponent({
|
|
71
|
+
name: 'wt-icon-btn',
|
|
72
|
+
})
|
|
73
|
+
.exists(),
|
|
74
|
+
).toBe(true);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('renders a nested wt-tree-line per child', () => {
|
|
78
|
+
const wrapper = mount(WtTreeLine, {
|
|
79
|
+
props: {
|
|
80
|
+
data: parent,
|
|
81
|
+
modelValue: null,
|
|
82
|
+
itemLabel: 'label',
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
const labels = wrapper.findAll('.wt-tree-line__label').map((l) => l.text());
|
|
86
|
+
expect(labels).toEqual([
|
|
87
|
+
'Parent',
|
|
88
|
+
'Child 1',
|
|
89
|
+
'Child 2',
|
|
90
|
+
]);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('emits update:modelValue with the raw data for a leaf when clicked', async () => {
|
|
94
|
+
const wrapper = shallowMount(WtTreeLine, {
|
|
95
|
+
props: {
|
|
96
|
+
data: leaf,
|
|
97
|
+
modelValue: null,
|
|
98
|
+
itemLabel: 'label',
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
await wrapper.find('.wt-tree-line__label-wrapper').trigger('click');
|
|
102
|
+
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([
|
|
103
|
+
leaf,
|
|
104
|
+
]);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('emits update:modelValue with itemData value when itemData is provided', async () => {
|
|
108
|
+
const keyedLeaf = {
|
|
109
|
+
id: 'a',
|
|
110
|
+
label: 'A',
|
|
111
|
+
};
|
|
112
|
+
const wrapper = shallowMount(WtTreeLine, {
|
|
113
|
+
props: {
|
|
114
|
+
data: keyedLeaf,
|
|
115
|
+
modelValue: null,
|
|
116
|
+
itemLabel: 'label',
|
|
117
|
+
itemData: 'id',
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
await wrapper.find('.wt-tree-line__label-wrapper').trigger('click');
|
|
121
|
+
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([
|
|
122
|
+
'a',
|
|
123
|
+
]);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('toggles collapsed state (and does not emit) when clicking a node with children, unless allowParent', async () => {
|
|
127
|
+
const wrapper = shallowMount(WtTreeLine, {
|
|
128
|
+
props: {
|
|
129
|
+
data: parent,
|
|
130
|
+
modelValue: null,
|
|
131
|
+
itemLabel: 'label',
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
await wrapper.find('.wt-tree-line__label-wrapper').trigger('click');
|
|
135
|
+
expect(wrapper.emitted()['update:modelValue']).toBeFalsy();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// NOTE: `allowParent`'s early-return branch only applies to nodes without children,
|
|
139
|
+
// and for those it emits the exact same value as the default (final) emit below it —
|
|
140
|
+
// so toggling `allowParent` has no observable effect on a leaf's click behavior, and
|
|
141
|
+
// none at all on a node with children (the collapse-toggle branch always wins first).
|
|
142
|
+
// Asserting the current (seemingly no-op) behavior rather than an intended one.
|
|
143
|
+
it('has no observable effect on click behavior for a leaf node', async () => {
|
|
144
|
+
const wrapper = shallowMount(WtTreeLine, {
|
|
145
|
+
props: {
|
|
146
|
+
data: leaf,
|
|
147
|
+
modelValue: null,
|
|
148
|
+
itemLabel: 'label',
|
|
149
|
+
allowParent: true,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
await wrapper.find('.wt-tree-line__label-wrapper').trigger('click');
|
|
153
|
+
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([
|
|
154
|
+
leaf,
|
|
155
|
+
]);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('marks the node active when it matches modelValue', () => {
|
|
159
|
+
const wrapper = shallowMount(WtTreeLine, {
|
|
160
|
+
props: {
|
|
161
|
+
data: leaf,
|
|
162
|
+
modelValue: leaf,
|
|
163
|
+
itemLabel: 'label',
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
expect(wrapper.find('.wt-tree-line__label-wrapper').classes()).toContain(
|
|
167
|
+
'active',
|
|
168
|
+
);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('marks the node searched when data has the searched flag', () => {
|
|
172
|
+
const searchedLeaf = {
|
|
173
|
+
label: 'Leaf',
|
|
174
|
+
searched: true,
|
|
175
|
+
};
|
|
176
|
+
const wrapper = shallowMount(WtTreeLine, {
|
|
177
|
+
props: {
|
|
178
|
+
data: searchedLeaf,
|
|
179
|
+
modelValue: null,
|
|
180
|
+
itemLabel: 'label',
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
expect(wrapper.find('.wt-tree-line__label-wrapper').classes()).toContain(
|
|
184
|
+
'searched',
|
|
185
|
+
);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('toggles multi-select values into an array in multiple mode', async () => {
|
|
189
|
+
const wrapper = shallowMount(WtTreeLine, {
|
|
190
|
+
props: {
|
|
191
|
+
data: leaf,
|
|
192
|
+
modelValue: [],
|
|
193
|
+
itemLabel: 'label',
|
|
194
|
+
itemData: 'label',
|
|
195
|
+
multiple: true,
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
await wrapper.find('.wt-tree-line__label-wrapper').trigger('click');
|
|
199
|
+
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([
|
|
200
|
+
[
|
|
201
|
+
'Leaf',
|
|
202
|
+
],
|
|
203
|
+
]);
|
|
204
|
+
});
|
|
205
|
+
});
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { mount, shallowMount } from '@vue/test-utils';
|
|
2
|
+
|
|
3
|
+
import WtTreeTable from '../wt-tree-table.vue';
|
|
4
|
+
|
|
5
|
+
const headers = [
|
|
6
|
+
{
|
|
7
|
+
value: 'name',
|
|
8
|
+
text: 'Name',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
value: 'age',
|
|
12
|
+
text: 'Age',
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const data = [
|
|
17
|
+
{
|
|
18
|
+
id: 1,
|
|
19
|
+
name: 'Alice',
|
|
20
|
+
age: 30,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 2,
|
|
24
|
+
name: 'Bob',
|
|
25
|
+
age: 25,
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
describe('WtTreeTable', () => {
|
|
30
|
+
it('renders a component', () => {
|
|
31
|
+
const wrapper = shallowMount(WtTreeTable, {
|
|
32
|
+
props: {
|
|
33
|
+
headers,
|
|
34
|
+
data,
|
|
35
|
+
childrenProp: 'children',
|
|
36
|
+
selected: [],
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
expect(wrapper.classes()).toContain('wt-tree-table');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('renders a header cell per header, an actions header, and a row per data item', () => {
|
|
43
|
+
const wrapper = shallowMount(WtTreeTable, {
|
|
44
|
+
props: {
|
|
45
|
+
headers,
|
|
46
|
+
data,
|
|
47
|
+
childrenProp: 'children',
|
|
48
|
+
selected: [],
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
expect(wrapper.findAll('.wt-tree-table-th').length).toBe(headers.length);
|
|
52
|
+
expect(wrapper.find('.wt-tree-table-th__actions').exists()).toBe(true);
|
|
53
|
+
expect(
|
|
54
|
+
wrapper.findAllComponents({
|
|
55
|
+
name: 'wt-tree-table-row',
|
|
56
|
+
}).length,
|
|
57
|
+
).toBe(data.length);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('does not render the actions header when gridActions is false', () => {
|
|
61
|
+
const wrapper = shallowMount(WtTreeTable, {
|
|
62
|
+
props: {
|
|
63
|
+
headers,
|
|
64
|
+
data,
|
|
65
|
+
childrenProp: 'children',
|
|
66
|
+
selected: [],
|
|
67
|
+
gridActions: false,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
expect(wrapper.find('.wt-tree-table-th__actions').exists()).toBe(false);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('renders a select-all checkbox on the first header when selectable', () => {
|
|
74
|
+
const wrapper = shallowMount(WtTreeTable, {
|
|
75
|
+
props: {
|
|
76
|
+
headers,
|
|
77
|
+
data,
|
|
78
|
+
childrenProp: 'children',
|
|
79
|
+
selected: [],
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
expect(
|
|
83
|
+
wrapper
|
|
84
|
+
.findComponent({
|
|
85
|
+
name: 'wt-checkbox',
|
|
86
|
+
})
|
|
87
|
+
.exists(),
|
|
88
|
+
).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('emits sort with the next sort order for a sortable column', async () => {
|
|
92
|
+
const sortableHeaders = [
|
|
93
|
+
{
|
|
94
|
+
value: 'name',
|
|
95
|
+
text: 'Name',
|
|
96
|
+
sort: null,
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
const wrapper = mount(WtTreeTable, {
|
|
100
|
+
props: {
|
|
101
|
+
headers: sortableHeaders,
|
|
102
|
+
data,
|
|
103
|
+
childrenProp: 'children',
|
|
104
|
+
selected: [],
|
|
105
|
+
sortable: true,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
await wrapper.find('.wt-tree-table-th').trigger('click');
|
|
109
|
+
expect(wrapper.emitted().sort).toBeTruthy();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('emits update:selected when a row toggles selection, given an explicit selected prop', async () => {
|
|
113
|
+
const wrapper = shallowMount(WtTreeTable, {
|
|
114
|
+
props: {
|
|
115
|
+
headers,
|
|
116
|
+
data,
|
|
117
|
+
childrenProp: 'children',
|
|
118
|
+
selected: [],
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
const row = wrapper.findComponent({
|
|
122
|
+
name: 'wt-tree-table-row',
|
|
123
|
+
});
|
|
124
|
+
await row.vm.$emit('update:selected', {
|
|
125
|
+
data: data[0],
|
|
126
|
+
select: true,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
expect(wrapper.emitted()['update:selected'][0]).toEqual([
|
|
130
|
+
[
|
|
131
|
+
data[0],
|
|
132
|
+
],
|
|
133
|
+
]);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('emits update:selected with all nested elements when select-all is toggled on', async () => {
|
|
137
|
+
const wrapper = shallowMount(WtTreeTable, {
|
|
138
|
+
props: {
|
|
139
|
+
headers,
|
|
140
|
+
data,
|
|
141
|
+
childrenProp: 'children',
|
|
142
|
+
selected: [],
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
await wrapper
|
|
146
|
+
.findComponent({
|
|
147
|
+
name: 'wt-checkbox',
|
|
148
|
+
})
|
|
149
|
+
.vm.$emit('update:selected', true);
|
|
150
|
+
|
|
151
|
+
expect(wrapper.emitted()['update:selected'][0]).toEqual([
|
|
152
|
+
data,
|
|
153
|
+
]);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { mount, shallowMount } from '@vue/test-utils';
|
|
2
|
+
|
|
3
|
+
import WtTreeTableRow from '../wt-tree-table-row.vue';
|
|
4
|
+
|
|
5
|
+
const dataHeaders = [
|
|
6
|
+
{
|
|
7
|
+
value: 'name',
|
|
8
|
+
text: 'Name',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
value: 'age',
|
|
12
|
+
text: 'Age',
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const leafRow = {
|
|
17
|
+
id: 1,
|
|
18
|
+
name: 'Alice',
|
|
19
|
+
age: 30,
|
|
20
|
+
};
|
|
21
|
+
const parentRow = {
|
|
22
|
+
id: 2,
|
|
23
|
+
name: 'Bob',
|
|
24
|
+
age: 40,
|
|
25
|
+
children: [
|
|
26
|
+
{
|
|
27
|
+
id: 3,
|
|
28
|
+
name: 'Charlie',
|
|
29
|
+
age: 10,
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
describe('WtTreeTableRow', () => {
|
|
35
|
+
it('renders a component', () => {
|
|
36
|
+
const wrapper = shallowMount(WtTreeTableRow, {
|
|
37
|
+
props: {
|
|
38
|
+
data: leafRow,
|
|
39
|
+
rowPosition: 0,
|
|
40
|
+
childrenProp: 'children',
|
|
41
|
+
selectedElements: [],
|
|
42
|
+
dataHeaders,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
expect(wrapper.find('.wt-tree-table-row').exists()).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('renders a cell with the value for each header', () => {
|
|
49
|
+
const wrapper = shallowMount(WtTreeTableRow, {
|
|
50
|
+
props: {
|
|
51
|
+
data: leafRow,
|
|
52
|
+
rowPosition: 0,
|
|
53
|
+
childrenProp: 'children',
|
|
54
|
+
selectedElements: [],
|
|
55
|
+
dataHeaders,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
const cells = wrapper.findAll('.wt-tree-table-td');
|
|
59
|
+
expect(cells[0].text()).toContain('Alice');
|
|
60
|
+
expect(cells[1].text()).toContain('30');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('applies the alternate class on odd row positions', () => {
|
|
64
|
+
const wrapper = shallowMount(WtTreeTableRow, {
|
|
65
|
+
props: {
|
|
66
|
+
data: leafRow,
|
|
67
|
+
rowPosition: 1,
|
|
68
|
+
childrenProp: 'children',
|
|
69
|
+
selectedElements: [],
|
|
70
|
+
dataHeaders,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
expect(wrapper.find('.wt-tree-table-row').classes()).toContain(
|
|
74
|
+
'wt-tree-table-row--alternate',
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('does not render an expand toggle for a row without children', () => {
|
|
79
|
+
const wrapper = shallowMount(WtTreeTableRow, {
|
|
80
|
+
props: {
|
|
81
|
+
data: leafRow,
|
|
82
|
+
rowPosition: 0,
|
|
83
|
+
childrenProp: 'children',
|
|
84
|
+
selectedElements: [],
|
|
85
|
+
dataHeaders,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
expect(
|
|
89
|
+
wrapper
|
|
90
|
+
.findComponent({
|
|
91
|
+
name: 'wt-icon-btn',
|
|
92
|
+
})
|
|
93
|
+
.exists(),
|
|
94
|
+
).toBe(false);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('renders an expand toggle and nested rows once expanded, for a row with children', async () => {
|
|
98
|
+
const wrapper = mount(WtTreeTableRow, {
|
|
99
|
+
props: {
|
|
100
|
+
data: parentRow,
|
|
101
|
+
rowPosition: 0,
|
|
102
|
+
childrenProp: 'children',
|
|
103
|
+
selectedElements: [],
|
|
104
|
+
dataHeaders,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
const toggle = wrapper.findComponent({
|
|
108
|
+
name: 'wt-icon-btn',
|
|
109
|
+
});
|
|
110
|
+
expect(toggle.exists()).toBe(true);
|
|
111
|
+
expect(wrapper.findAll('tr').length).toBe(1);
|
|
112
|
+
|
|
113
|
+
await toggle.trigger('click');
|
|
114
|
+
|
|
115
|
+
expect(wrapper.findAll('tr').length).toBe(2);
|
|
116
|
+
expect(wrapper.findAll('tr')[1].text()).toContain('Charlie');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('does not render a selection checkbox unless selectable', () => {
|
|
120
|
+
const wrapper = shallowMount(WtTreeTableRow, {
|
|
121
|
+
props: {
|
|
122
|
+
data: leafRow,
|
|
123
|
+
rowPosition: 0,
|
|
124
|
+
childrenProp: 'children',
|
|
125
|
+
selectedElements: [],
|
|
126
|
+
dataHeaders,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
expect(
|
|
130
|
+
wrapper
|
|
131
|
+
.findComponent({
|
|
132
|
+
name: 'wt-checkbox',
|
|
133
|
+
})
|
|
134
|
+
.exists(),
|
|
135
|
+
).toBe(false);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('emits update:selected with the row data when the checkbox is toggled', async () => {
|
|
139
|
+
const wrapper = shallowMount(WtTreeTableRow, {
|
|
140
|
+
props: {
|
|
141
|
+
data: leafRow,
|
|
142
|
+
rowPosition: 0,
|
|
143
|
+
childrenProp: 'children',
|
|
144
|
+
selectedElements: [],
|
|
145
|
+
dataHeaders,
|
|
146
|
+
selectable: true,
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
await wrapper
|
|
150
|
+
.findComponent({
|
|
151
|
+
name: 'wt-checkbox',
|
|
152
|
+
})
|
|
153
|
+
.vm.$emit('update:selected', true);
|
|
154
|
+
|
|
155
|
+
expect(wrapper.emitted()['update:selected'][0]).toEqual([
|
|
156
|
+
{
|
|
157
|
+
data: leafRow,
|
|
158
|
+
select: true,
|
|
159
|
+
},
|
|
160
|
+
]);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('does not render an actions cell when gridActions is false', () => {
|
|
164
|
+
const wrapper = shallowMount(WtTreeTableRow, {
|
|
165
|
+
props: {
|
|
166
|
+
data: leafRow,
|
|
167
|
+
rowPosition: 0,
|
|
168
|
+
childrenProp: 'children',
|
|
169
|
+
selectedElements: [],
|
|
170
|
+
dataHeaders,
|
|
171
|
+
gridActions: false,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
expect(wrapper.find('.wt-tree-table-td__actions').exists()).toBe(false);
|
|
175
|
+
});
|
|
176
|
+
});
|