-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Uptime] Edit uptime alerts (#68005)
* Extract store creation to plugin start, add redux providers to alert registration. * Update unit test. * Move alert registration to `setup` function. * Allow external editing of uptime client alert types. * Move alert initialization back to `start`. * Clean up interfaces for alert types. * Add code that will work for settings link even outside uptime app. * Create new atomic params type for status alerts. * Update executor params typing to support both alert params types. * Update snapshot for alert factory function. * Fix broken types and refresh snapshots. * Allow edits of filters for monitor alerts. * Support default parameter value for numTimes. * Support default parameter values for timerange. * Modify kuery bar to work for alert edits, fix some filter issues. * Clean up tests and fix types. * Fix types and add a test. * Add callout and validation handling for old alerts while editing. * Add a test for updated validation function. * Define window for overview filters fetch action. * Revert store initialization. * Make monitor counter function while editing alerts. * Refresh snapshot. * Move snapshot count in monitor status alert to callout. * Add new state for selected filters. * Add basic functional tests for uptime alert flyouts. * Fix broken types. * Update unit tests with mock provider. * Remove unneeded params from hook. * Add more unit tests. * Reducing functional test flakiness. * Alert flyout controls update url only within Uptime app. * Extract context interaction to container component, update snapshots. * Add missing parameter to test file. * Remove flaky functional test. Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Shahzad <[email protected]>
- Loading branch information
1 parent
891342a
commit 858523e
Showing
48 changed files
with
1,518 additions
and
383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
180 changes: 180 additions & 0 deletions
180
x-pack/plugins/uptime/public/components/overview/alerts/__tests__/add_filter_btn.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; | ||
import { AddFilterButton } from '../add_filter_btn'; | ||
import { EuiButtonEmpty, EuiContextMenuItem } from '@elastic/eui'; | ||
|
||
describe('AddFilterButton component', () => { | ||
it('provides all filter choices', () => { | ||
const component = shallowWithIntl( | ||
<AddFilterButton newFilters={[]} onNewFilter={jest.fn()} alertFilters={{}} /> | ||
); | ||
expect(component).toMatchInlineSnapshot(` | ||
<EuiPopover | ||
anchorPosition="downLeft" | ||
button={ | ||
<EuiButtonEmpty | ||
data-test-subj="uptimeCreateAlertAddFilter" | ||
disabled={false} | ||
iconType="plusInCircleFilled" | ||
onClick={[Function]} | ||
> | ||
Add filter | ||
</EuiButtonEmpty> | ||
} | ||
closePopover={[Function]} | ||
display="inlineBlock" | ||
hasArrow={true} | ||
id="singlePanel" | ||
isOpen={false} | ||
ownFocus={false} | ||
panelPaddingSize="none" | ||
> | ||
<EuiContextMenuPanel | ||
hasFocus={true} | ||
items={ | ||
Array [ | ||
<EuiContextMenuItem | ||
data-test-subj="uptimeAlertAddFilter.observer.geo.name" | ||
onClick={[Function]} | ||
> | ||
Location | ||
</EuiContextMenuItem>, | ||
<EuiContextMenuItem | ||
data-test-subj="uptimeAlertAddFilter.tags" | ||
onClick={[Function]} | ||
> | ||
Tag | ||
</EuiContextMenuItem>, | ||
<EuiContextMenuItem | ||
data-test-subj="uptimeAlertAddFilter.url.port" | ||
onClick={[Function]} | ||
> | ||
Port | ||
</EuiContextMenuItem>, | ||
<EuiContextMenuItem | ||
data-test-subj="uptimeAlertAddFilter.monitor.type" | ||
onClick={[Function]} | ||
> | ||
Type | ||
</EuiContextMenuItem>, | ||
] | ||
} | ||
/> | ||
</EuiPopover> | ||
`); | ||
}); | ||
|
||
it('excludes filters that already have selected values', () => { | ||
const component = shallowWithIntl( | ||
<AddFilterButton | ||
newFilters={['observer.geo.name', 'tags']} | ||
alertFilters={{ 'url.port': ['443', '80'] }} | ||
onNewFilter={jest.fn()} | ||
/> | ||
); | ||
expect(component).toMatchInlineSnapshot(` | ||
<EuiPopover | ||
anchorPosition="downLeft" | ||
button={ | ||
<EuiButtonEmpty | ||
data-test-subj="uptimeCreateAlertAddFilter" | ||
disabled={false} | ||
iconType="plusInCircleFilled" | ||
onClick={[Function]} | ||
> | ||
Add filter | ||
</EuiButtonEmpty> | ||
} | ||
closePopover={[Function]} | ||
display="inlineBlock" | ||
hasArrow={true} | ||
id="singlePanel" | ||
isOpen={false} | ||
ownFocus={false} | ||
panelPaddingSize="none" | ||
> | ||
<EuiContextMenuPanel | ||
hasFocus={true} | ||
items={ | ||
Array [ | ||
<EuiContextMenuItem | ||
data-test-subj="uptimeAlertAddFilter.monitor.type" | ||
onClick={[Function]} | ||
> | ||
Type | ||
</EuiContextMenuItem>, | ||
] | ||
} | ||
/> | ||
</EuiPopover> | ||
`); | ||
}); | ||
|
||
it('popover is disabled if no values are available', () => { | ||
const component = shallowWithIntl( | ||
<AddFilterButton | ||
newFilters={[]} | ||
alertFilters={{ | ||
'observer.geo.name': ['fairbanks'], | ||
tags: ['foo'], | ||
'url.port': ['80'], | ||
'monitor.type': ['http'], | ||
}} | ||
onNewFilter={jest.fn()} | ||
/> | ||
); | ||
expect(component).toMatchInlineSnapshot(` | ||
<EuiPopover | ||
anchorPosition="downLeft" | ||
button={ | ||
<EuiButtonEmpty | ||
data-test-subj="uptimeCreateAlertAddFilter" | ||
disabled={true} | ||
iconType="plusInCircleFilled" | ||
onClick={[Function]} | ||
> | ||
Add filter | ||
</EuiButtonEmpty> | ||
} | ||
closePopover={[Function]} | ||
display="inlineBlock" | ||
hasArrow={true} | ||
id="singlePanel" | ||
isOpen={false} | ||
ownFocus={false} | ||
panelPaddingSize="none" | ||
> | ||
<EuiContextMenuPanel | ||
hasFocus={true} | ||
items={Array []} | ||
/> | ||
</EuiPopover> | ||
`); | ||
}); | ||
|
||
it('filter select', () => { | ||
const mockOnNewFilter = jest.fn(); | ||
const component = mountWithIntl( | ||
<AddFilterButton newFilters={[]} alertFilters={{}} onNewFilter={mockOnNewFilter} /> | ||
); | ||
component.find(EuiButtonEmpty).simulate('click', { target: { value: '0' } }); | ||
component | ||
.find(EuiContextMenuItem) | ||
.first() | ||
.simulate('click', { target: { value: '0' } }); | ||
expect(mockOnNewFilter).toHaveBeenCalled(); | ||
expect(mockOnNewFilter.mock.calls).toMatchInlineSnapshot(` | ||
Array [ | ||
Array [ | ||
"observer.geo.name", | ||
], | ||
] | ||
`); | ||
}); | ||
}); |
Oops, something went wrong.