Skip to content

Commit

Permalink
[Security Solution] Fix tests for new data screen and update index check
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlog committed Sep 13, 2021
1 parent 5937a32 commit b128771
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { useShowTimeline } from '../../../common/utils/timeline/use_show_timelin
import { gutterTimeline } from '../../../common/lib/helpers';
import { useSourcererScope } from '../../../common/containers/sourcerer';
import { OverviewEmpty } from '../../../overview/components/overview_empty';
import { ENDPOINT_METADATA_INDEX } from '../../../../common/constants';
import { useFetchIndex } from '../../../common/containers/source';

/* eslint-disable react/display-name */

Expand Down Expand Up @@ -76,13 +78,17 @@ export const SecuritySolutionTemplateWrapper: React.FC<SecuritySolutionPageWrapp
const { show: isShowingTimelineOverlay } = useDeepEqualSelector((state) =>
getTimelineShowStatus(state, TimelineId.active)
);

const endpointMetadataIndex = useMemo<string[]>(() => {
return [ENDPOINT_METADATA_INDEX];
}, []);
const [, { indexExists: metadataIndexExists }] = useFetchIndex(endpointMetadataIndex, true);
const { indicesExist } = useSourcererScope();
const securityIndicesExist = indicesExist || metadataIndexExists;

/* StyledKibanaPageTemplate is a styled EuiPageTemplate. Security solution currently passes the header and page content as the children of StyledKibanaPageTemplate, as opposed to using the pageHeader prop, which may account for any style discrepancies, such as the bottom border not extending the full width of the page, between EuiPageTemplate and the security solution pages.
*/

return indicesExist ? (
return securityIndicesExist ? (
<StyledKibanaPageTemplate
$isTimelineBottomBarVisible={isTimelineBottomBarVisible}
$isShowingTimelineOverlay={isShowingTimelineOverlay}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const pageObjects = getPageObjects(['common', 'endpoint', 'header', 'endpointPageUtils']);
const esArchiver = getService('esArchiver');
const testSubjects = getService('testSubjects');
const browser = getService('browser');

const expectedData = [
[
Expand Down Expand Up @@ -84,10 +85,14 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});

it('finds data after load and polling', async () => {
await esArchiver.load('x-pack/test/functional/es_archives/endpoint/metadata/api_feature', {
useCreate: true,
});
await esArchiver.load(
'x-pack/test/functional/es_archives/endpoint/metadata/destination_index',
{ useCreate: true }
);
await browser.refresh();
await pageObjects.endpoint.waitForTableToHaveData('endpointListTable', 1100);
const tableData = await pageObjects.endpointPageUtils.tableData('endpointListTable');
expect(tableData).to.eql(expectedData);
Expand All @@ -96,11 +101,15 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

describe('when there is data,', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/endpoint/metadata/api_feature', {
useCreate: true,
});
await esArchiver.load(
'x-pack/test/functional/es_archives/endpoint/metadata/destination_index',
{ useCreate: true }
);
await pageObjects.endpoint.navigateToEndpointList();
await browser.refresh();
});
after(async () => {
await deleteMetadataStream(getService);
Expand Down Expand Up @@ -215,11 +224,15 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

describe('displays the correct table data for the kql queries', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/endpoint/metadata/api_feature', {
useCreate: true,
});
await esArchiver.load(
'x-pack/test/functional/es_archives/endpoint/metadata/destination_index',
{ useCreate: true }
);
await pageObjects.endpoint.navigateToEndpointList();
await browser.refresh();
});
after(async () => {
await deleteMetadataStream(getService);
Expand Down

0 comments on commit b128771

Please sign in to comment.