mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[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
This commit is contained in:
parent
28d9c1407c
commit
577381d821
26 changed files with 95 additions and 173 deletions
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
|
@ -222,8 +222,7 @@
|
|||
/x-pack/plugins/endpoint/ @elastic/endpoint-app-team @elastic/siem
|
||||
/x-pack/test/api_integration/apis/endpoint/ @elastic/endpoint-app-team @elastic/siem
|
||||
/x-pack/test/endpoint_api_integration_no_ingest/ @elastic/endpoint-app-team @elastic/siem
|
||||
/x-pack/test/functional_endpoint/ @elastic/endpoint-app-team @elastic/siem
|
||||
/x-pack/test/functional_endpoint_ingest_failure/ @elastic/endpoint-app-team @elastic/siem
|
||||
/x-pack/test/security_solution_endpoint/ @elastic/endpoint-app-team @elastic/siem
|
||||
/x-pack/test/functional/es_archives/endpoint/ @elastic/endpoint-app-team @elastic/siem
|
||||
/x-pack/test/plugin_functional/plugins/resolver_test/ @elastic/endpoint-app-team @elastic/siem
|
||||
/x-pack/test/plugin_functional/test_suites/resolver/ @elastic/endpoint-app-team @elastic/siem
|
||||
|
|
|
@ -35,8 +35,7 @@ export const ManagementPageView = memo<Omit<PageViewProps, 'tabs'>>((options) =>
|
|||
href: getManagementUrl({ name: 'policyList' }),
|
||||
},
|
||||
];
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [tabName]);
|
||||
}, [options.viewType, tabName]);
|
||||
return <PageView {...options} tabs={tabs} />;
|
||||
});
|
||||
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -40,6 +40,5 @@ export const mockManagementState: Immutable<ManagementState> = {
|
|||
export const managementReducer = immutableCombineReducers({
|
||||
[MANAGEMENT_STORE_POLICY_LIST_NAMESPACE]: policyListReducer,
|
||||
[MANAGEMENT_STORE_POLICY_DETAILS_NAMESPACE]: policyDetailsReducer,
|
||||
// @ts-ignore
|
||||
[MANAGEMENT_STORE_ENDPOINTS_NAMESPACE]: hostListReducer,
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
const alwaysImportedTests = [
|
||||
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'),
|
||||
|
|
|
@ -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 `<input>` which is not actually visible/accessible on the page.
|
||||
// In order to actually cause the state of the checkbox to change, the `<label>`
|
||||
// must be clicked.
|
||||
const euiCheckboxLabelElement = await find.byXPath(
|
||||
`//input[@data-test-subj='${euiCheckBoxTestId}']/../label`
|
||||
);
|
||||
|
||||
await euiCheckboxLabelElement.click();
|
||||
},
|
||||
};
|
||||
}
|
|
@ -1,14 +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 default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('endpoint when the ingest manager fails to setup correctly', function () {
|
||||
this.tags('ciGroup7');
|
||||
|
||||
loadTestFile(require.resolve('./landing_page'));
|
||||
});
|
||||
}
|
|
@ -1,22 +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 default ({ getPageObjects, getService }: FtrProviderContext) => {
|
||||
describe('home page', function () {
|
||||
const pageObjects = getPageObjects(['common']);
|
||||
const testSubjects = getService('testSubjects');
|
||||
|
||||
before(async () => {
|
||||
await pageObjects.common.navigateToApp('endpoint');
|
||||
});
|
||||
|
||||
it('displays an error toast', async () => {
|
||||
await testSubjects.existOrFail('euiToastHeader');
|
||||
});
|
||||
});
|
||||
};
|
|
@ -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 { resolve } from 'path';
|
||||
import { FtrConfigProviderContext } from '@kbn/test/types/ftr';
|
||||
|
||||
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
||||
const xpackFunctionalConfig = await readConfigFile(
|
||||
require.resolve('../functional_endpoint/config.ts')
|
||||
);
|
||||
|
||||
return {
|
||||
...xpackFunctionalConfig.getAll(),
|
||||
testFiles: [resolve(__dirname, './apps/endpoint')],
|
||||
junit: {
|
||||
reportName: 'X-Pack Endpoint Without Ingest Functional Tests',
|
||||
},
|
||||
kbnTestServer: {
|
||||
...xpackFunctionalConfig.get('kbnTestServer'),
|
||||
serverArgs: [
|
||||
...xpackFunctionalConfig.get('kbnTestServer.serverArgs'),
|
||||
// use a bogus port so the ingest manager setup will fail
|
||||
'--xpack.ingestManager.epm.registryUrl=http://127.0.0.1:12345',
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
|
@ -1,12 +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 { GenericFtrProviderContext } from '@kbn/test/types/ftr';
|
||||
|
||||
import { pageObjects } from '../functional_endpoint/page_objects';
|
||||
import { services } from '../functional/services';
|
||||
|
||||
export type FtrProviderContext = GenericFtrProviderContext<typeof services, typeof pageObjects>;
|
|
@ -16,7 +16,7 @@ import { pageObjects } from './page_objects';
|
|||
/* eslint-disable import/no-default-export */
|
||||
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
||||
const xpackFunctionalConfig = await readConfigFile(
|
||||
require.resolve('../functional_endpoint/config.ts')
|
||||
require.resolve('../security_solution_endpoint/config.ts')
|
||||
);
|
||||
|
||||
// Find all folders in ./plugins since we treat all them as plugin folder
|
||||
|
|
|
@ -8,7 +8,7 @@ import expect from '@kbn/expect';
|
|||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
||||
const pageObjects = getPageObjects(['common', 'endpoint', 'header']);
|
||||
const pageObjects = getPageObjects(['common', 'endpoint', 'header', 'endpointPageUtils']);
|
||||
const esArchiver = getService('esArchiver');
|
||||
const testSubjects = getService('testSubjects');
|
||||
|
||||
|
@ -73,7 +73,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
'Jan 24, 2020 @ 16:06:09.541',
|
||||
],
|
||||
];
|
||||
const tableData = await pageObjects.endpoint.getEndpointAppTableData('hostListTable');
|
||||
const tableData = await pageObjects.endpointPageUtils.tableData('hostListTable');
|
||||
expect(tableData).to.eql(expectedData);
|
||||
});
|
||||
|
||||
|
@ -126,7 +126,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
});
|
||||
it('displays no items found when empty', async () => {
|
||||
// get the endpoint list table data and verify message
|
||||
const [, [noItemsFoundMessage]] = await pageObjects.endpoint.getEndpointAppTableData(
|
||||
const [, [noItemsFoundMessage]] = await pageObjects.endpointPageUtils.tableData(
|
||||
'hostListTable'
|
||||
);
|
||||
expect(noItemsFoundMessage).to.equal('No items found');
|
|
@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context';
|
|||
import { PolicyTestResourceInfo } from '../../services/endpoint_policy';
|
||||
|
||||
export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
||||
const pageObjects = getPageObjects(['common', 'endpoint', 'policy']);
|
||||
const pageObjects = getPageObjects(['common', 'endpoint', 'policy', 'endpointPageUtils']);
|
||||
const testSubjects = getService('testSubjects');
|
||||
const policyTestResources = getService('policyTestResources');
|
||||
const RELATIVE_DATE_FORMAT = /\d (?:seconds|minutes) ago/i;
|
||||
|
@ -31,7 +31,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
expect(policyTotal).to.equal('0 Policies');
|
||||
});
|
||||
it('has correct table headers', async () => {
|
||||
const allHeaderCells = await pageObjects.endpoint.tableHeaderVisibleText('policyTable');
|
||||
const allHeaderCells = await pageObjects.endpointPageUtils.tableHeaderVisibleText(
|
||||
'policyTable'
|
||||
);
|
||||
expect(allHeaderCells).to.eql([
|
||||
'Policy Name',
|
||||
'Created By',
|
||||
|
@ -43,7 +45,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
]);
|
||||
});
|
||||
it('should show empty table results message', async () => {
|
||||
const [, [noItemsFoundMessage]] = await pageObjects.endpoint.getEndpointAppTableData(
|
||||
const [, [noItemsFoundMessage]] = await pageObjects.endpointPageUtils.tableData(
|
||||
'policyTable'
|
||||
);
|
||||
expect(noItemsFoundMessage).to.equal('No items found');
|
||||
|
@ -65,7 +67,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
it('should show policy on the list', async () => {
|
||||
const [, policyRow] = await pageObjects.endpoint.getEndpointAppTableData('policyTable');
|
||||
const [, policyRow] = await pageObjects.endpointPageUtils.tableData('policyTable');
|
||||
// Validate row data with the exception of the Date columns - since those are initially
|
||||
// shown as relative.
|
||||
expect([policyRow[0], policyRow[1], policyRow[3], policyRow[5], policyRow[6]]).to.eql([
|
|
@ -9,7 +9,7 @@ import { FtrProviderContext } from '../ftr_provider_context';
|
|||
|
||||
export function EndpointPageProvider({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const testSubjects = getService('testSubjects');
|
||||
const pageObjects = getPageObjects(['common', 'header']);
|
||||
const pageObjects = getPageObjects(['common', 'header', 'endpointPageUtils']);
|
||||
const retry = getService('retry');
|
||||
|
||||
return {
|
||||
|
@ -23,53 +23,9 @@ export function EndpointPageProvider({ getService, getPageObjects }: FtrProvider
|
|||
await pageObjects.header.waitUntilLoadingHasFinished();
|
||||
},
|
||||
|
||||
/**
|
||||
* Finds the Table with the given `selector` (test subject) and returns
|
||||
* back an array containing the table's header column text
|
||||
*
|
||||
* @param selector
|
||||
* @returns Promise<string[]>
|
||||
*/
|
||||
async tableHeaderVisibleText(selector: string) {
|
||||
const $ = await (await testSubjects.find('policyTable')).parseDomContent();
|
||||
return $('thead tr th')
|
||||
.toArray()
|
||||
.map((th) =>
|
||||
$(th)
|
||||
.text()
|
||||
.replace(/ /g, '')
|
||||
.trim()
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Finds a table and returns the data in a nested array with row 0 is the headers if they exist.
|
||||
* It uses euiTableCellContent to avoid poluting the array data with the euiTableRowCell__mobileHeader data.
|
||||
* @param dataTestSubj
|
||||
* @returns Promise<string[][]>
|
||||
*/
|
||||
async getEndpointAppTableData(dataTestSubj: string) {
|
||||
await testSubjects.exists(dataTestSubj);
|
||||
const hostTable: WebElementWrapper = await testSubjects.find(dataTestSubj);
|
||||
const $ = await hostTable.parseDomContent();
|
||||
return $('tr')
|
||||
.toArray()
|
||||
.map((row) =>
|
||||
$(row)
|
||||
.find('.euiTableCellContent')
|
||||
.toArray()
|
||||
.map((cell) =>
|
||||
$(cell)
|
||||
.text()
|
||||
.replace(/ /g, '')
|
||||
.trim()
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
async waitForTableToHaveData(dataTestSubj: string) {
|
||||
await retry.waitForWithTimeout('table to have data', 2000, async () => {
|
||||
const tableData = await this.getEndpointAppTableData(dataTestSubj);
|
||||
const tableData = await pageObjects.endpointPageUtils.tableData(dataTestSubj);
|
||||
if (tableData[1][0] === 'No items found') {
|
||||
return false;
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* 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';
|
||||
import { WebElementWrapper } from '../../../../test/functional/services/lib/web_element_wrapper';
|
||||
|
||||
export function EndpointPageUtils({ getService }: FtrProviderContext) {
|
||||
const testSubjects = getService('testSubjects');
|
||||
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 `<input>` which is not actually visible/accessible on the page.
|
||||
// In order to actually cause the state of the checkbox to change, the `<label>`
|
||||
// must be clicked.
|
||||
const euiCheckboxLabelElement = await find.byXPath(
|
||||
`//input[@data-test-subj='${euiCheckBoxTestId}']/../label`
|
||||
);
|
||||
|
||||
await euiCheckboxLabelElement.click();
|
||||
},
|
||||
|
||||
/**
|
||||
* Finds the Table with the given `selector` (test subject) and returns
|
||||
* back an array containing the table's header column text
|
||||
*
|
||||
* @param selector
|
||||
* @returns Promise<string[]>
|
||||
*/
|
||||
async tableHeaderVisibleText(selector: string) {
|
||||
const $ = await (await testSubjects.find(selector)).parseDomContent();
|
||||
return $('thead tr th')
|
||||
.toArray()
|
||||
.map((th) =>
|
||||
$(th)
|
||||
.text()
|
||||
.replace(/ /g, '')
|
||||
.trim()
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Finds a table and returns the data in a nested array with row 0 is the headers if they exist.
|
||||
* It uses euiTableCellContent to avoid poluting the array data with the euiTableRowCell__mobileHeader data.
|
||||
* @param dataTestSubj
|
||||
* @returns Promise<string[][]>
|
||||
*/
|
||||
async tableData(dataTestSubj: string) {
|
||||
await testSubjects.exists(dataTestSubj);
|
||||
const hostTable: WebElementWrapper = await testSubjects.find(dataTestSubj);
|
||||
const $ = await hostTable.parseDomContent();
|
||||
return $('tr')
|
||||
.toArray()
|
||||
.map((row) =>
|
||||
$(row)
|
||||
.find('.euiTableCellContent')
|
||||
.toArray()
|
||||
.map((cell) =>
|
||||
$(cell)
|
||||
.text()
|
||||
.replace(/ /g, '')
|
||||
.trim()
|
||||
)
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue