@@ -9,7 +9,6 @@ import customParseFormat from 'dayjs/plugin/customParseFormat';
99import dayjs from 'dayjs' ;
1010import { BASE_PATH } from '../../../utils/constants' ;
1111import { CURRENT_TENANT } from '../../../utils/commands' ;
12- import { devToolsRequest } from '../../../utils/helpers' ;
1312
1413dayjs . extend ( customParseFormat ) ;
1514
@@ -19,6 +18,8 @@ const Y_LABEL = 'A unique label for Y-axis';
1918const X_LABEL = 'A unique label for X-axis' ;
2019const DEFAULT_SIZE = 10 ;
2120
21+ const INDEX = 'jaeger' ;
22+ const delay = 100 ;
2223describe ( 'Dump test data' , ( ) => {
2324 it ( 'Indexes test data for gantt chart' , ( ) => {
2425 if ( Cypress . env ( 'SECURITY_ENABLED' ) ) {
@@ -30,38 +31,41 @@ describe('Dump test data', () => {
3031 } ) ;
3132 }
3233 CURRENT_TENANT . newTenant = 'private' ;
33- const dumpDataSet = ( ndjson , index ) =>
34- cy . request ( {
35- method : 'POST' ,
36- form : false ,
37- url : 'api/console/proxy' ,
38- headers : {
39- 'content-type' : 'application/json;charset=UTF-8' ,
40- 'osd-xsrf' : true ,
41- } ,
42- qs : {
43- path : `${ index } /_bulk` ,
44- method : 'POST' ,
45- } ,
46- body : ndjson ,
47- } ) ;
4834 cy . fixture ( 'plugins/gantt-chart-dashboards/jaeger-sample.txt' ) . then (
49- ( ndjson ) => {
50- dumpDataSet ( ndjson , 'jaeger' ) ;
51- }
35+ ( ndjson ) =>
36+ cy . request ( {
37+ method : 'POST' ,
38+ url : 'api/console/proxy' ,
39+ headers : {
40+ 'content-type' : 'application/json;charset=UTF-8' ,
41+ 'osd-xsrf' : true ,
42+ } ,
43+ // refresh=wait_for makes the bulk-indexed docs immediately searchable
44+ qs : { path : `${ INDEX } /_bulk?refresh=wait_for` , method : 'POST' } ,
45+ body : ndjson ,
46+ } )
5247 ) ;
5348
49+ // Create the index pattern with its field list for editor to read the stored `fields` attribute
5450 cy . request ( {
55- method : 'POST' ,
56- failOnStatusCode : false ,
57- url : 'api/saved_objects/index-pattern/jaeger' ,
58- headers : {
59- 'content-type' : 'application/json' ,
60- 'osd-xsrf' : true ,
61- } ,
62- body : JSON . stringify ( { attributes : { title : 'jaeger' } } ) ,
51+ method : 'GET' ,
52+ url : 'api/index_patterns/_fields_for_wildcard' ,
53+ qs : { pattern : INDEX } ,
54+ headers : { 'osd-xsrf' : true } ,
55+ } ) . then ( ( resp ) => {
56+ cy . request ( {
57+ method : 'POST' ,
58+ failOnStatusCode : false ,
59+ url : `api/saved_objects/index-pattern/${ INDEX } ` ,
60+ headers : { 'content-type' : 'application/json' , 'osd-xsrf' : true } ,
61+ body : JSON . stringify ( {
62+ attributes : {
63+ title : INDEX ,
64+ fields : JSON . stringify ( resp . body . fields ) ,
65+ } ,
66+ } ) ,
67+ } ) ;
6368 } ) ;
64- devToolsRequest ( '.kibana*/_refresh' , 'POST' ) ;
6569 } ) ;
6670} ) ;
6771
@@ -110,25 +114,33 @@ describe(
110114
111115 it ( 'Renders the chart' , ( ) => {
112116 cy . get ( 'button.euiSuperSelectControl' ) . eq ( 0 ) . click ( { force : true } ) ;
117+ cy . wait ( delay ) ;
113118 cy . get ( '.euiContextMenuItem__text' )
114119 . contains ( / ^ s p a n I D $ / )
115120 . click ( { force : true } ) ;
116121 // Click away so the dropdown closes
117122 cy . get ( '.euiTitle' ) . eq ( 1 ) . click ( ) ;
123+ cy . wait ( delay ) ;
118124 cy . get ( 'button.euiSuperSelectControl' ) . eq ( 1 ) . click ( { force : true } ) ;
125+ cy . wait ( delay ) ;
119126 cy . get ( '.euiContextMenuItem__text' )
120127 . contains ( / ^ s t a r t T i m e $ / )
121128 . click ( { force : true } ) ;
122129 // Click away so the dropdown closes
123130 cy . get ( '.euiTitle' ) . eq ( 1 ) . click ( ) ;
131+ cy . wait ( delay ) ;
124132 cy . get ( 'button.euiSuperSelectControl' ) . eq ( 2 ) . click ( { force : true } ) ;
133+ cy . wait ( delay ) ;
125134 cy . get ( '.euiContextMenuItem__text' )
126135 . contains ( / ^ d u r a t i o n $ / )
127136 . click ( { force : true } ) ;
137+ cy . wait ( delay ) ;
128138 cy . get ( '.euiButton__text' ) . contains ( 'Update' ) . click ( { force : true } ) ;
139+ cy . wait ( delay ) ;
129140
130141 cy . get ( '.traces' ) . should ( 'have.length' , DEFAULT_SIZE ) ;
131142 cy . get ( '.euiButton__text' ) . contains ( 'Save' ) . click ( { force : true } ) ;
143+ cy . wait ( delay ) ;
132144 cy . get ( 'button[data-test-subj="confirmSaveSavedObjectButton"]' ) . click ( {
133145 force : true ,
134146 } ) ;
0 commit comments