fix panel migration tests
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import mocks from '../../test-setup/mocks';
|
import mocks from '../../test-setup/mocks';
|
||||||
import {TriggerPanelCtrl} from '../triggers_panel_ctrl';
|
import {TriggerPanelCtrl} from '../triggers_panel_ctrl';
|
||||||
import {DEFAULT_TARGET, DEFAULT_SEVERITY, PANEL_DEFAULTS} from '../triggers_panel_ctrl';
|
import { DEFAULT_TARGET, DEFAULT_SEVERITY, PANEL_DEFAULTS } from '../triggers_panel_ctrl';
|
||||||
import {CURRENT_SCHEMA_VERSION} from '../migrations';
|
import { CURRENT_SCHEMA_VERSION } from '../migrations';
|
||||||
|
|
||||||
jest.mock('@grafana/runtime', () => {
|
jest.mock('@grafana/runtime', () => {
|
||||||
return {
|
return {
|
||||||
@@ -56,10 +56,17 @@ describe('Triggers Panel schema migration', () => {
|
|||||||
|
|
||||||
const expected = _.defaultsDeep({
|
const expected = _.defaultsDeep({
|
||||||
schemaVersion: CURRENT_SCHEMA_VERSION,
|
schemaVersion: CURRENT_SCHEMA_VERSION,
|
||||||
|
datasource: 'zabbix',
|
||||||
targets: [
|
targets: [
|
||||||
{
|
{
|
||||||
...DEFAULT_TARGET,
|
...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,
|
ageField: true,
|
||||||
@@ -79,27 +86,7 @@ describe('Triggers Panel schema migration', () => {
|
|||||||
|
|
||||||
const expected = _.defaultsDeep({
|
const expected = _.defaultsDeep({
|
||||||
schemaVersion: CURRENT_SCHEMA_VERSION,
|
schemaVersion: CURRENT_SCHEMA_VERSION,
|
||||||
targets: [{
|
|
||||||
...DEFAULT_TARGET,
|
|
||||||
datasource: 'zabbix_default'
|
|
||||||
}]
|
|
||||||
}, PANEL_DEFAULTS);
|
}, PANEL_DEFAULTS);
|
||||||
expect(updatedPanelCtrl.panel).toEqual(expected);
|
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