codecraftai-integration-runtime 1.3.0__py3-none-any.whl

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 (48) hide show
  1. ccai/integrationruntime/__init__.py +27 -0
  2. ccai/integrationruntime/entrypoints.py +59 -0
  3. ccai/integrationruntime/initialize.py +100 -0
  4. ccai/integrationruntime/integratedtestjob.py +100 -0
  5. ccai/integrationruntime/integrationruntimedefaulttypefactory.py +51 -0
  6. ccai/integrationruntime/py.typed +0 -0
  7. ccai/integrationruntime/results/__init__.py +13 -0
  8. ccai/integrationruntime/results/concentrators/__init__.py +13 -0
  9. ccai/integrationruntime/results/concentrators/progressconcentratorservice.py +526 -0
  10. ccai/integrationruntime/results/recorders/__init__.py +22 -0
  11. ccai/integrationruntime/results/recorders/integrationjsonresultrecorder.py +126 -0
  12. ccai/integrationruntime/results/recorders/streamingresultrecorder.py +271 -0
  13. ccai/integrationruntime/results/streaming/__init__.py +25 -0
  14. ccai/integrationruntime/results/streaming/resultstreamer.py +581 -0
  15. ccai/integrationruntime/runtimeoutputcontext.py +68 -0
  16. ccai/integrationruntime/runtimerunmetadata.py +165 -0
  17. ccai/integrationruntime/templates/v2/static/images/test-report-banner-background-image.png +0 -0
  18. ccai/integrationruntime/templates/v2/static/javascript/d3.v7.js +20625 -0
  19. ccai/integrationruntime/templates/v2/static/javascript/icon-components.js +510 -0
  20. ccai/integrationruntime/templates/v2/static/javascript/mojo-components.js +1417 -0
  21. ccai/integrationruntime/templates/v2/static/javascript/prism.js +1789 -0
  22. ccai/integrationruntime/templates/v2/static/javascript/testsummary-accessibility.js +704 -0
  23. ccai/integrationruntime/templates/v2/static/javascript/testsummary-comparison.js +1287 -0
  24. ccai/integrationruntime/templates/v2/static/javascript/testsummary-components.js +3499 -0
  25. ccai/integrationruntime/templates/v2/static/javascript/testsummary-helpers.js +426 -0
  26. ccai/integrationruntime/templates/v2/static/javascript/testsummary-responsive.js +493 -0
  27. ccai/integrationruntime/templates/v2/static/javascript/testsummary.js +1128 -0
  28. ccai/integrationruntime/templates/v2/static/javascript/webcomponent-helpers.js +112 -0
  29. ccai/integrationruntime/templates/v2/static/styles/branding-theme.css +144 -0
  30. ccai/integrationruntime/templates/v2/static/styles/icon-styles.css +9 -0
  31. ccai/integrationruntime/templates/v2/static/styles/mojo-components.css +384 -0
  32. ccai/integrationruntime/templates/v2/static/styles/prism.css +143 -0
  33. ccai/integrationruntime/templates/v2/static/styles/tabs-responsive.css +186 -0
  34. ccai/integrationruntime/templates/v2/static/styles/testsummary-accessibility.css +413 -0
  35. ccai/integrationruntime/templates/v2/static/styles/testsummary-comparison.css +746 -0
  36. ccai/integrationruntime/templates/v2/static/styles/testsummary-responsive.css +679 -0
  37. ccai/integrationruntime/templates/v2/static/styles/testsummary.css +1631 -0
  38. ccai/integrationruntime/templates/v2/tabs/tab-data.html +870 -0
  39. ccai/integrationruntime/templates/v2/tabs/tab-images.html +110 -0
  40. ccai/integrationruntime/templates/v2/tabs/tab-logs.html +594 -0
  41. ccai/integrationruntime/templates/v2/tabs/tab-sounds.html +112 -0
  42. ccai/integrationruntime/templates/v2/tabs/tab-timeseries.html +368 -0
  43. ccai/integrationruntime/templates/v2/tabs/tab-videos.html +372 -0
  44. ccai/integrationruntime/templates/v2/testsummary.html +81 -0
  45. codecraftai_integration_runtime-1.3.0.dist-info/METADATA +73 -0
  46. codecraftai_integration_runtime-1.3.0.dist-info/RECORD +48 -0
  47. codecraftai_integration_runtime-1.3.0.dist-info/WHEEL +4 -0
  48. codecraftai_integration_runtime-1.3.0.dist-info/licenses/LICENSE.md +204 -0
@@ -0,0 +1,704 @@
1
+ /*
2
+ Author: "Myron Walker"
3
+ Copyright: "Copyright 2024, Myron W Walker"
4
+ Version: = "2.0.0"
5
+ Email: myron.walker@gmail.com
6
+ */
7
+
8
+ /**
9
+ * @fileoverview Accessibility enhancements for the TestSummary HTML report.
10
+ * Provides ARIA labels, keyboard navigation, and screen reader compatibility.
11
+ * @module testsummary-accessibility
12
+ */
13
+
14
+ /**
15
+ * Flag indicating whether accessibility features have been initialized.
16
+ * @type {boolean}
17
+ * @private
18
+ */
19
+ let accessibilityInitialized = false;
20
+
21
+ /**
22
+ * Keyboard navigation key codes.
23
+ * @const {Object}
24
+ */
25
+ const KEYS = {
26
+ TAB: 'Tab',
27
+ ENTER: 'Enter',
28
+ SPACE: ' ',
29
+ ESCAPE: 'Escape',
30
+ ARROW_UP: 'ArrowUp',
31
+ ARROW_DOWN: 'ArrowDown',
32
+ ARROW_LEFT: 'ArrowLeft',
33
+ ARROW_RIGHT: 'ArrowRight',
34
+ HOME: 'Home',
35
+ END: 'End'
36
+ };
37
+
38
+ /**
39
+ * Initializes accessibility features for the test summary page.
40
+ * Should be called after the page content is loaded.
41
+ *
42
+ * @function init_accessibility
43
+ * @returns {void}
44
+ */
45
+ function init_accessibility() {
46
+ if (accessibilityInitialized) {
47
+ return;
48
+ }
49
+ accessibilityInitialized = true;
50
+
51
+ // Add skip link for keyboard users
52
+ addSkipLink();
53
+
54
+ // Set up landmark regions
55
+ setupLandmarkRegions();
56
+
57
+ // Initialize keyboard navigation
58
+ initKeyboardNavigation();
59
+
60
+ // Add ARIA labels to interactive elements
61
+ addAriaLabels();
62
+
63
+ // Set up focus management
64
+ setupFocusManagement();
65
+
66
+ // Add live region for dynamic content announcements
67
+ addLiveRegion();
68
+
69
+ console.log("Accessibility features initialized");
70
+ }
71
+
72
+ /**
73
+ * Adds a skip link at the top of the page for keyboard users to skip to main content.
74
+ *
75
+ * @function addSkipLink
76
+ * @returns {void}
77
+ */
78
+ function addSkipLink() {
79
+ // Check if skip link already exists
80
+ if (document.getElementById('skip-to-main')) {
81
+ return;
82
+ }
83
+
84
+ var skipLink = document.createElement('a');
85
+ skipLink.id = 'skip-to-main';
86
+ skipLink.href = '#testsummary-resultdetail';
87
+ skipLink.className = 'skip-link';
88
+ skipLink.textContent = 'Skip to main content';
89
+ skipLink.setAttribute('tabindex', '0');
90
+
91
+ // Insert at the beginning of body
92
+ document.body.insertBefore(skipLink, document.body.firstChild);
93
+
94
+ // Handle click to focus on main content
95
+ skipLink.addEventListener('click', function(event) {
96
+ event.preventDefault();
97
+ var mainContent = document.getElementById('testsummary-resultdetail');
98
+ if (mainContent) {
99
+ mainContent.setAttribute('tabindex', '-1');
100
+ mainContent.focus();
101
+ // Announce to screen readers
102
+ announceToScreenReader('Skipped to main content');
103
+ }
104
+ });
105
+ }
106
+
107
+ /**
108
+ * Sets up ARIA landmark regions for the page structure.
109
+ *
110
+ * @function setupLandmarkRegions
111
+ * @returns {void}
112
+ */
113
+ function setupLandmarkRegions() {
114
+ // Header section - banner landmark
115
+ var headerSection = document.querySelector('.section-header');
116
+ if (headerSection) {
117
+ headerSection.setAttribute('role', 'banner');
118
+ headerSection.setAttribute('aria-label', 'Test run summary banner');
119
+ }
120
+
121
+ // Body section - main landmark
122
+ var bodySection = document.querySelector('.section-body');
123
+ if (bodySection) {
124
+ bodySection.setAttribute('role', 'main');
125
+ bodySection.setAttribute('aria-label', 'Test results and configuration');
126
+ }
127
+
128
+ // Footer section - contentinfo landmark
129
+ var footerSection = document.querySelector('.section-footer');
130
+ if (footerSection) {
131
+ footerSection.setAttribute('role', 'contentinfo');
132
+ footerSection.setAttribute('aria-label', 'Files and folders navigation');
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Initializes keyboard navigation for interactive elements.
138
+ *
139
+ * @function initKeyboardNavigation
140
+ * @returns {void}
141
+ */
142
+ function initKeyboardNavigation() {
143
+ // Add keyboard handler for the document
144
+ document.addEventListener('keydown', handleGlobalKeydown);
145
+
146
+ // Set up keyboard navigation for collapsible elements
147
+ setupCollapsibleKeyboardNav();
148
+
149
+ // Set up keyboard navigation for tabs
150
+ setupTabKeyboardNav();
151
+
152
+ // Set up keyboard navigation for filter buttons
153
+ setupFilterKeyboardNav();
154
+ }
155
+
156
+ /**
157
+ * Handles global keyboard events for navigation.
158
+ *
159
+ * @function handleGlobalKeydown
160
+ * @param {KeyboardEvent} event - The keyboard event.
161
+ */
162
+ function handleGlobalKeydown(event) {
163
+ // Handle Escape key to close any open dialogs or return focus
164
+ if (event.key === KEYS.ESCAPE) {
165
+ var activeElement = document.activeElement;
166
+ if (activeElement && activeElement.closest('details[open]')) {
167
+ var details = activeElement.closest('details');
168
+ details.open = false;
169
+ details.querySelector('summary').focus();
170
+ }
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Sets up keyboard navigation for collapsible elements.
176
+ *
177
+ * @function setupCollapsibleKeyboardNav
178
+ * @returns {void}
179
+ */
180
+ function setupCollapsibleKeyboardNav() {
181
+ // Find all collapsible buttons in shadow DOMs
182
+ var collapsibles = document.querySelectorAll('mojo-collapsible, mojo-collapsible-lvl2, mojo-collapsible-lvl3');
183
+
184
+ collapsibles.forEach(function(collapsible) {
185
+ if (collapsible.shadowRoot) {
186
+ var button = collapsible.shadowRoot.querySelector('.mojo-collapsible-button, .mojo-collapsible-lvl2-button, .mojo-collapsible-lvl3-button');
187
+ if (button) {
188
+ // Make button focusable
189
+ button.setAttribute('tabindex', '0');
190
+ button.setAttribute('role', 'button');
191
+
192
+ // Add keyboard handler
193
+ button.addEventListener('keydown', function(event) {
194
+ if (event.key === KEYS.ENTER || event.key === KEYS.SPACE) {
195
+ event.preventDefault();
196
+ button.click();
197
+ }
198
+ });
199
+ }
200
+ }
201
+ });
202
+ }
203
+
204
+ /**
205
+ * Sets up keyboard navigation for tab components.
206
+ *
207
+ * @function setupTabKeyboardNav
208
+ * @returns {void}
209
+ */
210
+ function setupTabKeyboardNav() {
211
+ var tabsets = document.querySelectorAll('mojo-tabset');
212
+
213
+ tabsets.forEach(function(tabset) {
214
+ if (tabset.shadowRoot) {
215
+ var tabLabels = tabset.shadowRoot.querySelectorAll('.mojo-tab-label');
216
+
217
+ tabLabels.forEach(function(tabLabel, index) {
218
+ // Set up ARIA attributes
219
+ tabLabel.setAttribute('role', 'tab');
220
+ tabLabel.setAttribute('tabindex', index === 0 ? '0' : '-1');
221
+
222
+ // Add keyboard navigation
223
+ tabLabel.addEventListener('keydown', function(event) {
224
+ handleTabKeydown(event, tabLabels, index);
225
+ });
226
+ });
227
+
228
+ // Set up tab list container
229
+ var tabList = tabset.shadowRoot.querySelector('.mojo-tabset-label-collection');
230
+ if (tabList) {
231
+ tabList.setAttribute('role', 'tablist');
232
+ }
233
+
234
+ // Set up tab panels
235
+ var tabContents = tabset.shadowRoot.querySelectorAll('.mojo-tab-content');
236
+ tabContents.forEach(function(content, index) {
237
+ content.setAttribute('role', 'tabpanel');
238
+ content.setAttribute('tabindex', '0');
239
+ });
240
+ }
241
+ });
242
+ }
243
+
244
+ /**
245
+ * Handles keyboard events for tab navigation.
246
+ *
247
+ * @function handleTabKeydown
248
+ * @param {KeyboardEvent} event - The keyboard event.
249
+ * @param {NodeList} tabs - List of tab elements.
250
+ * @param {number} currentIndex - Current tab index.
251
+ */
252
+ function handleTabKeydown(event, tabs, currentIndex) {
253
+ var newIndex = currentIndex;
254
+
255
+ switch (event.key) {
256
+ case KEYS.ARROW_LEFT:
257
+ case KEYS.ARROW_UP:
258
+ event.preventDefault();
259
+ newIndex = currentIndex > 0 ? currentIndex - 1 : tabs.length - 1;
260
+ break;
261
+ case KEYS.ARROW_RIGHT:
262
+ case KEYS.ARROW_DOWN:
263
+ event.preventDefault();
264
+ newIndex = currentIndex < tabs.length - 1 ? currentIndex + 1 : 0;
265
+ break;
266
+ case KEYS.HOME:
267
+ event.preventDefault();
268
+ newIndex = 0;
269
+ break;
270
+ case KEYS.END:
271
+ event.preventDefault();
272
+ newIndex = tabs.length - 1;
273
+ break;
274
+ case KEYS.ENTER:
275
+ case KEYS.SPACE:
276
+ event.preventDefault();
277
+ tabs[currentIndex].click();
278
+ return;
279
+ default:
280
+ return;
281
+ }
282
+
283
+ // Update tabindex and focus
284
+ tabs[currentIndex].setAttribute('tabindex', '-1');
285
+ tabs[newIndex].setAttribute('tabindex', '0');
286
+ tabs[newIndex].focus();
287
+ tabs[newIndex].click();
288
+ }
289
+
290
+ /**
291
+ * Sets up keyboard navigation for filter buttons.
292
+ *
293
+ * @function setupFilterKeyboardNav
294
+ * @returns {void}
295
+ */
296
+ function setupFilterKeyboardNav() {
297
+ var resultDetail = document.getElementById('testsummary-resultdetail');
298
+ if (resultDetail && resultDetail.shadowRoot) {
299
+ var filterButtons = resultDetail.shadowRoot.querySelectorAll('.ts-filter-btn');
300
+
301
+ filterButtons.forEach(function(button, index) {
302
+ button.setAttribute('role', 'button');
303
+
304
+ button.addEventListener('keydown', function(event) {
305
+ if (event.key === KEYS.ARROW_LEFT || event.key === KEYS.ARROW_RIGHT) {
306
+ event.preventDefault();
307
+ var newIndex;
308
+ if (event.key === KEYS.ARROW_LEFT) {
309
+ newIndex = index > 0 ? index - 1 : filterButtons.length - 1;
310
+ } else {
311
+ newIndex = index < filterButtons.length - 1 ? index + 1 : 0;
312
+ }
313
+ filterButtons[newIndex].focus();
314
+ }
315
+ });
316
+ });
317
+ }
318
+ }
319
+
320
+ /**
321
+ * Adds ARIA labels to interactive elements throughout the page.
322
+ *
323
+ * @function addAriaLabels
324
+ * @returns {void}
325
+ */
326
+ function addAriaLabels() {
327
+ // Add ARIA labels to banner component
328
+ addBannerAriaLabels();
329
+
330
+ // Add ARIA labels to configuration component
331
+ addConfigurationAriaLabels();
332
+
333
+ // Add ARIA labels to result detail component
334
+ addResultDetailAriaLabels();
335
+
336
+ // Add ARIA labels to artifacts component
337
+ addArtifactsAriaLabels();
338
+
339
+ // Add ARIA labels to files and folders component
340
+ addFilesAndFoldersAriaLabels();
341
+ }
342
+
343
+ /**
344
+ * Adds ARIA labels to the banner component.
345
+ *
346
+ * @function addBannerAriaLabels
347
+ * @returns {void}
348
+ */
349
+ function addBannerAriaLabels() {
350
+ var banner = document.getElementById('testsummary-banner');
351
+ if (banner && banner.shadowRoot) {
352
+ var bannerEl = banner.shadowRoot.querySelector('.ts-banner');
353
+ if (bannerEl) {
354
+ bannerEl.setAttribute('role', 'region');
355
+ bannerEl.setAttribute('aria-label', 'Test run summary');
356
+ }
357
+
358
+ // Add labels to metrics
359
+ var metricsPanel = banner.shadowRoot.querySelector('.ts-banner-metrics-panel');
360
+ if (metricsPanel) {
361
+ metricsPanel.setAttribute('role', 'group');
362
+ metricsPanel.setAttribute('aria-label', 'Test result metrics');
363
+ }
364
+
365
+ // Add aria-live for dynamic metric updates
366
+ var metricValues = banner.shadowRoot.querySelectorAll('.ts-banner-metrics-value');
367
+ metricValues.forEach(function(value) {
368
+ value.setAttribute('aria-live', 'polite');
369
+ });
370
+ }
371
+ }
372
+
373
+ /**
374
+ * Adds ARIA labels to the configuration component.
375
+ *
376
+ * @function addConfigurationAriaLabels
377
+ * @returns {void}
378
+ */
379
+ function addConfigurationAriaLabels() {
380
+ var config = document.getElementById('testsummary-configuration');
381
+ if (config && config.shadowRoot) {
382
+ var configCard = config.shadowRoot.querySelector('.ts-configuration-card');
383
+ if (configCard) {
384
+ configCard.setAttribute('role', 'region');
385
+ configCard.setAttribute('aria-label', 'Test configuration');
386
+ }
387
+
388
+ // Add labels to collapsible sections
389
+ var collapsibles = config.shadowRoot.querySelectorAll('mojo-collapsible');
390
+ collapsibles.forEach(function(collapsible) {
391
+ if (collapsible.shadowRoot) {
392
+ var button = collapsible.shadowRoot.querySelector('.mojo-collapsible-button');
393
+ var content = collapsible.shadowRoot.querySelector('.mojo-collapsible-content');
394
+ if (button && content) {
395
+ var headerId = 'config-header-' + Math.random().toString(36).substr(2, 9);
396
+ var contentId = 'config-content-' + Math.random().toString(36).substr(2, 9);
397
+
398
+ button.setAttribute('id', headerId);
399
+ button.setAttribute('aria-expanded', content.style.display !== 'none');
400
+ button.setAttribute('aria-controls', contentId);
401
+
402
+ content.setAttribute('id', contentId);
403
+ content.setAttribute('aria-labelledby', headerId);
404
+ }
405
+ }
406
+ });
407
+ }
408
+ }
409
+
410
+ /**
411
+ * Adds ARIA labels to the result detail component.
412
+ *
413
+ * @function addResultDetailAriaLabels
414
+ * @returns {void}
415
+ */
416
+ function addResultDetailAriaLabels() {
417
+ var resultDetail = document.getElementById('testsummary-resultdetail');
418
+ if (resultDetail && resultDetail.shadowRoot) {
419
+ var resultCard = resultDetail.shadowRoot.querySelector('.ts-resultdetail-card');
420
+ if (resultCard) {
421
+ resultCard.setAttribute('role', 'region');
422
+ resultCard.setAttribute('aria-label', 'Test result details');
423
+ }
424
+
425
+ // Add labels to filter toolbar
426
+ var filterToolbar = resultDetail.shadowRoot.querySelector('.ts-filter-toolbar');
427
+ if (filterToolbar) {
428
+ filterToolbar.setAttribute('role', 'toolbar');
429
+ filterToolbar.setAttribute('aria-label', 'Result filters');
430
+ }
431
+
432
+ // Add labels to filter buttons
433
+ var filterButtons = resultDetail.shadowRoot.querySelectorAll('.ts-filter-btn');
434
+ filterButtons.forEach(function(button) {
435
+ var filter = button.getAttribute('data-filter');
436
+ button.setAttribute('aria-pressed', button.classList.contains('ts-filter-btn-active'));
437
+ button.setAttribute('aria-label', 'Filter by ' + filter.toLowerCase() + ' tests');
438
+ });
439
+
440
+ // Add label to search input
441
+ var searchInput = resultDetail.shadowRoot.querySelector('#id-search-input');
442
+ if (searchInput) {
443
+ searchInput.setAttribute('aria-label', 'Search test names');
444
+ searchInput.setAttribute('role', 'searchbox');
445
+ }
446
+
447
+ // Add labels to date inputs
448
+ var dateStart = resultDetail.shadowRoot.querySelector('#id-date-start');
449
+ var dateEnd = resultDetail.shadowRoot.querySelector('#id-date-end');
450
+ if (dateStart) {
451
+ dateStart.setAttribute('aria-label', 'Filter start date');
452
+ }
453
+ if (dateEnd) {
454
+ dateEnd.setAttribute('aria-label', 'Filter end date');
455
+ }
456
+
457
+ // Add labels to export buttons
458
+ var exportCSV = resultDetail.shadowRoot.querySelector('#id-export-csv');
459
+ var exportPDF = resultDetail.shadowRoot.querySelector('#id-export-pdf');
460
+ if (exportCSV) {
461
+ exportCSV.setAttribute('aria-label', 'Export results to CSV file');
462
+ }
463
+ if (exportPDF) {
464
+ exportPDF.setAttribute('aria-label', 'Export results to PDF file');
465
+ }
466
+
467
+ // Add label to display mode selector
468
+ var displayMode = resultDetail.shadowRoot.querySelector('#id-display-mode');
469
+ if (displayMode) {
470
+ displayMode.setAttribute('aria-label', 'Select result display mode');
471
+ }
472
+
473
+ // Add label to grouping selector
474
+ var groupingOption = resultDetail.shadowRoot.querySelector('#id-grouping-option');
475
+ if (groupingOption) {
476
+ groupingOption.setAttribute('aria-label', 'Select result grouping option');
477
+ }
478
+
479
+ // Add label to filter summary
480
+ var filterSummary = resultDetail.shadowRoot.querySelector('#id-filter-summary');
481
+ if (filterSummary) {
482
+ filterSummary.setAttribute('role', 'status');
483
+ filterSummary.setAttribute('aria-live', 'polite');
484
+ }
485
+ }
486
+ }
487
+
488
+ /**
489
+ * Adds ARIA labels to the artifacts component.
490
+ *
491
+ * @function addArtifactsAriaLabels
492
+ * @returns {void}
493
+ */
494
+ function addArtifactsAriaLabels() {
495
+ var artifacts = document.getElementById('testsummary-artifacts');
496
+ if (artifacts && artifacts.shadowRoot) {
497
+ var artifactsCard = artifacts.shadowRoot.querySelector('.ts-artifacts-card');
498
+ if (artifactsCard) {
499
+ artifactsCard.setAttribute('role', 'region');
500
+ artifactsCard.setAttribute('aria-label', 'Test artifacts');
501
+ }
502
+
503
+ // Add labels to iframes
504
+ var iframes = artifacts.shadowRoot.querySelectorAll('iframe');
505
+ iframes.forEach(function(iframe) {
506
+ var title = iframe.getAttribute('title') || 'Artifact viewer';
507
+ iframe.setAttribute('aria-label', title + ' artifact viewer');
508
+ });
509
+ }
510
+ }
511
+
512
+ /**
513
+ * Adds ARIA labels to the files and folders component.
514
+ *
515
+ * @function addFilesAndFoldersAriaLabels
516
+ * @returns {void}
517
+ */
518
+ function addFilesAndFoldersAriaLabels() {
519
+ var filesAndFolders = document.getElementById('testsummary-filesandfolders');
520
+ if (filesAndFolders && filesAndFolders.shadowRoot) {
521
+ var card = filesAndFolders.shadowRoot.querySelector('.ts-filesandfolders-card');
522
+ if (card) {
523
+ card.setAttribute('role', 'navigation');
524
+ card.setAttribute('aria-label', 'Output directory navigation');
525
+ }
526
+
527
+ // Add labels to folder and file lists
528
+ var foldersList = filesAndFolders.shadowRoot.querySelector('#id-folders-list');
529
+ var filesList = filesAndFolders.shadowRoot.querySelector('#id-files-list');
530
+
531
+ if (foldersList) {
532
+ foldersList.setAttribute('role', 'list');
533
+ foldersList.setAttribute('aria-label', 'Folders');
534
+ }
535
+ if (filesList) {
536
+ filesList.setAttribute('role', 'list');
537
+ filesList.setAttribute('aria-label', 'Files');
538
+ }
539
+ }
540
+ }
541
+
542
+ /**
543
+ * Sets up focus management for better keyboard navigation.
544
+ *
545
+ * @function setupFocusManagement
546
+ * @returns {void}
547
+ */
548
+ function setupFocusManagement() {
549
+ // Add visible focus indicators
550
+ document.addEventListener('keydown', function(event) {
551
+ if (event.key === KEYS.TAB) {
552
+ document.body.classList.add('keyboard-navigation');
553
+ }
554
+ });
555
+
556
+ document.addEventListener('mousedown', function() {
557
+ document.body.classList.remove('keyboard-navigation');
558
+ });
559
+
560
+ // Trap focus in modal-like elements when open
561
+ setupFocusTrap();
562
+ }
563
+
564
+ /**
565
+ * Sets up focus trapping for modal-like elements.
566
+ *
567
+ * @function setupFocusTrap
568
+ * @returns {void}
569
+ */
570
+ function setupFocusTrap() {
571
+ // Find all details elements that act as expandable sections
572
+ var detailsElements = document.querySelectorAll('details');
573
+
574
+ detailsElements.forEach(function(details) {
575
+ details.addEventListener('toggle', function() {
576
+ if (details.open) {
577
+ // Focus the first focusable element inside
578
+ var firstFocusable = details.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
579
+ if (firstFocusable) {
580
+ setTimeout(function() {
581
+ firstFocusable.focus();
582
+ }, 100);
583
+ }
584
+ }
585
+ });
586
+ });
587
+ }
588
+
589
+ /**
590
+ * Adds a live region for screen reader announcements.
591
+ *
592
+ * @function addLiveRegion
593
+ * @returns {void}
594
+ */
595
+ function addLiveRegion() {
596
+ // Check if live region already exists
597
+ if (document.getElementById('aria-live-region')) {
598
+ return;
599
+ }
600
+
601
+ var liveRegion = document.createElement('div');
602
+ liveRegion.id = 'aria-live-region';
603
+ liveRegion.setAttribute('role', 'status');
604
+ liveRegion.setAttribute('aria-live', 'polite');
605
+ liveRegion.setAttribute('aria-atomic', 'true');
606
+ liveRegion.className = 'sr-only';
607
+
608
+ document.body.appendChild(liveRegion);
609
+ }
610
+
611
+ /**
612
+ * Announces a message to screen readers via the live region.
613
+ *
614
+ * @function announceToScreenReader
615
+ * @param {string} message - The message to announce.
616
+ * @param {string} [priority='polite'] - The announcement priority ('polite' or 'assertive').
617
+ */
618
+ function announceToScreenReader(message, priority) {
619
+ priority = priority || 'polite';
620
+
621
+ var liveRegion = document.getElementById('aria-live-region');
622
+ if (!liveRegion) {
623
+ addLiveRegion();
624
+ liveRegion = document.getElementById('aria-live-region');
625
+ }
626
+
627
+ liveRegion.setAttribute('aria-live', priority);
628
+
629
+ // Clear and set message to trigger announcement
630
+ liveRegion.textContent = '';
631
+ setTimeout(function() {
632
+ liveRegion.textContent = message;
633
+ }, 100);
634
+ }
635
+
636
+ /**
637
+ * Updates ARIA attributes when filter state changes.
638
+ * Called by the result detail component when filters are applied.
639
+ *
640
+ * @function updateFilterAriaState
641
+ * @param {string} activeFilter - The currently active filter.
642
+ * @param {number} visibleCount - Number of visible results.
643
+ * @param {number} totalCount - Total number of results.
644
+ */
645
+ function updateFilterAriaState(activeFilter, visibleCount, totalCount) {
646
+ var resultDetail = document.getElementById('testsummary-resultdetail');
647
+ if (resultDetail && resultDetail.shadowRoot) {
648
+ // Update aria-pressed on filter buttons
649
+ var filterButtons = resultDetail.shadowRoot.querySelectorAll('.ts-filter-btn');
650
+ filterButtons.forEach(function(button) {
651
+ var filter = button.getAttribute('data-filter');
652
+ button.setAttribute('aria-pressed', filter === activeFilter);
653
+ });
654
+
655
+ // Announce filter change to screen readers
656
+ var message = 'Showing ' + visibleCount + ' of ' + totalCount + ' tests';
657
+ if (activeFilter !== 'ALL') {
658
+ message += ', filtered by ' + activeFilter.toLowerCase();
659
+ }
660
+ announceToScreenReader(message);
661
+ }
662
+ }
663
+
664
+ /**
665
+ * Updates ARIA attributes when a collapsible section is toggled.
666
+ *
667
+ * @function updateCollapsibleAriaState
668
+ * @param {HTMLElement} button - The collapsible button element.
669
+ * @param {boolean} expanded - Whether the section is expanded.
670
+ */
671
+ function updateCollapsibleAriaState(button, expanded) {
672
+ button.setAttribute('aria-expanded', expanded);
673
+
674
+ var headerText = button.querySelector('.mojo-collapsible-header, .mojo-collapsible-lvl2-header, .mojo-collapsible-lvl3-header');
675
+ var sectionName = headerText ? headerText.textContent : 'Section';
676
+
677
+ announceToScreenReader(sectionName + ' ' + (expanded ? 'expanded' : 'collapsed'));
678
+ }
679
+
680
+ /**
681
+ * Updates ARIA attributes when a tab is selected.
682
+ *
683
+ * @function updateTabAriaState
684
+ * @param {HTMLElement} selectedTab - The selected tab element.
685
+ * @param {NodeList} allTabs - All tab elements.
686
+ */
687
+ function updateTabAriaState(selectedTab, allTabs) {
688
+ allTabs.forEach(function(tab) {
689
+ tab.setAttribute('aria-selected', tab === selectedTab);
690
+ tab.setAttribute('tabindex', tab === selectedTab ? '0' : '-1');
691
+ });
692
+
693
+ var tabName = selectedTab.textContent || 'Tab';
694
+ announceToScreenReader(tabName + ' tab selected');
695
+ }
696
+
697
+ // Export functions for use by other modules
698
+ if (typeof window !== 'undefined') {
699
+ window.init_accessibility = init_accessibility;
700
+ window.announceToScreenReader = announceToScreenReader;
701
+ window.updateFilterAriaState = updateFilterAriaState;
702
+ window.updateCollapsibleAriaState = updateCollapsibleAriaState;
703
+ window.updateTabAriaState = updateTabAriaState;
704
+ }