mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 16:45:43 -06:00
* Began work on panel menu * SceneDashboard: Basic state handling for inspect panel * Switched to using scene url sync instead * Updated * Update comment on hack * Fixed url synnc issues and more / better DashboardsLoader tests * Progress on test * Updates * Progress * Progress * Update * Update * Update * Update * Update scenes lib * Update * Update --------- Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import { SceneGridItem, SceneGridLayout, VizPanel } from '@grafana/scenes';
|
|
|
|
import { DashboardScene } from './DashboardScene';
|
|
|
|
describe('DashboardScene', () => {
|
|
describe('Given a standard scene', () => {
|
|
it('Should set inspectPanelKey when url has inspect key', () => {
|
|
const scene = buildTestScene();
|
|
scene.urlSync?.updateFromUrl({ inspect: 'panel-2' });
|
|
expect(scene.state.inspectPanelKey).toBe('panel-2');
|
|
});
|
|
|
|
it('Should handle inspect key that is not found', () => {
|
|
const scene = buildTestScene();
|
|
scene.urlSync?.updateFromUrl({ inspect: '12321' });
|
|
expect(scene.state.inspectPanelKey).toBe(undefined);
|
|
});
|
|
|
|
it('Should set viewPanelKey when url has viewPanel', () => {
|
|
const scene = buildTestScene();
|
|
scene.urlSync?.updateFromUrl({ viewPanel: 'panel-2' });
|
|
expect(scene.state.viewPanelKey).toBe('panel-2');
|
|
});
|
|
});
|
|
});
|
|
|
|
function buildTestScene() {
|
|
const scene = new DashboardScene({
|
|
title: 'hello',
|
|
body: new SceneGridLayout({
|
|
children: [
|
|
new SceneGridItem({
|
|
body: new VizPanel({
|
|
title: 'Panel A',
|
|
key: 'panel-1',
|
|
pluginId: 'table',
|
|
}),
|
|
}),
|
|
new SceneGridItem({
|
|
body: new VizPanel({
|
|
title: 'Panel B',
|
|
key: 'panel-2',
|
|
pluginId: 'table',
|
|
}),
|
|
}),
|
|
],
|
|
}),
|
|
});
|
|
|
|
return scene;
|
|
}
|