@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
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
|
|
3
|
+
import WtTable from '../wt-table.vue';
|
|
4
|
+
|
|
5
|
+
global.ResizeObserver = vi.fn().mockImplementation(() => ({
|
|
6
|
+
observe: vi.fn(),
|
|
7
|
+
unobserve: vi.fn(),
|
|
8
|
+
disconnect: vi.fn(),
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
const headers = [
|
|
12
|
+
{
|
|
13
|
+
value: 'name',
|
|
14
|
+
text: 'Name',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
value: 'age',
|
|
18
|
+
text: 'Age',
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const data = [
|
|
23
|
+
{
|
|
24
|
+
id: 1,
|
|
25
|
+
name: 'Alice',
|
|
26
|
+
age: 30,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 2,
|
|
30
|
+
name: 'Bob',
|
|
31
|
+
age: 25,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
describe('WtTable', () => {
|
|
36
|
+
it('renders a component', () => {
|
|
37
|
+
const wrapper = mount(WtTable);
|
|
38
|
+
expect(
|
|
39
|
+
wrapper
|
|
40
|
+
.findComponent({
|
|
41
|
+
name: 'DataTable',
|
|
42
|
+
})
|
|
43
|
+
.exists(),
|
|
44
|
+
).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('passes data and column headers down to the underlying table', () => {
|
|
48
|
+
const wrapper = mount(WtTable, {
|
|
49
|
+
props: {
|
|
50
|
+
headers,
|
|
51
|
+
data,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
const table = wrapper.findComponent({
|
|
55
|
+
name: 'DataTable',
|
|
56
|
+
});
|
|
57
|
+
expect(table.props('value')).toEqual(data);
|
|
58
|
+
|
|
59
|
+
const columns = wrapper.findAllComponents({
|
|
60
|
+
name: 'Column',
|
|
61
|
+
});
|
|
62
|
+
const dataColumns = columns.filter((c) =>
|
|
63
|
+
headers.some((h) => h.value === c.props('columnKey')),
|
|
64
|
+
);
|
|
65
|
+
expect(dataColumns.length).toBe(headers.length);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('renders row-select column by default and can be disabled', () => {
|
|
69
|
+
const withSelect = mount(WtTable, {
|
|
70
|
+
props: {
|
|
71
|
+
headers,
|
|
72
|
+
data,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
expect(
|
|
76
|
+
withSelect
|
|
77
|
+
.findAllComponents({
|
|
78
|
+
name: 'Column',
|
|
79
|
+
})
|
|
80
|
+
.some((c) => c.props('columnKey') === 'row-select'),
|
|
81
|
+
).toBe(true);
|
|
82
|
+
|
|
83
|
+
const withoutSelect = mount(WtTable, {
|
|
84
|
+
props: {
|
|
85
|
+
headers,
|
|
86
|
+
data,
|
|
87
|
+
selectable: false,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
expect(
|
|
91
|
+
withoutSelect
|
|
92
|
+
.findAllComponents({
|
|
93
|
+
name: 'Column',
|
|
94
|
+
})
|
|
95
|
+
.some((c) => c.props('columnKey') === 'row-select'),
|
|
96
|
+
).toBe(false);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('renders the row-actions column when gridActions is true (default)', () => {
|
|
100
|
+
const wrapper = mount(WtTable, {
|
|
101
|
+
props: {
|
|
102
|
+
headers,
|
|
103
|
+
data,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
expect(
|
|
107
|
+
wrapper
|
|
108
|
+
.findAllComponents({
|
|
109
|
+
name: 'Column',
|
|
110
|
+
})
|
|
111
|
+
.some((c) => c.props('columnKey') === 'row-actions'),
|
|
112
|
+
).toBe(true);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('does not render the row-actions column when gridActions is false', () => {
|
|
116
|
+
const wrapper = mount(WtTable, {
|
|
117
|
+
props: {
|
|
118
|
+
headers,
|
|
119
|
+
data,
|
|
120
|
+
gridActions: false,
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
expect(
|
|
124
|
+
wrapper
|
|
125
|
+
.findAllComponents({
|
|
126
|
+
name: 'Column',
|
|
127
|
+
})
|
|
128
|
+
.some((c) => c.props('columnKey') === 'row-actions'),
|
|
129
|
+
).toBe(false);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('emits sort with the next sort order for a sortable column', async () => {
|
|
133
|
+
const sortableHeaders = [
|
|
134
|
+
{
|
|
135
|
+
value: 'name',
|
|
136
|
+
text: 'Name',
|
|
137
|
+
field: 'name',
|
|
138
|
+
sort: null,
|
|
139
|
+
},
|
|
140
|
+
];
|
|
141
|
+
const wrapper = mount(WtTable, {
|
|
142
|
+
props: {
|
|
143
|
+
headers: sortableHeaders,
|
|
144
|
+
data,
|
|
145
|
+
sortable: true,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
const table = wrapper.findComponent({
|
|
149
|
+
name: 'DataTable',
|
|
150
|
+
});
|
|
151
|
+
await table.vm.$emit('sort', {
|
|
152
|
+
sortField: 'name',
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
expect(wrapper.emitted().sort).toBeTruthy();
|
|
156
|
+
expect(wrapper.emitted().sort[0][0]).toEqual(sortableHeaders[0]);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('does not emit sort for a non-sortable table', async () => {
|
|
160
|
+
const wrapper = mount(WtTable, {
|
|
161
|
+
props: {
|
|
162
|
+
headers,
|
|
163
|
+
data,
|
|
164
|
+
sortable: false,
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
const table = wrapper.findComponent({
|
|
168
|
+
name: 'DataTable',
|
|
169
|
+
});
|
|
170
|
+
await table.vm.$emit('sort', {
|
|
171
|
+
sortField: 'name',
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
expect(wrapper.emitted().sort).toBeFalsy();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('resolves locale-based header text', () => {
|
|
178
|
+
const wrapper = mount(WtTable, {
|
|
179
|
+
props: {
|
|
180
|
+
headers: [
|
|
181
|
+
{
|
|
182
|
+
value: 'name',
|
|
183
|
+
locale: 'reusable.add',
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
data,
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
expect(wrapper.text()).toContain('Add');
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('hides columns with show: false', () => {
|
|
193
|
+
const wrapper = mount(WtTable, {
|
|
194
|
+
props: {
|
|
195
|
+
headers: [
|
|
196
|
+
{
|
|
197
|
+
value: 'name',
|
|
198
|
+
text: 'Name',
|
|
199
|
+
show: false,
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
data,
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
const col = wrapper
|
|
206
|
+
.findAllComponents({
|
|
207
|
+
name: 'Column',
|
|
208
|
+
})
|
|
209
|
+
.find((c) => c.props('columnKey') === 'name');
|
|
210
|
+
expect(col.props('hidden')).toBe(true);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('toggles all row selections via the header checkbox when no selected prop is given', async () => {
|
|
214
|
+
const rows = [
|
|
215
|
+
{
|
|
216
|
+
id: 1,
|
|
217
|
+
name: 'Alice',
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
id: 2,
|
|
221
|
+
name: 'Bob',
|
|
222
|
+
},
|
|
223
|
+
];
|
|
224
|
+
const wrapper = mount(WtTable, {
|
|
225
|
+
props: {
|
|
226
|
+
headers,
|
|
227
|
+
data: rows,
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
const headerCheckbox = wrapper.findComponent({
|
|
231
|
+
name: 'wt-checkbox',
|
|
232
|
+
});
|
|
233
|
+
await headerCheckbox.vm.$emit('update:selected', true);
|
|
234
|
+
|
|
235
|
+
expect(rows.every((r) => r._isSelected)).toBe(true);
|
|
236
|
+
});
|
|
237
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils';
|
|
1
|
+
import { mount, shallowMount } from '@vue/test-utils';
|
|
2
2
|
|
|
3
3
|
import WtTableActions from '../wt-table-actions.vue';
|
|
4
4
|
|
|
@@ -7,4 +7,156 @@ describe('WtTableActions', () => {
|
|
|
7
7
|
const wrapper = shallowMount(WtTableActions);
|
|
8
8
|
expect(wrapper.classes('wt-table-actions')).toBe(true);
|
|
9
9
|
});
|
|
10
|
+
|
|
11
|
+
it('renders only the refresh icon by default', () => {
|
|
12
|
+
const wrapper = shallowMount(WtTableActions);
|
|
13
|
+
expect(
|
|
14
|
+
wrapper.findAllComponents({
|
|
15
|
+
name: 'wt-icon-btn',
|
|
16
|
+
}).length,
|
|
17
|
+
).toBe(1);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('renders default slot content', () => {
|
|
21
|
+
const wrapper = shallowMount(WtTableActions, {
|
|
22
|
+
slots: {
|
|
23
|
+
default: 'Custom action',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
expect(wrapper.text()).toContain('Custom action');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it.each([
|
|
30
|
+
[
|
|
31
|
+
'import',
|
|
32
|
+
'import',
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
'export',
|
|
36
|
+
'export',
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
'filter-reset',
|
|
40
|
+
'filterReset',
|
|
41
|
+
],
|
|
42
|
+
[
|
|
43
|
+
'column-select',
|
|
44
|
+
'columnSelect',
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
'refresh',
|
|
48
|
+
'refresh',
|
|
49
|
+
],
|
|
50
|
+
])('emits input with "%s" when the %s icon is clicked', async (icon, emitted) => {
|
|
51
|
+
const wrapper = mount(WtTableActions, {
|
|
52
|
+
props: {
|
|
53
|
+
icons: [
|
|
54
|
+
icon,
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
await wrapper
|
|
59
|
+
.findComponent({
|
|
60
|
+
name: 'wt-icon-btn',
|
|
61
|
+
})
|
|
62
|
+
.trigger('click');
|
|
63
|
+
expect(wrapper.emitted().input[0]).toEqual([
|
|
64
|
+
emitted,
|
|
65
|
+
]);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// NOTE: the settings icon-btn is nested inside <wt-badge v-if="isSettingsBadge">,
|
|
69
|
+
// so it only renders (and can be clicked) when isSettingsBadge is true, even
|
|
70
|
+
// though `icons` includes 'settings' independently. This looks like an accidental
|
|
71
|
+
// regression (wt-badge supports a `hidden` prop for exactly this "always mount,
|
|
72
|
+
// toggle visibility" case), but the tests assert current, not intended, behavior.
|
|
73
|
+
it('emits input with "settings" when the settings icon is clicked, given isSettingsBadge is true', async () => {
|
|
74
|
+
const wrapper = mount(WtTableActions, {
|
|
75
|
+
props: {
|
|
76
|
+
icons: [
|
|
77
|
+
'settings',
|
|
78
|
+
],
|
|
79
|
+
isSettingsBadge: true,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
await wrapper
|
|
83
|
+
.findComponent({
|
|
84
|
+
name: 'wt-icon-btn',
|
|
85
|
+
})
|
|
86
|
+
.trigger('click');
|
|
87
|
+
expect(wrapper.emitted().input[0]).toEqual([
|
|
88
|
+
'settings',
|
|
89
|
+
]);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('does not render the settings icon when isSettingsBadge is false, even if icons includes "settings"', () => {
|
|
93
|
+
const wrapper = mount(WtTableActions, {
|
|
94
|
+
props: {
|
|
95
|
+
icons: [
|
|
96
|
+
'settings',
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
expect(
|
|
101
|
+
wrapper
|
|
102
|
+
.findComponent({
|
|
103
|
+
name: 'wt-icon-btn',
|
|
104
|
+
})
|
|
105
|
+
.exists(),
|
|
106
|
+
).toBe(false);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('renders multiple icons in the icons array', () => {
|
|
110
|
+
const wrapper = shallowMount(WtTableActions, {
|
|
111
|
+
props: {
|
|
112
|
+
icons: [
|
|
113
|
+
'import',
|
|
114
|
+
'export',
|
|
115
|
+
'refresh',
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
expect(
|
|
120
|
+
wrapper.findAllComponents({
|
|
121
|
+
name: 'wt-icon-btn',
|
|
122
|
+
}).length,
|
|
123
|
+
).toBe(3);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('shows a visible badge on the settings button when isSettingsBadge is true', () => {
|
|
127
|
+
const wrapper = shallowMount(WtTableActions, {
|
|
128
|
+
props: {
|
|
129
|
+
icons: [
|
|
130
|
+
'settings',
|
|
131
|
+
],
|
|
132
|
+
isSettingsBadge: true,
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
expect(
|
|
136
|
+
wrapper
|
|
137
|
+
.findComponent({
|
|
138
|
+
name: 'wt-badge',
|
|
139
|
+
})
|
|
140
|
+
.props('hidden'),
|
|
141
|
+
).toBe(false);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('marks the settings button active when isSettingsActive is true', () => {
|
|
145
|
+
const wrapper = mount(WtTableActions, {
|
|
146
|
+
props: {
|
|
147
|
+
icons: [
|
|
148
|
+
'settings',
|
|
149
|
+
],
|
|
150
|
+
isSettingsBadge: true,
|
|
151
|
+
isSettingsActive: true,
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
expect(
|
|
155
|
+
wrapper
|
|
156
|
+
.findComponent({
|
|
157
|
+
name: 'wt-icon-btn',
|
|
158
|
+
})
|
|
159
|
+
.classes(),
|
|
160
|
+
).toContain('active');
|
|
161
|
+
});
|
|
10
162
|
});
|
|
@@ -33,4 +33,151 @@ describe('WtTableColumnSelect', () => {
|
|
|
33
33
|
await wrapper.vm.$nextTick();
|
|
34
34
|
expect(wrapper.find('.wt-popup__popup').exists()).toBe(true);
|
|
35
35
|
});
|
|
36
|
+
|
|
37
|
+
it('renders a checkbox for each non-static header once opened', async () => {
|
|
38
|
+
const headers = [
|
|
39
|
+
{
|
|
40
|
+
value: 'name',
|
|
41
|
+
text: 'Name',
|
|
42
|
+
show: true,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
value: 'age',
|
|
46
|
+
text: 'Age',
|
|
47
|
+
show: false,
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
const wrapper = mount(WtTableColumnSelect, {
|
|
51
|
+
props: {
|
|
52
|
+
headers,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
await wrapper
|
|
56
|
+
.findComponent({
|
|
57
|
+
name: 'wt-icon-btn',
|
|
58
|
+
})
|
|
59
|
+
.vm.$emit('click');
|
|
60
|
+
await wrapper.vm.$nextTick();
|
|
61
|
+
|
|
62
|
+
const checkboxes = wrapper.findAllComponents({
|
|
63
|
+
name: 'wt-checkbox',
|
|
64
|
+
});
|
|
65
|
+
expect(checkboxes.length).toBe(2);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('excludes staticHeaders from the changeable list', async () => {
|
|
69
|
+
const headers = [
|
|
70
|
+
{
|
|
71
|
+
value: 'name',
|
|
72
|
+
text: 'Name',
|
|
73
|
+
show: true,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
value: 'id',
|
|
77
|
+
text: 'ID',
|
|
78
|
+
show: true,
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
const wrapper = mount(WtTableColumnSelect, {
|
|
82
|
+
props: {
|
|
83
|
+
headers,
|
|
84
|
+
staticHeaders: [
|
|
85
|
+
'id',
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
await wrapper
|
|
90
|
+
.findComponent({
|
|
91
|
+
name: 'wt-icon-btn',
|
|
92
|
+
})
|
|
93
|
+
.vm.$emit('click');
|
|
94
|
+
await wrapper.vm.$nextTick();
|
|
95
|
+
|
|
96
|
+
expect(
|
|
97
|
+
wrapper.findAllComponents({
|
|
98
|
+
name: 'wt-checkbox',
|
|
99
|
+
}).length,
|
|
100
|
+
).toBe(1);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('shows an empty state when there are no changeable headers', async () => {
|
|
104
|
+
const wrapper = mount(WtTableColumnSelect, {
|
|
105
|
+
props: {
|
|
106
|
+
headers: [],
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
await wrapper
|
|
110
|
+
.findComponent({
|
|
111
|
+
name: 'wt-icon-btn',
|
|
112
|
+
})
|
|
113
|
+
.vm.$emit('click');
|
|
114
|
+
await wrapper.vm.$nextTick();
|
|
115
|
+
|
|
116
|
+
expect(
|
|
117
|
+
wrapper
|
|
118
|
+
.findComponent({
|
|
119
|
+
name: 'wt-empty',
|
|
120
|
+
})
|
|
121
|
+
.exists(),
|
|
122
|
+
).toBe(true);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('emits change with the draft headers and closes when "Add" is clicked', async () => {
|
|
126
|
+
const headers = [
|
|
127
|
+
{
|
|
128
|
+
value: 'name',
|
|
129
|
+
text: 'Name',
|
|
130
|
+
show: true,
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
const wrapper = mount(WtTableColumnSelect, {
|
|
134
|
+
props: {
|
|
135
|
+
headers,
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
await wrapper
|
|
139
|
+
.findComponent({
|
|
140
|
+
name: 'wt-icon-btn',
|
|
141
|
+
})
|
|
142
|
+
.vm.$emit('click');
|
|
143
|
+
await wrapper.vm.$nextTick();
|
|
144
|
+
|
|
145
|
+
const [addButton] = wrapper.findAllComponents({
|
|
146
|
+
name: 'wt-button',
|
|
147
|
+
});
|
|
148
|
+
await addButton.trigger('click');
|
|
149
|
+
|
|
150
|
+
expect(wrapper.emitted().change).toBeTruthy();
|
|
151
|
+
expect(wrapper.emitted().change[0][0]).toEqual(headers);
|
|
152
|
+
expect(wrapper.find('.wt-popup__popup').exists()).toBe(false);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('closes without emitting change when "Cancel" is clicked', async () => {
|
|
156
|
+
const headers = [
|
|
157
|
+
{
|
|
158
|
+
value: 'name',
|
|
159
|
+
text: 'Name',
|
|
160
|
+
show: true,
|
|
161
|
+
},
|
|
162
|
+
];
|
|
163
|
+
const wrapper = mount(WtTableColumnSelect, {
|
|
164
|
+
props: {
|
|
165
|
+
headers,
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
await wrapper
|
|
169
|
+
.findComponent({
|
|
170
|
+
name: 'wt-icon-btn',
|
|
171
|
+
})
|
|
172
|
+
.vm.$emit('click');
|
|
173
|
+
await wrapper.vm.$nextTick();
|
|
174
|
+
|
|
175
|
+
const [, cancelButton] = wrapper.findAllComponents({
|
|
176
|
+
name: 'wt-button',
|
|
177
|
+
});
|
|
178
|
+
await cancelButton.trigger('click');
|
|
179
|
+
|
|
180
|
+
expect(wrapper.emitted().change).toBeFalsy();
|
|
181
|
+
expect(wrapper.find('.wt-popup__popup').exists()).toBe(false);
|
|
182
|
+
});
|
|
36
183
|
});
|
|
@@ -47,4 +47,59 @@ describe('WtTabs', () => {
|
|
|
47
47
|
});
|
|
48
48
|
expect(wrapper.find('.wt-tab').text()).toBe(custom);
|
|
49
49
|
});
|
|
50
|
+
|
|
51
|
+
it('highlights the tab matching current.value', () => {
|
|
52
|
+
const wrapper = shallowMount(WtTabs, {
|
|
53
|
+
props: {
|
|
54
|
+
tabs,
|
|
55
|
+
current: {
|
|
56
|
+
value: 'tab1',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
expect(wrapper.find('.wt-tab').classes()).toContain('wt-tab--highlight');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('does not highlight when current does not match any tab', () => {
|
|
64
|
+
const wrapper = shallowMount(WtTabs, {
|
|
65
|
+
props: {
|
|
66
|
+
tabs,
|
|
67
|
+
current: {
|
|
68
|
+
value: 'other',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
expect(wrapper.find('.wt-tab').classes()).not.toContain(
|
|
73
|
+
'wt-tab--highlight',
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('applies the wide modifier class', () => {
|
|
78
|
+
const wrapper = shallowMount(WtTabs, {
|
|
79
|
+
props: {
|
|
80
|
+
tabs,
|
|
81
|
+
wide: true,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
expect(wrapper.classes()).toContain('wt-tabs--wide');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('renders a button for every tab', () => {
|
|
88
|
+
const multiTabs = [
|
|
89
|
+
{
|
|
90
|
+
value: 'a',
|
|
91
|
+
text: 'A',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
value: 'b',
|
|
95
|
+
text: 'B',
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
const wrapper = shallowMount(WtTabs, {
|
|
99
|
+
props: {
|
|
100
|
+
tabs: multiTabs,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
expect(wrapper.findAll('.wt-tab').length).toBe(multiTabs.length);
|
|
104
|
+
});
|
|
50
105
|
});
|
|
@@ -52,4 +52,53 @@ describe('WtTextarea', () => {
|
|
|
52
52
|
});
|
|
53
53
|
expect(wrapper.emitted().enter).toBeFalsy();
|
|
54
54
|
});
|
|
55
|
+
|
|
56
|
+
it('always emits keydown regardless of autoresize', () => {
|
|
57
|
+
const wrapper = shallowMount(WtTextarea, {
|
|
58
|
+
stubs: {
|
|
59
|
+
WtLabel,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
wrapper.find('.wt-textarea__textarea').trigger('keydown', {
|
|
63
|
+
key: 'a',
|
|
64
|
+
});
|
|
65
|
+
expect(wrapper.emitted().keydown).toBeTruthy();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('does not emit enter for shift+Enter even with autoresize', () => {
|
|
69
|
+
const wrapper = shallowMount(WtTextarea, {
|
|
70
|
+
stubs: {
|
|
71
|
+
WtLabel,
|
|
72
|
+
},
|
|
73
|
+
props: {
|
|
74
|
+
autoresize: true,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
wrapper.find('.wt-textarea__textarea').trigger('keydown', {
|
|
78
|
+
key: 'Enter',
|
|
79
|
+
shiftKey: true,
|
|
80
|
+
});
|
|
81
|
+
expect(wrapper.emitted().enter).toBeFalsy();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('emits paste and blur events', () => {
|
|
85
|
+
const wrapper = shallowMount(WtTextarea, {
|
|
86
|
+
stubs: {
|
|
87
|
+
WtLabel,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
wrapper.find('.wt-textarea__textarea').trigger('paste');
|
|
91
|
+
wrapper.find('.wt-textarea__textarea').trigger('blur');
|
|
92
|
+
expect(wrapper.emitted().paste).toBeTruthy();
|
|
93
|
+
expect(wrapper.emitted().blur).toBeTruthy();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('does not render a label when no label prop or slot is passed', () => {
|
|
97
|
+
const wrapper = shallowMount(WtTextarea, {
|
|
98
|
+
stubs: {
|
|
99
|
+
WtLabel,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
expect(wrapper.findComponent(WtLabel).exists()).toBe(false);
|
|
103
|
+
});
|
|
55
104
|
});
|
|
@@ -42,4 +42,33 @@ describe('WtTimeInput', () => {
|
|
|
42
42
|
7,
|
|
43
43
|
]);
|
|
44
44
|
});
|
|
45
|
+
|
|
46
|
+
it('passes min/max/disabled/required down to wt-input-number', () => {
|
|
47
|
+
const wrapper = shallowMount(WtTimeInput, {
|
|
48
|
+
props: {
|
|
49
|
+
minValue: 5,
|
|
50
|
+
maxValue: 60,
|
|
51
|
+
disabled: true,
|
|
52
|
+
required: true,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
const input = wrapper.findComponent({
|
|
56
|
+
name: 'wt-input-number',
|
|
57
|
+
});
|
|
58
|
+
expect(input.props('min')).toBe(5);
|
|
59
|
+
expect(input.props('max')).toBe(60);
|
|
60
|
+
expect(input.props('disabled')).toBe(true);
|
|
61
|
+
expect(input.props('required')).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('defaults minValue to 0', () => {
|
|
65
|
+
const wrapper = shallowMount(WtTimeInput);
|
|
66
|
+
expect(
|
|
67
|
+
wrapper
|
|
68
|
+
.findComponent({
|
|
69
|
+
name: 'wt-input-number',
|
|
70
|
+
})
|
|
71
|
+
.props('min'),
|
|
72
|
+
).toBe(0);
|
|
73
|
+
});
|
|
45
74
|
});
|