2014-09-30 07:42:59 -05:00
|
|
|
define([
|
2014-12-23 14:01:50 -06:00
|
|
|
'helpers',
|
2015-05-08 03:56:54 -05:00
|
|
|
'features/dashboard/shareModalCtrl',
|
|
|
|
'features/panellinks/linkSrv',
|
2014-10-01 00:58:31 -05:00
|
|
|
], function(helpers) {
|
2014-09-30 07:42:59 -05:00
|
|
|
'use strict';
|
|
|
|
|
2015-03-29 08:01:27 -05:00
|
|
|
describe('ShareModalCtrl', function() {
|
2014-09-30 07:42:59 -05:00
|
|
|
var ctx = new helpers.ControllerTestContext();
|
|
|
|
|
2014-11-11 04:48:27 -06:00
|
|
|
function setTime(range) {
|
2015-05-28 02:35:47 -05:00
|
|
|
ctx.timeSrv.timeRange = sinon.stub().returns(range);
|
2014-11-11 04:48:27 -06:00
|
|
|
}
|
|
|
|
|
2015-05-28 02:35:47 -05:00
|
|
|
setTime({ from: new Date(1000), to: new Date(2000) });
|
2014-11-11 04:48:27 -06:00
|
|
|
|
2014-09-30 07:42:59 -05:00
|
|
|
beforeEach(module('grafana.controllers'));
|
2015-05-08 03:56:54 -05:00
|
|
|
beforeEach(module('grafana.services'));
|
2014-09-30 07:42:59 -05:00
|
|
|
|
|
|
|
beforeEach(ctx.providePhase());
|
2015-05-08 03:56:54 -05:00
|
|
|
|
2015-03-29 07:30:03 -05:00
|
|
|
beforeEach(ctx.createControllerPhase('ShareModalCtrl'));
|
2014-09-30 07:42:59 -05:00
|
|
|
|
|
|
|
describe('shareUrl with current time range and panel', function() {
|
|
|
|
|
|
|
|
it('should generate share url absolute time', function() {
|
|
|
|
ctx.$location.path('/test');
|
|
|
|
ctx.scope.panel = { id: 22 };
|
|
|
|
|
2015-03-29 08:01:27 -05:00
|
|
|
ctx.scope.init();
|
2015-05-28 02:35:47 -05:00
|
|
|
expect(ctx.scope.shareUrl).to.be('http://server/#/test?from=1000&to=2000&panelId=22&fullscreen');
|
2014-09-30 07:42:59 -05:00
|
|
|
});
|
|
|
|
|
2015-03-29 08:01:27 -05:00
|
|
|
it('should remove panel id when no panel in scope', function() {
|
2014-09-30 07:42:59 -05:00
|
|
|
ctx.$location.path('/test');
|
2015-04-02 02:21:38 -05:00
|
|
|
ctx.scope.options.forCurrent = true;
|
2015-03-29 08:01:27 -05:00
|
|
|
ctx.scope.panel = null;
|
2014-09-30 07:42:59 -05:00
|
|
|
|
2015-03-29 08:01:27 -05:00
|
|
|
ctx.scope.init();
|
2015-05-28 02:35:47 -05:00
|
|
|
expect(ctx.scope.shareUrl).to.be('http://server/#/test?from=1000&to=2000');
|
2014-09-30 07:42:59 -05:00
|
|
|
});
|
|
|
|
|
2015-04-02 02:21:38 -05:00
|
|
|
it('should add theme when specified', function() {
|
|
|
|
ctx.$location.path('/test');
|
|
|
|
ctx.scope.options.theme = 'light';
|
|
|
|
ctx.scope.panel = null;
|
|
|
|
|
|
|
|
ctx.scope.init();
|
2015-05-28 02:35:47 -05:00
|
|
|
expect(ctx.scope.shareUrl).to.be('http://server/#/test?from=1000&to=2000&theme=light');
|
2015-04-02 02:21:38 -05:00
|
|
|
});
|
|
|
|
|
2014-09-30 08:19:48 -05:00
|
|
|
it('should include template variables in url', function() {
|
|
|
|
ctx.$location.path('/test');
|
2015-04-02 02:21:38 -05:00
|
|
|
ctx.scope.options.includeTemplateVars = true;
|
2015-03-17 16:33:31 -05:00
|
|
|
|
2015-05-08 03:56:54 -05:00
|
|
|
ctx.templateSrv.fillVariableValuesForUrl = function(params) {
|
|
|
|
params['var-app'] = 'mupp';
|
|
|
|
params['var-server'] = 'srv-01';
|
|
|
|
};
|
2014-09-30 08:19:48 -05:00
|
|
|
|
|
|
|
ctx.scope.buildUrl();
|
2015-05-28 02:35:47 -05:00
|
|
|
expect(ctx.scope.shareUrl).to.be('http://server/#/test?from=1000&to=2000&var-app=mupp&var-server=srv-01');
|
2014-09-30 08:19:48 -05:00
|
|
|
});
|
|
|
|
|
2014-09-30 07:42:59 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|