Skip to content

Commit 3ee2b29

Browse files
[RAC] [Observability] Expand Observability alerts page functional tests (#111297) (#111867)
* Regenerate data and add tests Co-authored-by: Kerry Gallagher <471693+Kerry350@users.noreply.github.com>
1 parent b000066 commit 3ee2b29

File tree

8 files changed

+291
-26
lines changed

8 files changed

+291
-26
lines changed

x-pack/plugins/observability/public/pages/alerts/alerts_flyout/index.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ export function AlertsFlyout({
127127
];
128128

129129
return (
130-
<EuiFlyout onClose={onClose} size="s">
130+
<EuiFlyout onClose={onClose} size="s" data-test-subj="alertsFlyout">
131131
<EuiFlyoutHeader>
132-
<EuiTitle size="m">
132+
<EuiTitle size="m" data-test-subj="alertsFlyoutTitle">
133133
<h2>{alertData.fields[ALERT_RULE_NAME]}</h2>
134134
</EuiTitle>
135135
<EuiSpacer size="s" />
@@ -141,13 +141,27 @@ export function AlertsFlyout({
141141
compressed={true}
142142
type="responsiveColumn"
143143
listItems={overviewListItems}
144+
titleProps={
145+
{
146+
'data-test-subj': 'alertsFlyoutDescriptionListTitle',
147+
} as any // NOTE / TODO: This "any" is a temporary workaround: https://github.com/elastic/eui/issues/5148
148+
}
149+
descriptionProps={
150+
{
151+
'data-test-subj': 'alertsFlyoutDescriptionListDescription',
152+
} as any // NOTE / TODO: This "any" is a temporary workaround: https://github.com/elastic/eui/issues/5148
153+
}
144154
/>
145155
</EuiFlyoutBody>
146156
{alertData.link && !isInApp && (
147157
<EuiFlyoutFooter>
148158
<EuiFlexGroup justifyContent="flexEnd">
149159
<EuiFlexItem grow={false}>
150-
<EuiButton href={prepend && prepend(alertData.link)} fill>
160+
<EuiButton
161+
href={prepend && prepend(alertData.link)}
162+
data-test-subj="alertsFlyoutViewInAppButton"
163+
fill
164+
>
151165
View in app
152166
</EuiButton>
153167
</EuiFlexItem>

x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ function ObservabilityActions({
254254
iconType="expand"
255255
color="text"
256256
onClick={() => setFlyoutAlert(alert)}
257+
data-test-subj="openFlyoutButton"
257258
/>
258259
</EuiFlexItem>
259260
<EuiFlexItem>

x-pack/plugins/timelines/public/components/t_grid/shared/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const TGridEmpty: React.FC<{ height?: keyof typeof heights }> = ({ height
5151
const { http } = useKibana<CoreStart>().services;
5252

5353
return (
54-
<EuiPanel color="subdued">
54+
<EuiPanel color="subdued" data-test-subj="tGridEmptyState">
5555
<EuiFlexGroup style={{ height: heights[height] }} alignItems="center" justifyContent="center">
5656
<EuiFlexItem grow={false}>
5757
<EuiPanel hasBorder={true} style={panelStyle}>
Binary file not shown.

x-pack/test/functional/es_archives/observability/alerts/mappings.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@
6565
}
6666
}
6767
},
68-
"id": {
69-
"type": "keyword"
68+
"instance": {
69+
"properties": {
70+
"id": {
71+
"type": "keyword"
72+
}
73+
}
7074
},
7175
"reason": {
7276
"type": "keyword"
@@ -325,8 +329,12 @@
325329
}
326330
}
327331
},
328-
"id": {
329-
"type": "keyword"
332+
"instance": {
333+
"properties": {
334+
"id": {
335+
"type": "keyword"
336+
}
337+
}
330338
},
331339
"reason": {
332340
"type": "keyword"
@@ -561,8 +569,12 @@
561569
}
562570
}
563571
},
564-
"id": {
565-
"type": "keyword"
572+
"instance": {
573+
"properties": {
574+
"id": {
575+
"type": "keyword"
576+
}
577+
}
566578
},
567579
"reason": {
568580
"type": "keyword"
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import querystring from 'querystring';
9+
import { FtrProviderContext } from '../../ftr_provider_context';
10+
import { WebElementWrapper } from '../../../../../test/functional/services/lib/web_element_wrapper';
11+
12+
// Based on the x-pack/test/functional/es_archives/observability/alerts archive.
13+
const DATE_WITH_DATA = {
14+
rangeFrom: '2021-09-01T13:36:22.109Z',
15+
rangeTo: '2021-09-03T13:36:22.109Z',
16+
};
17+
18+
const ALERTS_FLYOUT_SELECTOR = 'alertsFlyout';
19+
20+
export function ObservabilityAlertsProvider({ getPageObjects, getService }: FtrProviderContext) {
21+
const testSubjects = getService('testSubjects');
22+
const flyoutService = getService('flyout');
23+
const pageObjects = getPageObjects(['common']);
24+
const retry = getService('retry');
25+
26+
const navigateToTimeWithData = async () => {
27+
return await pageObjects.common.navigateToUrlWithBrowserHistory(
28+
'observability',
29+
'/alerts',
30+
`?${querystring.stringify(DATE_WITH_DATA)}`
31+
);
32+
};
33+
34+
const getTableCells = async () => {
35+
// NOTE: This isn't ideal, but EuiDataGrid doesn't really have the concept of "rows"
36+
return await testSubjects.findAll('dataGridRowCell');
37+
};
38+
39+
const getTableOrFail = async () => {
40+
return await testSubjects.existOrFail('events-viewer-panel');
41+
};
42+
43+
const getNoDataStateOrFail = async () => {
44+
return await testSubjects.existOrFail('tGridEmptyState');
45+
};
46+
47+
// Query Bar
48+
const getQueryBar = async () => {
49+
return await testSubjects.find('queryInput');
50+
};
51+
52+
const getQuerySubmitButton = async () => {
53+
return await testSubjects.find('querySubmitButton');
54+
};
55+
56+
const clearQueryBar = async () => {
57+
return await (await getQueryBar()).clearValueWithKeyboard({ charByChar: true });
58+
};
59+
60+
const typeInQueryBar = async (query: string) => {
61+
return await (await getQueryBar()).type(query);
62+
};
63+
64+
const submitQuery = async (query: string) => {
65+
await typeInQueryBar(query);
66+
return await (await getQuerySubmitButton()).click();
67+
};
68+
69+
// Flyout
70+
const getOpenFlyoutButton = async () => {
71+
return await testSubjects.find('openFlyoutButton');
72+
};
73+
74+
const openAlertsFlyout = async () => {
75+
await (await getOpenFlyoutButton()).click();
76+
await retry.waitFor(
77+
'flyout open',
78+
async () => await testSubjects.exists(ALERTS_FLYOUT_SELECTOR, { timeout: 2500 })
79+
);
80+
};
81+
82+
const getAlertsFlyout = async () => {
83+
return await testSubjects.find(ALERTS_FLYOUT_SELECTOR);
84+
};
85+
86+
const getAlertsFlyoutOrFail = async () => {
87+
return await testSubjects.existOrFail(ALERTS_FLYOUT_SELECTOR);
88+
};
89+
90+
const getAlertsFlyoutTitle = async () => {
91+
return await testSubjects.find('alertsFlyoutTitle');
92+
};
93+
94+
const closeAlertsFlyout = async () => {
95+
return await flyoutService.close(ALERTS_FLYOUT_SELECTOR);
96+
};
97+
98+
const getAlertsFlyoutViewInAppButtonOrFail = async () => {
99+
return await testSubjects.existOrFail('alertsFlyoutViewInAppButton');
100+
};
101+
102+
const getAlertsFlyoutDescriptionListTitles = async (): Promise<WebElementWrapper[]> => {
103+
const flyout = await getAlertsFlyout();
104+
return await testSubjects.findAllDescendant('alertsFlyoutDescriptionListTitle', flyout);
105+
};
106+
107+
const getAlertsFlyoutDescriptionListDescriptions = async (): Promise<WebElementWrapper[]> => {
108+
const flyout = await getAlertsFlyout();
109+
return await testSubjects.findAllDescendant('alertsFlyoutDescriptionListDescription', flyout);
110+
};
111+
112+
return {
113+
clearQueryBar,
114+
typeInQueryBar,
115+
submitQuery,
116+
getTableCells,
117+
getTableOrFail,
118+
getNoDataStateOrFail,
119+
openAlertsFlyout,
120+
getAlertsFlyout,
121+
getAlertsFlyoutTitle,
122+
closeAlertsFlyout,
123+
navigateToTimeWithData,
124+
getAlertsFlyoutOrFail,
125+
getAlertsFlyoutViewInAppButtonOrFail,
126+
getAlertsFlyoutDescriptionListTitles,
127+
getAlertsFlyoutDescriptionListDescriptions,
128+
};
129+
}

x-pack/test/functional/services/observability/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77

88
import { FtrProviderContext } from '../../ftr_provider_context';
99
import { ObservabilityUsersProvider } from './users';
10+
import { ObservabilityAlertsProvider } from './alerts';
1011

1112
export function ObservabilityProvider(context: FtrProviderContext) {
1213
const users = ObservabilityUsersProvider(context);
14+
const alerts = ObservabilityAlertsProvider(context);
1315

1416
return {
1517
users,
18+
alerts,
1619
};
1720
}

0 commit comments

Comments
 (0)