Commit ed4ef086 by Steven Vachon Committed by GitHub

@grafana/e2e: annotation improvements (#27582)

* Removed Datadog-specific fields from config for annotation creation

* Added a custom form config option for annotation creation

* Added regex support to `selectOption`
parent 54b677bd
......@@ -6,9 +6,8 @@ import { v4 as uuidv4 } from 'uuid';
export interface AddAnnotationConfig {
dataSource: string;
dataSourceForm?: () => void;
name: string;
sources?: string;
tags?: string;
}
export interface AddDashboardConfig {
......@@ -111,7 +110,7 @@ const addAnnotation = (config: AddAnnotationConfig, isFirst: boolean) => {
.click();
}
const { dataSource, name, sources, tags } = config;
const { dataSource, dataSourceForm, name } = config;
// @todo add to e2e-selectors and `aria-label`
e2e()
......@@ -125,20 +124,8 @@ const addAnnotation = (config: AddAnnotationConfig, isFirst: boolean) => {
.find('input')
.type(name);
if (sources) {
// @todo add to e2e-selectors and `aria-label`
e2e()
.contains('.gf-form', 'Sources')
.find('input')
.type(sources);
}
if (tags) {
// @todo add to e2e-selectors and `aria-label`
e2e()
.contains('.gf-form', 'Tags')
.find('input')
.type(tags);
if (dataSourceForm) {
dataSourceForm();
}
// @todo add to e2e-selectors and `aria-label`
......
import { e2e } from '../index';
// @todo this actually returns type `Cypress.Chainable`
export const selectOption = (select: any, optionText: string, clickToOpen = true): any =>
export const selectOption = (select: any, optionText: string | RegExp, clickToOpen = true): any =>
select.within(() => {
if (clickToOpen) {
e2e()
......@@ -10,7 +10,15 @@ export const selectOption = (select: any, optionText: string, clickToOpen = true
}
e2e.components.Select.option()
.filter(`:contains("${optionText}")`)
.filter((_, { textContent }) => {
if (textContent === null) {
return false;
} else if (typeof optionText === 'string') {
return textContent.includes(optionText);
} else {
return optionText.test(textContent);
}
})
.scrollIntoView()
.click();
e2e()
......
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