|
|
@@ -21,28 +21,28 @@ import { MetricsPanelCtrl } from '../metrics_panel_ctrl';
|
|
|
describe('MetricsPanelCtrl', () => {
|
|
|
describe('when getting additional menu items', () => {
|
|
|
describe('and has no datasource set but user has access to explore', () => {
|
|
|
- it('should not return any items', () => {
|
|
|
+ it('should not return any items', async () => {
|
|
|
const ctrl = setupController({ hasAccessToExplore: true });
|
|
|
|
|
|
- expect(ctrl.getAdditionalMenuItems().length).toBe(0);
|
|
|
+ expect((await ctrl.getAdditionalMenuItems()).length).toBe(0);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
describe('and has datasource set that supports explore and user does not have access to explore', () => {
|
|
|
- it('should not return any items', () => {
|
|
|
+ it('should not return any items', async () => {
|
|
|
const ctrl = setupController({ hasAccessToExplore: false });
|
|
|
ctrl.datasource = { meta: { explore: true } } as any;
|
|
|
|
|
|
- expect(ctrl.getAdditionalMenuItems().length).toBe(0);
|
|
|
+ expect((await ctrl.getAdditionalMenuItems()).length).toBe(0);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
describe('and has datasource set that supports explore and user has access to explore', () => {
|
|
|
- it('should return one item', () => {
|
|
|
+ it('should return one item', async () => {
|
|
|
const ctrl = setupController({ hasAccessToExplore: true });
|
|
|
ctrl.datasource = { meta: { explore: true } } as any;
|
|
|
|
|
|
- expect(ctrl.getAdditionalMenuItems().length).toBe(1);
|
|
|
+ expect((await ctrl.getAdditionalMenuItems()).length).toBe(1);
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
@@ -58,6 +58,9 @@ function setupController({ hasAccessToExplore } = { hasAccessToExplore: false })
|
|
|
case 'contextSrv': {
|
|
|
return { hasAccessToExplore: () => hasAccessToExplore };
|
|
|
}
|
|
|
+ case 'timeSrv': {
|
|
|
+ return { timeRangeForUrl: () => {} };
|
|
|
+ }
|
|
|
default: {
|
|
|
return jest.fn();
|
|
|
}
|