forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ResponseOps][Rules] Use rule form instead of rule flyout in observab…
…ility solution (elastic#206774) ## Summary Resolves elastic#195574 This PR updates observability solution to use new rule form to `create` and `edit` rules same as `stack management > rules` page. It removes usage of rule flyout form o11y solution. Also updated functional tests. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### How to test - Create a rule in o11y, verify it works as expected - Edit rule in o11y via different options (from rule details page, rule list table, alert details page etc.) verify it works as expected - Verify the same in serverless o11y project ### Release Note Use rule form to create or edit rules in observability. --------- Co-authored-by: Maryam Saeidi <[email protected]>
- Loading branch information
1 parent
1ca4d96
commit dd6376d
Showing
12 changed files
with
469 additions
and
61 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
247 changes: 247 additions & 0 deletions
247
...tform/packages/shared/response-ops/rule_form/src/utils/get_initial_multi_consumer.test.ts
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,247 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { RuleTypeWithDescription } from '@kbn/alerts-ui-shared'; | ||
import { getInitialMultiConsumer } from './get_initial_multi_consumer'; | ||
|
||
describe('getInitialMultiConsumer', () => { | ||
const ruleType = { | ||
id: '.es-query', | ||
name: 'Test', | ||
actionGroups: [ | ||
{ | ||
id: 'testActionGroup', | ||
name: 'Test Action Group', | ||
}, | ||
{ | ||
id: 'recovered', | ||
name: 'Recovered', | ||
}, | ||
], | ||
defaultActionGroupId: 'testActionGroup', | ||
minimumLicenseRequired: 'basic', | ||
recoveryActionGroup: { | ||
id: 'recovered', | ||
name: 'Recovered', | ||
}, | ||
producer: 'logs', | ||
authorizedConsumers: { | ||
alerting: { read: true, all: true }, | ||
test: { read: true, all: true }, | ||
stackAlerts: { read: true, all: true }, | ||
logs: { read: true, all: true }, | ||
}, | ||
actionVariables: { | ||
params: [], | ||
state: [], | ||
}, | ||
enabledInLicense: true, | ||
category: 'test', | ||
} as RuleTypeWithDescription; | ||
|
||
const ruleTypes = [ | ||
{ | ||
id: '.es-query', | ||
name: 'Test', | ||
actionGroups: [ | ||
{ | ||
id: 'testActionGroup', | ||
name: 'Test Action Group', | ||
}, | ||
{ | ||
id: 'recovered', | ||
name: 'Recovered', | ||
}, | ||
], | ||
defaultActionGroupId: 'testActionGroup', | ||
minimumLicenseRequired: 'basic', | ||
recoveryActionGroup: { | ||
id: 'recovered', | ||
}, | ||
producer: 'logs', | ||
authorizedConsumers: { | ||
alerting: { read: true, all: true }, | ||
test: { read: true, all: true }, | ||
stackAlerts: { read: true, all: true }, | ||
logs: { read: true, all: true }, | ||
}, | ||
actionVariables: { | ||
params: [], | ||
state: [], | ||
}, | ||
enabledInLicense: true, | ||
}, | ||
{ | ||
enabledInLicense: true, | ||
recoveryActionGroup: { | ||
id: 'recovered', | ||
name: 'Recovered', | ||
}, | ||
actionGroups: [], | ||
defaultActionGroupId: 'threshold met', | ||
minimumLicenseRequired: 'basic', | ||
authorizedConsumers: { | ||
stackAlerts: { | ||
read: true, | ||
all: true, | ||
}, | ||
}, | ||
actionVariables: { | ||
params: [], | ||
state: [], | ||
}, | ||
id: '.index-threshold', | ||
name: 'Index threshold', | ||
category: 'management', | ||
producer: 'stackAlerts', | ||
}, | ||
] as RuleTypeWithDescription[]; | ||
|
||
test('should return null when rule type id does not match', () => { | ||
const res = getInitialMultiConsumer({ | ||
multiConsumerSelection: null, | ||
validConsumers: ['logs', 'observability'], | ||
ruleType: { | ||
...ruleType, | ||
id: 'test', | ||
}, | ||
ruleTypes, | ||
isServerless: false, | ||
}); | ||
|
||
expect(res).toBe(null); | ||
}); | ||
|
||
test('should return null when no valid consumers', () => { | ||
const res = getInitialMultiConsumer({ | ||
multiConsumerSelection: null, | ||
validConsumers: [], | ||
ruleType, | ||
ruleTypes, | ||
isServerless: false, | ||
}); | ||
|
||
expect(res).toBe(null); | ||
}); | ||
|
||
test('should return same valid consumer when only one valid consumer', () => { | ||
const res = getInitialMultiConsumer({ | ||
multiConsumerSelection: null, | ||
validConsumers: ['alerts'], | ||
ruleType, | ||
ruleTypes, | ||
isServerless: false, | ||
}); | ||
|
||
expect(res).toBe('alerts'); | ||
}); | ||
|
||
test('should not return observability consumer for non serverless', () => { | ||
const res = getInitialMultiConsumer({ | ||
multiConsumerSelection: null, | ||
validConsumers: ['logs', 'infrastructure', 'observability'], | ||
ruleType, | ||
ruleTypes, | ||
isServerless: false, | ||
}); | ||
|
||
expect(res).toBe('logs'); | ||
}); | ||
|
||
test('should return observability consumer for serverless', () => { | ||
const res = getInitialMultiConsumer({ | ||
multiConsumerSelection: null, | ||
validConsumers: ['logs', 'infrastructure', 'observability'], | ||
ruleType, | ||
ruleTypes, | ||
isServerless: true, | ||
}); | ||
|
||
expect(res).toBe('observability'); | ||
}); | ||
|
||
test('should return null when there is no authorized consumers', () => { | ||
const res = getInitialMultiConsumer({ | ||
multiConsumerSelection: null, | ||
validConsumers: ['alerts', 'infrastructure'], | ||
ruleType: { | ||
...ruleType, | ||
authorizedConsumers: {}, | ||
}, | ||
ruleTypes, | ||
isServerless: false, | ||
}); | ||
|
||
expect(res).toBe(null); | ||
}); | ||
|
||
test('should return null when multiConsumerSelection is null', () => { | ||
const res = getInitialMultiConsumer({ | ||
multiConsumerSelection: null, | ||
validConsumers: ['stackAlerts', 'logs'], | ||
ruleType: { | ||
...ruleType, | ||
authorizedConsumers: { | ||
stackAlerts: { read: true, all: true }, | ||
}, | ||
}, | ||
ruleTypes, | ||
isServerless: false, | ||
}); | ||
|
||
expect(res).toBe(null); | ||
}); | ||
|
||
test('should return valid multi consumer correctly', () => { | ||
const res = getInitialMultiConsumer({ | ||
multiConsumerSelection: 'logs', | ||
validConsumers: ['stackAlerts', 'logs'], | ||
ruleType: { | ||
...ruleType, | ||
authorizedConsumers: { | ||
stackAlerts: { read: true, all: true }, | ||
}, | ||
}, | ||
ruleTypes, | ||
isServerless: false, | ||
}); | ||
|
||
expect(res).toBe('logs'); | ||
}); | ||
|
||
test('should return stackAlerts correctly', () => { | ||
const res = getInitialMultiConsumer({ | ||
multiConsumerSelection: 'alerts', | ||
validConsumers: ['stackAlerts', 'logs'], | ||
ruleType: { | ||
...ruleType, | ||
authorizedConsumers: {}, | ||
}, | ||
ruleTypes, | ||
isServerless: false, | ||
}); | ||
|
||
expect(res).toBe('stackAlerts'); | ||
}); | ||
|
||
test('should return null valid consumer correctly', () => { | ||
const res = getInitialMultiConsumer({ | ||
multiConsumerSelection: 'alerts', | ||
validConsumers: ['infrastructure', 'logs'], | ||
ruleType: { | ||
...ruleType, | ||
authorizedConsumers: {}, | ||
}, | ||
ruleTypes: [], | ||
isServerless: false, | ||
}); | ||
|
||
expect(res).toBe(null); | ||
}); | ||
}); |
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
Oops, something went wrong.