Skip to content

Commit

Permalink
fixed up tests, cypress and unit passing locally
Browse files Browse the repository at this point in the history
  • Loading branch information
yctercero committed Mar 23, 2021
1 parent fc1f774 commit 11e2a2e
Show file tree
Hide file tree
Showing 18 changed files with 2,072 additions and 1,535 deletions.
8 changes: 8 additions & 0 deletions x-pack/plugins/lists/public/common/empty_value.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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.
*/

export const getEmptyValue = (): string => '—';
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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.
*/

export { AutocompleteFieldExistsComponent } from './field_value_exists';
export { AutocompleteFieldListsComponent } from './field_value_lists';
export { AutocompleteFieldMatchAnyComponent } from './field_value_match_any';
export { AutocompleteFieldMatchComponent } from './field_value_match';
export { FieldComponent } from './field';
export { OperatorComponent } from './operator';
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
/*
* 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 { Story, addDecorator } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import React from 'react';
import { ThemeProvider } from 'styled-components';
import euiLightVars from '@elastic/eui/dist/eui_theme_light.json';
import { HttpStart } from 'kibana/public';

import { OperatorEnum, OperatorTypeEnum } from '../../../../common';
import { AutocompleteStart } from '../../../../../../../src/plugins/data/public';
import { fields } from '../../../../../../../src/plugins/data/common/index_patterns/fields/fields.mocks';

import { BuilderEntryItem, EntryItemProps } from './entry_renderer';

const mockTheme = (): { darkMode: boolean; eui: unknown } => ({
darkMode: false,
eui: euiLightVars,
});
const mockAutocompleteService = ({
getValueSuggestions: () =>
new Promise((resolve) => {
setTimeout(() => {
resolve([
{
field: {
aggregatable: true,
count: 30,
esTypes: ['date'],
name: '@timestamp',
readFromDocValues: true,
scripted: false,
searchable: true,
type: 'date',
},
type: 'field',
},
{
field: {
aggregatable: true,
count: 0,
esTypes: ['ip'],
name: 'ip',
readFromDocValues: true,
scripted: false,
searchable: true,
type: 'ip',
},
type: 'field',
},
]);
}, 300);
}),
} as unknown) as AutocompleteStart;

addDecorator((storyFn) => <ThemeProvider theme={mockTheme}>{storyFn()}</ThemeProvider>);

export default {
argTypes: {
allowLargeValueLists: {
control: {
type: 'boolean',
},
description: '`boolean` - set to true to allow large value lists.',
table: {
defaultValue: {
summary: false,
},
},
type: {
required: false,
},
},
autoCompleteService: {
control: {
type: 'object',
},
description:
'`AutocompleteStart` - Kibana data plugin autocomplete service used for field value autocomplete.',
type: {
required: true,
},
},
entry: {
control: {
type: 'object',
},
description: '`FormattedBuilderEntry` - A single exception item entry.',
type: {
required: true,
},
},
httpService: {
control: {
type: 'object',
},
description: '`HttpStart` - Kibana service.',
type: {
required: true,
},
},
indexPattern: {
description:
'`IIndexPattern` - index patterns used to populate field options and value autocomplete.',
type: {
required: true,
},
},
listType: {
control: {
options: ['detection', 'endpoint'],
type: 'select',
},
description:
'`ExceptionListType` - Depending on the list type, certain validations may apply.',
type: {
required: true,
},
},

onChange: {
description:
'`(arg: BuilderEntry, i: number) => void` - callback invoked any time field, operator or value is updated.',
type: {
required: true,
},
},
onlyShowListOperators: {
description:
'`boolean` - set to true to display to user only operators related to large value lists. This is currently used due to limitations around combining large value list exceptions and non-large value list exceptions.',
table: {
defaultValue: {
summary: false,
},
},
type: {
required: false,
},
},
setErrorsExist: {
description: '`(arg: boolean) => void` - callback invoked to bubble up input errors.',
type: {
required: true,
},
},
showLabel: {
description:
'`boolean` - whether or not to show the input labels (normally just wanted for the first entry item).',
table: {
defaultValue: {
summary: false,
},
},
type: {
required: false,
},
},
},
component: BuilderEntryItem,
title: 'BuilderEntryItem',
};

const BuilderEntryItemTemplate: Story<EntryItemProps> = (args) => <BuilderEntryItem {...args} />;

export const Default = BuilderEntryItemTemplate.bind({});
Default.args = {
autocompleteService: mockAutocompleteService,

entry: {
correspondingKeywordField: undefined,
entryIndex: 0,
field: undefined,
id: 'e37ad550-05d2-470e-9a95-487db201ab56',
nested: undefined,
operator: {
message: 'is',
operator: OperatorEnum.INCLUDED,
type: OperatorTypeEnum.MATCH,
value: 'is',
},
parent: undefined,
value: '',
},
httpService: {} as HttpStart,
indexPattern: {
fields,
id: '1234',
title: 'logstash-*',
},
listType: 'detection',
onChange: action('onClick'),
onlyShowListOperators: false,
setErrorsExist: action('onClick'),
showLabel: false,
};
Loading

0 comments on commit 11e2a2e

Please sign in to comment.