Skip to content

Commit d3bd0ce

Browse files
committed
move dql test constants to separate file
Signed-off-by: Paul Sebastian <paulstn@amazon.com>
1 parent e32e0f2 commit d3bd0ce

File tree

2 files changed

+198
-187
lines changed

2 files changed

+198
-187
lines changed

src/plugins/data/public/antlr/dql/code_completion.test.ts

Lines changed: 6 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -5,193 +5,12 @@
55

66
import { monaco } from '@osd/monaco';
77
import { getSuggestions } from './code_completion';
8-
import { IIndexPattern } from '../..';
9-
10-
const testingIndex = ({
11-
title: 'opensearch_dashboards_sample_data_flights',
12-
fields: [
13-
{
14-
count: 0,
15-
name: 'Carrier',
16-
displayName: 'Carrier',
17-
type: 'string',
18-
esTypes: ['keyword'],
19-
scripted: false,
20-
searchable: true,
21-
aggregatable: true,
22-
readFromDocValues: true,
23-
subType: undefined,
24-
},
25-
{
26-
count: 2,
27-
name: 'DestCityName',
28-
displayName: 'DestCityName',
29-
type: 'string',
30-
esTypes: ['keyword'],
31-
scripted: false,
32-
searchable: true,
33-
aggregatable: true,
34-
readFromDocValues: true,
35-
subType: undefined,
36-
},
37-
{
38-
count: 0,
39-
name: 'DestCountry',
40-
displayName: 'DestCountry',
41-
type: 'string',
42-
esTypes: ['keyword'],
43-
scripted: false,
44-
searchable: true,
45-
aggregatable: true,
46-
readFromDocValues: true,
47-
subType: undefined,
48-
},
49-
{
50-
count: 0,
51-
name: 'DestWeather',
52-
displayName: 'DestWeather',
53-
type: 'string',
54-
esTypes: ['keyword'],
55-
scripted: false,
56-
searchable: true,
57-
aggregatable: true,
58-
readFromDocValues: true,
59-
subType: undefined,
60-
},
61-
{
62-
count: 0,
63-
name: 'DistanceMiles',
64-
displayName: 'DistanceMiles',
65-
type: 'number',
66-
esTypes: ['float'],
67-
scripted: false,
68-
searchable: true,
69-
aggregatable: true,
70-
readFromDocValues: true,
71-
subType: undefined,
72-
},
73-
{
74-
count: 0,
75-
name: 'FlightDelay',
76-
displayName: 'FlightDelay',
77-
type: 'boolean',
78-
esTypes: ['boolean'],
79-
scripted: false,
80-
searchable: true,
81-
aggregatable: true,
82-
readFromDocValues: true,
83-
subType: undefined,
84-
},
85-
{
86-
count: 0,
87-
name: 'FlightNum',
88-
displayName: 'FlightNum',
89-
type: 'string',
90-
esTypes: ['keyword'],
91-
scripted: false,
92-
searchable: true,
93-
aggregatable: true,
94-
readFromDocValues: true,
95-
subType: undefined,
96-
},
97-
{
98-
count: 0,
99-
name: 'OriginWeather',
100-
displayName: 'OriginWeather',
101-
type: 'string',
102-
esTypes: ['keyword'],
103-
scripted: false,
104-
searchable: true,
105-
aggregatable: true,
106-
readFromDocValues: true,
107-
subType: undefined,
108-
},
109-
{
110-
count: 0,
111-
name: '_id',
112-
displayName: '_id',
113-
type: 'string',
114-
esTypes: ['_id'],
115-
scripted: false,
116-
searchable: true,
117-
aggregatable: true,
118-
readFromDocValues: false,
119-
subType: undefined,
120-
},
121-
{
122-
count: 0,
123-
name: '_index',
124-
displayName: '_index',
125-
type: 'string',
126-
esTypes: ['_index'],
127-
scripted: false,
128-
searchable: true,
129-
aggregatable: true,
130-
readFromDocValues: false,
131-
subType: undefined,
132-
},
133-
{
134-
count: 0,
135-
name: '_score',
136-
displayName: '_score',
137-
type: 'number',
138-
scripted: false,
139-
searchable: false,
140-
aggregatable: false,
141-
readFromDocValues: false,
142-
subType: undefined,
143-
},
144-
{
145-
count: 0,
146-
name: '_source',
147-
displayName: '_source',
148-
type: '_source',
149-
esTypes: ['_source'],
150-
scripted: false,
151-
searchable: false,
152-
aggregatable: false,
153-
readFromDocValues: false,
154-
subType: undefined,
155-
},
156-
{
157-
count: 0,
158-
name: '_type',
159-
displayName: '_type',
160-
type: 'string',
161-
esTypes: ['_type'],
162-
scripted: false,
163-
searchable: true,
164-
aggregatable: true,
165-
readFromDocValues: false,
166-
subType: undefined,
167-
},
168-
],
169-
} as unknown) as IIndexPattern;
170-
171-
const booleanOperatorSuggestions = [
172-
{ text: 'or', type: 'keyword' },
173-
{ text: 'and', type: 'keyword' },
174-
];
175-
176-
const notOperatorSuggestion = { text: 'not', type: 'keyword' };
177-
178-
const fieldNameSuggestions = [
179-
{ text: 'Carrier', type: 'field' },
180-
{ text: 'DestCityName', type: 'field' },
181-
{ text: 'DestCountry', type: 'field' },
182-
{ text: 'DestWeather', type: 'field' },
183-
{ text: 'DistanceMiles', type: 'field' },
184-
{ text: 'FlightDelay', type: 'field' },
185-
{ text: 'FlightNum', type: 'field' },
186-
{ text: 'OriginWeather', type: 'field' },
187-
{ text: '_id', type: 'field' },
188-
{ text: '_index', type: 'field' },
189-
{ text: '_score', type: 'field' },
190-
{ text: '_source', type: 'field' },
191-
{ text: '_type', type: 'field' },
192-
];
193-
194-
const fieldNameWithNotSuggestions = fieldNameSuggestions.concat(notOperatorSuggestion);
8+
import {
9+
booleanOperatorSuggestions,
10+
fieldNameWithNotSuggestions,
11+
notOperatorSuggestion,
12+
testingIndex,
13+
} from '../shared/constants';
19514

19615
const getSuggestionsAtPos = async (query: string, endPos: number) => {
19716
return await getSuggestions({
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { IIndexPattern } from '../..';
7+
8+
export const testingIndex = ({
9+
title: 'opensearch_dashboards_sample_data_flights',
10+
fields: [
11+
{
12+
count: 0,
13+
name: 'Carrier',
14+
displayName: 'Carrier',
15+
type: 'string',
16+
esTypes: ['keyword'],
17+
scripted: false,
18+
searchable: true,
19+
aggregatable: true,
20+
readFromDocValues: true,
21+
subType: undefined,
22+
},
23+
{
24+
count: 2,
25+
name: 'DestCityName',
26+
displayName: 'DestCityName',
27+
type: 'string',
28+
esTypes: ['keyword'],
29+
scripted: false,
30+
searchable: true,
31+
aggregatable: true,
32+
readFromDocValues: true,
33+
subType: undefined,
34+
},
35+
{
36+
count: 0,
37+
name: 'DestCountry',
38+
displayName: 'DestCountry',
39+
type: 'string',
40+
esTypes: ['keyword'],
41+
scripted: false,
42+
searchable: true,
43+
aggregatable: true,
44+
readFromDocValues: true,
45+
subType: undefined,
46+
},
47+
{
48+
count: 0,
49+
name: 'DestWeather',
50+
displayName: 'DestWeather',
51+
type: 'string',
52+
esTypes: ['keyword'],
53+
scripted: false,
54+
searchable: true,
55+
aggregatable: true,
56+
readFromDocValues: true,
57+
subType: undefined,
58+
},
59+
{
60+
count: 0,
61+
name: 'DistanceMiles',
62+
displayName: 'DistanceMiles',
63+
type: 'number',
64+
esTypes: ['float'],
65+
scripted: false,
66+
searchable: true,
67+
aggregatable: true,
68+
readFromDocValues: true,
69+
subType: undefined,
70+
},
71+
{
72+
count: 0,
73+
name: 'FlightDelay',
74+
displayName: 'FlightDelay',
75+
type: 'boolean',
76+
esTypes: ['boolean'],
77+
scripted: false,
78+
searchable: true,
79+
aggregatable: true,
80+
readFromDocValues: true,
81+
subType: undefined,
82+
},
83+
{
84+
count: 0,
85+
name: 'FlightNum',
86+
displayName: 'FlightNum',
87+
type: 'string',
88+
esTypes: ['keyword'],
89+
scripted: false,
90+
searchable: true,
91+
aggregatable: true,
92+
readFromDocValues: true,
93+
subType: undefined,
94+
},
95+
{
96+
count: 0,
97+
name: 'OriginWeather',
98+
displayName: 'OriginWeather',
99+
type: 'string',
100+
esTypes: ['keyword'],
101+
scripted: false,
102+
searchable: true,
103+
aggregatable: true,
104+
readFromDocValues: true,
105+
subType: undefined,
106+
},
107+
{
108+
count: 0,
109+
name: '_id',
110+
displayName: '_id',
111+
type: 'string',
112+
esTypes: ['_id'],
113+
scripted: false,
114+
searchable: true,
115+
aggregatable: true,
116+
readFromDocValues: false,
117+
subType: undefined,
118+
},
119+
{
120+
count: 0,
121+
name: '_index',
122+
displayName: '_index',
123+
type: 'string',
124+
esTypes: ['_index'],
125+
scripted: false,
126+
searchable: true,
127+
aggregatable: true,
128+
readFromDocValues: false,
129+
subType: undefined,
130+
},
131+
{
132+
count: 0,
133+
name: '_score',
134+
displayName: '_score',
135+
type: 'number',
136+
scripted: false,
137+
searchable: false,
138+
aggregatable: false,
139+
readFromDocValues: false,
140+
subType: undefined,
141+
},
142+
{
143+
count: 0,
144+
name: '_source',
145+
displayName: '_source',
146+
type: '_source',
147+
esTypes: ['_source'],
148+
scripted: false,
149+
searchable: false,
150+
aggregatable: false,
151+
readFromDocValues: false,
152+
subType: undefined,
153+
},
154+
{
155+
count: 0,
156+
name: '_type',
157+
displayName: '_type',
158+
type: 'string',
159+
esTypes: ['_type'],
160+
scripted: false,
161+
searchable: true,
162+
aggregatable: true,
163+
readFromDocValues: false,
164+
subType: undefined,
165+
},
166+
],
167+
} as unknown) as IIndexPattern;
168+
169+
export const booleanOperatorSuggestions = [
170+
{ text: 'or', type: 'keyword' },
171+
{ text: 'and', type: 'keyword' },
172+
];
173+
174+
export const notOperatorSuggestion = { text: 'not', type: 'keyword' };
175+
176+
export const fieldNameSuggestions = [
177+
{ text: 'Carrier', type: 'field' },
178+
{ text: 'DestCityName', type: 'field' },
179+
{ text: 'DestCountry', type: 'field' },
180+
{ text: 'DestWeather', type: 'field' },
181+
{ text: 'DistanceMiles', type: 'field' },
182+
{ text: 'FlightDelay', type: 'field' },
183+
{ text: 'FlightNum', type: 'field' },
184+
{ text: 'OriginWeather', type: 'field' },
185+
{ text: '_id', type: 'field' },
186+
{ text: '_index', type: 'field' },
187+
{ text: '_score', type: 'field' },
188+
{ text: '_source', type: 'field' },
189+
{ text: '_type', type: 'field' },
190+
];
191+
192+
export const fieldNameWithNotSuggestions = fieldNameSuggestions.concat(notOperatorSuggestion);

0 commit comments

Comments
 (0)