9
9
} from '@open-wc/testing' ;
10
10
11
11
import { TestgridDashboardSummary } from '../src/testgrid-dashboard-summary.js' ;
12
+ import { TestgridFailuresSummary } from '../src/testgrid-failures-summary.js' ;
13
+ import { TabSummary } from '../src/tab-summary.js' ;
12
14
13
15
describe ( 'Testgrid Dashboard Summary page' , ( ) => {
14
16
let element : TestgridDashboardSummary ;
@@ -17,29 +19,139 @@ describe('Testgrid Dashboard Summary page', () => {
17
19
// See https://open-wc.org/docs/testing/helpers/#test-a-custom-class-with-properties
18
20
const tagName = defineCE ( class extends TestgridDashboardSummary { } ) ;
19
21
const tag = unsafeStatic ( tagName ) ;
20
- element = await fixture ( html `< ${ tag } .dashboardName=${ 'fake-dashboard-1' } > </ ${ tag } > ` ) ;
22
+ element = await fixture (
23
+ html `< ${ tag } .dashboardName=${ 'fake-dashboard-1' } > </ ${ tag } > `
24
+ ) ;
21
25
} ) ;
22
26
23
27
// TODO - add accessibility tests
24
28
it ( 'renders the tab summaries' , async ( ) => {
25
-
26
29
// waiting until list items (dashboards and groups) are fully rendered
27
30
await waitUntil (
28
31
( ) => element . shadowRoot ! . querySelector ( 'tab-summary' ) ,
29
32
'Dashboard summary did not render tab summaries' ,
30
33
{
31
34
timeout : 4000 ,
32
- } ,
35
+ }
33
36
) ;
34
37
35
38
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 ) ;
39
+ expect ( element . tabSummariesInfo [ 0 ] . name ) . to . equal ( 'fake-tab-1' ) ;
40
+ expect ( element . tabSummariesInfo [ 0 ] . overallStatus ) . to . equal ( 'PASSING' ) ;
41
+ expect (
42
+ element . tabSummariesInfo [ 0 ] . failuresSummary ?. failureStats . numFailingTests
43
+ ) . to . equal ( 1 ) ;
44
+ expect (
45
+ element . tabSummariesInfo [ 0 ] . failuresSummary ?. topFailingTests [ 0 ] . failCount
46
+ ) . to . equal ( 1 ) ;
47
+ expect (
48
+ element . tabSummariesInfo [ 0 ] . failuresSummary ?. topFailingTests [ 0 ]
49
+ . displayName
50
+ ) . to . equal ( 'fake-test-1' ) ;
51
+ expect (
52
+ element . tabSummariesInfo [ 0 ] . healthinessSummary ?. topFlakyTests [ 0 ]
53
+ . displayName
54
+ ) . to . equal ( 'fake-test-2' ) ;
55
+ expect (
56
+ element . tabSummariesInfo [ 0 ] . healthinessSummary ?. topFlakyTests [ 0 ] . flakiness
57
+ ) . to . equal ( 2 ) ;
58
+ expect (
59
+ element . tabSummariesInfo [ 0 ] . healthinessSummary ?. healthinessStats
60
+ . numFlakyTests
61
+ ) . to . equal ( 2 ) ;
62
+
63
+ const tabSummaries : NodeListOf < TabSummary > =
64
+ element . shadowRoot ! . querySelectorAll ( 'tab-summary' ) ;
65
+ await waitUntil (
66
+ ( ) =>
67
+ tabSummaries [ 0 ] ! . shadowRoot ! . querySelector (
68
+ 'testgrid-healthiness-summary'
69
+ ) ,
70
+ 'Dashboard summary did not render healthiness summary' ,
71
+ {
72
+ timeout : 4000 ,
73
+ }
74
+ ) ;
75
+
76
+ await waitUntil (
77
+ ( ) =>
78
+ tabSummaries [ 0 ] ! . shadowRoot ! . querySelector ( 'testgrid-failures-summary' ) ,
79
+ 'Dashboard summary did not render failures summary' ,
80
+ {
81
+ timeout : 4000 ,
82
+ }
83
+ ) ;
84
+ } ) ;
85
+
86
+ it ( 'show alerts when toggled' , async ( ) => {
87
+ // waiting until list items (dashboards and groups) are fully rendered
88
+ await waitUntil (
89
+ ( ) => element . shadowRoot ! . querySelector ( 'tab-summary' ) ,
90
+ 'Dashboard summary did not render tab summaries' ,
91
+ {
92
+ timeout : 4000 ,
93
+ }
94
+ ) ;
95
+
96
+ const dropdowns : NodeListOf < HTMLDivElement > = element
97
+ . shadowRoot ! . querySelectorAll ( 'tab-summary' ) [ 0 ] !
98
+ . shadowRoot ! . querySelector ( 'testgrid-failures-summary' ) !
99
+ . shadowRoot ! . querySelectorAll ( '.dropdown-container' ) ;
100
+ const table : HTMLTableElement | null = dropdowns [ 0 ] ! . querySelector ( 'table' ) ;
101
+ expect ( table ) . to . not . exist ;
102
+
103
+ // Show alerts.
104
+ const buttons : NodeListOf < HTMLButtonElement > | null =
105
+ dropdowns [ 0 ] ! . querySelectorAll ( 'button.btn' ) ;
106
+ buttons [ 0 ] ! . click ( ) ;
107
+
108
+ await waitUntil (
109
+ ( ) =>
110
+ element
111
+ . shadowRoot ! . querySelectorAll ( 'tab-summary' ) [ 0 ] !
112
+ . shadowRoot ! . querySelector ( 'testgrid-failures-summary' ) !
113
+ . shadowRoot ! . querySelectorAll ( '.dropdown-container' ) [ 0 ] !
114
+ . querySelector ( 'table' ) ,
115
+ 'Dashboard summary did not render healthiness table' ,
116
+ {
117
+ timeout : 4000 ,
118
+ }
119
+ ) ;
120
+ } ) ;
121
+
122
+ it ( 'show healthiness summary when toggled' , async ( ) => {
123
+ // waiting until list items (dashboards and groups) are fully rendered
124
+ await waitUntil (
125
+ ( ) => element . shadowRoot ! . querySelector ( 'tab-summary' ) ,
126
+ 'Dashboard summary did not render tab summaries' ,
127
+ {
128
+ timeout : 4000 ,
129
+ }
130
+ ) ;
131
+
132
+ const dropdowns : NodeListOf < HTMLDivElement > = element
133
+ . shadowRoot ! . querySelectorAll ( 'tab-summary' ) [ 0 ] !
134
+ . shadowRoot ! . querySelector ( 'testgrid-healthiness-summary' ) !
135
+ . shadowRoot ! . querySelectorAll ( '.dropdown-container' ) ;
136
+ const table : HTMLTableElement | null = dropdowns [ 0 ] ! . querySelector ( 'table' ) ;
137
+ expect ( table ) . to . not . exist ;
138
+
139
+ // Show healthiness summary.
140
+ const buttons : NodeListOf < HTMLButtonElement > | null =
141
+ dropdowns [ 0 ] ! . querySelectorAll ( 'button.btn' ) ;
142
+ buttons [ 0 ] ! . click ( ) ;
143
+
144
+ await waitUntil (
145
+ ( ) =>
146
+ element
147
+ . shadowRoot ! . querySelectorAll ( 'tab-summary' ) [ 0 ] !
148
+ . shadowRoot ! . querySelector ( 'testgrid-healthiness-summary' ) !
149
+ . shadowRoot ! . querySelectorAll ( '.dropdown-container' ) [ 0 ] !
150
+ . querySelector ( 'table' ) ,
151
+ 'Dashboard summary did not render healthiness table' ,
152
+ {
153
+ timeout : 4000 ,
154
+ }
155
+ ) ;
44
156
} ) ;
45
157
} ) ;
0 commit comments