Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Endpoint] Re-enable Functional test case for Endpoint related pages #68445

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -6,6 +6,7 @@

const alwaysImportedTests = [
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 () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this still be skipped?

Copy link
Contributor Author

@paul-tavares paul-tavares Jun 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinlog yes. Although I updated the tests with new paths, etc. they are still "flaky" - @charlie-pichette is (will) working on getting them reenabled. :)

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.

11 changes: 5 additions & 6 deletions x-pack/test/functional_endpoint/apps/endpoint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +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('./resolver'));
loadTestFile(require.resolve('./policy_details'));

// loadTestFile(require.resolve('./alerts'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit, we could add a TODO or just remove the commented out code and track enabling the rest of the tests in another ticket

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I will remove the commented out code in a subsquent PR and will create an Issue to follow up on it (I don't think these are applicable anymore)

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