From 7feaddea8f84b6d1a4a9106b36c4b80d9a2586af Mon Sep 17 00:00:00 2001 From: Marcus Andersson Date: Thu, 24 Sep 2020 18:47:25 +0200 Subject: [PATCH] Chore: adding platform independent typings for e2e tests. (#27768) * added typings that are platform independent in the tests. * fixing nits. --- e2e/suite1/specs/query-editor.spec.ts | 2 +- packages/grafana-e2e/src/index.ts | 2 ++ packages/grafana-e2e/src/typings/index.ts | 1 + packages/grafana-e2e/src/typings/undo.ts | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 packages/grafana-e2e/src/typings/index.ts create mode 100644 packages/grafana-e2e/src/typings/undo.ts diff --git a/e2e/suite1/specs/query-editor.spec.ts b/e2e/suite1/specs/query-editor.spec.ts index e7d2cc72ca4..62a116b7824 100644 --- a/e2e/suite1/specs/query-editor.spec.ts +++ b/e2e/suite1/specs/query-editor.spec.ts @@ -29,7 +29,7 @@ e2e.scenario({ cy.contains(queryText.slice(0, -1)).should('be.visible'); - e2e.components.QueryField.container().type('{ctrl}z'); + e2e.components.QueryField.container().type(e2e.typings.undo()); cy.contains(queryText).should('be.visible'); }, diff --git a/packages/grafana-e2e/src/index.ts b/packages/grafana-e2e/src/index.ts index a74b419f517..03143650308 100644 --- a/packages/grafana-e2e/src/index.ts +++ b/packages/grafana-e2e/src/index.ts @@ -8,6 +8,7 @@ import { getScenarioContext, setScenarioContext } from './support/scenarioContex import { e2eFactory } from './support'; import { selectors } from '@grafana/e2e-selectors'; import * as flows from './flows'; +import * as typings from './typings'; const e2eObject = { env: (args: string) => Cypress.env(args), @@ -16,6 +17,7 @@ const e2eObject = { imgSrcToBlob: (url: string) => Cypress.Blob.imgSrcToBlob(url), scenario: (args: ScenarioArguments) => e2eScenario(args), pages: e2eFactory({ selectors: selectors.pages }), + typings, components: e2eFactory({ selectors: selectors.components }), flows, getScenarioContext, diff --git a/packages/grafana-e2e/src/typings/index.ts b/packages/grafana-e2e/src/typings/index.ts new file mode 100644 index 00000000000..d4a4805a21f --- /dev/null +++ b/packages/grafana-e2e/src/typings/index.ts @@ -0,0 +1 @@ +export { undo } from './undo'; diff --git a/packages/grafana-e2e/src/typings/undo.ts b/packages/grafana-e2e/src/typings/undo.ts new file mode 100644 index 00000000000..9ee3c1cda40 --- /dev/null +++ b/packages/grafana-e2e/src/typings/undo.ts @@ -0,0 +1,19 @@ +// https://nodejs.org/api/os.html#os_os_platform +enum Platform { + osx = 'darwin', + windows = 'win32', + linux = 'linux', + aix = 'aix', + freebsd = 'freebsd', + openbsd = 'openbsd', + sunos = 'sunos', +} + +export const undo = () => { + switch (Cypress.platform) { + case Platform.osx: + return '{cmd}z'; + default: + return '{ctrl}z'; + } +};