2017-12-19 09:06:54 -06:00
|
|
|
import {
|
|
|
|
describe,
|
|
|
|
beforeEach,
|
|
|
|
it,
|
|
|
|
expect,
|
2017-12-20 05:33:33 -06:00
|
|
|
angularMocks,
|
|
|
|
} from 'test/lib/common';
|
|
|
|
import 'app/features/dashboard/view_state_srv';
|
|
|
|
import config from 'app/core/config';
|
2017-10-01 13:02:25 -05:00
|
|
|
|
2017-12-20 05:33:33 -06:00
|
|
|
describe('when updating view state', function() {
|
2017-10-01 13:02:25 -05:00
|
|
|
var viewState, location;
|
|
|
|
var timeSrv = {};
|
|
|
|
var templateSrv = {};
|
|
|
|
var contextSrv = {
|
|
|
|
user: {
|
2017-12-20 05:33:33 -06:00
|
|
|
orgId: 19,
|
|
|
|
},
|
2017-10-01 13:02:25 -05:00
|
|
|
};
|
|
|
|
beforeEach(function() {
|
|
|
|
config.bootData = {
|
|
|
|
user: {
|
2017-12-20 05:33:33 -06:00
|
|
|
orgId: 1,
|
|
|
|
},
|
2017-10-01 13:02:25 -05:00
|
|
|
};
|
|
|
|
});
|
2017-12-20 05:33:33 -06:00
|
|
|
beforeEach(angularMocks.module('grafana.services'));
|
2017-12-19 09:06:54 -06:00
|
|
|
beforeEach(
|
|
|
|
angularMocks.module(function($provide) {
|
2017-12-20 05:33:33 -06:00
|
|
|
$provide.value('timeSrv', timeSrv);
|
|
|
|
$provide.value('templateSrv', templateSrv);
|
|
|
|
$provide.value('contextSrv', contextSrv);
|
2017-12-19 09:06:54 -06:00
|
|
|
})
|
|
|
|
);
|
2017-10-01 13:02:25 -05:00
|
|
|
|
2017-12-19 09:06:54 -06:00
|
|
|
beforeEach(
|
|
|
|
angularMocks.inject(function(dashboardViewStateSrv, $location, $rootScope) {
|
|
|
|
$rootScope.onAppEvent = function() {};
|
|
|
|
$rootScope.dashboard = { meta: {} };
|
|
|
|
viewState = dashboardViewStateSrv.create($rootScope);
|
|
|
|
location = $location;
|
|
|
|
})
|
|
|
|
);
|
2017-10-01 13:02:25 -05:00
|
|
|
|
2017-12-20 05:33:33 -06:00
|
|
|
describe('to fullscreen true and edit true', function() {
|
|
|
|
it('should update querystring and view state', function() {
|
2017-12-19 09:06:54 -06:00
|
|
|
var updateState = { fullscreen: true, edit: true, panelId: 1 };
|
2017-10-01 13:02:25 -05:00
|
|
|
viewState.update(updateState);
|
2017-12-19 09:06:54 -06:00
|
|
|
expect(location.search()).to.eql({
|
|
|
|
fullscreen: true,
|
|
|
|
edit: true,
|
|
|
|
panelId: 1,
|
2017-12-20 05:33:33 -06:00
|
|
|
orgId: 1,
|
2017-12-19 09:06:54 -06:00
|
|
|
});
|
2017-10-01 13:02:25 -05:00
|
|
|
expect(viewState.dashboard.meta.fullscreen).to.be(true);
|
|
|
|
expect(viewState.state.fullscreen).to.be(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-12-20 05:33:33 -06:00
|
|
|
describe('to fullscreen false', function() {
|
|
|
|
it('should remove params from query string', function() {
|
2017-12-19 09:06:54 -06:00
|
|
|
viewState.update({ fullscreen: true, panelId: 1, edit: true });
|
|
|
|
viewState.update({ fullscreen: false });
|
2017-10-01 13:02:25 -05:00
|
|
|
expect(viewState.dashboard.meta.fullscreen).to.be(false);
|
|
|
|
expect(viewState.state.fullscreen).to.be(null);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|