44 * you may not use this file except in compliance with the Elastic License.
55 */
66
7- import { drag , drop } from '../../lib/drag_n_drop/helpers' ;
8- import {
9- clearFieldsBrowser ,
10- clickOutsideFieldsBrowser ,
11- openTimelineFieldsBrowser ,
12- populateTimeline ,
13- filterFieldsBrowser ,
14- } from '../../lib/fields_browser/helpers' ;
7+ import { HOSTS_PAGE } from '../../lib/urls' ;
8+
9+ import { loginAndWaitForPage , DEFAULT_TIMEOUT } from '../../../tasks/login' ;
10+
1511import {
12+ FIELDS_BROWSER_TITLE ,
13+ FIELDS_BROWSER_SELECTED_CATEGORY_TITLE ,
14+ FIELDS_BROWSER_SELECTED_CATEGORY_COUNT ,
1615 FIELDS_BROWSER_CATEGORIES_COUNT ,
17- FIELDS_BROWSER_CONTAINER ,
18- FIELDS_BROWSER_FIELDS_COUNT ,
19- FIELDS_BROWSER_FILTER_INPUT ,
2016 FIELDS_BROWSER_HOST_CATEGORIES_COUNT ,
21- FIELDS_BROWSER_SELECTED_CATEGORY_COUNT ,
22- FIELDS_BROWSER_SELECTED_CATEGORY_TITLE ,
2317 FIELDS_BROWSER_SYSTEM_CATEGORIES_COUNT ,
24- FIELDS_BROWSER_TITLE ,
25- } from '../../lib/fields_browser/selectors' ;
26- import { HOSTS_PAGE } from '../../lib/urls' ;
27- import { loginAndWaitForPage , DEFAULT_TIMEOUT } from '../../lib/util/helpers' ;
18+ FIELDS_BROWSER_FIELDS_COUNT ,
19+ FIELDS_BROWSER_MESSAGE_HEADER ,
20+ FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER ,
21+ FIELDS_BROWSER_HOST_GEO_COUNTRY_NAME_HEADER ,
22+ FIELDS_BROWSER_HEADER_HOST_GEO_CONTINENT_NAME_HEADER ,
23+ } from '../../../screens/timeline/fields_browser' ;
24+
25+ import {
26+ openTimeline ,
27+ populateTimeline ,
28+ openTimelineFieldsBrowser ,
29+ } from '../../../tasks/timeline/main' ;
30+
31+ import {
32+ clearFieldsBrowser ,
33+ filterFieldsBrowser ,
34+ closeFieldsBrowser ,
35+ removesMessageField ,
36+ addsHostGeoCityNameToTimeline ,
37+ addsHostGeoCountryNameToTimelineDraggingIt ,
38+ addsHostGeoContinentNameToTimeline ,
39+ resetFields ,
40+ } from '../../../tasks/timeline/fields_browser' ;
2841
2942const defaultHeaders = [
3043 { id : '@timestamp' } ,
@@ -41,6 +54,7 @@ describe('Fields Browser', () => {
4154 context ( 'Fields Browser rendering' , ( ) => {
4255 before ( ( ) => {
4356 loginAndWaitForPage ( HOSTS_PAGE ) ;
57+ openTimeline ( ) ;
4458 populateTimeline ( ) ;
4559 openTimelineFieldsBrowser ( ) ;
4660 } ) ;
@@ -78,7 +92,7 @@ describe('Fields Browser', () => {
7892
7993 filterFieldsBrowser ( filterInput ) ;
8094
81- cy . get ( FIELDS_BROWSER_CATEGORIES_COUNT )
95+ cy . get ( FIELDS_BROWSER_CATEGORIES_COUNT , { timeout : DEFAULT_TIMEOUT } )
8296 . invoke ( 'text' )
8397 . should ( 'eq' , '2 categories' ) ;
8498 } ) ;
@@ -88,18 +102,13 @@ describe('Fields Browser', () => {
88102
89103 filterFieldsBrowser ( filterInput ) ;
90104
91- cy . get ( FIELDS_BROWSER_FILTER_INPUT , { timeout : DEFAULT_TIMEOUT } ) . should (
92- 'not.have.class' ,
93- 'euiFieldSearch-isLoading'
94- ) ;
95-
96105 cy . get ( FIELDS_BROWSER_HOST_CATEGORIES_COUNT )
97106 . invoke ( 'text' )
98107 . then ( hostCategoriesCount => {
99108 cy . get ( FIELDS_BROWSER_SYSTEM_CATEGORIES_COUNT )
100109 . invoke ( 'text' )
101110 . then ( systemCategoriesCount => {
102- cy . get ( FIELDS_BROWSER_FIELDS_COUNT )
111+ cy . get ( FIELDS_BROWSER_FIELDS_COUNT , { timeout : DEFAULT_TIMEOUT } )
103112 . invoke ( 'text' )
104113 . should ( 'eq' , `${ + hostCategoriesCount + + systemCategoriesCount } fields` ) ;
105114 } ) ;
@@ -120,6 +129,7 @@ describe('Fields Browser', () => {
120129 context ( 'Editing the timeline' , ( ) => {
121130 before ( ( ) => {
122131 loginAndWaitForPage ( HOSTS_PAGE ) ;
132+ openTimeline ( ) ;
123133 populateTimeline ( ) ;
124134 openTimelineFieldsBrowser ( ) ;
125135 } ) ;
@@ -130,31 +140,17 @@ describe('Fields Browser', () => {
130140 } ) ;
131141
132142 it ( 'removes the message field from the timeline when the user un-checks the field' , ( ) => {
133- const toggleField = 'message' ;
134-
135- cy . get ( `[data-test-subj="timeline"] [data-test-subj="header-text-${ toggleField } "]` ) . should (
136- 'exist'
137- ) ;
143+ cy . get ( FIELDS_BROWSER_MESSAGE_HEADER ) . should ( 'exist' ) ;
138144
139- cy . get (
140- `[data-test-subj="timeline"] [data-test-subj="field-${ toggleField } -checkbox"]`
141- ) . uncheck ( {
142- force : true ,
143- } ) ;
145+ removesMessageField ( ) ;
146+ closeFieldsBrowser ( ) ;
144147
145- clickOutsideFieldsBrowser ( ) ;
146-
147- cy . get ( FIELDS_BROWSER_CONTAINER ) . should ( 'not.exist' ) ;
148-
149- cy . get ( `[data-test-subj="timeline"] [data-test-subj="header-text-${ toggleField } "]` ) . should (
150- 'not.exist'
151- ) ;
148+ cy . get ( FIELDS_BROWSER_MESSAGE_HEADER ) . should ( 'not.exist' ) ;
152149 } ) ;
153150
154151 it ( 'selects a search results label with the expected count of categories matching the filter input' , ( ) => {
155152 const category = 'host' ;
156-
157- filterFieldsBrowser ( `${ category } .` ) ;
153+ filterFieldsBrowser ( category ) ;
158154
159155 cy . get ( FIELDS_BROWSER_SELECTED_CATEGORY_TITLE )
160156 . invoke ( 'text' )
@@ -163,75 +159,47 @@ describe('Fields Browser', () => {
163159
164160 it ( 'adds a field to the timeline when the user clicks the checkbox' , ( ) => {
165161 const filterInput = 'host.geo.c' ;
166- const toggleField = 'host.geo.city_name' ;
167162
168163 filterFieldsBrowser ( filterInput ) ;
164+ cy . get ( FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER ) . should ( 'not.exist' ) ;
165+ addsHostGeoCityNameToTimeline ( ) ;
166+ closeFieldsBrowser ( ) ;
169167
170- cy . get ( `[data-test-subj="timeline"] [data-test-subj="header-text-${ toggleField } "]` ) . should (
171- 'not.exist'
172- ) ;
173-
174- cy . get ( `[data-test-subj="timeline"] [data-test-subj="field-${ toggleField } -checkbox"]` ) . check ( {
175- force : true ,
176- } ) ;
177-
178- clickOutsideFieldsBrowser ( ) ;
179-
180- cy . get ( `[data-test-subj="timeline"] [data-test-subj="header-text-${ toggleField } "]` , {
168+ cy . get ( FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER , {
181169 timeout : DEFAULT_TIMEOUT ,
182170 } ) . should ( 'exist' ) ;
183171 } ) ;
184172
185173 it ( 'adds a field to the timeline when the user drags and drops a field' , ( ) => {
186174 const filterInput = 'host.geo.c' ;
187- const toggleField = 'host.geo.country_name' ;
188175
189176 filterFieldsBrowser ( filterInput ) ;
190177
191- cy . get ( `[data-test-subj="timeline"] [data-test-subj="header-text-${ toggleField } "]` ) . should (
192- 'not.exist'
193- ) ;
194-
195- cy . get (
196- `[data-test-subj="timeline"] [data-test-subj="field-name-${ toggleField } "]`
197- ) . then ( field => drag ( field ) ) ;
178+ cy . get ( FIELDS_BROWSER_HOST_GEO_COUNTRY_NAME_HEADER ) . should ( 'not.exist' ) ;
198179
199- cy . get ( `[data-test-subj="timeline"] [data-test-subj="headers-group"]` ) . then ( headersDropArea =>
200- drop ( headersDropArea )
201- ) ;
180+ addsHostGeoCountryNameToTimelineDraggingIt ( ) ;
202181
203- cy . get ( `[data-test-subj="timeline"] [data-test-subj="header-text- ${ toggleField } "]` , {
182+ cy . get ( FIELDS_BROWSER_HOST_GEO_COUNTRY_NAME_HEADER , {
204183 timeout : DEFAULT_TIMEOUT ,
205184 } ) . should ( 'exist' ) ;
206185 } ) ;
207186
208187 it ( 'resets all fields in the timeline when `Reset Fields` is clicked' , ( ) => {
209188 const filterInput = 'host.geo.c' ;
210- const toggleField = 'host.geo.continent_name' ;
211189
212190 filterFieldsBrowser ( filterInput ) ;
213191
214- cy . get ( `[data-test-subj="timeline"] [data-test-subj="header-text-${ toggleField } "]` ) . should (
215- 'not.exist'
216- ) ;
217-
218- cy . get ( `[data-test-subj="timeline"] [data-test-subj="field-${ toggleField } -checkbox"]` ) . check ( {
219- force : true ,
220- } ) ;
192+ cy . get ( FIELDS_BROWSER_HEADER_HOST_GEO_CONTINENT_NAME_HEADER ) . should ( 'not.exist' ) ;
221193
222- clickOutsideFieldsBrowser ( ) ;
194+ addsHostGeoContinentNameToTimeline ( ) ;
195+ closeFieldsBrowser ( ) ;
223196
224- cy . get ( `[data-test-subj="timeline"] [data-test-subj="header-text-${ toggleField } "]` ) . should (
225- 'exist'
226- ) ;
197+ cy . get ( FIELDS_BROWSER_HEADER_HOST_GEO_CONTINENT_NAME_HEADER ) . should ( 'exist' ) ;
227198
228199 openTimelineFieldsBrowser ( ) ;
200+ resetFields ( ) ;
229201
230- cy . get ( '[data-test-subj="timeline"] [data-test-subj="reset-fields"]' ) . click ( { force : true } ) ;
231-
232- cy . get ( `[data-test-subj="timeline"] [data-test-subj="header-text-${ toggleField } "]` ) . should (
233- 'not.exist'
234- ) ;
202+ cy . get ( FIELDS_BROWSER_HEADER_HOST_GEO_CONTINENT_NAME_HEADER ) . should ( 'not.exist' ) ;
235203 } ) ;
236204 } ) ;
237205} ) ;
0 commit comments