From 7c7986092908635d2edf03292e38183ecf3180c4 Mon Sep 17 00:00:00 2001 From: MadameSheema Date: Wed, 29 Jan 2020 07:20:56 +0100 Subject: [PATCH] refactor (#56131) --- .../smoke_tests/navigation/navigation.spec.ts | 23 +++++++------------ .../plugins/siem/cypress/screens/header.ts | 8 +++++++ .../plugins/siem/cypress/tasks/header.ts | 9 ++++++++ .../plugins/siem/cypress/urls/navigation.ts | 7 ++++++ 4 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 x-pack/legacy/plugins/siem/cypress/tasks/header.ts create mode 100644 x-pack/legacy/plugins/siem/cypress/urls/navigation.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/navigation/navigation.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/navigation/navigation.spec.ts index a549b5eec2e7c0..364864b395d41e 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/navigation/navigation.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/navigation/navigation.spec.ts @@ -4,39 +4,32 @@ * you may not use this file except in compliance with the Elastic License. */ -import { TIMELINES_PAGE } from '../../lib/urls'; -import { - NAVIGATION_HOSTS, - NAVIGATION_NETWORK, - NAVIGATION_OVERVIEW, - NAVIGATION_TIMELINES, -} from '../../lib/navigation/selectors'; -import { loginAndWaitForPage } from '../../lib/util/helpers'; +import { TIMELINES_PAGE } from '../../../urls/navigation'; +import { HOSTS, NETWORK, OVERVIEW, TIMELINES } from '../../../screens/header'; +import { loginAndWaitForPage } from '../../../tasks/login'; +import { navigateFromHeaderTo } from '../../../tasks/header'; describe('top-level navigation common to all pages in the SIEM app', () => { before(() => { loginAndWaitForPage(TIMELINES_PAGE); }); it('navigates to the Overview page', () => { - cy.get(NAVIGATION_OVERVIEW).click({ force: true }); + navigateFromHeaderTo(OVERVIEW); cy.url().should('include', '/siem#/overview'); }); it('navigates to the Hosts page', () => { - cy.get(NAVIGATION_HOSTS).click({ force: true }); - + navigateFromHeaderTo(HOSTS); cy.url().should('include', '/siem#/hosts'); }); it('navigates to the Network page', () => { - cy.get(NAVIGATION_NETWORK).click({ force: true }); - + navigateFromHeaderTo(NETWORK); cy.url().should('include', '/siem#/network'); }); it('navigates to the Timelines page', () => { - cy.get(NAVIGATION_TIMELINES).click({ force: true }); - + navigateFromHeaderTo(TIMELINES); cy.url().should('include', '/siem#/timelines'); }); }); diff --git a/x-pack/legacy/plugins/siem/cypress/screens/header.ts b/x-pack/legacy/plugins/siem/cypress/screens/header.ts index cb018cda8f68db..6e4f5fc0e35cb6 100644 --- a/x-pack/legacy/plugins/siem/cypress/screens/header.ts +++ b/x-pack/legacy/plugins/siem/cypress/screens/header.ts @@ -5,3 +5,11 @@ */ export const KQL_INPUT = '[data-test-subj="queryInput"]'; + +export const HOSTS = '[data-test-subj="navigation-hosts"]'; + +export const NETWORK = '[data-test-subj="navigation-network"]'; + +export const OVERVIEW = '[data-test-subj="navigation-overview"]'; + +export const TIMELINES = '[data-test-subj="navigation-timelines"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/header.ts b/x-pack/legacy/plugins/siem/cypress/tasks/header.ts new file mode 100644 index 00000000000000..96412b1eb6a3cc --- /dev/null +++ b/x-pack/legacy/plugins/siem/cypress/tasks/header.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const navigateFromHeaderTo = (page: string) => { + cy.get(page).click({ force: true }); +}; diff --git a/x-pack/legacy/plugins/siem/cypress/urls/navigation.ts b/x-pack/legacy/plugins/siem/cypress/urls/navigation.ts new file mode 100644 index 00000000000000..4675829df839a8 --- /dev/null +++ b/x-pack/legacy/plugins/siem/cypress/urls/navigation.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const TIMELINES_PAGE = '/app/siem#/timelines';