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 historical results (Phase 1) #191898

Merged
merged 21 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
890e8ed
feat: restore original flyout tabs with disabled history
kapral18 Sep 2, 2024
037d83c
feat: historical results part1
kapral18 Sep 10, 2024
31837fd
refactor: lift shared markdown utils + translations
kapral18 Sep 13, 2024
76248dd
refactor: flatten index check flyout
kapral18 Sep 16, 2024
32498f6
refactor: introduce IncompatibleFieldMetadata and other more granual
kapral18 Sep 19, 2024
1ad6e80
feat: historical results part2
kapral18 Sep 24, 2024
a3f9812
chore: add tests for basic historical results
kapral18 Sep 26, 2024
b03d91e
chore: add remaining tests for basic historical results
kapral18 Sep 30, 2024
e6ee997
feat: update default historical results date range to 30 days
kapral18 Sep 30, 2024
19053b7
feat: add legacy check fields view + tests
kapral18 Oct 1, 2024
3bfb8e7
feat: add history and latest check tabs to data quality panel
kapral18 Oct 1, 2024
05e4a62
feat: add final redesign of legacy view
kapral18 Oct 3, 2024
0eadff1
fix(serverless): incorrect pass badge + disabled datepicker
kapral18 Oct 4, 2024
ce40a92
feat(translations):simplify view check history to just view history
kapral18 Oct 7, 2024
d8dc1d7
test: add tests and minor refactorings
kapral18 Oct 8, 2024
1770462
chore(types): fix outcome filter type issue from ci report
kapral18 Oct 8, 2024
c9f8506
chore(tests): fix timezone issue in tests reported by CI
kapral18 Oct 8, 2024
d2f71bf
improve(context): useMemo provider values
kapral18 Oct 8, 2024
b89a390
chore(translations): add changes following ui copy review
kapral18 Oct 9, 2024
6d898c5
chore(fix): remove left-behind checkState reference from both source …
kapral18 Oct 9, 2024
e282dde
chore(tests): add timeout to ci failing test
kapral18 Oct 11, 2024
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
Prev Previous commit
Next Next commit
feat: add legacy check fields view + tests
  • Loading branch information
kapral18 committed Oct 11, 2024
commit 19053b701c444a90669a14827d0e90407de17562
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import { screen, render } from '@testing-library/react';

import { INCOMPATIBLE_EMPTY, INCOMPATIBLE_EMPTY_TITLE } from './translations';
import { CheckSuccessEmptyPrompt } from '.';

describe('CheckSuccessEmptyPrompt', () => {
it('should render incompatible empty prompt message', () => {
render(<CheckSuccessEmptyPrompt />);

expect(screen.getByText(INCOMPATIBLE_EMPTY_TITLE)).toBeInTheDocument();
expect(screen.getByText(INCOMPATIBLE_EMPTY)).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ const CheckSuccessEmptyPromptComponent = () => {
const title = useMemo(() => <EmptyPromptTitle title={INCOMPATIBLE_EMPTY_TITLE} />, []);

return (
<EuiEmptyPrompt body={body} iconType="check" iconColor="success" title={title} titleSize="s" />
<EuiEmptyPrompt
data-test-subj="checkSuccessEmptyPrompt"
body={body}
iconType="check"
iconColor="success"
title={title}
titleSize="s"
/>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useCallback, useMemo, useState } from 'react';
import { EuiBadge, EuiButtonGroup, EuiFlexGroup, EuiSpacer } from '@elastic/eui';
import styled from 'styled-components';

import type { HistoricalResult } from '../../../../../../../../types';
import type { NonLegacyHistoricalResult } from '../../../../../../../../types';
import { getIncompatibleStatBadgeColor } from '../../../../../../../../utils/get_incompatible_stat_badge_color';
import { INCOMPATIBLE_FIELDS, SAME_FAMILY } from '../../../../../../../../translations';
import { INCOMPATIBLE_TAB_ID, SAME_FAMILY_TAB_ID } from '../../../../constants';
Expand Down Expand Up @@ -44,7 +44,7 @@ const StyledBadge = styled(EuiBadge)`

export interface Props {
indexName: string;
historicalResult: HistoricalResult;
historicalResult: NonLegacyHistoricalResult;
}

const HistoricalCheckFieldsComponent: React.FC<Props> = ({ indexName, historicalResult }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,79 +5,57 @@
* 2.0.
*/

import { HistoricalResult } from '../../../../../../../../../types';
import { getIncompatibleAndSameFamilyFieldsFromHistoricalResult } from './get_incompatible_and_same_family_fields_from_historical_result';
import { EcsFlatTyped } from '../../../../../../../../../constants';
import { getHistoricalResultStub } from '../../../../../../../../../stub/get_historical_result_stub';

describe('getIncompatibleAndSameFamilyFieldsFromHistoricalResult', () => {
it('should return incompatible and same family fields', () => {
const historicalResult = {
incompatibleFieldMappingItems: [
{
fieldName: 'host.name',
actualValue: 'text',
},
],
incompatibleFieldValueItems: [
{
fieldName: 'host.name',
actualValues: [
{
name: 'text',
count: 1,
},
],
},
],
sameFamilyFieldItems: [
{
fieldName: 'host.name',
expectedValue: 'keyword',
},
],
} as HistoricalResult;
const historicalResult = getHistoricalResultStub('test');

const result = getIncompatibleAndSameFamilyFieldsFromHistoricalResult(historicalResult);

expect(result).toEqual({
incompatibleMappingsFields: [
{
...EcsFlatTyped['host.name'],
indexFieldName: 'host.name',
indexFieldType: 'text',
indexInvalidValues: [],
hasEcsMetadata: true,
isEcsCompliant: false,
isInSameFamily: false,
},
],
incompatibleValuesFields: [
{
...EcsFlatTyped['host.name'],
indexFieldName: 'host.name',
indexFieldType: 'keyword',
indexInvalidValues: [
{
fieldName: 'text',
count: 1,
},
],
hasEcsMetadata: true,
isEcsCompliant: false,
isInSameFamily: false,
},
],
sameFamilyFields: [
{
...EcsFlatTyped['host.name'],
indexFieldName: 'host.name',
indexFieldType: 'keyword',
indexInvalidValues: [],
hasEcsMetadata: true,
isEcsCompliant: false,
isInSameFamily: true,
},
],
});
expect(result).toEqual(
expect.objectContaining({
incompatibleMappingsFields: [
{
...EcsFlatTyped['host.name'],
indexFieldName: 'host.name',
indexFieldType: 'text',
indexInvalidValues: [],
hasEcsMetadata: true,
isEcsCompliant: false,
isInSameFamily: false,
},
],
incompatibleValuesFields: [
{
...EcsFlatTyped['host.name'],
indexFieldName: 'host.name',
indexFieldType: 'keyword',
indexInvalidValues: [
{
fieldName: 'text',
count: 1,
},
],
hasEcsMetadata: true,
isEcsCompliant: false,
isInSameFamily: false,
},
],
sameFamilyFields: [
{
...EcsFlatTyped['host.name'],
indexFieldName: 'host.name',
indexFieldType: 'keyword',
indexInvalidValues: [],
hasEcsMetadata: true,
isEcsCompliant: false,
isInSameFamily: true,
},
],
})
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

import { EcsFlatTyped } from '../../../../../../../../../constants';
import {
HistoricalResult,
import type {
IncompatibleFieldMetadata,
NonLegacyHistoricalResult,
SameFamilyFieldMetadata,
} from '../../../../../../../../../types';

Expand All @@ -19,7 +19,7 @@ interface IncompatibleAndSameFamilyFields {
}

export const getIncompatibleAndSameFamilyFieldsFromHistoricalResult = (
historicalResult: HistoricalResult
historicalResult: NonLegacyHistoricalResult
): IncompatibleAndSameFamilyFields => {
const incompatibleAndSameFamilyFields: IncompatibleAndSameFamilyFields = {
incompatibleMappingsFields: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import { EuiSpacer } from '@elastic/eui';
import type { HistoricalResult as HistoricalResultType } from '../../../../../../../types';
import { IndexStatsPanel } from '../../../index_stats_panel';
import { HistoricalCheckFields } from './historical_check_fields';
// eslint-disable-next-line no-restricted-imports
import { isNonLegacyHistoricalResult } from './utils/is_non_legacy_historical_result';
// eslint-disable-next-line no-restricted-imports
import { LegacyHistoricalCheckFields } from './legacy_historical_check_fields';

export interface Props {
indexName: string;
Expand All @@ -24,22 +28,42 @@ const HistoricalResultComponent: React.FC<Props> = ({ indexName, historicalResul
ilmPhase,
ecsFieldCount,
totalFieldCount,
sameFamilyFieldCount,
customFieldCount,
checkedAt,
} = historicalResult;

return (
<div data-test-subj={`historicalResult-${checkedAt}`}>
<EuiSpacer />
<IndexStatsPanel
docsCount={docsCount}
sizeInBytes={sizeInBytes ?? 0}
ilmPhase={ilmPhase}
ecsCompliantFieldsCount={ecsFieldCount}
customFieldsCount={customFieldCount}
allFieldsCount={totalFieldCount}
/>
<EuiSpacer />
<HistoricalCheckFields indexName={indexName} historicalResult={historicalResult} />
{isNonLegacyHistoricalResult(historicalResult) ? (
<>
<IndexStatsPanel
docsCount={docsCount}
sizeInBytes={sizeInBytes ?? 0}
ilmPhase={ilmPhase}
ecsCompliantFieldsCount={ecsFieldCount}
customFieldsCount={customFieldCount}
allFieldsCount={totalFieldCount}
/>
<EuiSpacer />
<HistoricalCheckFields indexName={indexName} historicalResult={historicalResult} />
</>
) : (
<>
<IndexStatsPanel
docsCount={docsCount}
sizeInBytes={sizeInBytes ?? 0}
ilmPhase={ilmPhase}
sameFamilyFieldsCount={sameFamilyFieldCount}
ecsCompliantFieldsCount={ecsFieldCount}
customFieldsCount={customFieldCount}
allFieldsCount={totalFieldCount}
/>
<EuiSpacer />
<LegacyHistoricalCheckFields indexName={indexName} historicalResult={historicalResult} />
</>
)}
<EuiSpacer size="m" />
</div>
);
Expand Down
Loading