mirror of https://github.com/grafana/grafana
@grafana/e2e: improvements (#25708)
* Set time range when opening a dashboard * Set UTC timezone when creating a dashboard * Added flow for selecting options in custom select fields * Fix flaky testpull/25871/head
parent
5d7cd2e9fc
commit
fb3bec058a
@ -1,6 +1,49 @@ |
||||
import { e2e } from '../index'; |
||||
import { getScenarioContext } from '../support/scenarioContext'; |
||||
|
||||
// @todo remove this, as it's a page change and not a flow
|
||||
export const openDashboard = (dashboardUid: string) => { |
||||
e2e.pages.Dashboard.visit(dashboardUid); |
||||
}; |
||||
export interface OpenDashboardConfig { |
||||
uid: string; |
||||
timeRange: { |
||||
from: string; |
||||
to: string; |
||||
}; |
||||
} |
||||
|
||||
export const openDashboard = (config?: Partial<OpenDashboardConfig>) => |
||||
getScenarioContext().then(({ lastAddedDashboardUid }: any) => { |
||||
const fullConfig = { |
||||
timeRange: { |
||||
from: '2020-01-01 00:00:00', |
||||
to: '2020-01-01 01:00:00', |
||||
}, |
||||
uid: lastAddedDashboardUid, |
||||
...config, |
||||
} as OpenDashboardConfig; |
||||
|
||||
const { timeRange, uid } = fullConfig; |
||||
|
||||
e2e.pages.Dashboard.visit(uid); |
||||
|
||||
e2e.pages.Dashboard.Toolbar.navBar().within(() => { |
||||
e2e() |
||||
.get('[aria-label="TimePicker Open Button"]') |
||||
.click(); |
||||
e2e() |
||||
.get('[aria-label="TimePicker absolute time range"]') |
||||
.click(); |
||||
e2e() |
||||
.get('[aria-label="TimePicker from field"]') |
||||
.clear() |
||||
.type(timeRange.from); |
||||
e2e() |
||||
.get('[aria-label="TimePicker to field"]') |
||||
.clear() |
||||
.type(timeRange.to); |
||||
e2e() |
||||
.get('[aria-label="TimePicker submit button"]') |
||||
.click(); |
||||
}); |
||||
|
||||
// @todo remove `wrap` when possible
|
||||
return e2e().wrap({ config: fullConfig }); |
||||
}); |
||||
|
@ -0,0 +1,16 @@ |
||||
import { e2e } from '../index'; |
||||
|
||||
// @todo this actually returns type `Cypress.Chainable`
|
||||
export const selectOption = (select: any, optionText: string): any => |
||||
select.within(() => { |
||||
e2e() |
||||
.get('[class$="-input-suffix"]') |
||||
.click(); |
||||
e2e.components.Select.option() |
||||
.filter(`:contains("${optionText}")`) |
||||
.scrollIntoView() |
||||
.click(); |
||||
e2e() |
||||
.root() |
||||
.scrollIntoView(); |
||||
}); |
Loading…
Reference in new issue