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'; ...@@ -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 { ...@@ -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 => ...@@ -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 => ...@@ -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);
......
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