Commit 75a714aa by Steven Vachon Committed by GitHub

Added options to customize chart data listening (#25918)

parent 810ec4c5
......@@ -4,6 +4,10 @@ import { getScenarioContext } from '../support/scenarioContext';
import { selectOption } from './selectOption';
export interface AddPanelConfig {
chartData: {
method: string;
route: string | RegExp;
};
dashboardUid: string;
dataSourceName: string;
queriesForm: (config: AddPanelConfig) => void;
......@@ -16,6 +20,10 @@ export interface AddPanelConfig {
export const addPanel = (config?: Partial<AddPanelConfig>): any =>
getScenarioContext().then(({ lastAddedDashboardUid, lastAddedDataSource }: any) => {
const fullConfig = {
chartData: {
method: 'POST',
route: '/api/ds/query',
},
dashboardUid: lastAddedDashboardUid,
dataSourceName: lastAddedDataSource,
panelTitle: `e2e-${Date.now()}`,
......@@ -25,7 +33,7 @@ export const addPanel = (config?: Partial<AddPanelConfig>): any =>
...config,
} as AddPanelConfig;
const { dashboardUid, dataSourceName, panelTitle, queriesForm, visualizationName } = fullConfig;
const { chartData, dashboardUid, dataSourceName, panelTitle, queriesForm, visualizationName } = fullConfig;
e2e.flows.openDashboard({ uid: dashboardUid });
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
e2e()
.route('POST', '/api/ds/query')
.route(chartData.method, chartData.route)
.as('chartData');
selectOption(e2e.components.DataSourcePicker.container(), dataSourceName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment