improve triggers panel tests
This commit is contained in:
58
dist/panel-triggers/specs/migrations.spec.js
vendored
58
dist/panel-triggers/specs/migrations.spec.js
vendored
@@ -1,5 +1,7 @@
|
|||||||
|
import _ from 'lodash';
|
||||||
import {TriggerPanelCtrl} from '../triggers_panel_ctrl';
|
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', () => {
|
describe('Triggers Panel schema migration', () => {
|
||||||
let ctx = {};
|
let ctx = {};
|
||||||
@@ -43,35 +45,18 @@ describe('Triggers Panel schema migration', () => {
|
|||||||
it('should update old panel schema', () => {
|
it('should update old panel schema', () => {
|
||||||
let updatedPanelCtrl = new TriggerPanelCtrl(ctx.scope, {}, timeoutMock, datasourceSrvMock, {}, {}, {});
|
let updatedPanelCtrl = new TriggerPanelCtrl(ctx.scope, {}, timeoutMock, datasourceSrvMock, {}, {}, {});
|
||||||
|
|
||||||
let expected = {
|
let expected = _.defaultsDeep({
|
||||||
schemaVersion: 4,
|
schemaVersion: CURRENT_SCHEMA_VERSION,
|
||||||
datasources: ['zabbix'],
|
datasources: ['zabbix'],
|
||||||
targets: {
|
targets: {
|
||||||
'zabbix': DEFAULT_TARGET
|
'zabbix': DEFAULT_TARGET
|
||||||
},
|
},
|
||||||
hostField: true,
|
|
||||||
hostTechNameField: false,
|
|
||||||
hostGroups: false,
|
|
||||||
showTags: true,
|
|
||||||
statusField: false,
|
statusField: false,
|
||||||
severityField: 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,
|
limit: 10,
|
||||||
fontSize: '100%',
|
|
||||||
pageSize: 10,
|
|
||||||
highlightNewEvents: true,
|
|
||||||
highlightNewerThan: '1h',
|
|
||||||
customLastChangeFormat: false,
|
|
||||||
lastChangeFormat: "",
|
|
||||||
triggerSeverity: DEFAULT_SEVERITY,
|
|
||||||
okEventColor: 'rgba(0, 245, 153, 0.45)',
|
okEventColor: 'rgba(0, 245, 153, 0.45)',
|
||||||
ackEventColor: 'rgba(0, 0, 0, 0)'
|
ackEventColor: 'rgba(0, 0, 0, 0)'
|
||||||
};
|
}, PANEL_DEFAULTS);
|
||||||
|
|
||||||
expect(updatedPanelCtrl.panel).toEqual(expected);
|
expect(updatedPanelCtrl.panel).toEqual(expected);
|
||||||
});
|
});
|
||||||
@@ -80,36 +65,13 @@ describe('Triggers Panel schema migration', () => {
|
|||||||
ctx.scope.panel = {};
|
ctx.scope.panel = {};
|
||||||
let updatedPanelCtrl = new TriggerPanelCtrl(ctx.scope, {}, {}, datasourceSrvMock, {}, {}, {});
|
let updatedPanelCtrl = new TriggerPanelCtrl(ctx.scope, {}, {}, datasourceSrvMock, {}, {}, {});
|
||||||
|
|
||||||
let expected = {
|
let expected = _.defaultsDeep({
|
||||||
schemaVersion: 4,
|
schemaVersion: CURRENT_SCHEMA_VERSION,
|
||||||
datasources: ['zabbix_default'],
|
datasources: ['zabbix_default'],
|
||||||
targets: {
|
targets: {
|
||||||
'zabbix_default': DEFAULT_TARGET
|
'zabbix_default': DEFAULT_TARGET
|
||||||
},
|
}
|
||||||
hostField: true,
|
}, PANEL_DEFAULTS);
|
||||||
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)'
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(updatedPanelCtrl.panel).toEqual(expected);
|
expect(updatedPanelCtrl.panel).toEqual(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
import _ from 'lodash';
|
||||||
import {TriggerPanelCtrl} from '../triggers_panel_ctrl';
|
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', () => {
|
describe('Triggers Panel schema migration', () => {
|
||||||
let ctx = {};
|
let ctx = {};
|
||||||
@@ -43,35 +45,18 @@ describe('Triggers Panel schema migration', () => {
|
|||||||
it('should update old panel schema', () => {
|
it('should update old panel schema', () => {
|
||||||
let updatedPanelCtrl = new TriggerPanelCtrl(ctx.scope, {}, timeoutMock, datasourceSrvMock, {}, {}, {});
|
let updatedPanelCtrl = new TriggerPanelCtrl(ctx.scope, {}, timeoutMock, datasourceSrvMock, {}, {}, {});
|
||||||
|
|
||||||
let expected = {
|
let expected = _.defaultsDeep({
|
||||||
schemaVersion: 4,
|
schemaVersion: CURRENT_SCHEMA_VERSION,
|
||||||
datasources: ['zabbix'],
|
datasources: ['zabbix'],
|
||||||
targets: {
|
targets: {
|
||||||
'zabbix': DEFAULT_TARGET
|
'zabbix': DEFAULT_TARGET
|
||||||
},
|
},
|
||||||
hostField: true,
|
|
||||||
hostTechNameField: false,
|
|
||||||
hostGroups: false,
|
|
||||||
showTags: true,
|
|
||||||
statusField: false,
|
statusField: false,
|
||||||
severityField: 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,
|
limit: 10,
|
||||||
fontSize: '100%',
|
|
||||||
pageSize: 10,
|
|
||||||
highlightNewEvents: true,
|
|
||||||
highlightNewerThan: '1h',
|
|
||||||
customLastChangeFormat: false,
|
|
||||||
lastChangeFormat: "",
|
|
||||||
triggerSeverity: DEFAULT_SEVERITY,
|
|
||||||
okEventColor: 'rgba(0, 245, 153, 0.45)',
|
okEventColor: 'rgba(0, 245, 153, 0.45)',
|
||||||
ackEventColor: 'rgba(0, 0, 0, 0)'
|
ackEventColor: 'rgba(0, 0, 0, 0)'
|
||||||
};
|
}, PANEL_DEFAULTS);
|
||||||
|
|
||||||
expect(updatedPanelCtrl.panel).toEqual(expected);
|
expect(updatedPanelCtrl.panel).toEqual(expected);
|
||||||
});
|
});
|
||||||
@@ -80,36 +65,13 @@ describe('Triggers Panel schema migration', () => {
|
|||||||
ctx.scope.panel = {};
|
ctx.scope.panel = {};
|
||||||
let updatedPanelCtrl = new TriggerPanelCtrl(ctx.scope, {}, {}, datasourceSrvMock, {}, {}, {});
|
let updatedPanelCtrl = new TriggerPanelCtrl(ctx.scope, {}, {}, datasourceSrvMock, {}, {}, {});
|
||||||
|
|
||||||
let expected = {
|
let expected = _.defaultsDeep({
|
||||||
schemaVersion: 4,
|
schemaVersion: CURRENT_SCHEMA_VERSION,
|
||||||
datasources: ['zabbix_default'],
|
datasources: ['zabbix_default'],
|
||||||
targets: {
|
targets: {
|
||||||
'zabbix_default': DEFAULT_TARGET
|
'zabbix_default': DEFAULT_TARGET
|
||||||
},
|
}
|
||||||
hostField: true,
|
}, PANEL_DEFAULTS);
|
||||||
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)'
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(updatedPanelCtrl.panel).toEqual(expected);
|
expect(updatedPanelCtrl.panel).toEqual(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user