diff --git a/public/app/features/alerting/unified/components/rule-editor/AnnotationsField.test.tsx b/public/app/features/alerting/unified/components/rule-editor/AnnotationsField.test.tsx
index db52f555dec..f729227ec15 100644
--- a/public/app/features/alerting/unified/components/rule-editor/AnnotationsField.test.tsx
+++ b/public/app/features/alerting/unified/components/rule-editor/AnnotationsField.test.tsx
@@ -1,4 +1,4 @@
-import { findByText, findByTitle, render } from '@testing-library/react';
+import { findByRole, findByText, findByTitle, getByTestId, render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
@@ -107,8 +107,8 @@ describe('AnnotationsField', function () {
title: 'My dashboard',
uid: 'dash-test-uid',
panels: [
- { id: 1, title: 'First panel' },
- { id: 2, title: 'Second panel' },
+ { id: 1, title: 'First panel', type: 'timeseries' },
+ { id: 2, title: 'Second panel', type: 'timeseries' },
],
})
);
@@ -137,8 +137,8 @@ describe('AnnotationsField', function () {
title: 'My dashboard',
uid: 'dash-test-uid',
panels: [
- { id: 1, title: 'First panel' },
- { id: 2, title: 'Second panel' },
+ { id: 1, title: 'First panel', type: 'graph' },
+ { id: 2, title: 'Second panel', type: 'graph' },
],
})
);
@@ -171,7 +171,7 @@ describe('AnnotationsField', function () {
// this test _should_ work in theory but something is stopping the 'onClick' function on the dashboard item
// to trigger "handleDashboardChange" – skipping it for now but has been manually tested.
- it.skip('should update existing dashboard and panel identifies', async function () {
+ it('should update existing dashboard and panel identifies', async function () {
mockSearchApiResponse(server, [
mockDashboardSearchItem({ title: 'My dashboard', uid: 'dash-test-uid', type: DashboardSearchItemType.DashDB }),
mockDashboardSearchItem({
@@ -186,8 +186,8 @@ describe('AnnotationsField', function () {
title: 'My dashboard',
uid: 'dash-test-uid',
panels: [
- { id: 1, title: 'First panel' },
- { id: 2, title: 'Second panel' },
+ { id: 1, title: 'First panel', type: 'timeseries' },
+ { id: 2, title: 'Second panel', type: 'timeseries' },
],
})
);
@@ -195,7 +195,7 @@ describe('AnnotationsField', function () {
mockDashboardDto({
title: 'My other dashboard',
uid: 'dash-other-uid',
- panels: [{ id: 3, title: 'Third panel' }],
+ panels: [{ id: 3, title: 'Third panel', type: 'timeseries' }],
})
);
@@ -216,10 +216,12 @@ describe('AnnotationsField', function () {
expect(annotationValueElements[0]).toHaveTextContent('dash-test-uid');
expect(annotationValueElements[1]).toHaveTextContent('1');
+ const { confirmButton, dialog } = ui.dashboardPicker;
+
await user.click(ui.setDashboardButton.get());
- await user.click(await findByTitle(ui.dashboardPicker.dialog.get(), 'My other dashboard'));
- await user.click(await findByText(ui.dashboardPicker.dialog.get(), 'Third panel'));
- await user.click(ui.dashboardPicker.confirmButton.get());
+ await user.click(await findByRole(dialog.get(), 'button', { name: /My other dashboard/ }));
+ await user.click(await findByRole(dialog.get(), 'button', { name: /Third panel/ }));
+ await user.click(confirmButton.get());
expect(ui.dashboardPicker.dialog.query()).not.toBeInTheDocument();
@@ -235,6 +237,36 @@ describe('AnnotationsField', function () {
expect(annotationKeyElements[1]).toHaveTextContent('Panel ID');
expect(annotationValueElements[1]).toHaveTextContent('3');
});
+
+ it('should render warning icon for panels of type other than graph and timeseries', async function () {
+ mockSearchApiResponse(server, [
+ mockDashboardSearchItem({ title: 'My dashboard', uid: 'dash-test-uid', type: DashboardSearchItemType.DashDB }),
+ ]);
+
+ mockGetDashboardResponse(
+ mockDashboardDto({
+ title: 'My dashboard',
+ uid: 'dash-test-uid',
+ panels: [
+ { id: 1, title: 'First panel', type: 'bar' },
+ { id: 2, title: 'Second panel', type: 'graph' },
+ ],
+ })
+ );
+
+ const user = userEvent.setup();
+
+ render(