Skip to content

Commit

Permalink
[Endpoint] Re-enable Functional test case for Endpoint related pages (#…
Browse files Browse the repository at this point in the history
…68445) (#68699)

* Improve Policy test service provider
  - Added `getFullAgentConfig()` to Endpoint Policy Test data provider service
* enable Policy List functional tests
* Added Policy Details Tests
* Add test ids to policy detail Max and Linux forms
* Added page objects utilities and moved `clickOnEuiCheckbox` there

# Conflicts:
#	x-pack/test/functional_endpoint/apps/endpoint/index.ts

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
paul-tavares and elasticmachine authored Jun 10, 2020
1 parent 86ea134 commit 8ea487c
Show file tree
Hide file tree
Showing 19 changed files with 521 additions and 282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ export const PolicyDetails = React.memo(() => {
}
),
body: (
<FormattedMessage
id="xpack.securitySolution.endpoint.policy.details.updateSuccessMessage"
defaultMessage="Policy {name} has been updated."
values={{ name: policyName }}
/>
<span data-test-subj="policyDetailsSuccessMessage">
<FormattedMessage
id="xpack.securitySolution.endpoint.policy.details.updateSuccessMessage"
defaultMessage="Policy {name} has been updated."
values={{ name: policyName }}
/>
</span>
),
});
} else {
Expand Down Expand Up @@ -116,7 +118,7 @@ export const PolicyDetails = React.memo(() => {
<EuiLoadingSpinner size="xl" />
) : policyApiError ? (
<EuiCallOut color="danger" title={policyApiError?.error}>
{policyApiError?.message}
<span data-test-subj="policyDetailsIdNotFoundMessage">{policyApiError?.message}</span>
</EuiCallOut>
) : null}
<SpyRoute />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@
*/

import React, { useCallback, useMemo } from 'react';
import { EuiCheckbox, htmlIdGenerator } from '@elastic/eui';
import { EuiCheckbox, EuiCheckboxProps, htmlIdGenerator } from '@elastic/eui';
import { useDispatch } from 'react-redux';

import { usePolicyDetailsSelector } from '../../policy_hooks';
import { policyConfig } from '../../../store/policy_details/selectors';
import { PolicyDetailsAction } from '../../../store/policy_details';
import { UIPolicyConfig } from '../../../../../../../common/endpoint/types';

type EventsCheckboxProps = Omit<EuiCheckboxProps, 'id' | 'label' | 'checked' | 'onChange'> & {
name: string;
setter: (config: UIPolicyConfig, checked: boolean) => UIPolicyConfig;
getter: (config: UIPolicyConfig) => boolean;
};

export const EventsCheckbox = React.memo(function ({
name,
setter,
getter,
}: {
name: string;
setter: (config: UIPolicyConfig, checked: boolean) => UIPolicyConfig;
getter: (config: UIPolicyConfig) => boolean;
}) {
...otherProps
}: EventsCheckboxProps) {
const policyDetailsConfig = usePolicyDetailsSelector(policyConfig);
const selected = getter(policyDetailsConfig);
const dispatch = useDispatch<(action: PolicyDetailsAction) => void>();
Expand All @@ -44,6 +46,7 @@ export const EventsCheckbox = React.memo(function ({
label={name}
checked={selected}
onChange={handleCheckboxChange}
{...otherProps}
/>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const LinuxEvents = React.memo(() => {
<EventsCheckbox
name={item.name}
key={index}
data-test-subj={`policyLinuxEvent_${item.protectionField}`}
setter={(config, checked) =>
setIn(config)(item.os)('events')(item.protectionField)(checked)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const MacEvents = React.memo(() => {
<EventsCheckbox
name={item.name}
key={index}
data-test-subj={`policyMacEvent_${item.protectionField}`}
setter={(config, checked) =>
setIn(config)(item.os)('events')(item.protectionField)(checked)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export const WindowsEvents = React.memo(() => {
<EventsCheckbox
name={item.name}
key={index}
data-test-subj={`policyWindowsEvent_${item.protectionField}`}
setter={(config, checked) =>
setIn(config)(item.os)('events')(item.protectionField)(checked)
}
Expand Down
1 change: 1 addition & 0 deletions x-pack/scripts/functional_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +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/functional_with_es_ssl/config.ts'),
require.resolve('../test/functional/config_security_basic.ts'),
require.resolve('../test/functional/config_security_trial.ts'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,68 +13,71 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const testSubjects = getService('testSubjects');

// FLAKY: https://github.com/elastic/kibana/issues/63621
describe.skip('host list', function () {
describe.skip('endpoint list', function () {
this.tags('ciGroup7');
const sleep = (ms = 100) => new Promise((resolve) => setTimeout(resolve, ms));
before(async () => {
await esArchiver.load('endpoint/metadata/api_feature');
await pageObjects.common.navigateToUrlWithBrowserHistory('endpoint', '/hosts');
await pageObjects.header.waitUntilLoadingHasFinished();
await pageObjects.endpoint.navigateToEndpointList();
});

it('finds title', async () => {
const title = await testSubjects.getVisibleText('hostListTitle');
expect(title).to.equal('Hosts');
const title = await testSubjects.getVisibleText('pageViewHeaderLeftTitle');
expect(title).to.equal('Endpoints');
});

it('displays table data', async () => {
const expectedData = [
[
'Hostname',
'Host Status',
'Policy',
'Policy Status',
'Alerts',
'Operating System',
'IP Address',
'Sensor Version',
'Version',
'Last Active',
],
[
'cadmann-4.example.com',
'Error',
'Policy Name',
'Policy Status',
'0',
'windows 10.0',
'10.192.213.130, 10.70.28.129',
'version',
'xxxx',
'6.6.1',
'Jan 24, 2020 @ 16:06:09.541',
],
[
'thurlow-9.example.com',
'Error',
'Policy Name',
'Policy Status',
'0',
'windows 10.0',
'10.46.229.234',
'version',
'xxxx',
'6.0.0',
'Jan 24, 2020 @ 16:06:09.541',
],
[
'rezzani-7.example.com',
'Error',
'Policy Name',
'Policy Status',
'0',
'windows 10.0',
'10.101.149.26, 2606:a000:ffc0:39:11ef:37b9:3371:578c',
'version',
'xxxx',
'6.8.0',
'Jan 24, 2020 @ 16:06:09.541',
],
];
const tableData = await pageObjects.endpoint.getEndpointAppTableData('hostListTable');
expect(tableData).to.eql(expectedData);
});

it('no details flyout when host page displayed', async () => {
it('no details flyout when endpoint page displayed', async () => {
await testSubjects.missingOrFail('hostDetailsFlyout');
});

Expand Down Expand Up @@ -108,22 +111,21 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await (await testSubjects.findAll('hostnameCellLink'))[1].click();
await sleep(500); // give page time to refresh and verify it did not change
const hostDetailTitleNew = await testSubjects.getVisibleText('hostDetailsFlyoutTitle');
expect(hostDetailTitleNew).to.eql(hostDetailTitleInitial);
expect(hostDetailTitleNew).to.equal(hostDetailTitleInitial);
});

describe('no data', () => {
before(async () => {
// clear out the data and reload the page
await esArchiver.unload('endpoint/metadata/api_feature');
await pageObjects.common.navigateToUrlWithBrowserHistory('endpoint', '/hosts');
await pageObjects.header.waitUntilLoadingHasFinished();
await pageObjects.endpoint.navigateToEndpointList();
});
after(async () => {
// reload the data so the other tests continue to pass
await esArchiver.load('endpoint/metadata/api_feature');
});
it('displays no items found when empty', async () => {
// get the host list table data and verify message
// get the endpoint list table data and verify message
const [, [noItemsFoundMessage]] = await pageObjects.endpoint.getEndpointAppTableData(
'hostListTable'
);
Expand All @@ -133,12 +135,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

describe('has a url with a host id', () => {
before(async () => {
await pageObjects.common.navigateToUrlWithBrowserHistory(
'endpoint',
'/hosts',
await pageObjects.endpoint.navigateToEndpointList(
'selected_host=fc0ff548-feba-41b6-8367-65e8790d0eaf'
);
await pageObjects.header.waitUntilLoadingHasFinished();
});

it('shows a flyout', async () => {
Expand Down Expand Up @@ -168,7 +167,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
'',
'0',
'00000000-0000-0000-0000-000000000000',
'Successful',
'Unknown',
'10.101.149.262606:a000:ffc0:39:11ef:37b9:3371:578c',
'rezzani-7.example.com',
'6.8.0',
Expand Down

This file was deleted.

This file was deleted.

55 changes: 0 additions & 55 deletions x-pack/test/functional_endpoint/apps/endpoint/header_nav.ts

This file was deleted.

10 changes: 5 additions & 5 deletions x-pack/test/functional_endpoint/apps/endpoint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export default function ({ loadTestFile }: FtrProviderContext) {
describe('endpoint', function () {
this.tags('ciGroup7');

loadTestFile(require.resolve('./feature_controls'));
loadTestFile(require.resolve('./landing_page'));
loadTestFile(require.resolve('./header_nav'));
loadTestFile(require.resolve('./host_list'));
loadTestFile(require.resolve('./endpoint_list'));
loadTestFile(require.resolve('./policy_list'));
loadTestFile(require.resolve('./alerts'));
loadTestFile(require.resolve('./policy_details'));

// loadTestFile(require.resolve('./alerts'));
// loadTestFile(require.resolve('./resolver'));
});
}
Loading

0 comments on commit 8ea487c

Please sign in to comment.