Annotations provide a way to integrate event data into your graphs. They are visualized as vertical lines
diff --git a/public/app/features/dashboard-scene/settings/annotations/index.tsx b/public/app/features/dashboard-scene/settings/annotations/index.tsx
index 512165263b8..5c5ebb6cb18 100644
--- a/public/app/features/dashboard-scene/settings/annotations/index.tsx
+++ b/public/app/features/dashboard-scene/settings/annotations/index.tsx
@@ -1 +1,2 @@
+export { AnnotationSettingsEdit, newAnnotationName } from './AnnotationSettingsEdit';
export { AnnotationSettingsList } from './AnnotationSettingsList';
diff --git a/public/app/features/dashboard-scene/utils/dashboardSceneGraph.test.ts b/public/app/features/dashboard-scene/utils/dashboardSceneGraph.test.ts
index 8b4c65ab284..927e9bf6313 100644
--- a/public/app/features/dashboard-scene/utils/dashboardSceneGraph.test.ts
+++ b/public/app/features/dashboard-scene/utils/dashboardSceneGraph.test.ts
@@ -1,6 +1,8 @@
import {
+ SceneDataLayers,
SceneGridItem,
SceneGridLayout,
+ SceneGridRow,
SceneQueryRunner,
SceneRefreshPicker,
SceneTimePicker,
@@ -8,6 +10,8 @@ import {
VizPanel,
} from '@grafana/scenes';
+import { AlertStatesDataLayer } from '../scene/AlertStatesDataLayer';
+import { DashboardAnnotationsDataLayer } from '../scene/DashboardAnnotationsDataLayer';
import { DashboardControls } from '../scene/DashboardControls';
import { DashboardLinksControls } from '../scene/DashboardLinksControls';
import { DashboardScene, DashboardSceneState } from '../scene/DashboardScene';
@@ -91,6 +95,59 @@ describe('dashboardSceneGraph', () => {
expect(dashboardSceneGraph.getPanelLinks(panelWithNoLinks)).toBeInstanceOf(VizPanelLinks);
});
});
+
+ describe('getVizPanels', () => {
+ let scene: DashboardScene;
+
+ beforeEach(async () => {
+ scene = buildTestScene();
+ });
+
+ it('Should return all panels', () => {
+ const vizPanels = dashboardSceneGraph.getVizPanels(scene);
+
+ expect(vizPanels.length).toBe(6);
+ expect(vizPanels[0].state.title).toBe('Panel A');
+ expect(vizPanels[1].state.title).toBe('Panel B');
+ expect(vizPanels[2].state.title).toBe('Panel C');
+ expect(vizPanels[3].state.title).toBe('Panel D');
+ expect(vizPanels[4].state.title).toBe('Panel E');
+ expect(vizPanels[5].state.title).toBe('Panel F');
+ });
+
+ it('Should return an empty array when scene has no panels', () => {
+ scene.setState({
+ body: new SceneGridLayout({ children: [] }),
+ });
+
+ const vizPanels = dashboardSceneGraph.getVizPanels(scene);
+
+ expect(vizPanels.length).toBe(0);
+ });
+ });
+
+ describe('getDataLayers', () => {
+ let scene: DashboardScene;
+
+ beforeEach(async () => {
+ scene = buildTestScene();
+ });
+
+ it('should return the scene data layers', () => {
+ const dataLayers = dashboardSceneGraph.getDataLayers(scene);
+
+ expect(dataLayers).toBeInstanceOf(SceneDataLayers);
+ expect(dataLayers?.state.layers.length).toBe(2);
+ });
+
+ it('should throw if there are no scene data layers', () => {
+ scene.setState({
+ $data: undefined,
+ });
+
+ expect(() => dashboardSceneGraph.getDataLayers(scene)).toThrow('SceneDataLayers not found');
+ });
+ });
});
function buildTestScene(overrides?: Partial