github.com/web-platform-tests/wpt.fyi@v0.0.0-20240530210107-70cf978996f1/webapp/components/test/test-file-results-table.html (about)

     1  <!doctype html>
     2  <html>
     3  <head>
     4    <meta charset="utf-8">
     5    <script src="../../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
     6    <script src="../../node_modules/wct-browser-legacy/browser.js"></script>
     7  
     8    <script type="module" src="../test-file-results-table.js"></script>
     9  </head>
    10  <body>
    11    <test-fixture id="test-file-results-table-fixture">
    12      <template>
    13        <test-file-results-table
    14          path="/2dcontext/the-canvas-state/2d.state.saverestore.bitmap.html">
    15        </test-file-results-table>
    16      </template>
    17    </test-fixture>
    18    <script type="module">
    19  import { TestFileResultsTable } from '../test-file-results-table.js';
    20  import { TEST_RUNS_DATA } from './util/helpers.js';
    21  import { PolymerElement } from '../../node_modules/@polymer/polymer/polymer-element.js';
    22  
    23  suite('TestFileResultsTable', () => {
    24    let tfrt;
    25  
    26    setup(() => {
    27      const id = 'test-file-results-table-fixture';
    28      document.getElementById(id)
    29        .setAttribute('test-runs', JSON.stringify(TEST_RUNS_DATA));
    30      tfrt = fixture(id);
    31    });
    32  
    33    test('instanceof Polymer.Element', () => {
    34      assert.isTrue(new TestFileResultsTable() instanceof PolymerElement);
    35      assert.isTrue(document.createElement('test-file-results-table') instanceof PolymerElement);
    36    });
    37  
    38    suite('static get is()', () => {
    39      test('test-file-results-table', () => {
    40        assert.equal(TestFileResultsTable.is, 'test-file-results-table');
    41      });
    42    });
    43  
    44    suite('TestFileResultsTable.prototype.*', () => {
    45      suite('colorClass', () => {
    46        test('Pass and fail are colored differently', () => {
    47          assert.notEqual(tfrt.colorClass('PASS'), tfrt.colorClass('FAIL'));
    48        });
    49        test('Fail and error are colored identically', () => {
    50          assert.equal(tfrt.colorClass('FAIL'), tfrt.colorClass('ERROR'));
    51        });
    52        test('Harness status OK is equivalent to pass', () => {
    53          // OK is used for harness status and should not be colored green.
    54          assert.notEqual(tfrt.colorClass('OK'), tfrt.colorClass('PASS'));
    55        });
    56      });
    57  
    58      suite('computeDisplayedProducts', () => {
    59        test('null testRuns', () => {
    60          assert.deepEqual(tfrt.computeDisplayedProducts(null), []);
    61        });
    62        test('simple testRuns', () => {
    63          const testRuns = [{
    64            browser_name: 'firefox',
    65            browser_version: 1,
    66            labels: ['labelA'],
    67            revision: '0123456789',
    68          }];
    69  
    70          const result = tfrt.computeDisplayedProducts(testRuns);
    71  
    72          assert.equal(result.length, 1);
    73          assert.equal(result[0].browser_name, 'firefox');
    74          assert.equal(result[0].browser_version, 1);
    75          assert.deepEqual(result[0].labels, ['labelA']);
    76          assert.equal(result[0].revision, '0123456789');
    77        });
    78      });
    79    });
    80  
    81  });
    82  </script>
    83  </body>
    84  </html>