mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 20:59:35 +08:00

* WIP: Angular panel chrome, this is going to be tricky * AngularPanelChrome: initial render works * Options are showing up * viz options working * Fixed singlestat background * AngularPanels: Fixed alert tab * Removed anuglar loading spinner * Dashboard: Refactor dashboard reducer & actions * Dashboard: minor refactoring * PanelChrome: loading state moved to header * Subscribe to render events to solve title update issue * Time info and query errors now works * PanelHeader: unifying angular and react behavior * added getPanelMenu test * Scrollable now works again * Various fixes * Making stuff work * seperate event emitter for angular * Fixed issue sending updated dimensions to angular panel * Minor tweaks * Fixed tests * Alerting: alert state now works * Fixed unit tests * Fixed a few null check errors * Simplified events handling * Fixed strict null checks
65 lines
1.4 KiB
TypeScript
65 lines
1.4 KiB
TypeScript
jest.mock('app/core/core', () => ({}));
|
|
jest.mock('app/core/config', () => {
|
|
return {
|
|
bootData: {
|
|
user: {},
|
|
},
|
|
panels: {
|
|
test: {
|
|
id: 'test',
|
|
name: 'test',
|
|
},
|
|
},
|
|
config: {
|
|
appSubUrl: 'test',
|
|
},
|
|
};
|
|
});
|
|
|
|
// @ts-ignore
|
|
import q from 'q';
|
|
import { PanelModel } from 'app/features/dashboard/state/PanelModel';
|
|
import { MetricsPanelCtrl } from '../metrics_panel_ctrl';
|
|
|
|
describe('MetricsPanelCtrl', () => {
|
|
describe('can setup', () => {
|
|
it('should return controller', async () => {
|
|
const ctrl = setupController({ hasAccessToExplore: true });
|
|
expect((await ctrl.getAdditionalMenuItems()).length).toBe(0);
|
|
});
|
|
});
|
|
});
|
|
|
|
function setupController({ hasAccessToExplore } = { hasAccessToExplore: false }) {
|
|
const injectorStub = {
|
|
get: (type: any) => {
|
|
switch (type) {
|
|
case '$q': {
|
|
return q;
|
|
}
|
|
case 'contextSrv': {
|
|
return { hasAccessToExplore: () => hasAccessToExplore };
|
|
}
|
|
case 'timeSrv': {
|
|
return { timeRangeForUrl: () => {} };
|
|
}
|
|
default: {
|
|
return jest.fn();
|
|
}
|
|
}
|
|
},
|
|
};
|
|
|
|
const scope: any = {
|
|
panel: { events: [] },
|
|
appEvent: jest.fn(),
|
|
onAppEvent: jest.fn(),
|
|
$on: jest.fn(),
|
|
colors: [],
|
|
};
|
|
|
|
MetricsPanelCtrl.prototype.panel = new PanelModel({ type: 'test' });
|
|
|
|
return new MetricsPanelCtrl(scope, injectorStub);
|
|
}
|