2017-11-17 16:18:30 +01:00
|
|
|
import { SaveDashboardAsModalCtrl } from '../save_as_modal';
|
|
|
|
|
import { describe, it, expect } from 'test/lib/common';
|
2017-10-27 11:15:47 +02:00
|
|
|
|
|
|
|
|
describe('saving dashboard as', () => {
|
2017-11-17 16:18:30 +01:00
|
|
|
function scenario(name, panel, verify) {
|
|
|
|
|
describe(name, () => {
|
|
|
|
|
var json = {
|
|
|
|
|
title: 'name',
|
|
|
|
|
panels: [panel],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var mockDashboardSrv = {
|
|
|
|
|
getCurrent: function() {
|
|
|
|
|
return {
|
|
|
|
|
id: 5,
|
|
|
|
|
meta: {},
|
|
|
|
|
getSaveModelClone: function() {
|
|
|
|
|
return json;
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var ctrl = new SaveDashboardAsModalCtrl(mockDashboardSrv);
|
|
|
|
|
var ctx: any = {
|
|
|
|
|
clone: ctrl.clone,
|
|
|
|
|
ctrl: ctrl,
|
|
|
|
|
panel: panel
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
it('verify', () => {
|
|
|
|
|
verify(ctx);
|
|
|
|
|
});
|
2017-10-27 11:15:47 +02:00
|
|
|
});
|
2017-11-17 16:18:30 +01:00
|
|
|
}
|
2017-10-27 11:15:47 +02:00
|
|
|
|
2017-11-17 16:18:30 +01:00
|
|
|
scenario('default values', {}, ctx => {
|
|
|
|
|
var clone = ctx.clone;
|
|
|
|
|
expect(clone.id).toBe(null);
|
|
|
|
|
expect(clone.title).toBe('name Copy');
|
|
|
|
|
expect(clone.editable).toBe(true);
|
|
|
|
|
expect(clone.hideControls).toBe(false);
|
|
|
|
|
});
|
2017-10-27 11:15:47 +02:00
|
|
|
|
2017-11-17 16:18:30 +01:00
|
|
|
var graphPanel = { id: 1, type: 'graph', alert: { rule: 1 }, thresholds: { value: 3000 } };
|
2017-10-27 11:15:47 +02:00
|
|
|
|
2017-11-17 16:18:30 +01:00
|
|
|
scenario('should remove alert from graph panel', graphPanel, ctx => {
|
|
|
|
|
expect(ctx.panel.alert).toBe(undefined);
|
|
|
|
|
});
|
2017-10-27 11:15:47 +02:00
|
|
|
|
2017-11-17 16:18:30 +01:00
|
|
|
scenario('should remove threshold from graph panel', graphPanel, ctx => {
|
|
|
|
|
expect(ctx.panel.thresholds).toBe(undefined);
|
|
|
|
|
});
|
2017-10-27 11:15:47 +02:00
|
|
|
|
2017-11-17 16:18:30 +01:00
|
|
|
scenario('singlestat should keep threshold', { id: 1, type: 'singlestat', thresholds: { value: 3000 } }, ctx => {
|
|
|
|
|
expect(ctx.panel.thresholds).not.toBe(undefined);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
scenario('table should keep threshold', { id: 1, type: 'table', thresholds: { value: 3000 } }, ctx => {
|
|
|
|
|
expect(ctx.panel.thresholds).not.toBe(undefined);
|
|
|
|
|
});
|
2017-10-27 11:15:47 +02:00
|
|
|
});
|