improve triggers panel tests

This commit is contained in:
Alexander Zobnin
2017-12-20 13:28:44 +03:00
parent 63a2594cf3
commit 65a9669502
2 changed files with 20 additions and 96 deletions

View File

@@ -1,5 +1,7 @@
import _ from 'lodash';
import {TriggerPanelCtrl} from '../triggers_panel_ctrl';
import {DEFAULT_TARGET, DEFAULT_SEVERITY} from '../triggers_panel_ctrl';
import {DEFAULT_TARGET, DEFAULT_SEVERITY, PANEL_DEFAULTS} from '../triggers_panel_ctrl';
import {CURRENT_SCHEMA_VERSION} from '../migrations';
describe('Triggers Panel schema migration', () => {
let ctx = {};
@@ -43,35 +45,18 @@ describe('Triggers Panel schema migration', () => {
it('should update old panel schema', () => {
let updatedPanelCtrl = new TriggerPanelCtrl(ctx.scope, {}, timeoutMock, datasourceSrvMock, {}, {}, {});
let expected = {
schemaVersion: 4,
let expected = _.defaultsDeep({
schemaVersion: CURRENT_SCHEMA_VERSION,
datasources: ['zabbix'],
targets: {
'zabbix': DEFAULT_TARGET
},
hostField: true,
hostTechNameField: false,
hostGroups: false,
showTags: true,
statusField: false,
severityField: false,
descriptionField: true,
descriptionAtNewLine: false,
hostsInMaintenance: true,
showTriggers: 'all triggers',
sortTriggersBy: { text: 'last change', value: 'lastchange' },
showEvents: { text: 'Problems', value: '1' },
limit: 10,
fontSize: '100%',
pageSize: 10,
highlightNewEvents: true,
highlightNewerThan: '1h',
customLastChangeFormat: false,
lastChangeFormat: "",
triggerSeverity: DEFAULT_SEVERITY,
okEventColor: 'rgba(0, 245, 153, 0.45)',
ackEventColor: 'rgba(0, 0, 0, 0)'
};
}, PANEL_DEFAULTS);
expect(updatedPanelCtrl.panel).toEqual(expected);
});
@@ -80,36 +65,13 @@ describe('Triggers Panel schema migration', () => {
ctx.scope.panel = {};
let updatedPanelCtrl = new TriggerPanelCtrl(ctx.scope, {}, {}, datasourceSrvMock, {}, {}, {});
let expected = {
schemaVersion: 4,
let expected = _.defaultsDeep({
schemaVersion: CURRENT_SCHEMA_VERSION,
datasources: ['zabbix_default'],
targets: {
'zabbix_default': DEFAULT_TARGET
},
hostField: true,
hostTechNameField: false,
hostGroups: false,
showTags: true,
statusField: true,
severityField: true,
descriptionField: true,
descriptionAtNewLine: false,
hostsInMaintenance: true,
showTriggers: 'all triggers',
sortTriggersBy: { text: 'last change', value: 'lastchange' },
showEvents: { text: 'Problems', value: '1' },
limit: 100,
fontSize: '100%',
pageSize: 10,
highlightNewEvents: true,
highlightNewerThan: '1h',
customLastChangeFormat: false,
lastChangeFormat: "",
triggerSeverity: DEFAULT_SEVERITY,
okEventColor: 'rgb(56, 189, 113)',
ackEventColor: 'rgb(56, 219, 156)'
};
}
}, PANEL_DEFAULTS);
expect(updatedPanelCtrl.panel).toEqual(expected);
});
});

View File

@@ -1,5 +1,7 @@
import _ from 'lodash';
import {TriggerPanelCtrl} from '../triggers_panel_ctrl';
import {DEFAULT_TARGET, DEFAULT_SEVERITY} from '../triggers_panel_ctrl';
import {DEFAULT_TARGET, DEFAULT_SEVERITY, PANEL_DEFAULTS} from '../triggers_panel_ctrl';
import {CURRENT_SCHEMA_VERSION} from '../migrations';
describe('Triggers Panel schema migration', () => {
let ctx = {};
@@ -43,35 +45,18 @@ describe('Triggers Panel schema migration', () => {
it('should update old panel schema', () => {
let updatedPanelCtrl = new TriggerPanelCtrl(ctx.scope, {}, timeoutMock, datasourceSrvMock, {}, {}, {});
let expected = {
schemaVersion: 4,
let expected = _.defaultsDeep({
schemaVersion: CURRENT_SCHEMA_VERSION,
datasources: ['zabbix'],
targets: {
'zabbix': DEFAULT_TARGET
},
hostField: true,
hostTechNameField: false,
hostGroups: false,
showTags: true,
statusField: false,
severityField: false,
descriptionField: true,
descriptionAtNewLine: false,
hostsInMaintenance: true,
showTriggers: 'all triggers',
sortTriggersBy: { text: 'last change', value: 'lastchange' },
showEvents: { text: 'Problems', value: '1' },
limit: 10,
fontSize: '100%',
pageSize: 10,
highlightNewEvents: true,
highlightNewerThan: '1h',
customLastChangeFormat: false,
lastChangeFormat: "",
triggerSeverity: DEFAULT_SEVERITY,
okEventColor: 'rgba(0, 245, 153, 0.45)',
ackEventColor: 'rgba(0, 0, 0, 0)'
};
}, PANEL_DEFAULTS);
expect(updatedPanelCtrl.panel).toEqual(expected);
});
@@ -80,36 +65,13 @@ describe('Triggers Panel schema migration', () => {
ctx.scope.panel = {};
let updatedPanelCtrl = new TriggerPanelCtrl(ctx.scope, {}, {}, datasourceSrvMock, {}, {}, {});
let expected = {
schemaVersion: 4,
let expected = _.defaultsDeep({
schemaVersion: CURRENT_SCHEMA_VERSION,
datasources: ['zabbix_default'],
targets: {
'zabbix_default': DEFAULT_TARGET
},
hostField: true,
hostTechNameField: false,
hostGroups: false,
showTags: true,
statusField: true,
severityField: true,
descriptionField: true,
descriptionAtNewLine: false,
hostsInMaintenance: true,
showTriggers: 'all triggers',
sortTriggersBy: { text: 'last change', value: 'lastchange' },
showEvents: { text: 'Problems', value: '1' },
limit: 100,
fontSize: '100%',
pageSize: 10,
highlightNewEvents: true,
highlightNewerThan: '1h',
customLastChangeFormat: false,
lastChangeFormat: "",
triggerSeverity: DEFAULT_SEVERITY,
okEventColor: 'rgb(56, 189, 113)',
ackEventColor: 'rgb(56, 219, 156)'
};
}
}, PANEL_DEFAULTS);
expect(updatedPanelCtrl.panel).toEqual(expected);
});
});