fix: Viewers can edit means that viewers have acces to Explore #14281

This commit is contained in:
Hugo Häggmark
2019-01-21 08:47:41 +01:00
parent bc8f3374a3
commit 9d6ac2c3d4
7 changed files with 25 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ jest.mock('app/core/core', () => ({}));
jest.mock('app/core/config', () => {
return {
exploreEnabled: true,
viewersCanEdit: false,
panels: {
test: {
id: 'test',
@@ -14,6 +15,7 @@ jest.mock('app/core/config', () => {
import q from 'q';
import { PanelModel } from 'app/features/dashboard/panel_model';
import { MetricsPanelCtrl } from '../metrics_panel_ctrl';
import config from 'app/core/config';
describe('MetricsPanelCtrl', () => {
let ctrl;
@@ -46,6 +48,19 @@ describe('MetricsPanelCtrl', () => {
expect(additionalItems.length).toBe(1);
});
});
describe('and has datasource set that supports explore and viewersCanEdit is true', () => {
beforeEach(() => {
config.viewersCanEdit = true;
ctrl.contextSrv = { isEditor: false };
ctrl.datasource = { meta: { explore: true } };
additionalItems = ctrl.getAdditionalMenuItems();
});
it('should not return any items', () => {
expect(additionalItems.length).toBe(1);
});
});
});
});