Chore: Type improvements 🧹 (#75271)

* fix some e2e flows types

* some type fixes

* must... fix... more...

* MOAR

* MOREMOREMORE

* 1 more
This commit is contained in:
Ashley Harrison
2023-09-22 15:06:49 +01:00
committed by GitHub
parent eba74f0408
commit ff0642bf6e
65 changed files with 217 additions and 387 deletions
+2 -3
View File
@@ -3,7 +3,6 @@ import { v4 as uuidv4 } from 'uuid';
import { e2e } from '../index';
import { getDashboardUid } from '../support/url';
import { DeleteDashboardConfig } from './deleteDashboard';
import { selectOption } from './selectOption';
import { setDashboardTimeRange, TimeRangeConfig } from './setDashboardTimeRange';
@@ -154,9 +153,9 @@ export const addDashboard = (config?: Partial<AddDashboardConfig>) => {
.then((url: string) => {
const uid = getDashboardUid(url);
e2e.getScenarioContext().then(({ addedDashboards }: any) => {
e2e.getScenarioContext().then(({ addedDashboards }) => {
e2e.setScenarioContext({
addedDashboards: [...addedDashboards, { title, uid } as DeleteDashboardConfig],
addedDashboards: [...addedDashboards, { title, uid }],
});
});
+1 -1
View File
@@ -94,7 +94,7 @@ export const addDataSource = (config?: Partial<AddDataSourceConfig>) => {
cy.logToConsole('Added data source with name:', name);
return cy.url().then(() => {
e2e.getScenarioContext().then(({ addedDataSources }: any) => {
e2e.getScenarioContext().then(({ addedDataSources }) => {
e2e.setScenarioContext({
addedDataSources: [...addedDataSources, { name } as DeleteDataSourceConfig],
});
+1 -1
View File
@@ -5,7 +5,7 @@ import { getScenarioContext } from '../support/scenarioContext';
import { configurePanel, PartialAddPanelConfig } from './configurePanel';
export const addPanel = (config?: Partial<PartialAddPanelConfig>) =>
getScenarioContext().then(({ lastAddedDataSource }: any) =>
getScenarioContext().then(({ lastAddedDataSource }) =>
configurePanel({
dataSourceName: lastAddedDataSource,
panelTitle: `e2e-${uuidv4()}`,
+1 -3
View File
@@ -52,9 +52,8 @@ export type AddPanelConfig = ConfigurePanelConfig & AddPanelOverrides;
export type PartialEditPanelConfig = PartialConfigurePanelConfig & EditPanelOverrides;
export type EditPanelConfig = ConfigurePanelConfig & EditPanelOverrides;
// @todo this actually returns type `Cypress.Chainable<AddPanelConfig | EditPanelConfig | ConfigurePanelConfig>`
export const configurePanel = (config: PartialAddPanelConfig | PartialEditPanelConfig | PartialConfigurePanelConfig) =>
getScenarioContext().then(({ lastAddedDashboardUid }: any) => {
getScenarioContext().then(({ lastAddedDashboardUid }) => {
const fullConfig: AddPanelConfig | EditPanelConfig | ConfigurePanelConfig = {
chartData: {
method: 'POST',
@@ -171,7 +170,6 @@ export const configurePanel = (config: PartialAddPanelConfig | PartialEditPanelC
return cy.wrap({ config: fullConfig }, { log: false });
});
// @todo this actually returns type `Cypress.Chainable`
const closeOptions = () => e2e.components.PanelEditor.toggleVizOptions().click();
export const VISUALIZATION_ALERT_LIST = 'Alert list';
+1 -1
View File
@@ -18,7 +18,7 @@ export const deleteDashboard = ({ quick = false, title, uid }: DeleteDashboardCo
cy.logToConsole('Deleted dashboard with uid:', uid);
e2e.getScenarioContext().then(({ addedDashboards }: any) => {
e2e.getScenarioContext().then(({ addedDashboards }) => {
e2e.setScenarioContext({
addedDashboards: addedDashboards.filter((dashboard: DeleteDashboardConfig) => {
return dashboard.title !== title && dashboard.uid !== uid;
+1 -1
View File
@@ -18,7 +18,7 @@ export const deleteDataSource = ({ id, name, quick = false }: DeleteDataSourceCo
cy.logToConsole('Deleted data source with name:', name);
e2e.getScenarioContext().then(({ addedDataSources }: any) => {
e2e.getScenarioContext().then(({ addedDataSources }) => {
e2e.setScenarioContext({
addedDataSources: addedDataSources.filter((dataSource: DeleteDataSourceConfig) => {
return dataSource.id !== id && dataSource.name !== name;
+1 -2
View File
@@ -15,9 +15,8 @@ interface OpenDashboardOptional {
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) => {
getScenarioContext().then(({ lastAddedDashboardUid }) => {
const fullConfig: OpenDashboardConfig = {
uid: lastAddedDashboardUid,
...config,
+2 -2
View File
@@ -2,8 +2,8 @@ import { e2e } from '../index';
export const revertAllChanges = () => {
e2e.getScenarioContext().then(({ addedDashboards, addedDataSources, hasChangedUserPreferences }) => {
addedDashboards.forEach((dashboard: any) => e2e.flows.deleteDashboard({ ...dashboard, quick: true }));
addedDataSources.forEach((dataSource: any) => e2e.flows.deleteDataSource({ ...dataSource, quick: true }));
addedDashboards.forEach((dashboard) => e2e.flows.deleteDashboard({ ...dashboard, quick: true }));
addedDataSources.forEach((dataSource) => e2e.flows.deleteDataSource({ ...dataSource, quick: true }));
if (hasChangedUserPreferences) {
e2e.flows.setDefaultUserPreferences();
+2 -3
View File
@@ -2,13 +2,12 @@ import { e2e } from '../index';
export interface SelectOptionConfig {
clickToOpen?: boolean;
container: any;
container: Cypress.Chainable<JQuery<HTMLElement>>;
forceClickOption?: boolean;
optionText: string | RegExp;
}
// @todo this actually returns type `Cypress.Chainable`
export const selectOption = (config: SelectOptionConfig): any => {
export const selectOption = (config: SelectOptionConfig) => {
const fullConfig: SelectOptionConfig = {
clickToOpen: true,
forceClickOption: false,