mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Send complete test data to xMatters, so it can create an alert (#145431)
Fixes: #144062
This commit is contained in:
parent
1ed31e1e76
commit
55ca52ddb7
2 changed files with 63 additions and 0 deletions
|
@ -11,6 +11,14 @@ import { XmattersSeverityOptions } from '../../types';
|
|||
import XmattersParamsFields from './xmatters_params';
|
||||
|
||||
describe('XmattersParamsFields renders', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date('2022-01-01T12:00:00.000Z'));
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
test('all params fields is rendered', () => {
|
||||
const actionParams = {
|
||||
alertActionGroupName: 'Small t-shirt',
|
||||
|
@ -53,4 +61,42 @@ describe('XmattersParamsFields renders', () => {
|
|||
'test1, test2'
|
||||
);
|
||||
});
|
||||
|
||||
test('default params for testing', () => {
|
||||
const actionParams = {};
|
||||
const editAction = jest.fn();
|
||||
|
||||
mountWithIntl(
|
||||
<XmattersParamsFields
|
||||
actionParams={actionParams}
|
||||
errors={{
|
||||
alertActionGroupName: [],
|
||||
signalId: [],
|
||||
ruleName: [],
|
||||
date: [],
|
||||
spaceId: [],
|
||||
}}
|
||||
editAction={editAction}
|
||||
index={0}
|
||||
messageVariables={[
|
||||
{
|
||||
name: 'myVar',
|
||||
description: 'My variable description',
|
||||
useWithTripleBracesInTemplates: true,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(editAction).toHaveBeenNthCalledWith(1, 'signalId', 'test-alert', 0);
|
||||
expect(editAction).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
'alertActionGroupName',
|
||||
'test-rule:test-alert',
|
||||
0
|
||||
);
|
||||
expect(editAction).toHaveBeenNthCalledWith(3, 'ruleName', 'Test Rule', 0);
|
||||
expect(editAction).toHaveBeenNthCalledWith(4, 'date', '2022-01-01T12:00:00.000Z', 0);
|
||||
expect(editAction).toHaveBeenNthCalledWith(5, 'spaceId', 'test-space', 0);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -78,7 +78,24 @@ const XmattersParamsFields: React.FunctionComponent<ActionParamsProps<XmattersAc
|
|||
},
|
||||
index
|
||||
);
|
||||
} else {
|
||||
if (!actionParams.signalId) {
|
||||
editAction('signalId', 'test-alert', index);
|
||||
}
|
||||
if (!actionParams.alertActionGroupName) {
|
||||
editAction('alertActionGroupName', 'test-rule:test-alert', index);
|
||||
}
|
||||
if (!actionParams.ruleName) {
|
||||
editAction('ruleName', 'Test Rule', index);
|
||||
}
|
||||
if (!actionParams.date) {
|
||||
editAction('date', new Date().toISOString(), index);
|
||||
}
|
||||
if (!actionParams.spaceId) {
|
||||
editAction('spaceId', 'test-space', index);
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [actionParams]);
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue