Skip to content

Commit

Permalink
[8.x] [ResponseOps][Flapping] Update rule specific flapping tooltip UI (
Browse files Browse the repository at this point in the history
#194086) (#194779)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ResponseOps][Flapping] Update rule specific flapping tooltip UI
(#194086)](#194086)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Jiawei
Wu","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-03T03:48:11Z","message":"[ResponseOps][Flapping]
Update rule specific flapping tooltip UI (#194086)\n\n##
Summary\r\nUpdates the rule specific flapping UI according to the
finalized
figma\r\ndesigns:\r\nhttps://www.figma.com/design/eTr6WsKzhSLcQ24AlgrY8R/Flapping-per-Rule--%3E-%23294?node-id=5265-28064&node-type=instance&t=GX5pGpXe1blP0x0G-0\r\n\r\n<img
width=\"798\" alt=\"Screenshot 2024-09-25 at 8 56
47 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/2655a3cd-8097-442e-a3c0-71ab40675e31\">\r\n<img
width=\"588\" alt=\"Screenshot 2024-09-25 at 9 23
30 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/e40b43be-f5a5-4d80-a35c-c3032e017b56\">\r\n\r\n###
To test:\r\n1. Turn `IS_RULE_SPECIFIC_FLAPPING_ENABLED` to `true`.\r\n2.
Navigate to rule create/edit flyout and you should see the
new\r\ntooltips based on the figma designs linked above.\r\n\r\n###
Checklist\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"aab80bdee97a20e13e1b7ab83971088f1a6b447e","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","v9.0.0","backport:prev-minor","v8.16.0"],"title":"[ResponseOps][Flapping]
Update rule specific flapping tooltip
UI","number":194086,"url":"https://github.com/elastic/kibana/pull/194086","mergeCommit":{"message":"[ResponseOps][Flapping]
Update rule specific flapping tooltip UI (#194086)\n\n##
Summary\r\nUpdates the rule specific flapping UI according to the
finalized
figma\r\ndesigns:\r\nhttps://www.figma.com/design/eTr6WsKzhSLcQ24AlgrY8R/Flapping-per-Rule--%3E-%23294?node-id=5265-28064&node-type=instance&t=GX5pGpXe1blP0x0G-0\r\n\r\n<img
width=\"798\" alt=\"Screenshot 2024-09-25 at 8 56
47 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/2655a3cd-8097-442e-a3c0-71ab40675e31\">\r\n<img
width=\"588\" alt=\"Screenshot 2024-09-25 at 9 23
30 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/e40b43be-f5a5-4d80-a35c-c3032e017b56\">\r\n\r\n###
To test:\r\n1. Turn `IS_RULE_SPECIFIC_FLAPPING_ENABLED` to `true`.\r\n2.
Navigate to rule create/edit flyout and you should see the
new\r\ntooltips based on the figma designs linked above.\r\n\r\n###
Checklist\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"aab80bdee97a20e13e1b7ab83971088f1a6b447e"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/194086","number":194086,"mergeCommit":{"message":"[ResponseOps][Flapping]
Update rule specific flapping tooltip UI (#194086)\n\n##
Summary\r\nUpdates the rule specific flapping UI according to the
finalized
figma\r\ndesigns:\r\nhttps://www.figma.com/design/eTr6WsKzhSLcQ24AlgrY8R/Flapping-per-Rule--%3E-%23294?node-id=5265-28064&node-type=instance&t=GX5pGpXe1blP0x0G-0\r\n\r\n<img
width=\"798\" alt=\"Screenshot 2024-09-25 at 8 56
47 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/2655a3cd-8097-442e-a3c0-71ab40675e31\">\r\n<img
width=\"588\" alt=\"Screenshot 2024-09-25 at 9 23
30 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/e40b43be-f5a5-4d80-a35c-c3032e017b56\">\r\n\r\n###
To test:\r\n1. Turn `IS_RULE_SPECIFIC_FLAPPING_ENABLED` to `true`.\r\n2.
Navigate to rule create/edit flyout and you should see the
new\r\ntooltips based on the figma designs linked above.\r\n\r\n###
Checklist\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"aab80bdee97a20e13e1b7ab83971088f1a6b447e"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Jiawei Wu <[email protected]>
  • Loading branch information
kibanamachine and JiaweiWu authored Oct 3, 2024
1 parent c9cb0fa commit c8fdb03
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ jest.mock('../../lib/action_connector_api', () => ({
loadAllActions: jest.fn(),
}));

jest.mock('../../lib/rule_api/get_flapping_settings', () => ({
getFlappingSettings: jest.fn().mockResolvedValue({
lookBackWindow: 20,
statusChangeThreshold: 20,
}),
}));

const actionTypeRegistry = actionTypeRegistryMock.create();
const ruleTypeRegistry = ruleTypeRegistryMock.create();

Expand Down Expand Up @@ -149,6 +156,9 @@ describe('rule_add', () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
useKibanaMock().services.application.capabilities = {
...capabilities,
rulesSettings: {
writeFlappingSettingsUI: true,
},
rules: {
show: true,
save: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ jest.mock('@kbn/alerts-ui-shared/src/common/apis/fetch_ui_health_status', () =>
fetchUiHealthStatus: jest.fn(() => ({ isRulesAvailable: true })),
}));

jest.mock('../../lib/rule_api/get_flapping_settings', () => ({
getFlappingSettings: jest.fn().mockResolvedValue({
lookBackWindow: 20,
statusChangeThreshold: 20,
}),
}));

describe('rule_edit', () => {
let wrapper: ReactWrapper<any>;
let mockedCoreSetup: ReturnType<typeof coreMock.createSetup>;
Expand All @@ -80,6 +87,9 @@ describe('rule_edit', () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
useKibanaMock().services.application.capabilities = {
...capabilities,
rulesSettings: {
writeFlappingSettingsUI: true,
},
rules: {
show: true,
save: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ jest.mock('../../lib/capabilities', () => ({
hasShowActionsCapability: jest.fn(() => true),
hasExecuteActionsCapability: jest.fn(() => true),
}));
jest.mock('../../lib/rule_api/get_flapping_settings', () => ({
getFlappingSettings: jest.fn().mockResolvedValue({
lookBackWindow: 20,
statusChangeThreshold: 20,
}),
}));

describe('rule_form', () => {
const ruleType = {
Expand Down Expand Up @@ -203,6 +209,9 @@ describe('rule_form', () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
useKibanaMock().services.application.capabilities = {
...capabilities,
rulesSettings: {
writeFlappingSettingsUI: true,
},
rules: {
show: true,
save: true,
Expand Down Expand Up @@ -358,6 +367,9 @@ describe('rule_form', () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
useKibanaMock().services.application.capabilities = {
...capabilities,
rulesSettings: {
writeFlappingSettingsUI: true,
},
rules: {
show: true,
save: true,
Expand Down Expand Up @@ -1071,6 +1083,9 @@ describe('rule_form', () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
useKibanaMock().services.application.capabilities = {
...capabilities,
rulesSettings: {
writeFlappingSettingsUI: true,
},
rules: {
show: true,
save: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { __IntlProvider as IntlProvider } from '@kbn/i18n-react';
import { RuleFormAdvancedOptions } from './rule_form_advanced_options';
import { useKibana } from '../../../common/lib/kibana';
import userEvent from '@testing-library/user-event';
import { ApplicationStart } from '@kbn/core-application-browser';

jest.mock('../../../common/lib/kibana');

Expand All @@ -38,6 +39,11 @@ describe('ruleFormAdvancedOptions', () => {
enabled: true,
});
useKibanaMock().services.http = http;
useKibanaMock().services.application.capabilities = {
rulesSettings: {
writeFlappingSettingsUI: true,
},
} as unknown as ApplicationStart['capabilities'];
});

afterEach(() => {
Expand Down Expand Up @@ -80,7 +86,7 @@ describe('ruleFormAdvancedOptions', () => {

expect(await screen.findByText('ON')).toBeInTheDocument();
expect(screen.getByTestId('ruleFormAdvancedOptionsOverrideSwitch')).not.toBeChecked();
expect(screen.queryByText('Override')).not.toBeInTheDocument();
expect(screen.queryByText('Custom')).not.toBeInTheDocument();
expect(screen.getByTestId('ruleSettingsFlappingMessage')).toHaveTextContent(
'An alert is flapping if it changes status at least 3 times in the last 10 rule runs.'
);
Expand Down Expand Up @@ -111,7 +117,7 @@ describe('ruleFormAdvancedOptions', () => {
);

expect(await screen.findByTestId('ruleFormAdvancedOptionsOverrideSwitch')).toBeChecked();
expect(screen.getByText('Override')).toBeInTheDocument();
expect(screen.getByText('Custom')).toBeInTheDocument();
expect(screen.getByTestId('lookBackWindowRangeInput')).toHaveValue('6');
expect(screen.getByTestId('statusChangeThresholdRangeInput')).toHaveValue('4');
expect(screen.getByTestId('ruleSettingsFlappingMessage')).toHaveTextContent(
Expand Down Expand Up @@ -148,7 +154,7 @@ describe('ruleFormAdvancedOptions', () => {
);

expect(await screen.findByText('OFF')).toBeInTheDocument();
expect(screen.queryByText('Override')).not.toBeInTheDocument();
expect(screen.queryByText('Custom')).not.toBeInTheDocument();
expect(screen.queryByTestId('ruleFormAdvancedOptionsOverrideSwitch')).not.toBeInTheDocument();
expect(screen.queryByTestId('ruleSettingsFlappingMessage')).not.toBeInTheDocument();
});
Expand Down
Loading

0 comments on commit c8fdb03

Please sign in to comment.