github.com/web-platform-tests/wpt.fyi@v0.0.0-20240530210107-70cf978996f1/webapp/components/test/wpt-amend-metadata.html (about) 1 <!doctype html> 2 <html> 3 4 <head> 5 <meta charset="utf-8"> 6 <script src="../../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script> 7 <script src="../../node_modules/wct-browser-legacy/browser.js"></script> 8 9 <script type="module" src="../wpt-amend-metadata.js"></script> 10 </head> 11 12 <body> 13 <dom-module id="amend-metadata-util-concrete"> 14 <script type="module"> 15 import { PolymerElement } from '../../node_modules/@polymer/polymer/polymer-element.js'; 16 import { AmendMetadataMixin } from '../wpt-amend-metadata.js'; 17 18 class ConcreteType extends AmendMetadataMixin(PolymerElement) {} 19 window.customElements.define('amend-metadata-util-concrete', ConcreteType); 20 </script> 21 </dom-module> 22 23 <test-fixture id="amend-metadata-util-fixture"> 24 <template> 25 <amend-metadata-util-concrete></amend-metadata-util-concrete> 26 </template> 27 </test-fixture> 28 29 <test-fixture id="wpt-amend-metadata-fixture"> 30 <template> 31 <wpt-amend-metadata></wpt-amend-metadata> 32 </template> 33 </test-fixture> 34 35 <script type="module"> 36 37 import '../wpt-amend-metadata.js'; 38 suite('wpt-amend-metadata', () => { 39 suite('AmendMetadataMixin', () => { 40 let appFixture = null; 41 let td = null; 42 let toast = null; 43 44 setup(() => { 45 appFixture = fixture('amend-metadata-util-fixture'); 46 td = document.createElement('td'); 47 toast = document.createElement('paper-toast'); 48 }); 49 50 test('handleSelect', () => { 51 appFixture.handleSelect(td, 'chrome', 'testA', toast); 52 53 assert.deepEqual(appFixture.selectedMetadata, [{ test: 'testA', product: 'chrome' }]); 54 expect(td.hasAttribute('selected')).to.be.true; 55 expect(appFixture.selectedCells[0]).to.equal(td); 56 57 appFixture.handleSelect(td, 'chrome', 'testA', toast); 58 59 assert.deepEqual(appFixture.selectedMetadata, []); 60 expect(td.hasAttribute('selected')).to.be.false; 61 assert.deepEqual(appFixture.selectedMetadata, []); 62 }); 63 }); 64 65 suite('<wpt-amend-metadata>', () => { 66 let appFixture = null; 67 setup(() => { 68 appFixture = fixture('wpt-amend-metadata-fixture'); 69 }); 70 71 test('getTriagedMetadataMap(displayedMetadata) with a non-testfile path', () => { 72 appFixture.path = '/abc'; 73 const displayedMetadata = [ 74 { product: 'firefox', url: 'foo', tests: ['testA', 'testB'] }, 75 { product: 'chrome', url: 'bar', tests: ['testA', 'testB'] } 76 ]; 77 const expected = { 78 'testA': [{ url: 'foo', product: 'firefox' }, { url: 'bar', product: 'chrome' }], 79 'testB': [{ url: 'foo', product: 'firefox' }, { url: 'bar', product: 'chrome' }] 80 }; 81 82 assert.deepEqual(appFixture.getTriagedMetadataMap(displayedMetadata), expected); 83 }); 84 test('getTriagedMetadataMap(displayedMetadata) for a test-level triage', () => { 85 appFixture.path = '/abc'; 86 const displayedMetadata = [ 87 { product: '', url: 'foo', tests: ['testA.html'], label: '' }, 88 ]; 89 // When there is no product, we have to remove the product from the 90 // metadata map for calling into /api/metadata/triage. 91 const expected = { 92 'testA.html': [{ url: 'foo' }], 93 }; 94 95 assert.deepEqual(appFixture.getTriagedMetadataMap(displayedMetadata), expected); 96 }); 97 test('getTriagedMetadataMap(displayedMetadata) for a label triage', () => { 98 appFixture.path = '/abc'; 99 const displayedMetadata = [ 100 { product: '', url: '', tests: ['testA.html'], label: 'interop' }, 101 ]; 102 // When there is no product, we have to remove the product from the 103 // metadata map for calling into /api/metadata/triage. 104 const expected = { 105 'testA.html': [{ label: 'interop' }], 106 }; 107 108 assert.deepEqual(appFixture.getTriagedMetadataMap(displayedMetadata), expected); 109 }); 110 test('getTriagedMetadataMap(displayedMetadata) with a testfile path', () => { 111 appFixture.path = '/abc/foo.html'; 112 const displayedMetadata = [ 113 { product: 'firefox', url: 'foo', tests: ['testA', 'testB'] }, 114 { product: 'chrome', url: 'bar', tests: ['testA', 'testB'] } 115 ]; 116 const resultsFirefox = [{ subtest: 'testA' }, { subtest: 'testB' }]; 117 const resultsChrome = [{ subtest: 'testA' }, { subtest: 'testB' }]; 118 const expected = { 119 '/abc/foo.html': [{ url: 'foo', product: 'firefox', results: resultsFirefox }, { url: 'bar', product: 'chrome', results: resultsChrome }], 120 }; 121 122 assert.deepEqual(appFixture.getTriagedMetadataMap(displayedMetadata), expected); 123 }); 124 test('populateDisplayData() with a non-testfile path', () => { 125 appFixture.path = '/abc'; 126 appFixture.selectedMetadata = [ 127 { product: 'firefox', test: 'testA.html' }, 128 { product: 'firefox', test: 'testB.html' }, 129 { product: 'chrome', test: 'testC' }, 130 { product: 'chrome', test: 'testB.html' } 131 ]; 132 const expected = [ 133 { product: 'firefox', url: '', tests: ['testA.html', 'testB.html'] }, 134 { product: 'chrome', url: '', tests: ['testC/*', 'testB.html'] } 135 ]; 136 137 appFixture.populateDisplayData(); 138 assert.deepEqual(appFixture.displayedMetadata, expected); 139 }); 140 test('populateDisplayData() with a testfile path', () => { 141 appFixture.path = '/abc/foo.html'; 142 appFixture.selectedMetadata = [ 143 { product: 'firefox', test: 'testA' }, 144 { product: 'firefox', test: 'testB' }, 145 { product: 'chrome', test: 'testA' }, 146 { product: 'chrome', test: 'testB' } 147 ]; 148 const expected = [ 149 { product: 'firefox', url: '', tests: ['testA', 'testB'] }, 150 { product: 'chrome', url: '', tests: ['testA', 'testB'] } 151 ]; 152 153 appFixture.populateDisplayData(); 154 assert.deepEqual(appFixture.displayedMetadata, expected); 155 }); 156 test('getSearchURL', () => { 157 expect(appFixture.getSearchURL('/a/b/*', 'chrome')).to.equal('https://bugs.chromium.org/p/chromium/issues/list?q="/a/b"'); 158 expect(appFixture.getSearchURL('/a/b.html', 'chrome')).to.equal('https://bugs.chromium.org/p/chromium/issues/list?q="/a/b"'); 159 expect(appFixture.getSearchURL('/a/b', 'chrome')).to.equal('https://bugs.chromium.org/p/chromium/issues/list?q="/a/b"'); 160 expect(appFixture.getSearchURL('/a/b.any.html', 'chrome')).to.equal('https://bugs.chromium.org/p/chromium/issues/list?q="/a/b"'); 161 expect(appFixture.getSearchURL('/a/b.worker.html', 'chrome')).to.equal('https://bugs.chromium.org/p/chromium/issues/list?q="/a/b"'); 162 expect(appFixture.getSearchURL('/a/b.html', 'edge')).to.equal('https://bugs.chromium.org/p/chromium/issues/list?q="/a/b"'); 163 expect(appFixture.getSearchURL('/a/b.html', 'firefox')).to.equal('https://bugzilla.mozilla.org/buglist.cgi?quicksearch="/a/b"'); 164 expect(appFixture.getSearchURL('/a/b.html', 'safari')).to.equal('https://bugs.webkit.org/buglist.cgi?quicksearch="/a/b"'); 165 expect(appFixture.getSearchURL('/a/b.html', 'wktr')).to.equal('https://bugs.webkit.org/buglist.cgi?quicksearch="/a/b"'); 166 expect(appFixture.getSearchURL('/a/b.html', 'webkitgtk')).to.equal('https://bugs.webkit.org/buglist.cgi?quicksearch="/a/b"'); 167 expect(appFixture.getSearchURL('/a/b.html', 'servo')).to.equal('https://github.com/servo/servo/issues?q="/a/b"'); 168 }); 169 test('hasFileIssueURL', () => { 170 expect(appFixture.hasFileIssueURL('')).to.be.true; 171 expect(appFixture.hasFileIssueURL(null)).to.be.false; 172 expect(appFixture.hasFileIssueURL(undefined)).to.be.false; 173 expect(appFixture.hasFileIssueURL('chrome')).to.be.false; 174 expect(appFixture.hasFileIssueURL('firefox')).to.be.false; 175 }); 176 test('getFileIssueURL', () => { 177 const expectedURL = 'https://github.com/web-platform-tests/wpt-metadata' + 178 '/issues/new?title=%5Bcompat2021%5D+%2Ffoo%2Fbar.html+fails+due+to' + 179 '+test+issue&labels=compat2021-test-issue'; 180 expect(appFixture.getFileIssueURL('/foo/bar.html')).to.equal(expectedURL); 181 }); 182 }); 183 }); 184 </script> 185 </body> 186 187 </html>