|
|
@@ -1,11 +1,13 @@
|
|
|
import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
|
|
|
|
|
|
+import _ from 'lodash';
|
|
|
+import config from 'app/core/config';
|
|
|
import {DashboardExporter} from '../exporter';
|
|
|
|
|
|
describe.only('given dashboard with repeated panels', function() {
|
|
|
var dash, exported;
|
|
|
|
|
|
- beforeEach((done) => {
|
|
|
+ beforeEach(done => {
|
|
|
dash = {
|
|
|
rows: [],
|
|
|
templating: { list: [] }
|
|
|
@@ -19,7 +21,7 @@ describe.only('given dashboard with repeated panels', function() {
|
|
|
dash.rows.push({
|
|
|
repeat: 'test',
|
|
|
panels: [
|
|
|
- {id: 2, repeat: 'apps', datasource: 'gfdb'},
|
|
|
+ {id: 2, repeat: 'apps', datasource: 'gfdb', type: 'graph'},
|
|
|
{id: 2, repeat: null, repeatPanelId: 2},
|
|
|
]
|
|
|
});
|
|
|
@@ -31,19 +33,23 @@ describe.only('given dashboard with repeated panels', function() {
|
|
|
var datasourceSrvStub = {
|
|
|
get: sinon.stub().returns(Promise.resolve({
|
|
|
name: 'gfdb',
|
|
|
- meta: {id: "testdb"}
|
|
|
+ meta: {id: "testdb", info: {version: "1.2.1"}, name: "TestDB"}
|
|
|
}))
|
|
|
};
|
|
|
|
|
|
+ config.panels['graph'] = {
|
|
|
+ id: "graph",
|
|
|
+ name: "Graph",
|
|
|
+ info: {version: "1.1.0"}
|
|
|
+ };
|
|
|
+
|
|
|
var exporter = new DashboardExporter(datasourceSrvStub);
|
|
|
exporter.makeExportable(dash).then(clean => {
|
|
|
exported = clean;
|
|
|
done();
|
|
|
- console.log('done');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
-
|
|
|
it('exported dashboard should not contain repeated panels', function() {
|
|
|
expect(exported.rows[0].panels.length).to.be(1);
|
|
|
});
|
|
|
@@ -63,5 +69,20 @@ describe.only('given dashboard with repeated panels', function() {
|
|
|
expect(exported.__inputs[0].type).to.be("datasource");
|
|
|
});
|
|
|
|
|
|
+ it('should add datasource to required', function() {
|
|
|
+ var require = _.findWhere(exported.__requires, {name: 'TestDB'});
|
|
|
+ expect(require.name).to.be("TestDB");
|
|
|
+ expect(require.id).to.be("testdb");
|
|
|
+ expect(require.type).to.be("datasource");
|
|
|
+ expect(require.version).to.be("1.2.1");
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should add panel to required', function() {
|
|
|
+ var require = _.findWhere(exported.__requires, {name: 'Graph'});
|
|
|
+ expect(require.name).to.be("Graph");
|
|
|
+ expect(require.id).to.be("graph");
|
|
|
+ expect(require.version).to.be("1.1.0");
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|