Home | History | Annotate | Download | only in templates
      1 <!DOCTYPE html>
      2 <html id="add-form">
      3 <head>
      4     <title>Rebaseline Queue: Edit</title>
      5     <script src="http://test-results.appspot.com/dashboards/builders.js"></script>
      6     <link rel="stylesheet" href="/static/styles.css" type="text/css">
      7 </head>
      8 <body">
      9 
     10 <div id="loading-indicator" class="status">Loading...</div>
     11 
     12 <form method="POST" id="form-template" style="display: none">
     13     <table class="test-table">
     14         <caption></caption>
     15         <thead>
     16             <th>Test</th>
     17             <th>Expected</th>
     18             <th>Actual</th>
     19             <th>Results</th>
     20         </thead>
     21         <tbody></tbody>
     22         <tbody>
     23             <tr>
     24               <td colspan="4" class="submit-row">
     25                 <input type="submit" value="">
     26               </td>
     27             </tr>
     28         </tbody>
     29     </table>
     30 </form>
     31 
     32 <script>
     33 var TEST_RESULTS_SERVER = 'http://test-results.appspot.com/';
     34 var BUILDER_TO_GROUP = {};
     35 for (var builderGroupName in LAYOUT_TESTS_BUILDER_GROUPS) {
     36     for (var builderName in LAYOUT_TESTS_BUILDER_GROUPS[builderGroupName]) {
     37         BUILDER_TO_GROUP[builderName] = builderGroupName;
     38     }
     39 }
     40 
     41 // Extract template parameters
     42 var builderName = '{{ builder_name|escapejs }}';
     43 var queuedTestNames = {{ queued_test_names|safe }};
     44 
     45 function init()
     46 {
     47   var builderMaster = BUILDER_TO_MASTER[builderName];
     48   var resultsUrl = TEST_RESULTS_SERVER + 'testfile?builder=' + builderName +
     49       '&master=' + builderMaster.name +
     50       '&testtype=layout-tests&name=full_results.json';
     51 
     52   var script = document.createElement('script');
     53   script.src = resultsUrl;
     54   document.getElementsByTagName('head')[0].appendChild(script);
     55 }
     56 
     57 function ADD_RESULTS(results)
     58 {
     59     var builderGroupName = BUILDER_TO_GROUP[builderName];
     60 
     61     var tests = results.tests;
     62     var failingTests = [];
     63     var queuedTests = [];
     64     for (var test in tests) {
     65         var testResults = tests[test];
     66         if (testResults.actual == testResults.expected ||
     67             testResults.expected.split(' ').indexOf(testResults.actual) != -1 ||
     68             testResults.actual == 'SKIP' ||
     69             testResults.actual.indexOf('PASS') != -1 ||
     70             (testResults.actual != 'PASS' && testResults.expected.indexOf('FAIL') != -1)) {
     71             continue;
     72         }
     73 
     74         testResults.name = test;
     75 
     76         if (queuedTestNames.indexOf(test) != -1) {
     77             queuedTests.push(testResults);
     78             queuedTestNames.splice(queuedTestNames.indexOf(test), 1);
     79         } else {
     80             failingTests.push(testResults);
     81         }
     82     }
     83 
     84     // If we have remaining queued tests that are currently not failing,
     85     // synthesize results for them.
     86     queuedTestNames.forEach(function(queuedTestName) {
     87         queuedTests.push({
     88           name: queuedTestName,
     89           actual: 'UNKNOWN',
     90           expected: 'UNKNOWN'
     91         });
     92     });
     93 
     94     document.getElementById('loading-indicator').style.display = 'none';
     95 
     96     renderTestResults(
     97         failingTests,
     98         'add',
     99         'Failing tests',
    100         'Add to rebaseline queue',
    101         'No failing tests.');
    102     renderTestResults(
    103         queuedTests,
    104         'remove',
    105         'Queued tests',
    106         'Remove from rebaseline queue',
    107         'No queued tests.');
    108 }
    109 
    110 function renderTestResults(testResults, formAction, title, submitLabel, emptyMessage)
    111 {
    112     if (testResults.length == 0) {
    113         var emptyNode = document.createElement('div');
    114         emptyNode.className = 'status';
    115         emptyNode.textContent = emptyMessage;
    116         document.body.appendChild(emptyNode);
    117         return;
    118     }
    119 
    120     var form = document.getElementById('form-template').cloneNode(true);
    121     form.action = '/builder/' + builderName + '/queue/' + formAction;
    122     form.style.display = '';
    123     document.body.appendChild(form);
    124 
    125     var testsTable = form.querySelector('.test-table');
    126     testsTable.querySelector('caption').textContent = title;
    127     testsTable.querySelector('input[type=submit]').value = submitLabel;
    128 
    129     testResults.sort(function(a, b) {
    130         return a.name < b.name ? -1 : (a.name > b.name ? 1 : 0);
    131     });
    132 
    133     testResults.forEach(function(result) {
    134         var testRow = document.createElement('tr');
    135 
    136         var testCell = document.createElement('td');
    137         testRow.appendChild(testCell);
    138         var testCheckbox = document.createElement('input');
    139         testCheckbox.type = 'checkbox';
    140         testCheckbox.name = 'test';
    141         testCheckbox.value = result.name;
    142         testCheckbox.id = result.name;
    143         testCell.appendChild(testCheckbox);
    144 
    145         var testName = document.createElement('label');
    146         testName.textContent = result.name;
    147         testName.setAttribute('for', result.name);
    148         testCell.appendChild(testName);
    149 
    150         var expectedCell = document.createElement('td');
    151         testRow.appendChild(expectedCell);
    152         expectedCell.textContent = result.expected;
    153 
    154         var actualCell = document.createElement('td');
    155         testRow.appendChild(actualCell);
    156         actualCell.textContent = result.actual;
    157 
    158         var resultsCell = document.createElement('td');
    159         testRow.appendChild(resultsCell);
    160         var resultsLink = document.createElement('a');
    161         resultsLink.target = '_blank';
    162         resultsLink.href = TEST_RESULTS_SERVER +
    163             'dashboards/flakiness_dashboard.html#tests=' + result.name +
    164             '&group=' + builderGroupName;
    165         resultsLink.textContent = 'Flakiness dashboard';
    166         resultsCell.appendChild(resultsLink);
    167 
    168         testsTable.tBodies[0].appendChild(testRow);
    169     });
    170 }
    171 
    172 init();
    173 </script>
    174 
    175 </body>
    176 </html>
    177