[data views] DataViewBase now requires a title (#115082)

* dataViewBase now requires a title
This commit is contained in:
Matthew Kime 2021-10-15 05:06:47 -05:00 committed by GitHub
parent d19510535a
commit a935f6b723
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 69 additions and 48 deletions

View file

@ -12,13 +12,14 @@ import { luceneStringToDsl } from './lucene_string_to_dsl';
import { decorateQuery } from './decorate_query';
import { MatchAllFilter, Query } from '../filters';
import { fields } from '../filters/stubs';
import { IndexPatternBase } from './types';
import { DataViewBase } from './types';
jest.mock('../kuery/grammar');
describe('build query', () => {
const indexPattern: IndexPatternBase = {
const indexPattern: DataViewBase = {
fields,
title: 'dataView',
};
describe('buildEsQuery', () => {

View file

@ -9,11 +9,12 @@
import { buildQueryFromFilters } from './from_filters';
import { ExistsFilter, Filter, MatchAllFilter } from '../filters';
import { fields } from '../filters/stubs';
import { IndexPatternBase } from './types';
import { DataViewBase } from './types';
describe('build query', () => {
const indexPattern: IndexPatternBase = {
const indexPattern: DataViewBase = {
fields,
title: 'dataView',
};
describe('buildQueryFromFilters', () => {

View file

@ -9,14 +9,15 @@
import { buildQueryFromKuery } from './from_kuery';
import { fromKueryExpression, toElasticsearchQuery } from '../kuery';
import { fields } from '../filters/stubs';
import { IndexPatternBase } from './types';
import { DataViewBase } from './types';
import { Query } from '..';
jest.mock('../kuery/grammar');
describe('build query', () => {
const indexPattern: IndexPatternBase = {
const indexPattern: DataViewBase = {
fields,
title: 'dataView',
};
describe('buildQueryFromKuery', () => {

View file

@ -9,12 +9,13 @@
import { handleNestedFilter } from './handle_nested_filter';
import { fields } from '../filters/stubs';
import { buildPhraseFilter, buildQueryFilter } from '../filters';
import { IndexPatternBase } from './types';
import { DataViewBase } from './types';
describe('handleNestedFilter', function () {
const indexPattern: IndexPatternBase = {
const indexPattern: DataViewBase = {
id: 'logstash-*',
fields,
title: 'dataView',
};
it("should return the filter's query wrapped in nested query if the target field is nested", () => {

View file

@ -65,7 +65,7 @@ export type IndexPatternFieldBase = DataViewFieldBase;
export interface DataViewBase {
fields: DataViewFieldBase[];
id?: string;
title?: string;
title: string;
}
/**

View file

@ -7,13 +7,14 @@
*/
import { buildFilter, FilterStateStore, FILTERS } from '.';
import { IndexPatternBase } from '../..';
import { DataViewBase } from '../..';
import { fields as stubFields } from '../stubs';
describe('buildFilter', () => {
const stubIndexPattern: IndexPatternBase = {
const stubIndexPattern: DataViewBase = {
id: 'logstash-*',
fields: stubFields,
title: 'dataView',
};
it('should build phrase filters', () => {

View file

@ -6,13 +6,14 @@
* Side Public License, v 1.
*/
import { IndexPatternBase } from '../../es_query';
import { DataViewBase } from '../../es_query';
import { buildExistsFilter, getExistsFilterField } from './exists_filter';
import { fields } from '../stubs/fields.mocks';
describe('exists filter', function () {
const indexPattern: IndexPatternBase = {
const indexPattern: DataViewBase = {
fields,
title: 'dataView',
};
describe('getExistsFilterField', function () {

View file

@ -9,13 +9,14 @@
import { buildPhraseFilter } from './phrase_filter';
import { buildQueryFilter } from './query_string_filter';
import { getFilterField } from './get_filter_field';
import { IndexPatternBase } from '../../es_query';
import { DataViewBase } from '../../es_query';
import { fields } from '../stubs/fields.mocks';
describe('getFilterField', function () {
const indexPattern: IndexPatternBase = {
const indexPattern: DataViewBase = {
id: 'logstash-*',
fields,
title: 'dataView',
};
it('should return the field name from known filter types that target a specific field', () => {

View file

@ -13,16 +13,17 @@ import {
PhraseFilter,
} from './phrase_filter';
import { fields, getField } from '../stubs';
import { IndexPatternBase } from '../../es_query';
import { DataViewBase } from '../../es_query';
import { estypes } from '@elastic/elasticsearch';
describe('Phrase filter builder', () => {
let indexPattern: IndexPatternBase;
let indexPattern: DataViewBase;
beforeEach(() => {
indexPattern = {
id: 'id',
fields,
title: 'dataView',
};
});
@ -151,8 +152,9 @@ describe('buildInlineScriptForPhraseFilter', () => {
});
describe('getPhraseFilterField', function () {
const indexPattern: IndexPatternBase = {
const indexPattern: DataViewBase = {
fields,
title: 'dataView',
};
it('should return the name of the field a phrase query is targeting', () => {

View file

@ -6,13 +6,14 @@
* Side Public License, v 1.
*/
import { IndexPatternBase } from '../../es_query';
import { DataViewBase } from '../../es_query';
import { buildPhrasesFilter, getPhrasesFilterField } from './phrases_filter';
import { fields } from '../stubs';
describe('phrases filter', function () {
const indexPattern: IndexPatternBase = {
const indexPattern: DataViewBase = {
fields,
title: 'dataView',
};
describe('getPhrasesFilterField', function () {

View file

@ -8,18 +8,19 @@
import { fromKueryExpression, fromLiteralExpression, toElasticsearchQuery } from './ast';
import { nodeTypes } from '../node_types';
import { IndexPatternBase } from '../..';
import { DataViewBase } from '../..';
import { KueryNode } from '../types';
import { fields } from '../../filters/stubs';
jest.mock('../grammar');
describe('kuery AST API', () => {
let indexPattern: IndexPatternBase;
let indexPattern: DataViewBase;
beforeEach(() => {
indexPattern = {
fields,
title: 'dataView',
};
});

View file

@ -10,7 +10,7 @@ import { nodeTypes } from '../node_types';
import { fields } from '../../filters/stubs';
import * as ast from '../ast';
import * as and from './and';
import { IndexPatternBase } from '../../es_query';
import { DataViewBase } from '../../es_query';
jest.mock('../grammar');
@ -19,11 +19,12 @@ const childNode2 = nodeTypes.function.buildNode('is', 'extension', 'jpg');
describe('kuery functions', () => {
describe('and', () => {
let indexPattern: IndexPatternBase;
let indexPattern: DataViewBase;
beforeEach(() => {
indexPattern = {
fields,
title: 'dataView',
};
});

View file

@ -8,7 +8,7 @@
import { nodeTypes } from '../node_types';
import { fields } from '../../filters/stubs';
import { IndexPatternBase } from '../..';
import { DataViewBase } from '../..';
jest.mock('../grammar');
@ -17,11 +17,12 @@ import * as exists from './exists';
describe('kuery functions', () => {
describe('exists', () => {
let indexPattern: IndexPatternBase;
let indexPattern: DataViewBase;
beforeEach(() => {
indexPattern = {
fields,
title: 'dataView',
};
});

View file

@ -9,7 +9,7 @@
import { get } from 'lodash';
import { nodeTypes } from '../node_types';
import { fields } from '../../filters/stubs';
import { IndexPatternBase } from '../..';
import { DataViewBase } from '../..';
import * as geoBoundingBox from './geo_bounding_box';
import { JsonObject } from '@kbn/utility-types';
@ -29,11 +29,12 @@ const params = {
describe('kuery functions', () => {
describe('geoBoundingBox', () => {
let indexPattern: IndexPatternBase;
let indexPattern: DataViewBase;
beforeEach(() => {
indexPattern = {
fields,
title: 'dataView',
};
});

View file

@ -8,7 +8,7 @@
import { nodeTypes } from '../node_types';
import { fields } from '../../filters/stubs';
import { IndexPatternBase } from '../..';
import { DataViewBase } from '../..';
import * as geoPolygon from './geo_polygon';
@ -31,11 +31,12 @@ const points = [
describe('kuery functions', () => {
describe('geoPolygon', () => {
let indexPattern: IndexPatternBase;
let indexPattern: DataViewBase;
beforeEach(() => {
indexPattern = {
fields,
title: 'dataView',
};
});

View file

@ -10,18 +10,19 @@ import { nodeTypes } from '../node_types';
import { fields } from '../../filters/stubs';
import * as is from './is';
import { IndexPatternBase } from '../..';
import { DataViewBase } from '../..';
import { estypes } from '@elastic/elasticsearch';
jest.mock('../grammar');
describe('kuery functions', () => {
describe('is', () => {
let indexPattern: IndexPatternBase;
let indexPattern: DataViewBase;
beforeEach(() => {
indexPattern = {
fields,
title: 'dataView',
};
});

View file

@ -8,7 +8,7 @@
import { nodeTypes } from '../node_types';
import { fields } from '../../filters/stubs';
import { IndexPatternBase } from '../..';
import { DataViewBase } from '../..';
import * as ast from '../ast';
@ -20,11 +20,12 @@ const childNode = nodeTypes.function.buildNode('is', 'child', 'foo');
describe('kuery functions', () => {
describe('nested', () => {
let indexPattern: IndexPatternBase;
let indexPattern: DataViewBase;
beforeEach(() => {
indexPattern = {
fields,
title: 'dataView',
};
});

View file

@ -8,7 +8,7 @@
import { nodeTypes } from '../node_types';
import { fields } from '../../filters/stubs';
import { IndexPatternBase } from '../..';
import { DataViewBase } from '../..';
import * as ast from '../ast';
import * as not from './not';
@ -19,11 +19,12 @@ const childNode = nodeTypes.function.buildNode('is', 'extension', 'jpg');
describe('kuery functions', () => {
describe('not', () => {
let indexPattern: IndexPatternBase;
let indexPattern: DataViewBase;
beforeEach(() => {
indexPattern = {
fields,
title: 'dataView',
};
});

View file

@ -8,7 +8,7 @@
import { nodeTypes } from '../node_types';
import { fields } from '../../filters/stubs';
import { IndexPatternBase } from '../..';
import { DataViewBase } from '../..';
import * as ast from '../ast';
@ -20,11 +20,12 @@ const childNode2 = nodeTypes.function.buildNode('is', 'extension', 'jpg');
describe('kuery functions', () => {
describe('or', () => {
let indexPattern: IndexPatternBase;
let indexPattern: DataViewBase;
beforeEach(() => {
indexPattern = {
fields,
title: 'dataView',
};
});

View file

@ -9,7 +9,7 @@
import { get } from 'lodash';
import { nodeTypes } from '../node_types';
import { fields } from '../../filters/stubs';
import { IndexPatternBase } from '../..';
import { DataViewBase } from '../..';
import { RangeFilterParams } from '../../filters';
import * as range from './range';
@ -18,11 +18,12 @@ jest.mock('../grammar');
describe('kuery functions', () => {
describe('range', () => {
let indexPattern: IndexPatternBase;
let indexPattern: DataViewBase;
beforeEach(() => {
indexPattern = {
fields,
title: 'dataView',
};
});

View file

@ -8,17 +8,18 @@
import { nodeTypes } from '../../node_types';
import { fields } from '../../../filters/stubs';
import { IndexPatternBase } from '../../..';
import { DataViewBase } from '../../..';
import { getFullFieldNameNode } from './get_full_field_name_node';
jest.mock('../../grammar');
describe('getFullFieldNameNode', function () {
let indexPattern: IndexPatternBase;
let indexPattern: DataViewBase;
beforeEach(() => {
indexPattern = {
fields,
title: 'dataView',
};
});

View file

@ -10,18 +10,19 @@ import { nodeTypes } from './index';
import { buildNode, buildNodeWithArgumentNodes, toElasticsearchQuery } from './function';
import { toElasticsearchQuery as isFunctionToElasticsearchQuery } from '../functions/is';
import { IndexPatternBase } from '../../es_query';
import { DataViewBase } from '../../es_query';
import { fields } from '../../filters/stubs/fields.mocks';
jest.mock('../grammar');
describe('kuery node types', () => {
describe('function', () => {
let indexPattern: IndexPatternBase;
let indexPattern: DataViewBase;
beforeEach(() => {
indexPattern = {
fields,
title: 'dataView',
};
});

View file

@ -205,7 +205,7 @@ describe('kibanaContextFn', () => {
it('deduplicates duplicated filters and keeps the first enabled filter', async () => {
const { fn } = kibanaContextFn;
const filter1 = buildFilter(
{ fields: [] },
{ fields: [], title: 'dataView' },
{ name: 'test', type: 'test' },
FILTERS.PHRASE,
false,
@ -217,7 +217,7 @@ describe('kibanaContextFn', () => {
FilterStateStore.APP_STATE
);
const filter2 = buildFilter(
{ fields: [] },
{ fields: [], title: 'dataView' },
{ name: 'test', type: 'test' },
FILTERS.PHRASE,
false,
@ -230,7 +230,7 @@ describe('kibanaContextFn', () => {
);
const filter3 = buildFilter(
{ fields: [] },
{ fields: [], title: 'dataView' },
{ name: 'test', type: 'test' },
FILTERS.PHRASE,
false,

View file

@ -83,7 +83,6 @@ class WithKueryAutocompletionComponent extends React.Component<
query: expression,
selectionStart: cursorPosition,
selectionEnd: cursorPosition,
// @ts-expect-error (until data service updates to new types)
indexPatterns: [indexPattern],
boolFilter: [],
})) || [];