mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 03:02:27 +08:00

* fix some e2e flows types * some type fixes * must... fix... more... * MOAR * MOREMOREMORE * 1 more
36 lines
1019 B
TypeScript
36 lines
1019 B
TypeScript
import { e2e } from '../index';
|
|
import { getScenarioContext } from '../support/scenarioContext';
|
|
|
|
import { setDashboardTimeRange, TimeRangeConfig } from './setDashboardTimeRange';
|
|
|
|
interface OpenDashboardDefault {
|
|
uid: string;
|
|
}
|
|
|
|
interface OpenDashboardOptional {
|
|
timeRange?: TimeRangeConfig;
|
|
queryParams?: object;
|
|
}
|
|
|
|
export type PartialOpenDashboardConfig = Partial<OpenDashboardDefault> & OpenDashboardOptional;
|
|
export type OpenDashboardConfig = OpenDashboardDefault & OpenDashboardOptional;
|
|
|
|
export const openDashboard = (config?: PartialOpenDashboardConfig) =>
|
|
getScenarioContext().then(({ lastAddedDashboardUid }) => {
|
|
const fullConfig: OpenDashboardConfig = {
|
|
uid: lastAddedDashboardUid,
|
|
...config,
|
|
};
|
|
|
|
const { timeRange, uid, queryParams } = fullConfig;
|
|
|
|
e2e.pages.Dashboard.visit(uid, queryParams);
|
|
|
|
if (timeRange) {
|
|
setDashboardTimeRange(timeRange);
|
|
}
|
|
|
|
// @todo remove `wrap` when possible
|
|
return cy.wrap({ config: fullConfig }, { log: false });
|
|
});
|