|
33 | 33 | cursor: pointer; |
34 | 34 | font-size:20px; |
35 | 35 | } |
36 | | - |
| 36 | + |
37 | 37 | .diff_area { |
38 | 38 | font-size: 24px; |
39 | 39 | font-color: blue; |
|
102 | 102 | <script type="text/javascript"> |
103 | 103 | // Global for the test_type. |
104 | 104 | const test_type = "$test_type"; |
105 | | - |
| 105 | + |
106 | 106 | // Stores info from the json data fetched asynchronously. |
107 | 107 | let test_results = { |
108 | 108 | 'pass': { |
|
122 | 122 | count: 0, |
123 | 123 | characterized: null, |
124 | 124 | check_boxes: [], |
125 | | - widget_label_sets: [], |
| 125 | + widget_label_sets: [], |
126 | 126 | box_labels: [], |
127 | 127 | selected_set: null, |
128 | 128 | pagination_container: null |
|
160 | 160 | selected_set: null, |
161 | 161 | pagination_container: null |
162 | 162 | } |
163 | | - |
| 163 | + |
164 | 164 | }; |
165 | 165 |
|
166 | 166 | // Get the JSON data from the tests. |
|
196 | 196 | p5.then((response) => response.json()) |
197 | 197 | .then((data) => { |
198 | 198 | test_results['known_issue'].json = data}), |
199 | | - |
200 | | - |
| 199 | + |
| 200 | + |
201 | 201 | // TODO: Make a separate promise.all for this? |
202 | 202 | p_pass_char.then((response) => response.json()) |
203 | 203 | .then((data) => { |
|
261 | 261 | // Update the group selected with the intersection or inclusion of label sets |
262 | 262 | const class_name = widget.className; |
263 | 263 | const test_data = test_results[class_name]; |
264 | | - |
| 264 | + |
265 | 265 | // Start with all the tests, intersecting or removing data as needed. |
266 | 266 | test_data.selected_set = new Set(test_data.all_labels); |
267 | 267 |
|
268 | 268 | const selected_count_items = document.getElementsByName('selectedCount'); |
269 | | - |
| 269 | + |
270 | 270 | // Update the number of results size |
271 | 271 | let newSize = test_data.selected_set == null ? 0 : test_data.selected_set.size; |
272 | 272 | const output = [...selected_count_items].filter(elem => elem.className == class_name); |
|
276 | 276 | } |
277 | 277 |
|
278 | 278 | let excluded_set = new Set(); // Remove these label after the loop. |
279 | | - |
| 279 | + |
280 | 280 | // For each widget, if active, update the state of the selected and exclued sets |
281 | 281 | for (let index in test_data.check_boxes) { |
282 | 282 | const widget = test_data.check_boxes[index]; |
283 | 283 | const label_set = test_data.widget_label_sets[index]; |
284 | 284 |
|
285 | 285 | // This is a tristate item. |
286 | 286 | const which_state = widget.value; |
287 | | - |
| 287 | + |
288 | 288 | // Choose the value depending on the status of the control |
289 | 289 | if (which_state == check_mark) { |
290 | 290 | // Update by intersection with this set. |
291 | 291 | test_data.selected_set = |
292 | 292 | new Set([...test_data.selected_set].filter((x) => label_set.has(x))); |
293 | | - } |
| 293 | + } |
294 | 294 | else if (which_state == cross_mark) { |
295 | 295 | // Update by removing all these labels, i.e., intersect with the inverse |
296 | 296 | for (let label of label_set) { |
297 | 297 | excluded_set.add(label); |
298 | 298 | } |
299 | 299 | } |
300 | 300 | } |
301 | | - |
| 301 | + |
302 | 302 | // Remove the excluded values from selected set. |
303 | 303 | excluded_set.forEach((label) => { |
304 | 304 | test_data.selected_set.delete(label); |
|
310 | 310 | // Set the current count of items |
311 | 311 | output[0].innerHTML = output[0].innerText = newSize; |
312 | 312 | } |
313 | | - |
| 313 | + |
314 | 314 | // Get the characterized data from the correct set of items |
315 | 315 | if (newSize == 0) { |
316 | 316 | // Reset all widgets in this group |
|
320 | 320 | for (let index in test_data.check_boxes) { |
321 | 321 | const widget = test_data.check_boxes[index]; |
322 | 322 | const label_set = test_data.widget_label_sets[index]; |
323 | | - |
| 323 | + |
324 | 324 | // Compute overlap between the selected set and this widgetss data. |
325 | 325 | let intersectSet = new Set( |
326 | 326 | [...label_set].filter(i => test_data.selected_set.has(i))); |
|
364 | 364 | const diff_area_name = "diff_area_" + c_type; |
365 | 365 | const onclick_call = |
366 | 366 | '"captureInputDataOnClick(this);" onmouseover="hoverDiffText(this,' + diff_area_name + ');"'; |
367 | | - |
| 367 | + |
368 | 368 | let table_opening = |
369 | 369 | '<table id="table_' + c_type + |
370 | 370 | '" class="class_' + c_type + '">'; |
|
482 | 482 | // ----------------------- |
483 | 483 | function create_tristate_area( |
484 | 484 | id, data_class, characterization, count, container) { |
485 | | - // Make a tristate control for the items in this data class |
| 485 | + // Make a tristate control for the items in this data class |
486 | 486 | // Reference: https://jsfiddle.net/wf_bitplan_com/941std72/8/ |
487 | 487 | // Creates this widget, storing the result in the data_class |
488 | 488 | // <input title="this is a tri-state button: ❓,✅,❌" type="button" onclick="tristate1(this)" value="❓" /> |
|
511 | 511 | if (container) { |
512 | 512 | container.appendChild(box_div); |
513 | 513 | } |
514 | | - return box; |
| 514 | + return box; |
515 | 515 | } |
516 | 516 |
|
517 | 517 | function tristate1(control) { |
|
541 | 541 | // display the current value if it's unexpected |
542 | 542 | alert(control.value); |
543 | 543 | } |
544 | | - } |
| 544 | + } |
545 | 545 |
|
546 | 546 | function create_widget_area(data_class, make_widget_function) { |
547 | 547 | /* Given a set of labels and named characteristics, create a set of checkboxes with |
|
551 | 551 | const test_info = test_results[data_class]; |
552 | 552 |
|
553 | 553 | const selected_count_items = document.getElementsByName('selectedCount'); |
554 | | - |
| 554 | + |
555 | 555 | let leftover_labels = new Set(); |
556 | 556 | const json = test_info.json; |
557 | 557 | for (const item of json) { |
558 | | - const label = item['label']; |
| 558 | + const label = item['label']; |
559 | 559 | test_info.all_labels.add(label); |
560 | 560 | leftover_labels.add(label); |
561 | 561 | } |
|
566 | 566 | if (output) { |
567 | 567 | output[0].innerHTML = output[0].innerText = newSize; |
568 | 568 | } |
569 | | - |
| 569 | + |
570 | 570 | let div_name = data_class + '_characterized'; |
571 | 571 | let container = document.getElementById(div_name); |
572 | 572 | for (const characterization in test_info.characterized) { |
|
600 | 600 | test_info.check_boxes.push(new_widget); |
601 | 601 | } |
602 | 602 | } |
603 | | - |
| 603 | + |
604 | 604 | // Handle any non-characterized tests. |
605 | 605 | if (leftover_labels.size > 0) { |
606 | 606 | // Create an item for non-categorized results. |
|
624 | 624 | div_for_checkbox.attributeStyleMap.clear(); |
625 | 625 | }); |
626 | 626 |
|
627 | | - |
| 627 | + |
628 | 628 | // reset the number of results size |
629 | 629 | const selected_count_items = document.getElementsByName('selectedCount'); |
630 | 630 | const newSize = test_data.selected_set == null ? 0 : test_data.all_labels.size; |
|
636 | 636 | } |
637 | 637 | } |
638 | 638 |
|
| 639 | + function unEscape(htmlStr) { |
| 640 | + var doc = new DOMParser().parseFromString(htmlStr, "text/html"); |
| 641 | + return doc.documentElement.textContent; |
| 642 | + } |
| 643 | + |
639 | 644 | // For getting contents of output into json string for testing |
640 | 645 | function captureInputDataOnClick(element) { |
641 | 646 | const text = element.innerHTML; |
|
647 | 652 | } |
648 | 653 | // alert(output); |
649 | 654 | // Copy to clipboard. |
650 | | - navigator.clipboard.writeText(output); |
| 655 | + navigator.clipboard.writeText(unEscape(output)); |
651 | 656 | } |
652 | 657 |
|
653 | 658 | // On hover, show the difference between expected and actual result |
|
676 | 681 | let found = false; |
677 | 682 | const label_data = document.getElementById('label_data'); |
678 | 683 | label_data.innerHTML = "???"; |
679 | | - |
| 684 | + |
680 | 685 | let item_index; |
681 | 686 | let pagination_container; |
682 | 687 | let pagination_obj; |
683 | 688 |
|
684 | 689 | for (const type of result_types) { |
685 | 690 | const results = test_results[type].all_labels; |
686 | | - |
| 691 | + |
687 | 692 | if (results.has(label)) { |
688 | 693 | // Show the result type and the data for this one, |
689 | 694 | // i.e., label, expected result, result, input_data. |
|
733 | 738 | Intended to use for differences between expected and actual result. |
734 | 739 | --> |
735 | 740 | <script src="../../../diff_match_patch.js"></script> |
736 | | - |
| 741 | + |
737 | 742 | </head> |
738 | 743 | <body> |
739 | 744 | <h1>Verification report: $test_type on $library_name</h1> |
@@ -845,7 +850,7 @@ <h3>Find label</h3> |
845 | 850 | </div> <!-- grid end --> |
846 | 851 | </details> |
847 | 852 | </div> |
848 | | - </details> |
| 853 | + </details> |
849 | 854 |
|
850 | 855 | <details id="error_details"> |
851 | 856 | <summary>Test errors <span id='error_count'>($error_count)</span></summary> |
|
0 commit comments