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