fix panel migration tests
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import _ from 'lodash';
|
||||
import mocks from '../../test-setup/mocks';
|
||||
import {TriggerPanelCtrl} from '../triggers_panel_ctrl';
|
||||
import {DEFAULT_TARGET, DEFAULT_SEVERITY, PANEL_DEFAULTS} from '../triggers_panel_ctrl';
|
||||
import {CURRENT_SCHEMA_VERSION} from '../migrations';
|
||||
import { DEFAULT_TARGET, DEFAULT_SEVERITY, PANEL_DEFAULTS } from '../triggers_panel_ctrl';
|
||||
import { CURRENT_SCHEMA_VERSION } from '../migrations';
|
||||
|
||||
jest.mock('@grafana/runtime', () => {
|
||||
return {
|
||||
@@ -56,10 +56,17 @@ describe('Triggers Panel schema migration', () => {
|
||||
|
||||
const expected = _.defaultsDeep({
|
||||
schemaVersion: CURRENT_SCHEMA_VERSION,
|
||||
datasource: 'zabbix',
|
||||
targets: [
|
||||
{
|
||||
...DEFAULT_TARGET,
|
||||
datasource: 'zabbix',
|
||||
queryType: 5,
|
||||
options: {
|
||||
hostsInMaintenance: true,
|
||||
showTriggers: 'all triggers',
|
||||
sortTriggersBy: { text: 'last change', value: 'lastchange' },
|
||||
showEvents: { text: 'Problems', value: 1 },
|
||||
}
|
||||
}
|
||||
],
|
||||
ageField: true,
|
||||
@@ -79,27 +86,7 @@ describe('Triggers Panel schema migration', () => {
|
||||
|
||||
const expected = _.defaultsDeep({
|
||||
schemaVersion: CURRENT_SCHEMA_VERSION,
|
||||
targets: [{
|
||||
...DEFAULT_TARGET,
|
||||
datasource: 'zabbix_default'
|
||||
}]
|
||||
}, PANEL_DEFAULTS);
|
||||
expect(updatedPanelCtrl.panel).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should set default targets for new panel with empty targets', () => {
|
||||
ctx.scope.panel = {
|
||||
targets: []
|
||||
};
|
||||
const updatedPanelCtrl = updatePanelCtrl(ctx.scope);
|
||||
|
||||
const expected = _.defaultsDeep({
|
||||
targets: [{
|
||||
...DEFAULT_TARGET,
|
||||
datasource: 'zabbix_default'
|
||||
}]
|
||||
}, PANEL_DEFAULTS);
|
||||
|
||||
expect(updatedPanelCtrl.panel).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user