Skip to content

Commit 1e51784

Browse files
Merge pull request #1224 from bryan-lou/bryanlou-dev-1
Add healthiness report dropdown to dashboard summary tab
2 parents e2be4c4 + b69da8b commit 1e51784

File tree

4 files changed

+153
-1
lines changed

4 files changed

+153
-1
lines changed

web/src/fake-api/data.json

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,20 @@
266266
"failure_stats": {
267267
"num_failing_tests":1
268268
}
269+
},
270+
"healthiness_summary": {
271+
"top_flaky_tests": [
272+
{
273+
"display_name": "fake-test-2",
274+
"flakiness": "2"
275+
}
276+
],
277+
"healthiness_stats": {
278+
"start": "2023-05-29T11:25:20.000Z",
279+
"end": "2023-05-29T11:25:20.000Z",
280+
"num_flaky_tests": 2,
281+
"average_flakiness": 2.2
282+
}
269283
}
270284
},
271285
{
@@ -284,7 +298,21 @@
284298
"detailed_status_message": "Tab stats: 3 of 5 (60 %) recent columns passed (5 of 7 or 71.43 % cells)",
285299
"last_run_timestamp": "2023-05-29T11:25:20.000Z",
286300
"last_update_timestamp": "2023-05-29T11:25:20.000Z",
287-
"latest_passing_build": "0987654"
301+
"latest_passing_build": "0987654",
302+
"healthiness_summary": {
303+
"top_flaky_tests": [
304+
{
305+
"display_name": "fake-test-2",
306+
"flakiness": "2"
307+
}
308+
],
309+
"healthiness_stats": {
310+
"start": "2023-05-29T11:25:20.000Z",
311+
"end": "2023-05-29T11:25:20.000Z",
312+
"num_flaky_tests": 2,
313+
"average_flakiness": 2.2
314+
}
315+
}
288316
},
289317
{
290318
"dashboard_name": "fake-dashboard-1",

web/src/tab-summary.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { map } from 'lit/directives/map.js';
44
import { customElement, property } from 'lit/decorators.js';
55
import { TabSummaryInfo } from './testgrid-dashboard-summary';
66
import './testgrid-failures-summary';
7+
import './testgrid-healthiness-summary';
8+
79
@customElement('tab-summary')
810
// eslint-disable-next-line @typescript-eslint/no-unused-vars
911
export class TabSummary extends LitElement {
@@ -45,6 +47,9 @@ export class TabSummary extends LitElement {
4547
${this.info?.failuresSummary !== undefined ?
4648
html `<testgrid-failures-summary .info=${this.info}>
4749
</testgrid-failures-summary>`:''}
50+
${this.info?.healthinessSummary !== undefined ?
51+
html `<testgrid-healthiness-summary .info=${this.info}>
52+
</testgrid-healthiness-summary>`:''}
4853
`;
4954
}
5055
/**

web/src/testgrid-dashboard-summary.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface TabSummaryInfo {
1616
latestGreenBuild: string;
1717
dashboardName: string;
1818
failuresSummary?: FailuresSummaryInfo;
19+
healthinessSummary?: HealthinessSummaryInfo;
1920
}
2021

2122
interface FailuresSummaryInfo {
@@ -28,6 +29,25 @@ interface FailingTestInfo {
2829
failCount: number;
2930
passTimestamp: string;
3031
failTimestamp: string;
32+
healthinessSummary?: HealthinessSummaryInfo;
33+
}
34+
35+
interface HealthinessSummaryInfo {
36+
topFlakyTests: FlakyTestInfo[];
37+
healthinessStats: HealthinessStats;
38+
}
39+
40+
interface FlakyTestInfo {
41+
displayName: string;
42+
flakiness: number;
43+
}
44+
45+
interface HealthinessStats {
46+
startTimestamp: string;
47+
endTimestamp: string;
48+
numFlakyTests: number;
49+
averageFlakiness: number;
50+
previousFlakiness: number;
3151
}
3252

3353
interface FailureStats {
@@ -76,6 +96,27 @@ function convertResponse(ts: TabSummary) {
7696
tsi.failuresSummary!.topFailingTests.push(failingTest)
7797
});
7898
}
99+
100+
if (ts.healthinessSummary !== undefined) {
101+
tsi.healthinessSummary = {} as HealthinessSummaryInfo
102+
const healthinessStats: HealthinessStats = {
103+
startTimestamp: Timestamp.toDate(ts.healthinessSummary!.healthinessStats!.start!).toISOString(),
104+
endTimestamp: Timestamp.toDate(ts.healthinessSummary!.healthinessStats!.end!).toISOString(),
105+
numFlakyTests: ts.healthinessSummary!.healthinessStats!.numFlakyTests,
106+
averageFlakiness: ts.healthinessSummary!.healthinessStats!.averageFlakiness,
107+
previousFlakiness: ts.healthinessSummary!.healthinessStats!.previousFlakiness,
108+
}
109+
tsi.healthinessSummary!.healthinessStats = healthinessStats
110+
111+
tsi.healthinessSummary!.topFlakyTests = [];
112+
ts.healthinessSummary?.topFlakyTests.forEach( test => {
113+
const flakyTest: FlakyTestInfo = {
114+
displayName: test.displayName,
115+
flakiness: test.flakiness,
116+
}
117+
tsi.healthinessSummary!.topFlakyTests.push(flakyTest)
118+
})
119+
}
79120
return tsi;
80121
}
81122

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { LitElement, html, css } from 'lit';
2+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3+
import { customElement, property, state } from 'lit/decorators.js';
4+
import { TabSummaryInfo } from './testgrid-dashboard-summary';
5+
import { map } from 'lit/directives/map.js';
6+
7+
@customElement('testgrid-healthiness-summary')
8+
export class TestgridTabTable extends LitElement {
9+
@state() showHealthinesSummary = false;
10+
@property() info?: TabSummaryInfo;
11+
12+
render() {
13+
return html`
14+
<div class="dropdown-container">
15+
<button @click="${() => this.dropdownTable()}" class="btn">
16+
${this.showHealthinesSummary ? html`- Hide Healthiness Report -`: html `- Show Healthiness Report -`}
17+
</button>
18+
${this.showHealthinesSummary ? html`
19+
<table class="dropdown-menu">
20+
<tr>
21+
<th>Test Name</th>
22+
<th>Flakiness (Previous)</th>
23+
<th>Flakiness (Current)</th>
24+
<th>Trend</th>
25+
<th>Infra Failure Rate</th>
26+
<th>Flaky Tests Count</th>
27+
</tr>
28+
${map(
29+
this.info?.healthinessSummary!.topFlakyTests,
30+
(test: any) => html`
31+
<tr>
32+
<td>${test.displayName}</td>
33+
<td>${this.info?.healthinessSummary?.healthinessStats.previousFlakiness}</td>
34+
<td>${this.info?.healthinessSummary?.healthinessStats.averageFlakiness}</td>
35+
<td>N/A</td>
36+
<td>${test.flakiness}</td>
37+
<td>${this.info?.healthinessSummary?.healthinessStats.numFlakyTests}</td>
38+
</tr>
39+
`)}
40+
</table>`
41+
: ''}
42+
</div>
43+
`
44+
}
45+
private dropdownTable(){
46+
this.showHealthinesSummary = !this.showHealthinesSummary;
47+
}
48+
49+
static styles = css`
50+
.dropdown-container {
51+
border-left: 1px solid #6b90da;
52+
border-right: 1px solid #6b90da;
53+
border-bottom: 1px solid #6b90da;
54+
border-radius: 0 0 6px 6px;
55+
color: #000;
56+
display: block;
57+
position: relative;
58+
}
59+
60+
.dropdown-menu {
61+
position: relative;
62+
width: 100%;
63+
}
64+
65+
.btn {
66+
display: grid;
67+
border-radius: var(--radius);
68+
border: none;
69+
cursor: pointer;
70+
position: relative;
71+
width: 100%;
72+
}
73+
74+
th {
75+
text-align: left;
76+
}
77+
`
78+
}

0 commit comments

Comments
 (0)