mirror of
https://github.com/grafana/grafana.git
synced 2026-02-03 20:49:50 -05:00
add exporter test
This commit is contained in:
parent
d10e5d170b
commit
c092af9f6b
1 changed files with 31 additions and 0 deletions
|
|
@ -7,6 +7,8 @@ import {
|
|||
LibraryPanelKind,
|
||||
PanelKind,
|
||||
QueryVariableKind,
|
||||
AdhocVariableKind,
|
||||
GroupByVariableKind,
|
||||
} from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import { handyTestingSchema } from '@grafana/schema/dist/esm/schema/dashboard/v2_examples';
|
||||
import config from 'app/core/config';
|
||||
|
|
@ -718,6 +720,35 @@ describe('dashboard exporter v2', () => {
|
|||
expect(annotationQuery.spec.query?.datasource?.name).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should assign export labels to data queries during export', async () => {
|
||||
const { dashboard } = await setup();
|
||||
|
||||
const panel = dashboard.elements['panel-1'];
|
||||
if (panel.kind !== 'Panel') {
|
||||
throw new Error('Panel should be a Panel');
|
||||
}
|
||||
const panelQuery = panel.spec.data.spec.queries[0];
|
||||
expect(panelQuery.spec.query.labels?.exportLabel).toBe('prometheus-1');
|
||||
|
||||
const queryVariable = dashboard.variables.find(
|
||||
(variable) => variable.kind === 'QueryVariable'
|
||||
) as QueryVariableKind;
|
||||
expect(queryVariable.spec.query.labels?.exportLabel).toBe('prometheus-1');
|
||||
|
||||
const groupByVariable = dashboard.variables.find(
|
||||
(variable) => variable.kind === 'GroupByVariable'
|
||||
) as GroupByVariableKind;
|
||||
expect(groupByVariable.labels?.exportLabel).toBe('prometheus-2');
|
||||
|
||||
const adhocVariable = dashboard.variables.find(
|
||||
(variable) => variable.kind === 'AdhocVariable'
|
||||
) as AdhocVariableKind;
|
||||
expect(adhocVariable.labels?.exportLabel).toBe('prometheus-3');
|
||||
|
||||
const annotationQuery = dashboard.annotations[0];
|
||||
expect(annotationQuery.spec.query.labels?.exportLabel).toBe('prometheus-4');
|
||||
});
|
||||
|
||||
it('should not remove datasource ref from panel that uses a datasource variable', async () => {
|
||||
const { dashboard } = await setup();
|
||||
const panel = dashboard.elements['panel-using-datasource-var'];
|
||||
|
|
|
|||
Loading…
Reference in a new issue