@mhjuma/traverse 0.1.0

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.
Files changed (90) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +46 -0
  3. package/src/bootstrap.spec.tsx +290 -0
  4. package/src/bootstrap.tsx +195 -0
  5. package/src/colors.ts +23 -0
  6. package/src/components/ChartPanel/ChartPanel.logic.spec.ts +358 -0
  7. package/src/components/ChartPanel/ChartPanel.logic.ts +318 -0
  8. package/src/components/ChartPanel/ChartPanel.spec.tsx +331 -0
  9. package/src/components/ChartPanel/ChartPanel.styles.ts +14 -0
  10. package/src/components/ChartPanel/ChartPanel.tsx +151 -0
  11. package/src/components/ConnectionDialog/ConnectionDialog.spec.tsx +767 -0
  12. package/src/components/ConnectionDialog/ConnectionDialog.tsx +652 -0
  13. package/src/components/ConnectionDialog/ConnectionRow.spec.tsx +104 -0
  14. package/src/components/ConnectionDialog/ConnectionRow.tsx +177 -0
  15. package/src/components/EditorToolbar/EditorToolbar.spec.tsx +599 -0
  16. package/src/components/EditorToolbar/EditorToolbar.tsx +259 -0
  17. package/src/components/Explorer/Explorer.spec.tsx +615 -0
  18. package/src/components/Explorer/Explorer.tsx +49 -0
  19. package/src/components/ExplorerWorkspace/ExplorerWorkspace.logic.spec.ts +715 -0
  20. package/src/components/ExplorerWorkspace/ExplorerWorkspace.logic.ts +324 -0
  21. package/src/components/ExplorerWorkspace/ExplorerWorkspace.spec.tsx +450 -0
  22. package/src/components/ExplorerWorkspace/ExplorerWorkspace.styles.ts +478 -0
  23. package/src/components/ExplorerWorkspace/ExplorerWorkspace.tsx +648 -0
  24. package/src/components/ExplorerWorkspace/kqlLanguage.spec.ts +321 -0
  25. package/src/components/ExplorerWorkspace/kqlLanguage.ts +155 -0
  26. package/src/components/ResultsPanel/ElapsedTimer.spec.tsx +51 -0
  27. package/src/components/ResultsPanel/ElapsedTimer.tsx +15 -0
  28. package/src/components/ResultsPanel/HistoryItem.spec.tsx +123 -0
  29. package/src/components/ResultsPanel/HistoryItem.tsx +56 -0
  30. package/src/components/ResultsPanel/ResultSetTab.tsx +18 -0
  31. package/src/components/ResultsPanel/ResultsPanel.spec.tsx +1194 -0
  32. package/src/components/ResultsPanel/ResultsPanel.tsx +321 -0
  33. package/src/components/ResultsPanel/TabButton.tsx +11 -0
  34. package/src/components/ResultsTable/ColumnHeader.tsx +42 -0
  35. package/src/components/ResultsTable/ColumnPickerItem.tsx +16 -0
  36. package/src/components/ResultsTable/FilterCell.tsx +24 -0
  37. package/src/components/ResultsTable/ResultsTable.logic.spec.ts +655 -0
  38. package/src/components/ResultsTable/ResultsTable.logic.ts +264 -0
  39. package/src/components/ResultsTable/ResultsTable.spec.tsx +930 -0
  40. package/src/components/ResultsTable/ResultsTable.styles.ts +108 -0
  41. package/src/components/ResultsTable/ResultsTable.tsx +501 -0
  42. package/src/components/ResultsTable/VirtualCell.spec.tsx +55 -0
  43. package/src/components/ResultsTable/VirtualCell.tsx +32 -0
  44. package/src/components/ResultsTable/VirtualRow.tsx +55 -0
  45. package/src/components/SchemaSidebar/FolderRow.tsx +35 -0
  46. package/src/components/SchemaSidebar/SchemaColumnItem.tsx +41 -0
  47. package/src/components/SchemaSidebar/SchemaContextMenu.spec.tsx +148 -0
  48. package/src/components/SchemaSidebar/SchemaContextMenu.tsx +49 -0
  49. package/src/components/SchemaSidebar/SchemaSidebar.logic.spec.ts +230 -0
  50. package/src/components/SchemaSidebar/SchemaSidebar.logic.ts +74 -0
  51. package/src/components/SchemaSidebar/SchemaSidebar.spec.tsx +1111 -0
  52. package/src/components/SchemaSidebar/SchemaSidebar.tsx +244 -0
  53. package/src/components/SchemaSidebar/SchemaTableItem.tsx +77 -0
  54. package/src/components/TabBar/TabBar.logic.spec.ts +127 -0
  55. package/src/components/TabBar/TabBar.logic.ts +35 -0
  56. package/src/components/TabBar/TabBar.spec.tsx +929 -0
  57. package/src/components/TabBar/TabBar.tsx +284 -0
  58. package/src/components/TabBar/TabItem.tsx +166 -0
  59. package/src/components/VegaChart/VegaChart.spec.tsx +126 -0
  60. package/src/components/VegaChart/VegaChart.tsx +224 -0
  61. package/src/config.spec.ts +44 -0
  62. package/src/config.ts +47 -0
  63. package/src/context/ExplorerColorContext.ts +14 -0
  64. package/src/context/ExplorerStateContext.ts +49 -0
  65. package/src/context/KustoClientContext.ts +12 -0
  66. package/src/context/context.spec.tsx +183 -0
  67. package/src/index.ts +14 -0
  68. package/src/services/cache.spec.ts +31 -0
  69. package/src/services/cache.ts +16 -0
  70. package/src/services/concurrency.spec.ts +139 -0
  71. package/src/services/concurrency.ts +46 -0
  72. package/src/services/kusto.spec.ts +919 -0
  73. package/src/services/kusto.ts +472 -0
  74. package/src/services/queryHistory.spec.ts +287 -0
  75. package/src/services/queryHistory.ts +146 -0
  76. package/src/services/schema.spec.ts +618 -0
  77. package/src/services/schema.ts +294 -0
  78. package/src/services/state-service.spec.ts +670 -0
  79. package/src/services/state-service.ts +602 -0
  80. package/src/services/useKustoQuery.spec.ts +234 -0
  81. package/src/services/useKustoQuery.ts +124 -0
  82. package/src/state/actions.ts +50 -0
  83. package/src/state/index.ts +3 -0
  84. package/src/state/reducer.spec.ts +644 -0
  85. package/src/state/reducer.ts +207 -0
  86. package/src/state/types.ts +54 -0
  87. package/tsconfig.json +7 -0
  88. package/tsconfig.lint.json +4 -0
  89. package/tsconfig.spec.json +7 -0
  90. package/vitest.config.ts +34 -0
@@ -0,0 +1,1111 @@
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
+ import React from 'react';
3
+ import { createRoot } from 'react-dom/client';
4
+ import { act } from 'react';
5
+ import { SchemaSidebar } from './SchemaSidebar';
6
+ import { Input } from '@fluentui/react-components';
7
+
8
+ vi.mock('../../context/ExplorerColorContext', () => ({
9
+ useExplorerColors: () => ({
10
+ semantic: { functionBadge: '#fn', materializedViewBadge: '#mv', lookupBadge: '#lu', backdrop: '#000', shadowMedium: '#000', shadowLight: '#000', scrollThumb: '#ccc', scrollThumbHover: '#aaa', selectionBg: '#00f', selectionSubtle: '#eef', highlightHoverBg: '#ffa' },
11
+ chart: { palette: [] },
12
+ }),
13
+ }));
14
+ vi.mock('../ExplorerWorkspace/ExplorerWorkspace.styles', () => ({
15
+ useExplorerStyles: () => new Proxy({}, { get: (_, p) => String(p) }),
16
+ }));
17
+ vi.mock('@fluentui/react-components', () => ({
18
+ Input: vi.fn((p: Record<string, unknown>) => React.createElement('input', p)),
19
+ Button: (p: Record<string, unknown>) => React.createElement('button', p, p['children'] as React.ReactNode),
20
+ Tooltip: (p: Record<string, unknown>) => React.createElement('div', null, p['children'] as React.ReactNode),
21
+ Spinner: () => React.createElement('span', null, 'loading'),
22
+ Menu: (p: Record<string, unknown>) => p['open'] ? React.createElement('div', null, p['children'] as React.ReactNode) : null,
23
+ MenuList: (p: Record<string, unknown>) => React.createElement('div', null, p['children'] as React.ReactNode),
24
+ MenuItem: (p: Record<string, unknown>) => React.createElement('div', { onClick: p['onClick'] as () => void, onKeyDown: (e: React.KeyboardEvent) => { if (e.key === 'Enter' || e.key === ' ') { (p['onClick'] as (() => void))?.(); } }, tabIndex: 0 }, p['children'] as React.ReactNode),
25
+ MenuPopover: (p: Record<string, unknown>) => React.createElement('div', null, p['children'] as React.ReactNode),
26
+ tokens: { colorBrandForeground1: '#brand' },
27
+ }));
28
+ vi.mock('@fluentui/react-icons', () => ({
29
+ FolderRegular: () => React.createElement('span', null, 'icon'),
30
+ FolderOpenRegular: () => React.createElement('span', null, 'icon'),
31
+ TableSimpleRegular: () => React.createElement('span', null, 'icon'),
32
+ ChevronRightRegular: () => React.createElement('span', null, 'icon'),
33
+ ChevronDownRegular: () => React.createElement('span', null, 'icon'),
34
+ SearchRegular: () => React.createElement('span', null, 'icon'),
35
+ DismissRegular: () => React.createElement('span', null, 'icon'),
36
+ TextAddRegular: () => React.createElement('span', null, 'icon'),
37
+ TableSearchRegular: () => React.createElement('span', null, 'icon'),
38
+ NumberSymbolRegular: () => React.createElement('span', null, 'icon'),
39
+ TextDescriptionRegular: () => React.createElement('span', null, 'icon'),
40
+ CalendarRegular: () => React.createElement('span', null, 'icon'),
41
+ }));
42
+
43
+ describe('SchemaSidebar', () => {
44
+ let container: HTMLDivElement;
45
+ let root: ReturnType<typeof createRoot>;
46
+ let consoleErrorSpy: ReturnType<typeof vi.spyOn>;
47
+ let consoleWarnSpy: ReturnType<typeof vi.spyOn>;
48
+
49
+ beforeEach(() => {
50
+ consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
51
+ consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
52
+ container = document.createElement('div');
53
+ document.body.appendChild(container);
54
+ root = createRoot(container);
55
+ });
56
+
57
+ afterEach(() => {
58
+ act(() => {
59
+ root.unmount();
60
+ });
61
+ container.remove();
62
+ consoleErrorSpy.mockRestore();
63
+ consoleWarnSpy.mockRestore();
64
+ });
65
+
66
+ it('renders with empty schema', () => {
67
+ act(() => {
68
+ root.render(React.createElement(SchemaSidebar, {
69
+ schema: [],
70
+ insertText: vi.fn(),
71
+ schemaContextRunQuery: vi.fn(),
72
+ }));
73
+ });
74
+ expect(container.innerHTML).not.toBe('');
75
+ });
76
+
77
+ it('renders with schema data', () => {
78
+ const schema = [
79
+ {
80
+ name: 'TestTable',
81
+ folder: 'Tables',
82
+ kind: 'table' as const,
83
+ description: 'A test table',
84
+ columns: [
85
+ { name: 'Id', type: 'int' },
86
+ { name: 'Name', type: 'string' },
87
+ ],
88
+ },
89
+ ];
90
+
91
+ act(() => {
92
+ root.render(React.createElement(SchemaSidebar, {
93
+ schema,
94
+ insertText: vi.fn(),
95
+ schemaContextRunQuery: vi.fn(),
96
+ }));
97
+ });
98
+ expect(container.innerHTML).not.toBe('');
99
+ });
100
+
101
+ it('renders folders and expands them on click', () => {
102
+ const schema = [
103
+ {
104
+ name: 'Events',
105
+ folder: 'Telemetry',
106
+ kind: 'table' as const,
107
+ description: 'Events table',
108
+ columns: [{ name: 'Timestamp', type: 'datetime' }, { name: 'Message', type: 'string' }],
109
+ },
110
+ {
111
+ name: 'Errors',
112
+ folder: 'Telemetry',
113
+ kind: 'table' as const,
114
+ description: 'Error logs',
115
+ columns: [{ name: 'ErrorId', type: 'int' }],
116
+ },
117
+ ];
118
+
119
+ act(() => {
120
+ root.render(React.createElement(SchemaSidebar, {
121
+ schema,
122
+ insertText: vi.fn(),
123
+ schemaContextRunQuery: vi.fn(),
124
+ }));
125
+ });
126
+ expect(container.textContent).toContain('Tables');
127
+
128
+ // Expand kind group
129
+ const kindGroup = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
130
+ (el) => el.textContent?.includes('Tables'),
131
+ ) as HTMLElement;
132
+ act(() => { kindGroup.click(); });
133
+ expect(container.textContent).toContain('Telemetry');
134
+
135
+ // Click folder to expand
136
+ const folderRow = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
137
+ (el) => el.textContent?.includes('Telemetry'),
138
+ ) as HTMLElement;
139
+ if (folderRow) {
140
+ act(() => { folderRow.click(); });
141
+ expect(container.textContent).toContain('Events');
142
+ expect(container.textContent).toContain('Errors');
143
+ }
144
+ });
145
+
146
+ it('expands a table to show columns', () => {
147
+ const schema = [
148
+ {
149
+ name: 'Users',
150
+ folder: 'Data',
151
+ kind: 'table' as const,
152
+ description: '',
153
+ columns: [{ name: 'UserId', type: 'guid' }, { name: 'UserName', type: 'string' }],
154
+ },
155
+ ];
156
+
157
+ act(() => {
158
+ root.render(React.createElement(SchemaSidebar, {
159
+ schema,
160
+ insertText: vi.fn(),
161
+ schemaContextRunQuery: vi.fn(),
162
+ }));
163
+ });
164
+
165
+ // Expand folder first
166
+ const folderEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
167
+ (el) => el.textContent?.includes('Data'),
168
+ ) as HTMLElement;
169
+ if (folderEl) {
170
+ act(() => { folderEl.click(); });
171
+ }
172
+
173
+ // Now expand the table
174
+ const tableEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
175
+ (el) => el.textContent?.includes('Users'),
176
+ ) as HTMLElement;
177
+ if (tableEl) {
178
+ act(() => { tableEl.click(); });
179
+ expect(container.textContent).toContain('UserId');
180
+ expect(container.textContent).toContain('UserName');
181
+ }
182
+ });
183
+
184
+ it('filters schema by search term', () => {
185
+ const schema = [
186
+ {
187
+ name: 'PageViews',
188
+ folder: 'Analytics',
189
+ kind: 'table' as const,
190
+ description: '',
191
+ columns: [{ name: 'Url', type: 'string' }],
192
+ },
193
+ {
194
+ name: 'CustomEvents',
195
+ folder: 'Analytics',
196
+ kind: 'table' as const,
197
+ description: '',
198
+ columns: [{ name: 'Name', type: 'string' }],
199
+ },
200
+ ];
201
+
202
+ act(() => {
203
+ root.render(React.createElement(SchemaSidebar, {
204
+ schema,
205
+ insertText: vi.fn(),
206
+ schemaContextRunQuery: vi.fn(),
207
+ }));
208
+ });
209
+
210
+ const input = container.querySelector('input') as HTMLInputElement;
211
+ if (input) {
212
+ act(() => {
213
+ const changeHandler = (input as unknown as { onChange?: (e: unknown, d: { value: string }) => void }).onChange;
214
+ if (changeHandler) {
215
+ changeHandler({}, { value: 'PageViews' });
216
+ }
217
+ });
218
+ }
219
+ });
220
+
221
+ it('renders function and materializedView icons', () => {
222
+ const schema = [
223
+ {
224
+ name: 'MyFunc',
225
+ folder: 'Functions',
226
+ kind: 'function' as const,
227
+ description: 'A function',
228
+ columns: [],
229
+ },
230
+ {
231
+ name: 'MyView',
232
+ folder: 'Views',
233
+ kind: 'materializedView' as const,
234
+ description: 'A view',
235
+ columns: [],
236
+ },
237
+ {
238
+ name: 'LookupTable',
239
+ folder: 'Lookup',
240
+ kind: 'table' as const,
241
+ description: 'A lookup',
242
+ columns: [{ name: 'Key', type: 'string' }],
243
+ },
244
+ ];
245
+
246
+ act(() => {
247
+ root.render(React.createElement(SchemaSidebar, {
248
+ schema,
249
+ insertText: vi.fn(),
250
+ schemaContextRunQuery: vi.fn(),
251
+ }));
252
+ });
253
+
254
+ // Click expand all button (toggleAll expands all folders AND tables)
255
+ const buttons = container.querySelectorAll('button');
256
+ const expandBtn = buttons[buttons.length - 1];
257
+ if (expandBtn) {
258
+ act(() => { expandBtn.click(); });
259
+ }
260
+
261
+ // After expand all, folders and tables should be visible
262
+ expect(container.textContent).toContain('MyFunc');
263
+ expect(container.textContent).toContain('fn');
264
+ expect(container.textContent).toContain('MV');
265
+ expect(container.textContent).toContain('LU');
266
+ });
267
+
268
+ it('inserts text when a column is clicked', () => {
269
+ const insertText = vi.fn();
270
+ const schema = [
271
+ {
272
+ name: 'Events',
273
+ folder: 'Tables',
274
+ kind: 'table' as const,
275
+ description: '',
276
+ columns: [{ name: 'Timestamp', type: 'datetime' }],
277
+ },
278
+ ];
279
+
280
+ act(() => {
281
+ root.render(React.createElement(SchemaSidebar, {
282
+ schema,
283
+ insertText,
284
+ schemaContextRunQuery: vi.fn(),
285
+ }));
286
+ });
287
+
288
+ // Expand folder
289
+ const folderEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
290
+ (el) => el.textContent?.includes('Tables'),
291
+ ) as HTMLElement;
292
+ if (folderEl) {
293
+ act(() => { folderEl.click(); });
294
+ }
295
+
296
+ // Expand table
297
+ const tableEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
298
+ (el) => el.textContent?.includes('Events'),
299
+ ) as HTMLElement;
300
+ if (tableEl) {
301
+ act(() => { tableEl.click(); });
302
+ }
303
+
304
+ // Click column
305
+ const colEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
306
+ (el) => el.textContent?.includes('Timestamp'),
307
+ ) as HTMLElement;
308
+ if (colEl) {
309
+ act(() => { colEl.click(); });
310
+ expect(insertText).toHaveBeenCalledWith('Timestamp');
311
+ }
312
+ });
313
+
314
+ it('shows context menu on right-click of table', () => {
315
+ const schemaContextRunQuery = vi.fn();
316
+ const schema = [
317
+ {
318
+ name: 'Events',
319
+ folder: 'Tables',
320
+ kind: 'table' as const,
321
+ description: '',
322
+ columns: [{ name: 'Id', type: 'int' }],
323
+ },
324
+ ];
325
+
326
+ act(() => {
327
+ root.render(React.createElement(SchemaSidebar, {
328
+ schema,
329
+ insertText: vi.fn(),
330
+ schemaContextRunQuery,
331
+ }));
332
+ });
333
+
334
+ // Expand folder
335
+ const folderEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
336
+ (el) => el.textContent?.includes('Tables'),
337
+ ) as HTMLElement;
338
+ if (folderEl) {
339
+ act(() => { folderEl.click(); });
340
+ }
341
+
342
+ // Right-click table
343
+ const tableEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
344
+ (el) => el.textContent?.includes('Events'),
345
+ ) as HTMLElement;
346
+ if (tableEl) {
347
+ act(() => {
348
+ const ev = new MouseEvent('contextmenu', { bubbles: true, clientX: 100, clientY: 200 });
349
+ tableEl.dispatchEvent(ev);
350
+ });
351
+ expect(container.textContent).toContain('Insert name');
352
+ expect(container.textContent).toContain('Take 100');
353
+ expect(container.textContent).toContain('Count rows');
354
+ expect(container.textContent).toContain('Show schema');
355
+ expect(container.textContent).toContain('Date range');
356
+
357
+ // Click Take 100
358
+ const take100Btn = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
359
+ (el) => el.textContent === 'Take 100',
360
+ ) as HTMLElement;
361
+ if (take100Btn) {
362
+ act(() => { take100Btn.click(); });
363
+ expect(schemaContextRunQuery).toHaveBeenCalled();
364
+ }
365
+ }
366
+ });
367
+
368
+ it('handles toggle all expand/collapse', () => {
369
+ const schema = [
370
+ {
371
+ name: 'T1',
372
+ folder: 'F1',
373
+ kind: 'table' as const,
374
+ description: '',
375
+ columns: [{ name: 'C1', type: 'string' }],
376
+ },
377
+ ];
378
+
379
+ act(() => {
380
+ root.render(React.createElement(SchemaSidebar, {
381
+ schema,
382
+ insertText: vi.fn(),
383
+ schemaContextRunQuery: vi.fn(),
384
+ }));
385
+ });
386
+
387
+ // Click expand all
388
+ const buttons = container.querySelectorAll('button');
389
+ const expandAllBtn = buttons[buttons.length - 1];
390
+ if (expandAllBtn) {
391
+ act(() => { expandAllBtn.click(); });
392
+ expect(container.textContent).toContain('T1');
393
+ expect(container.textContent).toContain('C1');
394
+
395
+ // Click again to collapse all
396
+ act(() => { expandAllBtn.click(); });
397
+ }
398
+ });
399
+
400
+ it('toggles folder via keyboard Enter', () => {
401
+ const schema = [
402
+ {
403
+ name: 'Events',
404
+ folder: 'Telemetry',
405
+ kind: 'table' as const,
406
+ description: '',
407
+ columns: [{ name: 'Timestamp', type: 'datetime' }],
408
+ },
409
+ ];
410
+
411
+ act(() => {
412
+ root.render(React.createElement(SchemaSidebar, {
413
+ schema,
414
+ insertText: vi.fn(),
415
+ schemaContextRunQuery: vi.fn(),
416
+ }));
417
+ });
418
+
419
+ // Expand kind group first
420
+ const kindGroup = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
421
+ (el) => el.textContent?.includes('Tables'),
422
+ ) as HTMLElement;
423
+ act(() => { kindGroup.click(); });
424
+
425
+ const folderRow = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
426
+ (el) => el.textContent?.includes('Telemetry'),
427
+ ) as HTMLElement;
428
+ expect(folderRow).toBeTruthy();
429
+
430
+ act(() => {
431
+ folderRow.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
432
+ });
433
+ expect(container.textContent).toContain('Events');
434
+ });
435
+
436
+ it('toggles folder via keyboard Space', () => {
437
+ const schema = [
438
+ {
439
+ name: 'Events',
440
+ folder: 'Telemetry',
441
+ kind: 'table' as const,
442
+ description: '',
443
+ columns: [{ name: 'Timestamp', type: 'datetime' }],
444
+ },
445
+ ];
446
+
447
+ act(() => {
448
+ root.render(React.createElement(SchemaSidebar, {
449
+ schema,
450
+ insertText: vi.fn(),
451
+ schemaContextRunQuery: vi.fn(),
452
+ }));
453
+ });
454
+
455
+ // Expand kind group first
456
+ const kindGroup = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
457
+ (el) => el.textContent?.includes('Tables'),
458
+ ) as HTMLElement;
459
+ act(() => { kindGroup.click(); });
460
+
461
+ const folderRow = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
462
+ (el) => el.textContent?.includes('Telemetry'),
463
+ ) as HTMLElement;
464
+
465
+ act(() => {
466
+ folderRow.dispatchEvent(new KeyboardEvent('keydown', { key: ' ', bubbles: true }));
467
+ });
468
+ expect(container.textContent).toContain('Events');
469
+ });
470
+
471
+ it('toggles table via keyboard Enter', () => {
472
+ const schema = [
473
+ {
474
+ name: 'Users',
475
+ folder: 'Data',
476
+ kind: 'table' as const,
477
+ description: '',
478
+ columns: [{ name: 'UserId', type: 'guid' }],
479
+ },
480
+ ];
481
+
482
+ act(() => {
483
+ root.render(React.createElement(SchemaSidebar, {
484
+ schema,
485
+ insertText: vi.fn(),
486
+ schemaContextRunQuery: vi.fn(),
487
+ }));
488
+ });
489
+
490
+ // Expand kind group first
491
+ const kindGroup = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
492
+ (el) => el.textContent?.includes('Tables'),
493
+ ) as HTMLElement;
494
+ act(() => { kindGroup.click(); });
495
+
496
+ // Expand sub-folder
497
+ const folderEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
498
+ (el) => el.textContent?.includes('Data'),
499
+ ) as HTMLElement;
500
+ act(() => { folderEl.click(); });
501
+
502
+ // Toggle table via Enter
503
+ const tableEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
504
+ (el) => el.textContent?.includes('Users'),
505
+ ) as HTMLElement;
506
+ act(() => {
507
+ tableEl.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
508
+ });
509
+ expect(container.textContent).toContain('UserId');
510
+ });
511
+
512
+ it('inserts column text via keyboard Enter', () => {
513
+ const insertText = vi.fn();
514
+ const schema = [
515
+ {
516
+ name: 'Events',
517
+ folder: '',
518
+ kind: 'table' as const,
519
+ description: '',
520
+ columns: [{ name: 'Timestamp', type: 'datetime' }],
521
+ },
522
+ ];
523
+
524
+ act(() => {
525
+ root.render(React.createElement(SchemaSidebar, {
526
+ schema,
527
+ insertText,
528
+ schemaContextRunQuery: vi.fn(),
529
+ }));
530
+ });
531
+
532
+ // Expand folder
533
+ const folderEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
534
+ (el) => el.textContent?.includes('Tables'),
535
+ ) as HTMLElement;
536
+ act(() => { folderEl.click(); });
537
+
538
+ // Expand table
539
+ const tableEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
540
+ (el) => el.textContent?.includes('Events'),
541
+ ) as HTMLElement;
542
+ act(() => { tableEl.click(); });
543
+
544
+ // Press Enter on column
545
+ const colEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
546
+ (el) => el.textContent?.includes('Timestamp'),
547
+ ) as HTMLElement;
548
+ act(() => {
549
+ colEl.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
550
+ });
551
+ expect(insertText).toHaveBeenCalledWith('Timestamp');
552
+ });
553
+
554
+ it('inserts column text via keyboard Space', () => {
555
+ const insertText = vi.fn();
556
+ const schema = [
557
+ {
558
+ name: 'Events',
559
+ folder: '',
560
+ kind: 'table' as const,
561
+ description: '',
562
+ columns: [{ name: 'Col1', type: 'string' }],
563
+ },
564
+ ];
565
+
566
+ act(() => {
567
+ root.render(React.createElement(SchemaSidebar, {
568
+ schema,
569
+ insertText,
570
+ schemaContextRunQuery: vi.fn(),
571
+ }));
572
+ });
573
+
574
+ // Expand folder, table
575
+ const folderEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
576
+ (el) => el.textContent?.includes('Tables'),
577
+ ) as HTMLElement;
578
+ act(() => { folderEl.click(); });
579
+ const tableEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
580
+ (el) => el.textContent?.includes('Events'),
581
+ ) as HTMLElement;
582
+ act(() => { tableEl.click(); });
583
+
584
+ const colEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
585
+ (el) => el.textContent?.includes('Col1'),
586
+ ) as HTMLElement;
587
+ act(() => {
588
+ colEl.dispatchEvent(new KeyboardEvent('keydown', { key: ' ', bubbles: true }));
589
+ });
590
+ expect(insertText).toHaveBeenCalledWith('Col1');
591
+ });
592
+
593
+ it('handles table drag start', () => {
594
+ const schema = [
595
+ {
596
+ name: 'Events',
597
+ folder: '',
598
+ kind: 'table' as const,
599
+ description: '',
600
+ columns: [{ name: 'Id', type: 'int' }],
601
+ },
602
+ ];
603
+
604
+ act(() => {
605
+ root.render(React.createElement(SchemaSidebar, {
606
+ schema,
607
+ insertText: vi.fn(),
608
+ schemaContextRunQuery: vi.fn(),
609
+ }));
610
+ });
611
+
612
+ // Expand folder
613
+ const folderEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
614
+ (el) => el.textContent?.includes('Tables'),
615
+ ) as HTMLElement;
616
+ act(() => { folderEl.click(); });
617
+
618
+ const tableEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
619
+ (el) => el.textContent?.includes('Events'),
620
+ ) as HTMLElement;
621
+
622
+ let dragData = '';
623
+ const dragEvent = new Event('dragstart', { bubbles: true }) as unknown as DragEvent;
624
+ Object.defineProperty(dragEvent, 'dataTransfer', {
625
+ value: {
626
+ setData: (_: string, v: string) => { dragData = v; },
627
+ effectAllowed: '',
628
+ },
629
+ });
630
+ act(() => { tableEl.dispatchEvent(dragEvent); });
631
+ expect(dragData).toBe('Events');
632
+ });
633
+
634
+ it('handles column drag start', () => {
635
+ const schema = [
636
+ {
637
+ name: 'Events',
638
+ folder: '',
639
+ kind: 'table' as const,
640
+ description: '',
641
+ columns: [{ name: 'Timestamp', type: 'datetime' }],
642
+ },
643
+ ];
644
+
645
+ act(() => {
646
+ root.render(React.createElement(SchemaSidebar, {
647
+ schema,
648
+ insertText: vi.fn(),
649
+ schemaContextRunQuery: vi.fn(),
650
+ }));
651
+ });
652
+
653
+ // Expand folder, table
654
+ const folderEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
655
+ (el) => el.textContent?.includes('Tables'),
656
+ ) as HTMLElement;
657
+ act(() => { folderEl.click(); });
658
+ const tableEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
659
+ (el) => el.textContent?.includes('Events'),
660
+ ) as HTMLElement;
661
+ act(() => { tableEl.click(); });
662
+
663
+ const colEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
664
+ (el) => el.textContent?.includes('Timestamp'),
665
+ ) as HTMLElement;
666
+
667
+ let dragData = '';
668
+ const dragEvent = new Event('dragstart', { bubbles: true }) as unknown as DragEvent;
669
+ Object.defineProperty(dragEvent, 'dataTransfer', {
670
+ value: {
671
+ setData: (_: string, v: string) => { dragData = v; },
672
+ effectAllowed: '',
673
+ },
674
+ });
675
+ act(() => { colEl.dispatchEvent(dragEvent); });
676
+ expect(dragData).toBe('Timestamp');
677
+ });
678
+
679
+ it('handles context menu Insert name action', () => {
680
+ const insertText = vi.fn();
681
+ const schema = [
682
+ {
683
+ name: 'Events',
684
+ folder: '',
685
+ kind: 'table' as const,
686
+ description: '',
687
+ columns: [{ name: 'Id', type: 'int' }],
688
+ },
689
+ ];
690
+
691
+ act(() => {
692
+ root.render(React.createElement(SchemaSidebar, {
693
+ schema,
694
+ insertText,
695
+ schemaContextRunQuery: vi.fn(),
696
+ }));
697
+ });
698
+
699
+ // Expand folder
700
+ const folderEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
701
+ (el) => el.textContent?.includes('Tables'),
702
+ ) as HTMLElement;
703
+ act(() => { folderEl.click(); });
704
+
705
+ // Right-click table
706
+ const tableEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
707
+ (el) => el.textContent?.includes('Events'),
708
+ ) as HTMLElement;
709
+ act(() => {
710
+ tableEl.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, clientX: 10, clientY: 10 }));
711
+ });
712
+
713
+ // Click Insert name
714
+ const insertBtn = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
715
+ (el) => el.textContent === 'Insert name',
716
+ ) as HTMLElement;
717
+ act(() => { insertBtn.click(); });
718
+ expect(insertText).toHaveBeenCalledWith('Events');
719
+ });
720
+
721
+ it('handles context menu Count rows action', () => {
722
+ const schemaContextRunQuery = vi.fn();
723
+ const schema = [
724
+ {
725
+ name: 'Events',
726
+ folder: '',
727
+ kind: 'table' as const,
728
+ description: '',
729
+ columns: [{ name: 'Id', type: 'int' }],
730
+ },
731
+ ];
732
+
733
+ act(() => {
734
+ root.render(React.createElement(SchemaSidebar, {
735
+ schema,
736
+ insertText: vi.fn(),
737
+ schemaContextRunQuery,
738
+ }));
739
+ });
740
+
741
+ // Expand folder
742
+ const folderEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
743
+ (el) => el.textContent?.includes('Tables'),
744
+ ) as HTMLElement;
745
+ act(() => { folderEl.click(); });
746
+
747
+ // Right-click table
748
+ const tableEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
749
+ (el) => el.textContent?.includes('Events'),
750
+ ) as HTMLElement;
751
+ act(() => {
752
+ tableEl.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, clientX: 10, clientY: 10 }));
753
+ });
754
+
755
+ const countBtn = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
756
+ (el) => el.textContent === 'Count rows',
757
+ ) as HTMLElement;
758
+ act(() => { countBtn.click(); });
759
+ expect(schemaContextRunQuery).toHaveBeenCalledWith('Events\n| count');
760
+ });
761
+
762
+ it('handles context menu Show schema action', () => {
763
+ const schemaContextRunQuery = vi.fn();
764
+ const schema = [
765
+ {
766
+ name: 'Events',
767
+ folder: '',
768
+ kind: 'table' as const,
769
+ description: '',
770
+ columns: [{ name: 'Id', type: 'int' }],
771
+ },
772
+ ];
773
+
774
+ act(() => {
775
+ root.render(React.createElement(SchemaSidebar, {
776
+ schema,
777
+ insertText: vi.fn(),
778
+ schemaContextRunQuery,
779
+ }));
780
+ });
781
+
782
+ const folderEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
783
+ (el) => el.textContent?.includes('Tables'),
784
+ ) as HTMLElement;
785
+ act(() => { folderEl.click(); });
786
+
787
+ const tableEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
788
+ (el) => el.textContent?.includes('Events'),
789
+ ) as HTMLElement;
790
+ act(() => {
791
+ tableEl.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, clientX: 10, clientY: 10 }));
792
+ });
793
+
794
+ const showSchemaBtn = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
795
+ (el) => el.textContent === 'Show schema',
796
+ ) as HTMLElement;
797
+ act(() => { showSchemaBtn.click(); });
798
+ expect(schemaContextRunQuery).toHaveBeenCalledWith('Events\n| getschema');
799
+ });
800
+
801
+ it('handles context menu Date range action', () => {
802
+ const schemaContextRunQuery = vi.fn();
803
+ const schema = [
804
+ {
805
+ name: 'Events',
806
+ folder: '',
807
+ kind: 'table' as const,
808
+ description: '',
809
+ columns: [{ name: 'Id', type: 'int' }],
810
+ },
811
+ ];
812
+
813
+ act(() => {
814
+ root.render(React.createElement(SchemaSidebar, {
815
+ schema,
816
+ insertText: vi.fn(),
817
+ schemaContextRunQuery,
818
+ }));
819
+ });
820
+
821
+ const folderEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
822
+ (el) => el.textContent?.includes('Tables'),
823
+ ) as HTMLElement;
824
+ act(() => { folderEl.click(); });
825
+
826
+ const tableEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
827
+ (el) => el.textContent?.includes('Events'),
828
+ ) as HTMLElement;
829
+ act(() => {
830
+ tableEl.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, clientX: 10, clientY: 10 }));
831
+ });
832
+
833
+ const dateRangeBtn = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
834
+ (el) => el.textContent === 'Date range',
835
+ ) as HTMLElement;
836
+ act(() => { dateRangeBtn.click(); });
837
+ expect(schemaContextRunQuery).toHaveBeenCalledWith('Events\n| take 1000\n| summarize min(Timestamp), max(Timestamp)');
838
+ });
839
+
840
+ it('handles context menu item keyboard Enter', () => {
841
+ const schemaContextRunQuery = vi.fn();
842
+ const schema = [
843
+ {
844
+ name: 'Events',
845
+ folder: '',
846
+ kind: 'table' as const,
847
+ description: '',
848
+ columns: [{ name: 'Id', type: 'int' }],
849
+ },
850
+ ];
851
+
852
+ act(() => {
853
+ root.render(React.createElement(SchemaSidebar, {
854
+ schema,
855
+ insertText: vi.fn(),
856
+ schemaContextRunQuery,
857
+ }));
858
+ });
859
+
860
+ const folderEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
861
+ (el) => el.textContent?.includes('Tables'),
862
+ ) as HTMLElement;
863
+ act(() => { folderEl.click(); });
864
+
865
+ const tableEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
866
+ (el) => el.textContent?.includes('Events'),
867
+ ) as HTMLElement;
868
+ act(() => {
869
+ tableEl.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, clientX: 10, clientY: 10 }));
870
+ });
871
+
872
+ const countBtn = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
873
+ (el) => el.textContent === 'Count rows',
874
+ ) as HTMLElement;
875
+ act(() => {
876
+ countBtn.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
877
+ });
878
+ expect(schemaContextRunQuery).toHaveBeenCalledWith('Events\n| count');
879
+ });
880
+
881
+ it('groups tables without folder into Other', () => {
882
+ const schema = [
883
+ {
884
+ name: 'Orphan',
885
+ folder: '',
886
+ kind: 'table' as const,
887
+ description: '',
888
+ columns: [{ name: 'X', type: 'int' }],
889
+ },
890
+ ];
891
+
892
+ act(() => {
893
+ root.render(React.createElement(SchemaSidebar, {
894
+ schema,
895
+ insertText: vi.fn(),
896
+ schemaContextRunQuery: vi.fn(),
897
+ }));
898
+ });
899
+
900
+ expect(container.textContent).toContain('Tables');
901
+ });
902
+
903
+ it('filters schema by table name search and shows matching columns', () => {
904
+ // Override Input mock to properly forward onChange in Fluent UI format
905
+ vi.mocked(Input).mockImplementation(
906
+ ((p: Record<string, unknown>) => {
907
+ const onChange = p['onChange'] as ((e: unknown, d: { value: string }) => void) | undefined;
908
+ return React.createElement('input', {
909
+ 'data-testid': 'search-input',
910
+ value: p['value'],
911
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => {
912
+ onChange?.(e, { value: e.target.value });
913
+ },
914
+ });
915
+ }) as never,
916
+ );
917
+
918
+ const schema = [
919
+ {
920
+ name: 'Events',
921
+ folder: 'Data',
922
+ kind: 'table' as const,
923
+ description: '',
924
+ columns: [
925
+ { name: 'Timestamp', type: 'datetime' },
926
+ { name: 'Message', type: 'string' },
927
+ ],
928
+ },
929
+ {
930
+ name: 'Other',
931
+ folder: 'Data',
932
+ kind: 'table' as const,
933
+ description: '',
934
+ columns: [{ name: 'Id', type: 'int' }],
935
+ },
936
+ ];
937
+
938
+ act(() => {
939
+ root.render(React.createElement(SchemaSidebar, {
940
+ schema,
941
+ insertText: vi.fn(),
942
+ schemaContextRunQuery: vi.fn(),
943
+ }));
944
+ });
945
+
946
+ const input = container.querySelector('[data-testid="search-input"]') as HTMLInputElement;
947
+ act(() => {
948
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(input, 'Events');
949
+ input.dispatchEvent(new Event('change', { bubbles: true }));
950
+ });
951
+
952
+ // Filtered view should show only Events table
953
+ expect(container.textContent).toContain('Events');
954
+ });
955
+
956
+ it('filters schema by column name and highlights matching columns', () => {
957
+ vi.mocked(Input).mockImplementation(
958
+ ((p: Record<string, unknown>) => {
959
+ const onChange = p['onChange'] as ((e: unknown, d: { value: string }) => void) | undefined;
960
+ return React.createElement('input', {
961
+ 'data-testid': 'search-input',
962
+ value: p['value'],
963
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => {
964
+ onChange?.(e, { value: e.target.value });
965
+ },
966
+ });
967
+ }) as never,
968
+ );
969
+
970
+ const schema = [
971
+ {
972
+ name: 'Events',
973
+ folder: 'Data',
974
+ kind: 'table' as const,
975
+ description: '',
976
+ columns: [
977
+ { name: 'Timestamp', type: 'datetime' },
978
+ { name: 'Message', type: 'string' },
979
+ ],
980
+ },
981
+ ];
982
+
983
+ act(() => {
984
+ root.render(React.createElement(SchemaSidebar, {
985
+ schema,
986
+ insertText: vi.fn(),
987
+ schemaContextRunQuery: vi.fn(),
988
+ }));
989
+ });
990
+
991
+ const input = container.querySelector('[data-testid="search-input"]') as HTMLInputElement;
992
+ act(() => {
993
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(input, 'timestamp');
994
+ input.dispatchEvent(new Event('change', { bubbles: true }));
995
+ });
996
+
997
+ // Events table should appear because Timestamp column matches
998
+ expect(container.textContent).toContain('Events');
999
+ expect(container.textContent).toContain('Timestamp');
1000
+ });
1001
+
1002
+ it('clears search and returns to folder view', () => {
1003
+ vi.mocked(Input).mockImplementation(
1004
+ ((p: Record<string, unknown>) => {
1005
+ const onChange = p['onChange'] as ((e: unknown, d: { value: string }) => void) | undefined;
1006
+ const contentAfter = p['contentAfter'] as React.ReactNode;
1007
+ return React.createElement('div', null,
1008
+ React.createElement('input', {
1009
+ 'data-testid': 'search-input',
1010
+ value: p['value'],
1011
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => {
1012
+ onChange?.(e, { value: e.target.value });
1013
+ },
1014
+ }),
1015
+ contentAfter,
1016
+ );
1017
+ }) as never,
1018
+ );
1019
+
1020
+ const schema = [
1021
+ {
1022
+ name: 'Events',
1023
+ folder: 'Analytics',
1024
+ kind: 'table' as const,
1025
+ description: '',
1026
+ columns: [{ name: 'Id', type: 'int' }],
1027
+ },
1028
+ ];
1029
+
1030
+ act(() => {
1031
+ root.render(React.createElement(SchemaSidebar, {
1032
+ schema,
1033
+ insertText: vi.fn(),
1034
+ schemaContextRunQuery: vi.fn(),
1035
+ }));
1036
+ });
1037
+
1038
+ // Type search
1039
+ const input = container.querySelector('[data-testid="search-input"]') as HTMLInputElement;
1040
+ act(() => {
1041
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(input, 'Events');
1042
+ input.dispatchEvent(new Event('change', { bubbles: true }));
1043
+ });
1044
+
1045
+ // Should show filtered view
1046
+ expect(container.textContent).toContain('Events');
1047
+
1048
+ // Click the clear button (contentAfter renders a dismiss button)
1049
+ const clearBtns = container.querySelectorAll('button');
1050
+ const clearBtn = Array.from(clearBtns).find(b => b.querySelector('span'));
1051
+ if (clearBtn) {
1052
+ act(() => { clearBtn.click(); });
1053
+ }
1054
+ });
1055
+
1056
+ it('expands table in search results to show all columns', () => {
1057
+ vi.mocked(Input).mockImplementation(
1058
+ ((p: Record<string, unknown>) => {
1059
+ const onChange = p['onChange'] as ((e: unknown, d: { value: string }) => void) | undefined;
1060
+ return React.createElement('input', {
1061
+ 'data-testid': 'search-input',
1062
+ value: p['value'],
1063
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => {
1064
+ onChange?.(e, { value: e.target.value });
1065
+ },
1066
+ });
1067
+ }) as never,
1068
+ );
1069
+
1070
+ const schema = [
1071
+ {
1072
+ name: 'Events',
1073
+ folder: 'Data',
1074
+ kind: 'table' as const,
1075
+ description: '',
1076
+ columns: [
1077
+ { name: 'Timestamp', type: 'datetime' },
1078
+ { name: 'Source', type: 'string' },
1079
+ ],
1080
+ },
1081
+ ];
1082
+
1083
+ act(() => {
1084
+ root.render(React.createElement(SchemaSidebar, {
1085
+ schema,
1086
+ insertText: vi.fn(),
1087
+ schemaContextRunQuery: vi.fn(),
1088
+ }));
1089
+ });
1090
+
1091
+ // Search for a column name
1092
+ const input = container.querySelector('[data-testid="search-input"]') as HTMLInputElement;
1093
+ act(() => {
1094
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(input, 'Timestamp');
1095
+ input.dispatchEvent(new Event('change', { bubbles: true }));
1096
+ });
1097
+
1098
+ // Timestamp is a matching column, should be visible
1099
+ expect(container.textContent).toContain('Timestamp');
1100
+
1101
+ // Now click the table to expand and show all columns
1102
+ const tableEl = Array.from(container.querySelectorAll('[tabindex="0"]')).find(
1103
+ (el) => el.textContent?.includes('Events'),
1104
+ ) as HTMLElement;
1105
+ if (tableEl) {
1106
+ act(() => { tableEl.click(); });
1107
+ // After expanding, both columns should be visible
1108
+ expect(container.textContent).toContain('Source');
1109
+ }
1110
+ });
1111
+ });