github.com/GoogleCloudPlatform/testgrid@v0.0.174/web/test/testgrid-dashboard-summary.test.ts (about) 1 import { 2 html, 3 fixture, 4 defineCE, 5 unsafeStatic, 6 expect, 7 waitUntil, 8 aTimeout, 9 } from '@open-wc/testing'; 10 11 import { TestgridDashboardSummary } from '../src/testgrid-dashboard-summary.js'; 12 13 describe('Testgrid Dashboard Summary page', () => { 14 let element: TestgridDashboardSummary; 15 beforeEach(async () => { 16 // Need to wrap an element to apply its properties (ex. @customElement) 17 // See https://open-wc.org/docs/testing/helpers/#test-a-custom-class-with-properties 18 const tagName = defineCE(class extends TestgridDashboardSummary {}); 19 const tag = unsafeStatic(tagName); 20 element = await fixture(html`<${tag} .dashboardName=${'fake-dashboard-1'}></${tag}>`); 21 }); 22 23 // TODO - add accessibility tests 24 it('renders the tab summaries', async () => { 25 26 // waiting until list items (dashboards and groups) are fully rendered 27 await waitUntil( 28 () => element.shadowRoot!.querySelector('tab-summary'), 29 'Dashboard summary did not render tab summaries', 30 { 31 timeout: 4000, 32 }, 33 ); 34 35 expect(element.tabSummariesInfo.length).to.equal(4); 36 expect(element.tabSummariesInfo[0].name).to.equal("fake-tab-1"); 37 expect(element.tabSummariesInfo[0].overallStatus).to.equal("PASSING"); 38 expect(element.tabSummariesInfo[0].failuresSummary?.failureStats.numFailingTests).to.equal(1); 39 expect(element.tabSummariesInfo[0].failuresSummary?.topFailingTests[0].failCount).to.equal(1); 40 expect(element.tabSummariesInfo[0].failuresSummary?.topFailingTests[0].displayName).to.equal("fake-test-1"); 41 expect(element.tabSummariesInfo[0].healthinessSummary?.topFlakyTests[0].displayName).to.equal("fake-test-2"); 42 expect(element.tabSummariesInfo[0].healthinessSummary?.topFlakyTests[0].flakiness).to.equal(2); 43 expect(element.tabSummariesInfo[0].healthinessSummary?.healthinessStats.numFlakyTests).to.equal(2); 44 }); 45 });