@grafana/e2e: selectOption flow now accepts a config object (#27827)
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -1,8 +1,23 @@
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user