Commit f38e4316 by Steven Vachon Committed by GitHub

@grafana/e2e: selectOption flow now accepts a config object (#27827)

parent 1dc658f5
...@@ -121,7 +121,10 @@ export const configurePanel = (config: PartialAddPanelConfig | PartialEditPanelC ...@@ -121,7 +121,10 @@ export const configurePanel = (config: PartialAddPanelConfig | PartialEditPanelC
.as('chartData'); .as('chartData');
if (dataSourceName) { if (dataSourceName) {
selectOption(e2e.components.DataSourcePicker.container(), dataSourceName); selectOption({
container: e2e.components.DataSourcePicker.container(),
optionText: dataSourceName,
});
} }
// @todo instead wait for '@pluginModule' // @todo instead wait for '@pluginModule'
......
import { e2e } from '../index'; import { e2e } from '../index';
export interface SelectOptionConfig {
clickToOpen?: boolean;
container: any;
forceClickOption?: boolean;
optionText: string | RegExp;
}
// @todo this actually returns type `Cypress.Chainable` // @todo this actually returns type `Cypress.Chainable`
export const selectOption = (select: any, optionText: string | RegExp, clickToOpen = true): any => export const selectOption = (config: SelectOptionConfig): any => {
select.within(() => { const fullConfig: SelectOptionConfig = {
clickToOpen: true,
forceClickOption: false,
...config,
};
const { clickToOpen, container, forceClickOption, optionText } = fullConfig;
return container.within(() => {
if (clickToOpen) { if (clickToOpen) {
e2e() e2e()
.get('[class$="-input-suffix"]') .get('[class$="-input-suffix"]')
...@@ -20,8 +35,9 @@ export const selectOption = (select: any, optionText: string | RegExp, clickToOp ...@@ -20,8 +35,9 @@ export const selectOption = (select: any, optionText: string | RegExp, clickToOp
} }
}) })
.scrollIntoView() .scrollIntoView()
.click(); .click({ force: forceClickOption });
e2e() e2e()
.root() .root()
.scrollIntoView(); .scrollIntoView();
}); });
};
...@@ -16,7 +16,12 @@ export const setTimeRange = ({ from, to, zone }: TimeRangeConfig) => { ...@@ -16,7 +16,12 @@ export const setTimeRange = ({ from, to, zone }: TimeRangeConfig) => {
e2e() e2e()
.contains('button', 'Change time zone') .contains('button', 'Change time zone')
.click(); .click();
selectOption(e2e.components.TimeZonePicker.container(), zone, false);
selectOption({
clickToOpen: false,
container: e2e.components.TimeZonePicker.container(),
optionText: zone,
});
} }
// For smaller screens // For smaller screens
......
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