6
6
import {
7
7
ALERTING_INDEX ,
8
8
ALERTING_PLUGIN_NAME ,
9
+ ALERTING_PLUGIN_TIMEOUT ,
9
10
} from '../../../utils/plugins/alerting-dashboards-plugin/constants' ;
10
11
import sampleAlertsFlyoutBucketMonitor from '../../../fixtures/plugins/alerting-dashboards-plugin/sample_alerts_flyout_bucket_level_monitor.json' ;
11
12
import sampleAlertsFlyoutQueryMonitor from '../../../fixtures/plugins/alerting-dashboards-plugin/sample_alerts_flyout_query_level_monitor.json' ;
@@ -44,8 +45,8 @@ describe('Alerts by trigger flyout', () => {
44
45
cy . visit ( `${ BASE_PATH } /app/${ ALERTING_PLUGIN_NAME } #/monitors` ) ;
45
46
46
47
// Confirm test monitors were created successfully
47
- cy . contains ( BUCKET_MONITOR_NAME ) ;
48
- cy . contains ( QUERY_MONITOR_NAME ) ;
48
+ cy . contains ( BUCKET_MONITOR_NAME , { timeout : ALERTING_PLUGIN_TIMEOUT } ) ;
49
+ cy . contains ( QUERY_MONITOR_NAME , { timeout : ALERTING_PLUGIN_TIMEOUT } ) ;
49
50
50
51
// Wait 1 minutes for the test monitors to trigger alerts,
51
52
// then go to the 'Alerts by trigger' dashboard page to view alerts
@@ -57,8 +58,8 @@ describe('Alerts by trigger flyout', () => {
57
58
cy . visit ( `${ BASE_PATH } /app/${ ALERTING_PLUGIN_NAME } #/dashboard` ) ;
58
59
59
60
// Confirm dashboard is displaying rows for the test monitors.
60
- cy . contains ( BUCKET_MONITOR_NAME ) ;
61
- cy . contains ( QUERY_MONITOR_NAME ) ;
61
+ cy . contains ( BUCKET_MONITOR_NAME , { timeout : ALERTING_PLUGIN_TIMEOUT } ) ;
62
+ cy . contains ( QUERY_MONITOR_NAME , { timeout : ALERTING_PLUGIN_TIMEOUT } ) ;
62
63
63
64
// Waiting 5 seconds for alerts to finish loading.
64
65
// This short wait period alleviates flakiness observed during these tests.
@@ -67,91 +68,144 @@ describe('Alerts by trigger flyout', () => {
67
68
68
69
it ( 'Bucket-level monitor flyout test' , ( ) => {
69
70
// Click the link for the flyout.
70
- cy . get ( `[data-test-subj="euiLink_${ BUCKET_TRIGGER } "]` ) . click ( ) ;
71
+ cy . get ( `[data-test-subj="euiLink_${ BUCKET_TRIGGER } "]` , {
72
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
73
+ } ) . click ( ) ;
71
74
72
75
// Perform the test checks within the flyout component.
73
- cy . get ( `[data-test-subj="alertsDashboardFlyout_${ BUCKET_TRIGGER } "]` ) . within (
74
- ( ) => {
75
- // Confirm flyout header contains expected text.
76
- cy . get (
77
- `[data-test-subj="alertsDashboardFlyout_header_${ BUCKET_TRIGGER } "]`
78
- ) . contains ( `Alerts by ${ BUCKET_TRIGGER } ` ) ;
79
-
80
- // Confirm 'Trigger name' sections renders as expected.
81
- cy . get (
82
- `[data-test-subj="alertsDashboardFlyout_triggerName_${ BUCKET_TRIGGER } "]`
83
- ) . as ( 'triggerName' ) ;
84
- cy . get ( '@triggerName' ) . contains ( 'Trigger name' ) ;
85
- cy . get ( '@triggerName' ) . contains ( BUCKET_TRIGGER ) ;
86
-
87
- // Confirm 'Severity' sections renders as expected.
88
- cy . get (
89
- `[data-test-subj="alertsDashboardFlyout_severity_${ BUCKET_TRIGGER } "]`
90
- ) . as ( 'severity' ) ;
91
- cy . get ( '@severity' ) . contains ( 'Severity' ) ;
92
- cy . get ( '@severity' ) . contains ( '4 (Low)' ) ;
93
-
94
- // Confirm 'Monitor' sections renders as expected.
95
- cy . get (
96
- `[data-test-subj="alertsDashboardFlyout_monitor_${ BUCKET_TRIGGER } "]`
97
- ) . as ( 'monitor' ) ;
98
- cy . get ( '@monitor' ) . contains ( 'Monitor' ) ;
99
- cy . get ( '@monitor' ) . contains ( BUCKET_MONITOR_NAME ) ;
100
-
101
- // Confirm 'Conditions' sections renders as expected.
102
- cy . get (
103
- `[data-test-subj="alertsDashboardFlyout_conditions_${ BUCKET_TRIGGER } "]`
104
- ) . as ( 'conditions' ) ;
105
- cy . get ( '@conditions' ) . contains ( 'Conditions' ) ;
106
-
107
- // Confirm the 'Conditions' sections renders with all of the expected conditions.
108
- [
109
- 'params._count < 10000' ,
110
- 'OR' ,
111
- 'params.avg_products_price == 10' ,
112
- ] . forEach ( ( entry ) => cy . get ( '@conditions' ) . contains ( entry ) ) ;
113
-
114
- // Confirm 'Time range for the last' sections renders as expected.
115
- cy . get (
116
- `[data-test-subj="alertsDashboardFlyout_timeRange_${ BUCKET_TRIGGER } "]`
117
- ) . as ( 'timeRange' ) ;
118
- cy . get ( '@timeRange' ) . contains ( 'Time range for the last' ) ;
119
- cy . get ( '@timeRange' ) . contains ( '10 day(s)' ) ;
120
-
121
- // Confirm 'Filters' sections renders as expected.
122
- cy . get (
123
- `[data-test-subj="alertsDashboardFlyout_filters_${ BUCKET_TRIGGER } "]`
124
- ) . as ( 'filters' ) ;
125
- cy . get ( '@filters' ) . contains ( 'Filters' ) ;
126
- cy . get ( '@filters' ) . contains ( 'All fields are included' ) ;
127
-
128
- // Confirm 'Group by' sections renders as expected.
129
- cy . get (
130
- `[data-test-subj="alertsDashboardFlyout_groupBy_${ BUCKET_TRIGGER } "]`
131
- ) . as ( 'groupBy' ) ;
132
- cy . get ( '@groupBy' ) . contains ( 'Group by' ) ;
133
- cy . get ( '@groupBy' ) . contains ( 'customer_gender, user' ) ;
134
-
135
- // Set the 'severity' filter to only display ACTIVE alerts.
136
- cy . get ( '[data-test-subj="dashboardAlertStateFilter"]' ) . select ( 'Active' ) ;
137
-
138
- // This monitor configuration consistently returns 46 alerts when testing locally.
139
- // Confirm the flyout dashboard contains more than 1 ACTIVE alert.
140
- cy . get ( 'tbody > tr' ) . should ( ( $tr ) =>
141
- expect ( $tr ) . to . have . length . greaterThan ( 1 )
142
- ) ;
143
-
144
- // Select the first and last alerts in the table.
145
- cy . get ( 'input[data-test-subj^="checkboxSelectRow-"]' ) . first ( ) . click ( ) ;
146
- cy . get ( 'input[data-test-subj^="checkboxSelectRow-"]' ) . last ( ) . click ( ) ;
147
-
148
- // Press the flyout 'Acknowledge button, and wait for the AcknowledgeAlerts API call to complete.
149
- cy . get ( '[data-test-subj="flyoutAcknowledgeAlertsButton"]' ) . click ( ) ;
150
- }
151
- ) ;
76
+ cy . get ( `[data-test-subj="alertsDashboardFlyout_${ BUCKET_TRIGGER } "]` , {
77
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
78
+ } ) . within ( ( ) => {
79
+ // Confirm flyout header contains expected text.
80
+ cy . get (
81
+ `[data-test-subj="alertsDashboardFlyout_header_${ BUCKET_TRIGGER } "]` ,
82
+ { timeout : ALERTING_PLUGIN_TIMEOUT }
83
+ ) . contains ( `Alerts by ${ BUCKET_TRIGGER } ` , {
84
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
85
+ } ) ;
86
+
87
+ // Confirm 'Trigger name' sections renders as expected.
88
+ cy . get (
89
+ `[data-test-subj="alertsDashboardFlyout_triggerName_${ BUCKET_TRIGGER } "]` ,
90
+ { timeout : ALERTING_PLUGIN_TIMEOUT }
91
+ ) . as ( 'triggerName' ) ;
92
+ cy . get ( '@triggerName' ) . contains ( 'Trigger name' , {
93
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
94
+ } ) ;
95
+ cy . get ( '@triggerName' ) . contains ( BUCKET_TRIGGER , {
96
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
97
+ } ) ;
98
+
99
+ // Confirm 'Severity' sections renders as expected.
100
+ cy . get (
101
+ `[data-test-subj="alertsDashboardFlyout_severity_${ BUCKET_TRIGGER } "]` ,
102
+ { timeout : ALERTING_PLUGIN_TIMEOUT }
103
+ ) . as ( 'severity' ) ;
104
+ cy . get ( '@severity' , { timeout : ALERTING_PLUGIN_TIMEOUT } ) . contains (
105
+ 'Severity' ,
106
+ { timeout : ALERTING_PLUGIN_TIMEOUT }
107
+ ) ;
108
+ cy . get ( '@severity' , { timeout : ALERTING_PLUGIN_TIMEOUT } ) . contains (
109
+ '4 (Low)' ,
110
+ { timeout : ALERTING_PLUGIN_TIMEOUT }
111
+ ) ;
112
+
113
+ // Confirm 'Monitor' sections renders as expected.
114
+ cy . get (
115
+ `[data-test-subj="alertsDashboardFlyout_monitor_${ BUCKET_TRIGGER } "]`
116
+ ) . as ( 'monitor' ) ;
117
+ cy . get ( '@monitor' ) . contains ( 'Monitor' , {
118
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
119
+ } ) ;
120
+ cy . get ( '@monitor' ) . contains ( BUCKET_MONITOR_NAME , {
121
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
122
+ } ) ;
123
+
124
+ // Confirm 'Conditions' sections renders as expected.
125
+ cy . get (
126
+ `[data-test-subj="alertsDashboardFlyout_conditions_${ BUCKET_TRIGGER } "]`
127
+ ) . as ( 'conditions' ) ;
128
+ cy . get ( '@conditions' ) . contains ( 'Conditions' , {
129
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
130
+ } ) ;
131
+
132
+ // Confirm the 'Conditions' sections renders with all of the expected conditions.
133
+ [
134
+ 'params._count < 10000' ,
135
+ 'OR' ,
136
+ 'params.avg_products_price == 10' ,
137
+ ] . forEach ( ( entry ) =>
138
+ cy
139
+ . get ( '@conditions' )
140
+ . contains ( entry , { timeout : ALERTING_PLUGIN_TIMEOUT } )
141
+ ) ;
142
+
143
+ // Confirm 'Time range for the last' sections renders as expected.
144
+ cy . get (
145
+ `[data-test-subj="alertsDashboardFlyout_timeRange_${ BUCKET_TRIGGER } "]`
146
+ ) . as ( 'timeRange' ) ;
147
+ cy . get ( '@timeRange' ) . contains ( 'Time range for the last' , {
148
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
149
+ } ) ;
150
+ cy . get ( '@timeRange' ) . contains ( '10 day(s)' , {
151
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
152
+ } ) ;
153
+
154
+ // Confirm 'Filters' sections renders as expected.
155
+ cy . get (
156
+ `[data-test-subj="alertsDashboardFlyout_filters_${ BUCKET_TRIGGER } "]`
157
+ ) . as ( 'filters' ) ;
158
+ cy . get ( '@filters' ) . contains ( 'Filters' , {
159
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
160
+ } ) ;
161
+ cy . get ( '@filters' ) . contains ( 'All fields are included' , {
162
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
163
+ } ) ;
164
+
165
+ // Confirm 'Group by' sections renders as expected.
166
+ cy . get (
167
+ `[data-test-subj="alertsDashboardFlyout_groupBy_${ BUCKET_TRIGGER } "]`
168
+ ) . as ( 'groupBy' ) ;
169
+ cy . get ( '@groupBy' ) . contains ( 'Group by' , {
170
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
171
+ } ) ;
172
+ cy . get ( '@groupBy' ) . contains ( 'customer_gender, user' , {
173
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
174
+ } ) ;
175
+
176
+ // Set the 'severity' filter to only display ACTIVE alerts.
177
+ cy . get ( '[data-test-subj="dashboardAlertStateFilter"]' , {
178
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
179
+ } ) . select ( 'Active' ) ;
180
+
181
+ // This monitor configuration consistently returns 46 alerts when testing locally.
182
+ // Confirm the flyout dashboard contains more than 1 ACTIVE alert.
183
+ cy . get ( 'tbody > tr' ) . should ( ( $tr ) =>
184
+ expect ( $tr ) . to . have . length . greaterThan ( 1 )
185
+ ) ;
186
+
187
+ // Select the first and last alerts in the table.
188
+ cy . get ( 'input[data-test-subj^="checkboxSelectRow-"]' , {
189
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
190
+ } )
191
+ . first ( )
192
+ . click ( ) ;
193
+ cy . get ( 'input[data-test-subj^="checkboxSelectRow-"]' , {
194
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
195
+ } )
196
+ . last ( )
197
+ . click ( ) ;
198
+
199
+ // Press the flyout 'Acknowledge button, and wait for the AcknowledgeAlerts API call to complete.
200
+ cy . get ( '[data-test-subj="flyoutAcknowledgeAlertsButton"]' , {
201
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
202
+ } ) . click ( ) ;
203
+ } ) ;
152
204
153
205
// Confirm acknowledge alerts toast displays expected text.
154
- cy . contains ( 'Successfully acknowledged 2 alerts.' ) ;
206
+ cy . contains ( 'Successfully acknowledged 2 alerts.' , {
207
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
208
+ } ) ;
155
209
156
210
// Confirm alerts were acknowledged as expected.
157
211
cy . get ( `[data-test-subj="alertsDashboardFlyout_${ BUCKET_TRIGGER } "]` ) . within (
@@ -185,58 +239,85 @@ describe('Alerts by trigger flyout', () => {
185
239
// Confirm flyout header contains expected text.
186
240
cy . get (
187
241
`[data-test-subj="alertsDashboardFlyout_header_${ QUERY_TRIGGER } "]`
188
- ) . contains ( `Alerts by ${ QUERY_TRIGGER } ` ) ;
242
+ ) . contains ( `Alerts by ${ QUERY_TRIGGER } ` , {
243
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
244
+ } ) ;
189
245
190
246
// Confirm 'Trigger name' sections renders as expected.
191
247
cy . get (
192
248
`[data-test-subj="alertsDashboardFlyout_triggerName_${ QUERY_TRIGGER } "]`
193
249
) . as ( 'triggerName' ) ;
194
- cy . get ( '@triggerName' ) . contains ( 'Trigger name' ) ;
195
- cy . get ( '@triggerName' ) . contains ( QUERY_TRIGGER ) ;
250
+ cy . get ( '@triggerName' ) . contains ( 'Trigger name' , {
251
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
252
+ } ) ;
253
+ cy . get ( '@triggerName' ) . contains ( QUERY_TRIGGER , {
254
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
255
+ } ) ;
196
256
197
257
// Confirm 'Severity' sections renders as expected.
198
258
cy . get (
199
259
`[data-test-subj="alertsDashboardFlyout_severity_${ QUERY_TRIGGER } "]`
200
260
) . as ( 'severity' ) ;
201
- cy . get ( '@severity' ) . contains ( 'Severity' ) ;
202
- cy . get ( '@severity' ) . contains ( '2 (High)' ) ;
261
+ cy . get ( '@severity' ) . contains ( 'Severity' , {
262
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
263
+ } ) ;
264
+ cy . get ( '@severity' ) . contains ( '2 (High)' , {
265
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
266
+ } ) ;
203
267
204
268
// Confirm 'Monitor' sections renders as expected.
205
269
cy . get (
206
270
`[data-test-subj="alertsDashboardFlyout_monitor_${ QUERY_TRIGGER } "]`
207
271
) . as ( 'monitor' ) ;
208
- cy . get ( '@monitor' ) . contains ( 'Monitor' ) ;
209
- cy . get ( '@monitor' ) . contains ( QUERY_MONITOR_NAME ) ;
272
+ cy . get ( '@monitor' ) . contains ( 'Monitor' , {
273
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
274
+ } ) ;
275
+ cy . get ( '@monitor' ) . contains ( QUERY_MONITOR_NAME , {
276
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
277
+ } ) ;
210
278
211
279
// Confirm 'Conditions' sections renders as expected.
212
280
cy . get (
213
281
`[data-test-subj="alertsDashboardFlyout_conditions_${ QUERY_TRIGGER } "]`
214
282
) . as ( 'conditions' ) ;
215
- cy . get ( '@conditions' ) . contains ( 'Condition' ) ;
283
+ cy . get ( '@conditions' ) . contains ( 'Condition' , {
284
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
285
+ } ) ;
216
286
cy . get ( '@conditions' ) . contains (
217
- `ctx.results[0].hits.total.value < 10000`
287
+ `ctx.results[0].hits.total.value < 10000` ,
288
+ { timeout : ALERTING_PLUGIN_TIMEOUT }
218
289
) ;
219
290
220
291
// Confirm 'Time range for the last' sections renders as expected.
221
292
cy . get (
222
293
`[data-test-subj="alertsDashboardFlyout_timeRange_${ QUERY_TRIGGER } "]`
223
294
) . as ( 'timeRange' ) ;
224
- cy . get ( '@timeRange' ) . contains ( 'Time range for the last' ) ;
225
- cy . get ( '@timeRange' ) . contains ( '10 day(s)' ) ;
295
+ cy . get ( '@timeRange' ) . contains ( 'Time range for the last' , {
296
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
297
+ } ) ;
298
+ cy . get ( '@timeRange' ) . contains ( '10 day(s)' , {
299
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
300
+ } ) ;
226
301
227
302
// Confirm 'Filters' sections renders as expected.
228
303
cy . get (
229
304
`[data-test-subj="alertsDashboardFlyout_filters_${ QUERY_TRIGGER } "]`
230
305
) . as ( 'filters' ) ;
231
- cy . get ( '@filters' ) . contains ( 'Filters' ) ;
232
- cy . get ( '@filters' ) . contains ( '-' ) ;
306
+ cy . get ( '@filters' ) . contains ( 'Filters' , {
307
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
308
+ } ) ;
309
+ cy . get ( '@filters' ) . contains ( '-' , { timeout : ALERTING_PLUGIN_TIMEOUT } ) ;
233
310
234
311
// Confirm 'Group by' sections renders as expected.
235
312
cy . get (
236
313
`[data-test-subj="alertsDashboardFlyout_groupBy_${ QUERY_TRIGGER } "]`
237
314
) . as ( 'groupBy' ) ;
238
- cy . get ( '@groupBy' ) . contains ( 'Group by' ) ;
239
- cy . get ( '@groupBy' ) . contains ( 'user' ) ;
315
+ cy . get ( '@groupBy' ) . contains ( 'Group by' , {
316
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
317
+ } ) ;
318
+ cy . get ( '@groupBy' ) . contains ( 'user' , {
319
+ timeout : ALERTING_PLUGIN_TIMEOUT ,
320
+ } ) ;
240
321
241
322
// Set the 'severity' filter to only display ACTIVE alerts.
242
323
cy . get ( '[data-test-subj="dashboardAlertStateFilter"]' ) . select ( 'Active' ) ;
0 commit comments