Chore: remove wrapping of cy in the e2e object (#74650)

* remove cy. wrapping as e2e().

* make trace-view-scrolling more stable and remove waits

* improve stability more
This commit is contained in:
Ashley Harrison
2023-09-11 11:20:54 +01:00
committed by GitHub
parent 7718a67b77
commit 247d91be2b
54 changed files with 518 additions and 622 deletions
+10 -14
View File
@@ -49,28 +49,24 @@ export const benchmark = ({
return it(testName, () => {
e2e.flows.openDashboard();
e2e().wait(dashboard.delayAfterOpening);
cy.wait(dashboard.delayAfterOpening);
if (appStats) {
const startCollecting = appStats.startCollecting;
if (startCollecting) {
e2e()
.window()
.then((win) => startCollecting(win));
cy.window().then((win) => startCollecting(win));
}
e2e().startBenchmarking(testName);
e2e().wait(duration);
cy.startBenchmarking(testName);
cy.wait(duration);
e2e()
.window()
.then((win) => {
e2e().stopBenchmarking(testName, appStats.collect(win));
});
cy.window().then((win) => {
cy.stopBenchmarking(testName, appStats.collect(win));
});
} else {
e2e().startBenchmarking(testName);
e2e().wait(duration);
e2e().stopBenchmarking(testName, {});
cy.startBenchmarking(testName);
cy.wait(duration);
cy.stopBenchmarking(testName, {});
}
});
});
+1 -3
View File
@@ -2,9 +2,7 @@ import { e2e } from '../index';
// @todo this actually returns type `Cypress.Chainable`
const get = (key: string): any =>
e2e()
.wrap({ getLocalStorage: () => localStorage.getItem(key) }, { log: false })
.invoke('getLocalStorage');
cy.wrap({ getLocalStorage: () => localStorage.getItem(key) }, { log: false }).invoke('getLocalStorage');
// @todo this actually returns type `Cypress.Chainable`
export const getLocalStorage = (key: string): any =>
+2 -2
View File
@@ -37,7 +37,7 @@ const lastProperty = <T extends DeleteDashboardConfig | DeleteDataSourceConfig,
) => items[items.length - 1]?.[key] ?? '';
export const getScenarioContext = (): Cypress.Chainable<ScenarioContext> =>
e2e()
cy
.wrap(
{
getScenarioContext: (): ScenarioContext => ({ ...scenarioContext }),
@@ -47,7 +47,7 @@ export const getScenarioContext = (): Cypress.Chainable<ScenarioContext> =>
.invoke({ log: false }, 'getScenarioContext');
export const setScenarioContext = (newContext: Partial<ScenarioContext>): Cypress.Chainable<ScenarioContext> =>
e2e()
cy
.wrap(
{
setScenarioContext: () => {
+9 -11
View File
@@ -1,7 +1,5 @@
import { CssSelector, FunctionSelector, Selectors, StringSelector, UrlSelector } from '@grafana/e2e-selectors';
import { e2e } from '../index';
import { Selector } from './selector';
import { fromBaseUrl } from './url';
@@ -34,7 +32,7 @@ export type E2EFactoryArgs<S extends Selectors> = { selectors: S };
export type CypressOptions = Partial<Cypress.Loggable & Cypress.Timeoutable & Cypress.Withinable & Cypress.Shadow>;
const processSelectors = <S extends Selectors>(e2eObjects: E2EFunctions<S>, selectors: S): E2EFunctions<S> => {
const logOutput = (data: any) => e2e().logToConsole('Retrieving Selector:', data);
const logOutput = (data: any) => cy.logToConsole('Retrieving Selector:', data);
const keys = Object.keys(selectors);
for (let index = 0; index < keys.length; index++) {
const key = keys[index];
@@ -52,11 +50,11 @@ const processSelectors = <S extends Selectors>(e2eObjects: E2EFunctions<S>, sele
parsedUrl = fromBaseUrl(value(args));
}
e2e().logToConsole('Visiting', parsedUrl);
cy.logToConsole('Visiting', parsedUrl);
if (queryParams) {
return e2e().visit({ url: parsedUrl, qs: queryParams });
return cy.visit({ url: parsedUrl, qs: queryParams });
} else {
return e2e().visit(parsedUrl);
return cy.visit(parsedUrl);
}
};
@@ -71,7 +69,7 @@ const processSelectors = <S extends Selectors>(e2eObjects: E2EFunctions<S>, sele
? Selector.fromDataTestId(value)
: Selector.fromAriaLabel(value);
return e2e().get(selector, options);
return cy.get(selector, options);
};
continue;
@@ -85,7 +83,7 @@ const processSelectors = <S extends Selectors>(e2eObjects: E2EFunctions<S>, sele
const selector = value(undefined as unknown as string);
logOutput(selector);
return e2e().get(selector);
return cy.get(selector);
}
// the input can be (text) or (options)
@@ -97,12 +95,12 @@ const processSelectors = <S extends Selectors>(e2eObjects: E2EFunctions<S>, sele
: Selector.fromAriaLabel(selectorText);
logOutput(selector);
return e2e().get(selector);
return cy.get(selector);
}
const selector = value(undefined as unknown as string);
logOutput(selector);
return e2e().get(selector, textOrOptions);
return cy.get(selector, textOrOptions);
}
// the input can only be (text, options)
@@ -114,7 +112,7 @@ const processSelectors = <S extends Selectors>(e2eObjects: E2EFunctions<S>, sele
: Selector.fromAriaLabel(selectorText);
logOutput(selector);
return e2e().get(selector, options);
return cy.get(selector, options);
}
};