kempo-ui 0.0.36 → 0.0.37
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 +2 -2
- package/src/components/Table.js +2 -1
- package/src/components/tableControls/PageSelect.js +20 -28
- package/tests/components/Accordion.browser-test.js +470 -0
- package/tests/components/Card.browser-test.js +286 -0
- package/tests/components/ColorPicker.browser-test.js +658 -0
- package/tests/components/ContentSlider.browser-test.js +495 -0
- package/tests/components/Dialog.browser-test.js +677 -0
- package/tests/components/FocusCapture.browser-test.js +187 -0
- package/tests/components/HybridComponent.browser-test.js +1 -1
- package/tests/components/Icon.browser-test.js +355 -0
- package/tests/components/Import.browser-test.js +312 -0
- package/tests/components/PhotoViewer.browser-test.js +640 -0
- package/tests/components/Resize.browser-test.js +553 -0
- package/tests/components/ShadowComponent.browser-test.js +3 -3
- package/tests/components/ShowMore.browser-test.js +618 -0
- package/tests/components/SideMenu.browser-test.js +667 -0
- package/tests/components/Sortable.browser-test.js +650 -0
- package/tests/components/Split.browser-test.js +629 -0
- package/tests/components/Table.browser-test.js +1119 -0
- package/tests/components/Tabs.browser-test.js +847 -0
- package/tests/components/Tags.browser-test.js +604 -0
- package/tests/components/ThemeSwitcher.browser-test.js +413 -0
- package/tests/components/Timestamp.browser-test.js +509 -0
- package/tests/components/Toast.browser-test.js +616 -0
- package/tests/components/Toggle.browser-test.js +557 -0
- package/tests/components/Tree.browser-test.js +790 -0
- package/tests/components/tableControls/ExportControls.browser-test.js +307 -0
- package/tests/components/tableControls/FieldSortHide.browser-test.js +347 -0
- package/tests/components/tableControls/Filters.browser-test.js +376 -0
- package/tests/components/tableControls/HiddenCount.browser-test.js +263 -0
- package/tests/components/tableControls/PaginationControls.browser-test.js +514 -0
- package/tests/components/tableControls/RecordControls.browser-test.js +360 -0
- package/tests/components/tableControls/Search.browser-test.js +283 -0
- package/tests/components/tableControls/TableControl.browser-test.js +300 -0
- package/tests/utils/context.test.js +224 -0
- package/tests/utils/cookie.browser-test.js +146 -0
- package/tests/utils/drag.browser-test.js +285 -0
- package/tests/utils/formatTimestamp.test.js +224 -0
- package/tests/utils/object.browser-test.js +378 -0
- package/tests/utils/propConverters.test.js +207 -0
- package/tests/utils/string.test.js +379 -0
- package/tests/utils/theme.browser-test.js +177 -0
- package/tests/utils/type.test.js +211 -0
- package/tests/utils/wait.browser-test.js +19 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import Import from '../../src/components/Import.js';
|
|
2
|
+
|
|
3
|
+
const createImport = async (options = {}) => {
|
|
4
|
+
const container = document.createElement('div');
|
|
5
|
+
container.innerHTML = `
|
|
6
|
+
<k-import
|
|
7
|
+
${options.src ? `src="${options.src}"` : ''}
|
|
8
|
+
></k-import>
|
|
9
|
+
`;
|
|
10
|
+
document.body.appendChild(container);
|
|
11
|
+
|
|
12
|
+
const importEl = container.querySelector('k-import');
|
|
13
|
+
await importEl.updateComplete;
|
|
14
|
+
|
|
15
|
+
return { container, importEl };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const cleanup = container => {
|
|
19
|
+
if(container && container.parentNode){
|
|
20
|
+
container.parentNode.removeChild(container);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default {
|
|
25
|
+
/*
|
|
26
|
+
Element Creation Tests
|
|
27
|
+
*/
|
|
28
|
+
'should create import element': async ({pass, fail}) => {
|
|
29
|
+
const { container, importEl } = await createImport();
|
|
30
|
+
|
|
31
|
+
if(!importEl){
|
|
32
|
+
cleanup(container);
|
|
33
|
+
fail('Import element should be created');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if(!(importEl instanceof Import)){
|
|
38
|
+
cleanup(container);
|
|
39
|
+
fail('Element should be instance of Import');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
cleanup(container);
|
|
44
|
+
pass('Import element created correctly');
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
'should extend LightComponent': async ({pass, fail}) => {
|
|
48
|
+
const { container, importEl } = await createImport();
|
|
49
|
+
|
|
50
|
+
// LightComponent doesn't use shadow root
|
|
51
|
+
if(importEl.shadowRoot){
|
|
52
|
+
cleanup(container);
|
|
53
|
+
fail('Import should not have shadow root (uses LightComponent)');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
cleanup(container);
|
|
58
|
+
pass('Import extends LightComponent (no shadow root)');
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
Property Tests
|
|
63
|
+
*/
|
|
64
|
+
'should have src property': async ({pass, fail}) => {
|
|
65
|
+
const { container, importEl } = await createImport({ src: '/test.html' });
|
|
66
|
+
|
|
67
|
+
if(importEl.src !== '/test.html'){
|
|
68
|
+
cleanup(container);
|
|
69
|
+
fail(`Expected src "/test.html", got "${importEl.src}"`);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
cleanup(container);
|
|
74
|
+
pass('src property set correctly');
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
'should reflect src to attribute': async ({pass, fail}) => {
|
|
78
|
+
const { container, importEl } = await createImport();
|
|
79
|
+
|
|
80
|
+
importEl.src = '/new-source.html';
|
|
81
|
+
await importEl.updateComplete;
|
|
82
|
+
|
|
83
|
+
if(importEl.getAttribute('src') !== '/new-source.html'){
|
|
84
|
+
cleanup(container);
|
|
85
|
+
fail(`Expected attribute "/new-source.html", got "${importEl.getAttribute('src')}"`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
cleanup(container);
|
|
90
|
+
pass('src reflects to attribute');
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
/*
|
|
94
|
+
Content Property Tests
|
|
95
|
+
*/
|
|
96
|
+
'should have content property': async ({pass, fail}) => {
|
|
97
|
+
const { container, importEl } = await createImport();
|
|
98
|
+
|
|
99
|
+
// Content should initially be empty string
|
|
100
|
+
if(importEl.content === undefined){
|
|
101
|
+
cleanup(container);
|
|
102
|
+
fail('Import should have content property');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
cleanup(container);
|
|
107
|
+
pass('content property exists');
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
'should have scripts property': async ({pass, fail}) => {
|
|
111
|
+
const { container, importEl } = await createImport();
|
|
112
|
+
|
|
113
|
+
if(!Array.isArray(importEl.scripts)){
|
|
114
|
+
cleanup(container);
|
|
115
|
+
fail('Import should have scripts array property');
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
cleanup(container);
|
|
120
|
+
pass('scripts property exists as array');
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
/*
|
|
124
|
+
Static Replacements Tests
|
|
125
|
+
*/
|
|
126
|
+
'should have static replacements object': async ({pass, fail}) => {
|
|
127
|
+
if(!Import.replacements || typeof Import.replacements !== 'object'){
|
|
128
|
+
fail('Import should have static replacements object');
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
pass('Static replacements object exists');
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
'should apply static replacements in fetch': async ({pass, fail}) => {
|
|
136
|
+
// This test verifies the replacement mechanism exists
|
|
137
|
+
const originalReplacements = { ...Import.replacements };
|
|
138
|
+
|
|
139
|
+
Import.replacements = { TEST_KEY: 'TEST_VALUE' };
|
|
140
|
+
|
|
141
|
+
// Restore after test
|
|
142
|
+
Import.replacements = originalReplacements;
|
|
143
|
+
|
|
144
|
+
pass('Static replacements mechanism exists');
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
/*
|
|
148
|
+
Method Tests
|
|
149
|
+
*/
|
|
150
|
+
'should have fetch method': async ({pass, fail}) => {
|
|
151
|
+
const { container, importEl } = await createImport();
|
|
152
|
+
|
|
153
|
+
if(typeof importEl.fetch !== 'function'){
|
|
154
|
+
cleanup(container);
|
|
155
|
+
fail('Import should have fetch method');
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
cleanup(container);
|
|
160
|
+
pass('fetch method exists');
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
'should have executeScripts method': async ({pass, fail}) => {
|
|
164
|
+
const { container, importEl } = await createImport();
|
|
165
|
+
|
|
166
|
+
if(typeof importEl.executeScripts !== 'function'){
|
|
167
|
+
cleanup(container);
|
|
168
|
+
fail('Import should have executeScripts method');
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
cleanup(container);
|
|
173
|
+
pass('executeScripts method exists');
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
'executeScripts should run scripts from scripts array': async ({pass, fail}) => {
|
|
177
|
+
const { container, importEl } = await createImport();
|
|
178
|
+
|
|
179
|
+
// Use a unique variable name to avoid conflicts between test runs
|
|
180
|
+
const uniqueVar = `__importTestVar_${Date.now()}`;
|
|
181
|
+
window[uniqueVar] = false;
|
|
182
|
+
|
|
183
|
+
// Set up the scripts array as the component would
|
|
184
|
+
importEl.scripts = [
|
|
185
|
+
{ text: `window.${uniqueVar} = true;`, type: 'text/javascript' }
|
|
186
|
+
];
|
|
187
|
+
|
|
188
|
+
importEl.executeScripts();
|
|
189
|
+
|
|
190
|
+
// Allow script to be added to head and execute
|
|
191
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
192
|
+
|
|
193
|
+
if(window[uniqueVar] !== true){
|
|
194
|
+
cleanup(container);
|
|
195
|
+
delete window[uniqueVar];
|
|
196
|
+
fail('Scripts should be executed from scripts array');
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
delete window[uniqueVar];
|
|
201
|
+
cleanup(container);
|
|
202
|
+
pass('executeScripts runs scripts from scripts array');
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
'executeScripts should clear scripts array after execution': async ({pass, fail}) => {
|
|
206
|
+
const { container, importEl } = await createImport();
|
|
207
|
+
|
|
208
|
+
importEl.scripts = [
|
|
209
|
+
{ text: 'var x = 1;', type: 'text/javascript' }
|
|
210
|
+
];
|
|
211
|
+
|
|
212
|
+
importEl.executeScripts();
|
|
213
|
+
|
|
214
|
+
// Allow script to execute
|
|
215
|
+
await new Promise(resolve => setTimeout(resolve, 10));
|
|
216
|
+
|
|
217
|
+
if(importEl.scripts.length !== 0){
|
|
218
|
+
cleanup(container);
|
|
219
|
+
fail('Scripts array should be cleared after execution');
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
cleanup(container);
|
|
224
|
+
pass('executeScripts clears scripts array');
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
/*
|
|
228
|
+
renderLightDom Tests
|
|
229
|
+
*/
|
|
230
|
+
'should have renderLightDom method': async ({pass, fail}) => {
|
|
231
|
+
const { container, importEl } = await createImport();
|
|
232
|
+
|
|
233
|
+
if(typeof importEl.renderLightDom !== 'function'){
|
|
234
|
+
cleanup(container);
|
|
235
|
+
fail('Import should have renderLightDom method');
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
cleanup(container);
|
|
240
|
+
pass('renderLightDom method exists');
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
'should render content to light DOM': async ({pass, fail}) => {
|
|
244
|
+
const { container, importEl } = await createImport();
|
|
245
|
+
|
|
246
|
+
importEl.content = '<div id="imported-content">Test Content</div>';
|
|
247
|
+
await importEl.updateComplete;
|
|
248
|
+
|
|
249
|
+
// Wait for light DOM render
|
|
250
|
+
await new Promise(resolve => setTimeout(resolve, 10));
|
|
251
|
+
|
|
252
|
+
const content = importEl.querySelector('#imported-content');
|
|
253
|
+
|
|
254
|
+
if(!content){
|
|
255
|
+
cleanup(container);
|
|
256
|
+
fail('Content should be rendered to light DOM');
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if(content.textContent !== 'Test Content'){
|
|
261
|
+
cleanup(container);
|
|
262
|
+
fail(`Expected "Test Content", got "${content.textContent}"`);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
cleanup(container);
|
|
267
|
+
pass('Content rendered to light DOM');
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
/*
|
|
271
|
+
Edge Case Tests
|
|
272
|
+
*/
|
|
273
|
+
'should handle empty src': async ({pass, fail}) => {
|
|
274
|
+
const { container, importEl } = await createImport();
|
|
275
|
+
|
|
276
|
+
try {
|
|
277
|
+
importEl.src = '';
|
|
278
|
+
await importEl.updateComplete;
|
|
279
|
+
} catch(e) {
|
|
280
|
+
cleanup(container);
|
|
281
|
+
fail(`Should not throw on empty src: ${e.message}`);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
cleanup(container);
|
|
286
|
+
pass('Handles empty src');
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
'should handle empty content': async ({pass, fail}) => {
|
|
290
|
+
const { container, importEl } = await createImport();
|
|
291
|
+
|
|
292
|
+
importEl.content = '';
|
|
293
|
+
await importEl.updateComplete;
|
|
294
|
+
|
|
295
|
+
// Should not throw, should just render nothing
|
|
296
|
+
cleanup(container);
|
|
297
|
+
pass('Handles empty content');
|
|
298
|
+
},
|
|
299
|
+
|
|
300
|
+
/*
|
|
301
|
+
CSS Display Tests
|
|
302
|
+
*/
|
|
303
|
+
'should display correctly': async ({pass, fail}) => {
|
|
304
|
+
const { container, importEl } = await createImport();
|
|
305
|
+
|
|
306
|
+
const style = window.getComputedStyle(importEl);
|
|
307
|
+
|
|
308
|
+
// LightComponent sets display: contents
|
|
309
|
+
cleanup(container);
|
|
310
|
+
pass('Import has appropriate display');
|
|
311
|
+
}
|
|
312
|
+
};
|