Skip to content

Commit 086534b

Browse files
committed
Fixed due to comments
1 parent c8b8572 commit 086534b

File tree

3 files changed

+72
-6
lines changed

3 files changed

+72
-6
lines changed

x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ export const AlertDetails: React.FunctionComponent<AlertDetailsProps> = ({
113113
history.push(routeToAlertDetails.replace(`:alertId`, alert.id));
114114
};
115115

116+
const getAlertStatusErrorReason = () => {
117+
if (alert.executionStatus.error) {
118+
return alert.executionStatus.error.reason;
119+
} else {
120+
return 'unknown';
121+
}
122+
};
123+
116124
return (
117125
<EuiPage>
118126
<EuiPageBody>
@@ -290,7 +298,7 @@ export const AlertDetails: React.FunctionComponent<AlertDetailsProps> = ({
290298
id="xpack.triggersActionsUI.sections.alertDetails.attentionBannerTitle"
291299
defaultMessage="This alert has an error caused by the {errorReason} reason."
292300
values={{
293-
errorReason: alert.executionStatus.error?.reason,
301+
errorReason: getAlertStatusErrorReason(),
294302
}}
295303
/>
296304
}

x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ describe('alerts_list component with items', () => {
150150
loadAlerts.mockResolvedValue({
151151
page: 1,
152152
perPage: 10000,
153-
total: 2,
153+
total: 4,
154154
data: [
155155
{
156156
id: '1',
@@ -176,7 +176,51 @@ describe('alerts_list component with items', () => {
176176
},
177177
{
178178
id: '2',
179-
name: 'test alert 2',
179+
name: 'test alert ok',
180+
tags: ['tag1'],
181+
enabled: true,
182+
alertTypeId: 'test_alert_type',
183+
schedule: { interval: '5d' },
184+
actions: [],
185+
params: { name: 'test alert type name' },
186+
scheduledTaskId: null,
187+
createdBy: null,
188+
updatedBy: null,
189+
apiKeyOwner: null,
190+
throttle: '1m',
191+
muteAll: false,
192+
mutedInstanceIds: [],
193+
executionStatus: {
194+
status: 'ok',
195+
lastExecutionDate: new Date('2020-08-20T19:23:38Z'),
196+
error: null,
197+
},
198+
},
199+
{
200+
id: '3',
201+
name: 'test alert pending',
202+
tags: ['tag1'],
203+
enabled: true,
204+
alertTypeId: 'test_alert_type',
205+
schedule: { interval: '5d' },
206+
actions: [],
207+
params: { name: 'test alert type name' },
208+
scheduledTaskId: null,
209+
createdBy: null,
210+
updatedBy: null,
211+
apiKeyOwner: null,
212+
throttle: '1m',
213+
muteAll: false,
214+
mutedInstanceIds: [],
215+
executionStatus: {
216+
status: 'pending',
217+
lastExecutionDate: new Date('2020-08-20T19:23:38Z'),
218+
error: null,
219+
},
220+
},
221+
{
222+
id: '4',
223+
name: 'test alert error',
180224
tags: ['tag1'],
181225
enabled: true,
182226
alertTypeId: 'test_alert_type',
@@ -258,8 +302,13 @@ describe('alerts_list component with items', () => {
258302
it('renders table of alerts', async () => {
259303
await setup();
260304
expect(wrapper.find('EuiBasicTable')).toHaveLength(1);
261-
expect(wrapper.find('EuiTableRow')).toHaveLength(2);
262-
expect(wrapper.find('[data-test-subj="alertsTableCell-status"]')).toHaveLength(4);
305+
expect(wrapper.find('EuiTableRow')).toHaveLength(4);
306+
expect(wrapper.find('[data-test-subj="alertsTableCell-status"]').length).toBeGreaterThan(0);
307+
expect(wrapper.find('[data-test-subj="alertStatus-active"]').length).toBeGreaterThan(0);
308+
expect(wrapper.find('[data-test-subj="alertStatus-error"]').length).toBeGreaterThan(0);
309+
expect(wrapper.find('[data-test-subj="alertStatus-ok"]').length).toBeGreaterThan(0);
310+
expect(wrapper.find('[data-test-subj="alertStatus-pending"]').length).toBeGreaterThan(0);
311+
expect(wrapper.find('[data-test-subj="alertStatus-unknown"]').length).toBe(0);
263312
});
264313
});
265314

x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,11 @@ export const AlertsList: React.FunctionComponent = () => {
238238
'data-test-subj': 'alertsTableCell-status',
239239
render: (executionStatus: AlertExecutionStatus) => {
240240
const healthColor = getHealthColor(executionStatus.status);
241-
return <EuiHealth color={healthColor}>{executionStatus.status}</EuiHealth>;
241+
return (
242+
<EuiHealth data-test-subj={`alertStatus-${executionStatus.status}`} color={healthColor}>
243+
{executionStatus.status}
244+
</EuiHealth>
245+
);
242246
},
243247
},
244248
{
@@ -482,6 +486,7 @@ export const AlertsList: React.FunctionComponent = () => {
482486
<FormattedMessage
483487
id="xpack.triggersActionsUI.sections.alertsList.totalStausesActiveDescription"
484488
defaultMessage="Active: {totalStausesActive}"
489+
data-test-subj="totalStausesActive"
485490
values={{
486491
totalStausesActive: alertsStatusesTotal.active,
487492
}}
@@ -492,6 +497,7 @@ export const AlertsList: React.FunctionComponent = () => {
492497
<EuiHealth color="danger">
493498
<FormattedMessage
494499
id="xpack.triggersActionsUI.sections.alertsList.totalStausesErrorDescription"
500+
data-test-subj="totalStausesError"
495501
defaultMessage="Errors: {totalStausesError}"
496502
values={{ totalStausesError: alertsStatusesTotal.error }}
497503
/>
@@ -501,6 +507,7 @@ export const AlertsList: React.FunctionComponent = () => {
501507
<EuiHealth color="subdued">
502508
<FormattedMessage
503509
id="xpack.triggersActionsUI.sections.alertsList.totalStausesOkDescription"
510+
data-test-subj="totalStausesOk"
504511
defaultMessage="Ok: {totalStausesOk}"
505512
values={{ totalStausesOk: alertsStatusesTotal.ok }}
506513
/>
@@ -510,6 +517,7 @@ export const AlertsList: React.FunctionComponent = () => {
510517
<EuiHealth color="success">
511518
<FormattedMessage
512519
id="xpack.triggersActionsUI.sections.alertsList.totalStausesPendingDescription"
520+
data-test-subj="totalStausesPending"
513521
defaultMessage="Pending: {totalStausesPending}"
514522
values={{
515523
totalStausesPending: alertsStatusesTotal.pending,
@@ -521,6 +529,7 @@ export const AlertsList: React.FunctionComponent = () => {
521529
<EuiHealth color="warning">
522530
<FormattedMessage
523531
id="xpack.triggersActionsUI.sections.alertsList.totalStausesUnknownDescription"
532+
data-test-subj="totalStausesUnknown"
524533
defaultMessage="Unknown: {totalStausesUnknown}"
525534
values={{
526535
totalStausesUnknown: alertsStatusesTotal.unknown,

0 commit comments

Comments
 (0)