@htlkg/components 0.0.4 → 0.0.9
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/package.json +70 -69
- package/src/data/Table.test.ts +76 -176
- package/src/data/Table.unit.test.ts +146 -337
package/package.json
CHANGED
|
@@ -1,70 +1,71 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
2
|
+
"name": "@htlkg/components",
|
|
3
|
+
"version": "0.0.9",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"import": "./dist/index.js",
|
|
8
|
+
"types": "./src/index.ts"
|
|
9
|
+
},
|
|
10
|
+
"./data": {
|
|
11
|
+
"import": "./dist/data/index.js",
|
|
12
|
+
"types": "./src/data/index.ts"
|
|
13
|
+
},
|
|
14
|
+
"./forms": {
|
|
15
|
+
"import": "./dist/forms/index.js",
|
|
16
|
+
"types": "./src/forms/index.ts"
|
|
17
|
+
},
|
|
18
|
+
"./navigation": {
|
|
19
|
+
"import": "./dist/navigation/index.js",
|
|
20
|
+
"types": "./src/navigation/index.ts"
|
|
21
|
+
},
|
|
22
|
+
"./overlays": {
|
|
23
|
+
"import": "./dist/overlays/index.js",
|
|
24
|
+
"types": "./src/overlays/index.ts"
|
|
25
|
+
},
|
|
26
|
+
"./domain": {
|
|
27
|
+
"import": "./dist/domain/index.js",
|
|
28
|
+
"types": "./src/domain/index.ts"
|
|
29
|
+
},
|
|
30
|
+
"./composables": {
|
|
31
|
+
"import": "./dist/composables/index.js",
|
|
32
|
+
"types": "./src/composables/index.ts"
|
|
33
|
+
},
|
|
34
|
+
"./stores": {
|
|
35
|
+
"import": "./dist/stores/index.js",
|
|
36
|
+
"types": "./src/stores/index.ts"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"src",
|
|
41
|
+
"dist"
|
|
42
|
+
],
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "vite build",
|
|
45
|
+
"dev": "vite build --watch",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"test:watch": "vitest",
|
|
48
|
+
"prepublishOnly": "pnpm build",
|
|
49
|
+
"version:patch": "pnpm version patch --no-git-tag-version",
|
|
50
|
+
"version:minor": "pnpm version minor --no-git-tag-version",
|
|
51
|
+
"version:major": "pnpm version major --no-git-tag-version"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@hotelinking/ui": "^16.49.16",
|
|
55
|
+
"@htlkg/core": "^0.0.9",
|
|
56
|
+
"@htlkg/data": "^0.0.9",
|
|
57
|
+
"ajv": "^8.17.1",
|
|
58
|
+
"ajv-formats": "^3.0.1",
|
|
59
|
+
"vue": "^3.5.22"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@vitejs/plugin-vue": "^5.2.4",
|
|
66
|
+
"@vue/test-utils": "^2.4.6",
|
|
67
|
+
"typescript": "^5.9.2",
|
|
68
|
+
"vite": "^6.3.5",
|
|
69
|
+
"vitest": "^3.2.4"
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/data/Table.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, it, expect, vi
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
2
|
import { mount } from '@vue/test-utils';
|
|
3
3
|
import { nextTick } from 'vue';
|
|
4
4
|
import Table from './Table.vue';
|
|
@@ -8,55 +8,48 @@ import Table from './Table.vue';
|
|
|
8
8
|
* Tests user interactions, real-world scenarios, and component integration
|
|
9
9
|
*/
|
|
10
10
|
describe('Table integration tests', () => {
|
|
11
|
-
const
|
|
12
|
-
{ name: '
|
|
13
|
-
{ name: '
|
|
14
|
-
{ name: '
|
|
15
|
-
{ name: '
|
|
11
|
+
const mockHeader = [
|
|
12
|
+
{ name: 'id', label: 'ID', sortable: true },
|
|
13
|
+
{ name: 'name', label: 'Name', sortable: true },
|
|
14
|
+
{ name: 'email', label: 'Email', sortable: true },
|
|
15
|
+
{ name: 'status', label: 'Status', sortable: true }
|
|
16
16
|
];
|
|
17
17
|
|
|
18
18
|
const mockItems = [
|
|
19
|
-
{ id: 1,
|
|
20
|
-
{ id: 2,
|
|
21
|
-
{ id: 3,
|
|
22
|
-
{ id: 4,
|
|
23
|
-
{ id: 5,
|
|
19
|
+
{ id: 1, row: [1, 'John Doe', 'john@example.com', 'active'] },
|
|
20
|
+
{ id: 2, row: [2, 'Jane Smith', 'jane@example.com', 'inactive'] },
|
|
21
|
+
{ id: 3, row: [3, 'Bob Johnson', 'bob@example.com', 'active'] },
|
|
22
|
+
{ id: 4, row: [4, 'Alice Williams', 'alice@example.com', 'pending'] },
|
|
23
|
+
{ id: 5, row: [5, 'Charlie Brown', 'charlie@example.com', 'active'] }
|
|
24
24
|
];
|
|
25
25
|
|
|
26
26
|
const globalStubs = {
|
|
27
|
-
uiTable: true
|
|
28
|
-
uiPagination: true,
|
|
29
|
-
uiDropdown: true,
|
|
30
|
-
uiSmartFilterMultipleV2: true,
|
|
31
|
-
uiNoResults: true
|
|
27
|
+
uiTable: true
|
|
32
28
|
};
|
|
33
29
|
|
|
34
30
|
describe('User List Management', () => {
|
|
35
|
-
it('should
|
|
31
|
+
it('should accept items and header props', async () => {
|
|
36
32
|
const wrapper = mount(Table, {
|
|
37
33
|
props: {
|
|
38
34
|
items: mockItems,
|
|
39
|
-
|
|
35
|
+
header: mockHeader,
|
|
40
36
|
currentPage: 1,
|
|
41
37
|
totalPages: 2,
|
|
42
38
|
totalItems: 5,
|
|
43
|
-
|
|
44
|
-
showPagination: true
|
|
39
|
+
pageSize: 10
|
|
45
40
|
},
|
|
46
41
|
global: { stubs: globalStubs }
|
|
47
42
|
});
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
expect(
|
|
51
|
-
expect(vm.showTable).toBe(true);
|
|
52
|
-
expect(vm.showPagination).toBe(true);
|
|
44
|
+
expect(wrapper.props('items')).toHaveLength(5);
|
|
45
|
+
expect(wrapper.props('header')).toHaveLength(4);
|
|
53
46
|
});
|
|
54
47
|
|
|
55
|
-
it('should handle sorting
|
|
48
|
+
it('should handle sorting events', async () => {
|
|
56
49
|
const wrapper = mount(Table, {
|
|
57
50
|
props: {
|
|
58
51
|
items: mockItems,
|
|
59
|
-
|
|
52
|
+
header: mockHeader,
|
|
60
53
|
orderedBy: '',
|
|
61
54
|
orderDirection: 'asc'
|
|
62
55
|
},
|
|
@@ -69,14 +62,14 @@ describe('Table integration tests', () => {
|
|
|
69
62
|
|
|
70
63
|
expect(wrapper.emitted('update:orderedBy')?.[0]).toEqual(['name']);
|
|
71
64
|
expect(wrapper.emitted('update:orderDirection')?.[0]).toEqual(['desc']);
|
|
72
|
-
expect(wrapper.emitted('order-
|
|
65
|
+
expect(wrapper.emitted('order-by')?.[0]).toEqual([{ value: 'name', orderDirection: 'desc' }]);
|
|
73
66
|
});
|
|
74
67
|
|
|
75
68
|
it('should handle page navigation', async () => {
|
|
76
69
|
const wrapper = mount(Table, {
|
|
77
70
|
props: {
|
|
78
71
|
items: mockItems,
|
|
79
|
-
|
|
72
|
+
header: mockHeader,
|
|
80
73
|
currentPage: 1,
|
|
81
74
|
totalPages: 3
|
|
82
75
|
},
|
|
@@ -84,13 +77,13 @@ describe('Table integration tests', () => {
|
|
|
84
77
|
});
|
|
85
78
|
|
|
86
79
|
const vm = wrapper.vm as any;
|
|
87
|
-
|
|
80
|
+
|
|
88
81
|
// Navigate to page 2
|
|
89
82
|
vm.handleChangePage(2);
|
|
90
83
|
await nextTick();
|
|
91
84
|
|
|
92
85
|
expect(wrapper.emitted('update:currentPage')?.[0]).toEqual([2]);
|
|
93
|
-
expect(wrapper.emitted('page
|
|
86
|
+
expect(wrapper.emitted('change-page')?.[0]).toEqual([2]);
|
|
94
87
|
|
|
95
88
|
// Navigate to page 3
|
|
96
89
|
vm.handleChangePage(3);
|
|
@@ -103,20 +96,20 @@ describe('Table integration tests', () => {
|
|
|
103
96
|
const wrapper = mount(Table, {
|
|
104
97
|
props: {
|
|
105
98
|
items: mockItems,
|
|
106
|
-
|
|
99
|
+
header: mockHeader,
|
|
107
100
|
currentPage: 3,
|
|
108
|
-
|
|
101
|
+
pageSize: 10
|
|
109
102
|
},
|
|
110
103
|
global: { stubs: globalStubs }
|
|
111
104
|
});
|
|
112
105
|
|
|
113
106
|
const vm = wrapper.vm as any;
|
|
114
|
-
vm.handleChangePageSize(
|
|
107
|
+
vm.handleChangePageSize(25);
|
|
115
108
|
await nextTick();
|
|
116
109
|
|
|
117
|
-
expect(wrapper.emitted('update:
|
|
110
|
+
expect(wrapper.emitted('update:pageSize')?.[0]).toEqual([25]);
|
|
118
111
|
expect(wrapper.emitted('update:currentPage')?.[0]).toEqual([1]);
|
|
119
|
-
expect(wrapper.emitted('
|
|
112
|
+
expect(wrapper.emitted('change-page-size')?.[0]).toEqual([25]);
|
|
120
113
|
});
|
|
121
114
|
});
|
|
122
115
|
|
|
@@ -125,7 +118,7 @@ describe('Table integration tests', () => {
|
|
|
125
118
|
const wrapper = mount(Table, {
|
|
126
119
|
props: {
|
|
127
120
|
items: mockItems,
|
|
128
|
-
|
|
121
|
+
header: mockHeader
|
|
129
122
|
},
|
|
130
123
|
global: { stubs: globalStubs }
|
|
131
124
|
});
|
|
@@ -137,22 +130,19 @@ describe('Table integration tests', () => {
|
|
|
137
130
|
expect(vm.selectedItemIds.size).toBe(5);
|
|
138
131
|
expect(wrapper.emitted('select-all-items')).toBeDefined();
|
|
139
132
|
expect(wrapper.emitted('update:selected')).toBeDefined();
|
|
140
|
-
|
|
141
|
-
const selectedItems = wrapper.emitted('update:selected')?.[0]?.[0] as any[];
|
|
142
|
-
expect(selectedItems).toHaveLength(5);
|
|
143
133
|
});
|
|
144
134
|
|
|
145
135
|
it('should deselect all items', async () => {
|
|
146
136
|
const wrapper = mount(Table, {
|
|
147
137
|
props: {
|
|
148
138
|
items: mockItems,
|
|
149
|
-
|
|
139
|
+
header: mockHeader
|
|
150
140
|
},
|
|
151
141
|
global: { stubs: globalStubs }
|
|
152
142
|
});
|
|
153
143
|
|
|
154
144
|
const vm = wrapper.vm as any;
|
|
155
|
-
|
|
145
|
+
|
|
156
146
|
// First select all
|
|
157
147
|
vm.handleSelectAllItems();
|
|
158
148
|
await nextTick();
|
|
@@ -163,16 +153,13 @@ describe('Table integration tests', () => {
|
|
|
163
153
|
|
|
164
154
|
expect(vm.selectedItemIds.size).toBe(0);
|
|
165
155
|
expect(wrapper.emitted('deselect-all-items')).toBeDefined();
|
|
166
|
-
|
|
167
|
-
const selectedItems = wrapper.emitted('update:selected')?.slice(-1)[0]?.[0] as any[];
|
|
168
|
-
expect(selectedItems).toHaveLength(0);
|
|
169
156
|
});
|
|
170
157
|
|
|
171
158
|
it('should handle table action with selected items', async () => {
|
|
172
159
|
const wrapper = mount(Table, {
|
|
173
160
|
props: {
|
|
174
161
|
items: mockItems,
|
|
175
|
-
|
|
162
|
+
header: mockHeader,
|
|
176
163
|
actions: [
|
|
177
164
|
{ name: 'Delete', id: 'delete' },
|
|
178
165
|
{ name: 'Export', id: 'export' }
|
|
@@ -195,88 +182,57 @@ describe('Table integration tests', () => {
|
|
|
195
182
|
const wrapper = mount(Table, {
|
|
196
183
|
props: {
|
|
197
184
|
items: mockItems,
|
|
198
|
-
|
|
185
|
+
header: mockHeader
|
|
199
186
|
},
|
|
200
187
|
global: { stubs: globalStubs }
|
|
201
188
|
});
|
|
202
189
|
|
|
203
190
|
const vm = wrapper.vm as any;
|
|
204
|
-
|
|
191
|
+
|
|
205
192
|
// Select some items
|
|
206
193
|
vm.selectedItemIds = new Set([1, 2, 3]);
|
|
207
|
-
|
|
194
|
+
|
|
208
195
|
// Clear selection
|
|
209
196
|
vm.clearSelection();
|
|
210
197
|
await nextTick();
|
|
211
198
|
|
|
212
199
|
expect(vm.selectedItemIds.size).toBe(0);
|
|
213
|
-
expect(
|
|
200
|
+
expect(wrapper.emitted('update:resetSelected')?.[0]).toEqual([true]);
|
|
214
201
|
});
|
|
215
202
|
});
|
|
216
203
|
|
|
217
204
|
describe('Filtering and Search', () => {
|
|
218
205
|
it('should handle smart filter application', async () => {
|
|
219
|
-
const availableCategories = [
|
|
220
|
-
{
|
|
221
|
-
name: 'name',
|
|
222
|
-
label: 'Name',
|
|
223
|
-
componentType: 'uiInput' as const,
|
|
224
|
-
defaultProps: {}
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
name: 'status',
|
|
228
|
-
label: 'Status',
|
|
229
|
-
componentType: 'uiSelect' as const,
|
|
230
|
-
defaultProps: {}
|
|
231
|
-
}
|
|
232
|
-
];
|
|
233
|
-
|
|
234
206
|
const wrapper = mount(Table, {
|
|
235
207
|
props: {
|
|
236
208
|
items: mockItems,
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
209
|
+
header: mockHeader,
|
|
210
|
+
smartFilterCategories: [
|
|
211
|
+
{
|
|
212
|
+
id: 'name',
|
|
213
|
+
name: 'Name',
|
|
214
|
+
componentType: 'uiInput' as const,
|
|
215
|
+
defaultProps: {}
|
|
216
|
+
}
|
|
217
|
+
]
|
|
240
218
|
},
|
|
241
219
|
global: { stubs: globalStubs }
|
|
242
220
|
});
|
|
243
221
|
|
|
244
222
|
const vm = wrapper.vm as any;
|
|
245
223
|
const filters = { name: 'John', status: 'active' };
|
|
246
|
-
|
|
224
|
+
|
|
247
225
|
vm.handleSmartFiltersSent(filters);
|
|
248
226
|
await nextTick();
|
|
249
227
|
|
|
250
|
-
expect(vm.hasUserSearched).toBe(true);
|
|
251
228
|
expect(wrapper.emitted('smart-filters-sent')?.[0]).toEqual([filters]);
|
|
252
|
-
expect(wrapper.emitted('multiple-filters-applied')?.[0]).toEqual([filters]);
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
it('should show search no results after filtering', async () => {
|
|
256
|
-
const wrapper = mount(Table, {
|
|
257
|
-
props: {
|
|
258
|
-
items: [],
|
|
259
|
-
columns: mockColumns,
|
|
260
|
-
loading: false
|
|
261
|
-
},
|
|
262
|
-
global: { stubs: globalStubs }
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
const vm = wrapper.vm as any;
|
|
266
|
-
|
|
267
|
-
// Simulate user search
|
|
268
|
-
vm.handleSmartFiltersSent({ name: 'NonExistent' });
|
|
269
|
-
await nextTick();
|
|
270
|
-
|
|
271
|
-
expect(vm.showSearchNoResults).toBe(true);
|
|
272
|
-
expect(vm.showInitialNoResults).toBe(false);
|
|
273
229
|
});
|
|
274
230
|
|
|
275
231
|
it('should clear filters', async () => {
|
|
276
232
|
const wrapper = mount(Table, {
|
|
277
233
|
props: {
|
|
278
234
|
items: mockItems,
|
|
279
|
-
|
|
235
|
+
header: mockHeader
|
|
280
236
|
},
|
|
281
237
|
global: { stubs: globalStubs }
|
|
282
238
|
});
|
|
@@ -292,7 +248,7 @@ describe('Table integration tests', () => {
|
|
|
292
248
|
const wrapper = mount(Table, {
|
|
293
249
|
props: {
|
|
294
250
|
items: mockItems,
|
|
295
|
-
|
|
251
|
+
header: mockHeader
|
|
296
252
|
},
|
|
297
253
|
global: { stubs: globalStubs }
|
|
298
254
|
});
|
|
@@ -310,91 +266,60 @@ describe('Table integration tests', () => {
|
|
|
310
266
|
const wrapper = mount(Table, {
|
|
311
267
|
props: {
|
|
312
268
|
items: mockItems,
|
|
313
|
-
|
|
269
|
+
header: mockHeader
|
|
314
270
|
},
|
|
315
271
|
global: { stubs: globalStubs }
|
|
316
272
|
});
|
|
317
273
|
|
|
318
274
|
const vm = wrapper.vm as any;
|
|
319
|
-
|
|
275
|
+
|
|
320
276
|
// Hide column 1
|
|
321
277
|
vm.handleColumnsVisibilityChanged({ index: 1, hidden: true });
|
|
322
278
|
await nextTick();
|
|
323
279
|
|
|
324
|
-
expect(vm.
|
|
280
|
+
expect(vm.internalHiddenColumns).toContain(1);
|
|
325
281
|
expect(vm.getHiddenColumns()).toContain(1);
|
|
326
282
|
|
|
327
283
|
// Show column 1 again
|
|
328
284
|
vm.handleColumnsVisibilityChanged({ index: 1, hidden: false });
|
|
329
285
|
await nextTick();
|
|
330
286
|
|
|
331
|
-
expect(vm.
|
|
287
|
+
expect(vm.internalHiddenColumns).not.toContain(1);
|
|
332
288
|
});
|
|
333
289
|
|
|
334
290
|
it('should handle multiple hidden columns', async () => {
|
|
335
291
|
const wrapper = mount(Table, {
|
|
336
292
|
props: {
|
|
337
293
|
items: mockItems,
|
|
338
|
-
|
|
294
|
+
header: mockHeader
|
|
339
295
|
},
|
|
340
296
|
global: { stubs: globalStubs }
|
|
341
297
|
});
|
|
342
298
|
|
|
343
299
|
const vm = wrapper.vm as any;
|
|
344
|
-
|
|
300
|
+
|
|
345
301
|
// Hide multiple columns
|
|
346
302
|
vm.handleColumnsVisibilityChanged({ index: 0, hidden: true });
|
|
347
303
|
vm.handleColumnsVisibilityChanged({ index: 2, hidden: true });
|
|
348
304
|
await nextTick();
|
|
349
305
|
|
|
350
|
-
expect(vm.
|
|
351
|
-
expect(vm.
|
|
352
|
-
expect(vm.
|
|
306
|
+
expect(vm.internalHiddenColumns).toHaveLength(2);
|
|
307
|
+
expect(vm.internalHiddenColumns).toContain(0);
|
|
308
|
+
expect(vm.internalHiddenColumns).toContain(2);
|
|
353
309
|
});
|
|
354
310
|
});
|
|
355
311
|
|
|
356
312
|
describe('Empty States', () => {
|
|
357
|
-
it('should show initial no results when no data', async () => {
|
|
358
|
-
const wrapper = mount(Table, {
|
|
359
|
-
props: {
|
|
360
|
-
items: [],
|
|
361
|
-
columns: mockColumns,
|
|
362
|
-
loading: false
|
|
363
|
-
},
|
|
364
|
-
global: { stubs: globalStubs }
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
const vm = wrapper.vm as any;
|
|
368
|
-
expect(vm.showInitialNoResults).toBe(true);
|
|
369
|
-
expect(vm.showTable).toBe(false);
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
it('should show loading state', async () => {
|
|
373
|
-
const wrapper = mount(Table, {
|
|
374
|
-
props: {
|
|
375
|
-
items: [],
|
|
376
|
-
columns: mockColumns,
|
|
377
|
-
loading: true
|
|
378
|
-
},
|
|
379
|
-
global: { stubs: globalStubs }
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
const vm = wrapper.vm as any;
|
|
383
|
-
expect(vm.showTable).toBe(true);
|
|
384
|
-
expect(vm.showInitialNoResults).toBe(false);
|
|
385
|
-
});
|
|
386
|
-
|
|
387
313
|
it('should handle no results action', async () => {
|
|
388
314
|
const wrapper = mount(Table, {
|
|
389
315
|
props: {
|
|
390
316
|
items: [],
|
|
391
|
-
|
|
317
|
+
header: mockHeader,
|
|
392
318
|
loading: false,
|
|
393
319
|
noResults: {
|
|
394
320
|
title: 'No users found',
|
|
395
321
|
message: 'Create your first user',
|
|
396
|
-
actions: [{ action: 'create', text: 'Create User' }]
|
|
397
|
-
select: { name: '', value: '' }
|
|
322
|
+
actions: [{ action: 'create', text: 'Create User' }]
|
|
398
323
|
}
|
|
399
324
|
},
|
|
400
325
|
global: { stubs: globalStubs }
|
|
@@ -408,29 +333,12 @@ describe('Table integration tests', () => {
|
|
|
408
333
|
});
|
|
409
334
|
});
|
|
410
335
|
|
|
411
|
-
describe('
|
|
412
|
-
it('should handle refresh action', async () => {
|
|
413
|
-
const wrapper = mount(Table, {
|
|
414
|
-
props: {
|
|
415
|
-
items: mockItems,
|
|
416
|
-
columns: mockColumns,
|
|
417
|
-
showRefresh: true
|
|
418
|
-
},
|
|
419
|
-
global: { stubs: globalStubs }
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
const vm = wrapper.vm as any;
|
|
423
|
-
vm.handleDropdownAction({ value: 'refreshData' });
|
|
424
|
-
await nextTick();
|
|
425
|
-
|
|
426
|
-
expect(wrapper.emitted('refresh:data')).toBeDefined();
|
|
427
|
-
});
|
|
428
|
-
|
|
336
|
+
describe('Actions', () => {
|
|
429
337
|
it('should handle table action button click', async () => {
|
|
430
338
|
const wrapper = mount(Table, {
|
|
431
339
|
props: {
|
|
432
340
|
items: mockItems,
|
|
433
|
-
|
|
341
|
+
header: mockHeader,
|
|
434
342
|
tableActionButtons: [
|
|
435
343
|
{ id: 'export', text: 'Export' },
|
|
436
344
|
{ id: 'import', text: 'Import' }
|
|
@@ -452,7 +360,7 @@ describe('Table integration tests', () => {
|
|
|
452
360
|
const wrapper = mount(Table, {
|
|
453
361
|
props: {
|
|
454
362
|
items: mockItems,
|
|
455
|
-
|
|
363
|
+
header: mockHeader
|
|
456
364
|
},
|
|
457
365
|
global: { stubs: globalStubs }
|
|
458
366
|
});
|
|
@@ -468,42 +376,37 @@ describe('Table integration tests', () => {
|
|
|
468
376
|
});
|
|
469
377
|
|
|
470
378
|
describe('State Management', () => {
|
|
471
|
-
it('should
|
|
379
|
+
it('should initialize with provided hiddenColumns prop', async () => {
|
|
472
380
|
const wrapper = mount(Table, {
|
|
473
381
|
props: {
|
|
474
382
|
items: mockItems,
|
|
475
|
-
|
|
383
|
+
header: mockHeader,
|
|
384
|
+
hiddenColumns: [1, 2]
|
|
476
385
|
},
|
|
477
386
|
global: { stubs: globalStubs }
|
|
478
387
|
});
|
|
479
388
|
|
|
480
389
|
const vm = wrapper.vm as any;
|
|
481
|
-
vm.
|
|
482
|
-
|
|
483
|
-
// Change items
|
|
484
|
-
await wrapper.setProps({ items: mockItems.slice(0, 3) });
|
|
485
|
-
await nextTick();
|
|
486
|
-
|
|
487
|
-
expect(vm.resetSelected).toBe(false);
|
|
390
|
+
expect(vm.internalHiddenColumns).toEqual([1, 2]);
|
|
488
391
|
});
|
|
489
392
|
|
|
490
393
|
it('should maintain hidden columns across updates', async () => {
|
|
491
394
|
const wrapper = mount(Table, {
|
|
492
395
|
props: {
|
|
493
396
|
items: mockItems,
|
|
494
|
-
|
|
397
|
+
header: mockHeader
|
|
495
398
|
},
|
|
496
399
|
global: { stubs: globalStubs }
|
|
497
400
|
});
|
|
498
401
|
|
|
499
402
|
const vm = wrapper.vm as any;
|
|
500
403
|
vm.handleColumnsVisibilityChanged({ index: 1, hidden: true });
|
|
501
|
-
|
|
404
|
+
|
|
502
405
|
// Update items
|
|
503
406
|
await wrapper.setProps({ items: mockItems.slice(0, 2) });
|
|
504
407
|
await nextTick();
|
|
505
408
|
|
|
506
|
-
expect(vm.
|
|
409
|
+
expect(vm.internalHiddenColumns).toContain(1);
|
|
507
410
|
});
|
|
508
411
|
});
|
|
509
412
|
|
|
@@ -512,16 +415,14 @@ describe('Table integration tests', () => {
|
|
|
512
415
|
const wrapper = mount(Table, {
|
|
513
416
|
props: {
|
|
514
417
|
items: mockItems,
|
|
515
|
-
|
|
418
|
+
header: mockHeader,
|
|
516
419
|
currentPage: 1,
|
|
517
420
|
totalPages: 2,
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
showFilters: true,
|
|
521
|
-
availableCategories: [
|
|
421
|
+
pageSize: 10,
|
|
422
|
+
smartFilterCategories: [
|
|
522
423
|
{
|
|
523
|
-
|
|
524
|
-
|
|
424
|
+
id: 'status',
|
|
425
|
+
name: 'Status',
|
|
525
426
|
componentType: 'uiSelect' as const,
|
|
526
427
|
defaultProps: {}
|
|
527
428
|
}
|
|
@@ -540,7 +441,7 @@ describe('Table integration tests', () => {
|
|
|
540
441
|
// 2. Sort by name
|
|
541
442
|
vm.handleOrderBy({ value: 'name', orderDirection: 'asc' });
|
|
542
443
|
await nextTick();
|
|
543
|
-
expect(wrapper.emitted('order-
|
|
444
|
+
expect(wrapper.emitted('order-by')).toBeDefined();
|
|
544
445
|
|
|
545
446
|
// 3. Select items
|
|
546
447
|
vm.handleSelectAllItems();
|
|
@@ -555,8 +456,7 @@ describe('Table integration tests', () => {
|
|
|
555
456
|
// 5. Change page
|
|
556
457
|
vm.handleChangePage(2);
|
|
557
458
|
await nextTick();
|
|
558
|
-
expect(wrapper.emitted('page
|
|
559
|
-
expect(vm.resetSelected).toBe(true);
|
|
459
|
+
expect(wrapper.emitted('change-page')).toBeDefined();
|
|
560
460
|
});
|
|
561
461
|
});
|
|
562
462
|
});
|