mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Added options to customize chart data listening (#25918)
This commit is contained in:
parent
810ec4c5f8
commit
75a714aa51
@ -4,6 +4,10 @@ import { getScenarioContext } from '../support/scenarioContext';
|
|||||||
import { selectOption } from './selectOption';
|
import { selectOption } from './selectOption';
|
||||||
|
|
||||||
export interface AddPanelConfig {
|
export interface AddPanelConfig {
|
||||||
|
chartData: {
|
||||||
|
method: string;
|
||||||
|
route: string | RegExp;
|
||||||
|
};
|
||||||
dashboardUid: string;
|
dashboardUid: string;
|
||||||
dataSourceName: string;
|
dataSourceName: string;
|
||||||
queriesForm: (config: AddPanelConfig) => void;
|
queriesForm: (config: AddPanelConfig) => void;
|
||||||
@ -16,6 +20,10 @@ export interface AddPanelConfig {
|
|||||||
export const addPanel = (config?: Partial<AddPanelConfig>): any =>
|
export const addPanel = (config?: Partial<AddPanelConfig>): any =>
|
||||||
getScenarioContext().then(({ lastAddedDashboardUid, lastAddedDataSource }: any) => {
|
getScenarioContext().then(({ lastAddedDashboardUid, lastAddedDataSource }: any) => {
|
||||||
const fullConfig = {
|
const fullConfig = {
|
||||||
|
chartData: {
|
||||||
|
method: 'POST',
|
||||||
|
route: '/api/ds/query',
|
||||||
|
},
|
||||||
dashboardUid: lastAddedDashboardUid,
|
dashboardUid: lastAddedDashboardUid,
|
||||||
dataSourceName: lastAddedDataSource,
|
dataSourceName: lastAddedDataSource,
|
||||||
panelTitle: `e2e-${Date.now()}`,
|
panelTitle: `e2e-${Date.now()}`,
|
||||||
@ -25,7 +33,7 @@ export const addPanel = (config?: Partial<AddPanelConfig>): any =>
|
|||||||
...config,
|
...config,
|
||||||
} as AddPanelConfig;
|
} as AddPanelConfig;
|
||||||
|
|
||||||
const { dashboardUid, dataSourceName, panelTitle, queriesForm, visualizationName } = fullConfig;
|
const { chartData, dashboardUid, dataSourceName, panelTitle, queriesForm, visualizationName } = fullConfig;
|
||||||
|
|
||||||
e2e.flows.openDashboard({ uid: dashboardUid });
|
e2e.flows.openDashboard({ uid: dashboardUid });
|
||||||
e2e.pages.Dashboard.Toolbar.toolbarItems('Add panel').click();
|
e2e.pages.Dashboard.Toolbar.toolbarItems('Add panel').click();
|
||||||
@ -36,7 +44,7 @@ export const addPanel = (config?: Partial<AddPanelConfig>): any =>
|
|||||||
// @todo alias '/**/*.js*' as '@pluginModule' when possible: https://github.com/cypress-io/cypress/issues/1296
|
// @todo alias '/**/*.js*' as '@pluginModule' when possible: https://github.com/cypress-io/cypress/issues/1296
|
||||||
|
|
||||||
e2e()
|
e2e()
|
||||||
.route('POST', '/api/ds/query')
|
.route(chartData.method, chartData.route)
|
||||||
.as('chartData');
|
.as('chartData');
|
||||||
|
|
||||||
selectOption(e2e.components.DataSourcePicker.container(), dataSourceName);
|
selectOption(e2e.components.DataSourcePicker.container(), dataSourceName);
|
||||||
|
Loading…
Reference in New Issue
Block a user