From 521493f344808b6d13f6fd243c1351d7d83b5cab Mon Sep 17 00:00:00 2001 From: Paul Tavares <56442535+paul-tavares@users.noreply.github.com> Date: Fri, 12 Jun 2020 08:04:45 -0400 Subject: [PATCH] [7.x] [Endpoint] Functional Tests cleanup (#68756) (#68822) * [Endpoint] Functional Tests cleanup (#68756) * Removed several unnecessary disabled eslint rules * moved common pageobject from endpoint_list to page_utils * Rename functional_endpoint to security_solution_endpoint * Delete `functional_endpoint_ingest_failure` no longer applicable # Conflicts: # .github/CODEOWNERS # x-pack/test/security_solution_endpoint/apps/endpoint/resolver.ts * Sync Endpoint Alerts page objects with master - PR https://github.com/elastic/kibana/pull/64704 was never backported, thus this change is needed to ensure build is successful. Co-authored-by: Elastic Machine --- .../components/management_page_view.tsx | 3 +- .../view/details/host_details.tsx | 9 +- .../public/management/store/reducer.ts | 1 - x-pack/scripts/functional_tests.js | 2 +- .../page_objects/endpoint_alerts_page.ts | 27 -- .../page_objects/page_utils.ts | 30 -- .../apps/endpoint/index.ts | 14 - .../apps/endpoint/landing_page.ts | 22 -- .../config.ts | 30 -- .../ftr_provider_context.d.ts | 12 - x-pack/test/plugin_functional/config.ts | 2 +- .../apps/endpoint/alerts.ts | 0 .../apps/endpoint/endpoint_list.ts | 6 +- .../apps/endpoint/index.ts | 0 .../apps/endpoint/policy_details.ts | 0 .../apps/endpoint/policy_list.ts | 10 +- .../apps/endpoint/resolver.ts | 259 ++++++++++++++++++ .../config.ts | 0 .../ftr_provider_context.d.ts | 0 .../page_objects/endpoint_alerts_page.ts | 120 ++++++++ .../page_objects/endpoint_page.ts | 48 +--- .../page_objects/index.ts | 0 .../page_objects/page_utils.ts | 76 +++++ .../page_objects/policy_page.ts | 0 .../services/endpoint_policy.ts | 0 .../services/index.ts | 0 26 files changed, 473 insertions(+), 198 deletions(-) delete mode 100644 x-pack/test/functional_endpoint/page_objects/endpoint_alerts_page.ts delete mode 100644 x-pack/test/functional_endpoint/page_objects/page_utils.ts delete mode 100644 x-pack/test/functional_endpoint_ingest_failure/apps/endpoint/index.ts delete mode 100644 x-pack/test/functional_endpoint_ingest_failure/apps/endpoint/landing_page.ts delete mode 100644 x-pack/test/functional_endpoint_ingest_failure/config.ts delete mode 100644 x-pack/test/functional_endpoint_ingest_failure/ftr_provider_context.d.ts rename x-pack/test/{functional_endpoint => security_solution_endpoint}/apps/endpoint/alerts.ts (100%) rename x-pack/test/{functional_endpoint => security_solution_endpoint}/apps/endpoint/endpoint_list.ts (97%) rename x-pack/test/{functional_endpoint => security_solution_endpoint}/apps/endpoint/index.ts (100%) rename x-pack/test/{functional_endpoint => security_solution_endpoint}/apps/endpoint/policy_details.ts (100%) rename x-pack/test/{functional_endpoint => security_solution_endpoint}/apps/endpoint/policy_list.ts (92%) create mode 100644 x-pack/test/security_solution_endpoint/apps/endpoint/resolver.ts rename x-pack/test/{functional_endpoint => security_solution_endpoint}/config.ts (100%) rename x-pack/test/{functional_endpoint => security_solution_endpoint}/ftr_provider_context.d.ts (100%) create mode 100644 x-pack/test/security_solution_endpoint/page_objects/endpoint_alerts_page.ts rename x-pack/test/{functional_endpoint => security_solution_endpoint}/page_objects/endpoint_page.ts (61%) rename x-pack/test/{functional_endpoint => security_solution_endpoint}/page_objects/index.ts (100%) create mode 100644 x-pack/test/security_solution_endpoint/page_objects/page_utils.ts rename x-pack/test/{functional_endpoint => security_solution_endpoint}/page_objects/policy_page.ts (100%) rename x-pack/test/{functional_endpoint => security_solution_endpoint}/services/endpoint_policy.ts (100%) rename x-pack/test/{functional_endpoint => security_solution_endpoint}/services/index.ts (100%) diff --git a/x-pack/plugins/security_solution/public/management/components/management_page_view.tsx b/x-pack/plugins/security_solution/public/management/components/management_page_view.tsx index 4fbbcfc8d948a..8f7e0e06fb7a1 100644 --- a/x-pack/plugins/security_solution/public/management/components/management_page_view.tsx +++ b/x-pack/plugins/security_solution/public/management/components/management_page_view.tsx @@ -35,8 +35,7 @@ export const ManagementPageView = memo>((options) => href: getManagementUrl({ name: 'policyList' }), }, ]; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [tabName]); + }, [options.viewType, tabName]); return ; }); diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/details/host_details.tsx b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/details/host_details.tsx index 6c447df618791..9b0ca73cf021f 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/details/host_details.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/details/host_details.tsx @@ -137,15 +137,14 @@ export const HostDetails = memo(({ details }: { details: HostMetadata }) => { description: details.agent.version, }, ]; - // eslint-disable-next-line react-hooks/exhaustive-deps }, [ - details.agent.version, details.endpoint.policy.id, - details.host.hostname, details.host.ip, - policyResponseUri.search, - policyStatusClickHandler, + details.host.hostname, + details.agent.version, policyStatus, + policyResponseUri, + policyStatusClickHandler, ]); return ( diff --git a/x-pack/plugins/security_solution/public/management/store/reducer.ts b/x-pack/plugins/security_solution/public/management/store/reducer.ts index e00b3ec9e0f5b..2ed3dfe86d2f8 100644 --- a/x-pack/plugins/security_solution/public/management/store/reducer.ts +++ b/x-pack/plugins/security_solution/public/management/store/reducer.ts @@ -40,6 +40,5 @@ export const mockManagementState: Immutable = { export const managementReducer = immutableCombineReducers({ [MANAGEMENT_STORE_POLICY_LIST_NAMESPACE]: policyListReducer, [MANAGEMENT_STORE_POLICY_DETAILS_NAMESPACE]: policyDetailsReducer, - // @ts-ignore [MANAGEMENT_STORE_ENDPOINTS_NAMESPACE]: hostListReducer, }); diff --git a/x-pack/scripts/functional_tests.js b/x-pack/scripts/functional_tests.js index 9769d81d8f147..87d43366ba1c8 100644 --- a/x-pack/scripts/functional_tests.js +++ b/x-pack/scripts/functional_tests.js @@ -8,7 +8,7 @@ require('@kbn/plugin-helpers').babelRegister(); require('@kbn/test').runTestsCli([ require.resolve('../test/functional/config.js'), - require.resolve('../test/functional_endpoint/config.ts'), + require.resolve('../test/security_solution_endpoint/config.ts'), require.resolve('../test/functional_with_es_ssl/config.ts'), require.resolve('../test/functional/config_security_basic.ts'), require.resolve('../test/functional/config_security_trial.ts'), diff --git a/x-pack/test/functional_endpoint/page_objects/endpoint_alerts_page.ts b/x-pack/test/functional_endpoint/page_objects/endpoint_alerts_page.ts deleted file mode 100644 index a5ad45536de89..0000000000000 --- a/x-pack/test/functional_endpoint/page_objects/endpoint_alerts_page.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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. - */ - -import { FtrProviderContext } from '../ftr_provider_context'; - -export function EndpointAlertsPageProvider({ getService }: FtrProviderContext) { - const testSubjects = getService('testSubjects'); - - return { - async enterSearchBarQuery(query: string) { - return await testSubjects.setValue('alertsSearchBar', query, { clearWithKeyboard: true }); - }, - async submitSearchBarFilter() { - return await testSubjects.click('querySubmitButton'); - }, - async setSearchBarDate(timestamp: string) { - await testSubjects.click('superDatePickerShowDatesButton'); - await testSubjects.click('superDatePickerstartDatePopoverButton'); - await testSubjects.click('superDatePickerAbsoluteTab'); - await testSubjects.setValue('superDatePickerAbsoluteDateInput', timestamp); - await this.submitSearchBarFilter(); - }, - }; -} diff --git a/x-pack/test/functional_endpoint/page_objects/page_utils.ts b/x-pack/test/functional_endpoint/page_objects/page_utils.ts deleted file mode 100644 index daf66464f7e1e..0000000000000 --- a/x-pack/test/functional_endpoint/page_objects/page_utils.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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. - */ - -import { FtrProviderContext } from '../ftr_provider_context'; - -export function EndpointPageUtils({ getService }: FtrProviderContext) { - const find = getService('find'); - - return { - /** - * Finds a given EuiCheckbox by test subject and clicks on it - * - * @param euiCheckBoxTestId - */ - async clickOnEuiCheckbox(euiCheckBoxTestId: string) { - // This utility is needed because EuiCheckbox forwards the test subject on to - // the actual `` which is not actually visible/accessible on the page. - // In order to actually cause the state of the checkbox to change, the `