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

[Secuity Solution][DQD] add list view and latest flyout (Phase 1) #188468

Merged
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -9,16 +9,16 @@ import { render, screen } from '@testing-library/react';
import React from 'react';

import { mockAllowedValues } from '../../mock/allowed_values/mock_allowed_values';
import { TestProviders } from '../../mock/test_providers/test_providers';
import { TestExternalProviders } from '../../mock/test_providers/test_providers';
import { EcsAllowedValues } from '.';

describe('EcsAllowedValues', () => {
describe('when `allowedValues` exists', () => {
beforeEach(() => {
render(
<TestProviders>
<TestExternalProviders>
<EcsAllowedValues allowedValues={mockAllowedValues} />
</TestProviders>
</TestExternalProviders>
);
});

Expand All @@ -36,9 +36,9 @@ describe('EcsAllowedValues', () => {
describe('when `allowedValues` is undefined', () => {
beforeEach(() => {
render(
<TestProviders>
<TestExternalProviders>
<EcsAllowedValues allowedValues={undefined} />
</TestProviders>
</TestExternalProviders>
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@

import { EuiCode, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import React from 'react';
import styled from 'styled-components';

import { EMPTY_PLACEHOLDER } from '../helpers';
import { CodeSuccess } from '../../styles';
import type { AllowedValue } from '../../types';

const EcsAllowedValueFlexItem = styled(EuiFlexItem)`
margin-bottom: ${({ theme }) => theme.eui.euiSizeXS};
`;

interface Props {
allowedValues: AllowedValue[] | undefined;
}
Expand All @@ -25,11 +20,11 @@ const EcsAllowedValuesComponent: React.FC<Props> = ({ allowedValues }) =>
allowedValues == null ? (
<EuiCode data-test-subj="ecsAllowedValuesEmpty">{EMPTY_PLACEHOLDER}</EuiCode>
) : (
<EuiFlexGroup data-test-subj="ecsAllowedValues" direction="column" gutterSize="none">
<EuiFlexGroup data-test-subj="ecsAllowedValues" direction="row" wrap={true} gutterSize="xs">
{allowedValues.map((x, i) => (
<EcsAllowedValueFlexItem grow={false} key={`${x.name}_${i}`}>
<EuiFlexItem grow={false} key={`${x.name}_${i}`}>
<CodeSuccess>{x.name}</CodeSuccess>
</EcsAllowedValueFlexItem>
</EuiFlexItem>
))}
</EuiFlexGroup>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
someField,
eventCategoryWithUnallowedValues,
} from '../../mock/enriched_field_metadata/mock_enriched_field_metadata';
import { TestProviders } from '../../mock/test_providers/test_providers';
import { TestExternalProviders } from '../../mock/test_providers/test_providers';
import {
DOCUMENT_VALUES_ACTUAL,
ECS_DESCRIPTION,
Expand All @@ -30,7 +30,7 @@ import { EMPTY_PLACEHOLDER, getCommonTableColumns } from '.';
describe('getCommonTableColumns', () => {
test('it returns the expected column configuration', () => {
expect(getCommonTableColumns().map((x) => omit('render', x))).toEqual([
{ field: 'indexFieldName', name: FIELD, sortable: true, truncateText: false, width: '20%' },
{ field: 'indexFieldName', name: FIELD, sortable: true, truncateText: false, width: '15%' },
{
field: 'type',
name: ECS_MAPPING_TYPE_EXPECTED,
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('getCommonTableColumns', () => {
name: ECS_DESCRIPTION,
sortable: false,
truncateText: false,
width: '20%',
width: '25%',
},
]);
});
Expand All @@ -76,9 +76,9 @@ describe('getCommonTableColumns', () => {
const expected = 'keyword';

render(
<TestProviders>
<TestExternalProviders>
{typeColumnRender != null && typeColumnRender(eventCategory.type, eventCategory)}
</TestProviders>
</TestExternalProviders>
);

expect(screen.getByTestId('codeSuccess')).toHaveTextContent(expected);
Expand All @@ -89,9 +89,9 @@ describe('getCommonTableColumns', () => {
const typeColumnRender = columns[1].render;

render(
<TestProviders>
<TestExternalProviders>
{typeColumnRender != null && typeColumnRender(undefined, eventCategory)}
</TestProviders>
</TestExternalProviders>
);

expect(screen.getByTestId('codeSuccess')).toHaveTextContent(EMPTY_PLACEHOLDER);
Expand All @@ -113,13 +113,13 @@ describe('getCommonTableColumns', () => {
};

render(
<TestProviders>
<TestExternalProviders>
{indexFieldTypeColumnRender != null &&
indexFieldTypeColumnRender(
withTypeMismatchSameFamily.indexFieldType,
withTypeMismatchSameFamily
)}
</TestProviders>
</TestExternalProviders>
);
});

Expand All @@ -146,13 +146,13 @@ describe('getCommonTableColumns', () => {
};

render(
<TestProviders>
<TestExternalProviders>
{indexFieldTypeColumnRender != null &&
indexFieldTypeColumnRender(
withTypeMismatchDifferentFamily.indexFieldType,
withTypeMismatchDifferentFamily
)}
</TestProviders>
</TestExternalProviders>
);

expect(screen.getByTestId('codeDanger')).toHaveTextContent(indexFieldType);
Expand All @@ -165,10 +165,10 @@ describe('getCommonTableColumns', () => {
const indexFieldTypeColumnRender = columns[2].render;

render(
<TestProviders>
<TestExternalProviders>
{indexFieldTypeColumnRender != null &&
indexFieldTypeColumnRender(eventCategory.indexFieldType, eventCategory)}
</TestProviders>
</TestExternalProviders>
);

expect(screen.getByTestId('codeSuccess')).toHaveTextContent(eventCategory.indexFieldType);
Expand All @@ -187,10 +187,10 @@ describe('getCommonTableColumns', () => {
: 'unexpected';

render(
<TestProviders>
<TestExternalProviders>
{allowedValuesolumnRender != null &&
allowedValuesolumnRender(eventCategory.allowed_values, eventCategory)}
</TestProviders>
</TestExternalProviders>
);

expect(screen.getByTestId('ecsAllowedValues')).toHaveTextContent(expectedAllowedValuesNames);
Expand All @@ -206,10 +206,10 @@ describe('getCommonTableColumns', () => {
};

render(
<TestProviders>
<TestExternalProviders>
{allowedValuesolumnRender != null &&
allowedValuesolumnRender(undefined, withUndefinedAllowedValues)}
</TestProviders>
</TestExternalProviders>
);

expect(screen.getByTestId('ecsAllowedValuesEmpty')).toHaveTextContent(EMPTY_PLACEHOLDER);
Expand All @@ -222,13 +222,13 @@ describe('getCommonTableColumns', () => {
const indexInvalidValuesRender = columns[4].render;

render(
<TestProviders>
<TestExternalProviders>
{indexInvalidValuesRender != null &&
indexInvalidValuesRender(
eventCategoryWithUnallowedValues.indexInvalidValues,
eventCategoryWithUnallowedValues
)}
</TestProviders>
</TestExternalProviders>
);

expect(screen.getByTestId('indexInvalidValues')).toHaveTextContent(
Expand All @@ -249,10 +249,10 @@ describe('getCommonTableColumns', () => {
};

render(
<TestProviders>
<TestExternalProviders>
{descriptionolumnRender != null &&
descriptionolumnRender(withDescription.description, withDescription)}
</TestProviders>
</TestExternalProviders>
);

expect(screen.getByTestId('description')).toHaveTextContent(expectedDescription);
Expand All @@ -263,9 +263,9 @@ describe('getCommonTableColumns', () => {
const descriptionolumnRender = columns[5].render;

render(
<TestProviders>
<TestExternalProviders>
{descriptionolumnRender != null && descriptionolumnRender(undefined, someField)}
</TestProviders>
</TestExternalProviders>
);

expect(screen.getByTestId('emptyDescription')).toHaveTextContent(EMPTY_PLACEHOLDER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const getCommonTableColumns = (): Array<
name: i18n.FIELD,
sortable: true,
truncateText: false,
width: '20%',
width: '15%',
},
{
field: 'type',
Expand Down Expand Up @@ -98,6 +98,6 @@ export const getCommonTableColumns = (): Array<
),
sortable: false,
truncateText: false,
width: '20%',
width: '25%',
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { omit } from 'lodash/fp';
import React from 'react';

import { SAME_FAMILY } from '../../data_quality_panel/same_family/translations';
import { TestProviders } from '../../mock/test_providers/test_providers';
import { TestExternalProviders } from '../../mock/test_providers/test_providers';
import { eventCategory } from '../../mock/enriched_field_metadata/mock_enriched_field_metadata';
import { EcsBasedFieldMetadata } from '../../types';
import { getIncompatibleMappingsTableColumns } from '.';
Expand All @@ -25,7 +25,7 @@ describe('getIncompatibleMappingsTableColumns', () => {
name: 'Field',
sortable: true,
truncateText: false,
width: '25%',
width: '15%',
},
{
field: 'type',
Expand All @@ -46,7 +46,7 @@ describe('getIncompatibleMappingsTableColumns', () => {
name: 'ECS description',
sortable: false,
truncateText: false,
width: '25%',
width: '35%',
},
]);
});
Expand All @@ -58,9 +58,9 @@ describe('getIncompatibleMappingsTableColumns', () => {
const expected = 'keyword';

render(
<TestProviders>
<TestExternalProviders>
{typeColumnRender != null && typeColumnRender(eventCategory.type, eventCategory)}
</TestProviders>
</TestExternalProviders>
);

expect(screen.getByTestId('codeSuccess')).toHaveTextContent(expected);
Expand All @@ -82,13 +82,13 @@ describe('getIncompatibleMappingsTableColumns', () => {
};

render(
<TestProviders>
<TestExternalProviders>
{indexFieldTypeColumnRender != null &&
indexFieldTypeColumnRender(
withTypeMismatchSameFamily.indexFieldType,
withTypeMismatchSameFamily
)}
</TestProviders>
</TestExternalProviders>
);
});

Expand All @@ -115,13 +115,13 @@ describe('getIncompatibleMappingsTableColumns', () => {
};

render(
<TestProviders>
<TestExternalProviders>
{indexFieldTypeColumnRender != null &&
indexFieldTypeColumnRender(
withTypeMismatchDifferentFamily.indexFieldType,
withTypeMismatchDifferentFamily
)}
</TestProviders>
</TestExternalProviders>
);

expect(screen.getByTestId('codeDanger')).toHaveTextContent(indexFieldType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const getIncompatibleMappingsTableColumns = (): Array<
name: i18n.FIELD,
sortable: true,
truncateText: false,
width: '25%',
width: '15%',
},
{
field: 'type',
Expand Down Expand Up @@ -54,6 +54,6 @@ export const getIncompatibleMappingsTableColumns = (): Array<
name: i18n.ECS_DESCRIPTION,
sortable: false,
truncateText: false,
width: '25%',
width: '35%',
},
];
Loading