mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
247d91be2b
* remove cy. wrapping as e2e(). * make trace-view-scrolling more stable and remove waits * improve stability more
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
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;
|
|
|
|
// @todo this actually returns type `Cypress.Chainable<OpenDashboardConfig>`
|
|
export const openDashboard = (config?: PartialOpenDashboardConfig) =>
|
|
getScenarioContext().then(({ lastAddedDashboardUid }: any) => {
|
|
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 });
|
|
});
|