@@ -41,12 +41,50 @@ function getTransformConfig(): TransformPivotConfig {
4141 } ;
4242}
4343
44+ function getTransformConfigWithRuntimeMappings ( ) : TransformPivotConfig {
45+ const date = Date . now ( ) ;
46+
47+ return {
48+ id : `ec_cloning_runtime_${ date } ` ,
49+ source : {
50+ index : [ 'ft_ecommerce' ] ,
51+ runtime_mappings : {
52+ rt_gender_lower : {
53+ type : 'keyword' ,
54+ script : "emit(doc['customer_gender'].value.toLowerCase())" ,
55+ } ,
56+ rt_total_charge : {
57+ type : 'double' ,
58+ script : {
59+ source : "emit(doc['taxful_total_price'].value + 4.00)" ,
60+ } ,
61+ } ,
62+ } ,
63+ } ,
64+ pivot : {
65+ group_by : { rt_gender_lower : { terms : { field : 'rt_gender_lower' } } } ,
66+ aggregations : {
67+ 'rt_total_charge.avg' : { avg : { field : 'rt_total_charge' } } ,
68+ 'rt_total_charge.min' : { min : { field : 'rt_total_charge' } } ,
69+ 'rt_total_charge.max' : { max : { field : 'rt_total_charge' } } ,
70+ } ,
71+ } ,
72+ description : 'ecommerce batch transform grouped by terms(rt_gender_lower)' ,
73+ frequency : '3s' ,
74+ settings : {
75+ max_page_search_size : 250 ,
76+ } ,
77+ dest : { index : `user-ec_2_${ date } ` } ,
78+ } ;
79+ }
80+
4481export default function ( { getService } : FtrProviderContext ) {
4582 const esArchiver = getService ( 'esArchiver' ) ;
4683 const transform = getService ( 'transform' ) ;
4784
4885 describe ( 'cloning' , function ( ) {
4986 const transformConfigWithPivot = getTransformConfig ( ) ;
87+ const transformConfigWithRuntimeMapping = getTransformConfigWithRuntimeMappings ( ) ;
5088 // const transformConfigWithLatest = getLatestTransformConfig();
5189
5290 before ( async ( ) => {
@@ -56,6 +94,11 @@ export default function ({ getService }: FtrProviderContext) {
5694 transformConfigWithPivot . id ,
5795 transformConfigWithPivot
5896 ) ;
97+ await transform . api . createAndRunTransform (
98+ transformConfigWithRuntimeMapping . id ,
99+ transformConfigWithRuntimeMapping
100+ ) ;
101+
59102 // await transform.api.createAndRunTransform(
60103 // transformConfigWithLatest.id,
61104 // transformConfigWithLatest
@@ -67,8 +110,13 @@ export default function ({ getService }: FtrProviderContext) {
67110
68111 after ( async ( ) => {
69112 await transform . testResources . deleteIndexPatternByTitle ( transformConfigWithPivot . dest . index ) ;
113+ await transform . testResources . deleteIndexPatternByTitle (
114+ transformConfigWithRuntimeMapping . dest . index
115+ ) ;
116+
70117 // await transform.testResources.deleteIndexPatternByTitle(transformConfigWithLatest.dest.index);
71118 await transform . api . deleteIndices ( transformConfigWithPivot . dest . index ) ;
119+ await transform . api . deleteIndices ( transformConfigWithRuntimeMapping . dest . index ) ;
72120 // await transform.api.deleteIndices(transformConfigWithLatest.dest.index);
73121 await transform . api . cleanTransformIndices ( ) ;
74122 } ) ;
@@ -84,6 +132,7 @@ export default function ({ getService }: FtrProviderContext) {
84132 return `user-${ this . transformId } ` ;
85133 } ,
86134 expected : {
135+ runtimeMappingsEditorValueArr : [ '' ] ,
87136 aggs : {
88137 index : 0 ,
89138 label : 'products.base_price.avg' ,
@@ -108,6 +157,35 @@ export default function ({ getService }: FtrProviderContext) {
108157 } ,
109158 } ,
110159 } ,
160+ {
161+ type : 'pivot' as const ,
162+ suiteTitle : 'clone transform with runtime mappings' ,
163+ originalConfig : transformConfigWithRuntimeMapping ,
164+ transformId : `clone_${ transformConfigWithRuntimeMapping . id } ` ,
165+ transformDescription : `a cloned transform with runtime mappings` ,
166+ get destinationIndex ( ) : string {
167+ return `user-${ this . transformId } ` ;
168+ } ,
169+ expected : {
170+ runtimeMappingsEditorValueArr : [ '{' , ' "rt_gender_lower": {' , ' "type": "keyword",' ] ,
171+ aggs : {
172+ index : 0 ,
173+ label : 'rt_total_charge.avg' ,
174+ } ,
175+ indexPreview : {
176+ columns : 10 ,
177+ rows : 5 ,
178+ } ,
179+ groupBy : {
180+ index : 0 ,
181+ label : 'rt_gender_lower' ,
182+ } ,
183+ transformPreview : {
184+ column : 0 ,
185+ values : [ `female` , `male` ] ,
186+ } ,
187+ } ,
188+ } ,
111189 // TODO enable tests when https://github.com/elastic/elasticsearch/issues/67148 is resolved
112190 // {
113191 // type: 'latest' as const,
@@ -168,6 +246,18 @@ export default function ({ getService }: FtrProviderContext) {
168246 } ) ;
169247
170248 it ( 'navigates through the wizard, checks and sets all needed fields' , async ( ) => {
249+ await transform . testExecution . logTestStep ( 'should have runtime mapping editor' ) ;
250+ await transform . wizard . assertRuntimeMappingsEditorSwitchExists ( ) ;
251+ await transform . wizard . assertRuntimeMappingsEditorSwitchCheckState ( false ) ;
252+
253+ if ( testData . expected . runtimeMappingsEditorValueArr ) {
254+ await transform . wizard . toggleRuntimeMappingsEditorSwitch ( true ) ;
255+ await transform . wizard . assertRuntimeMappingsEditorExists ( ) ;
256+ await transform . wizard . assertRuntimeMappingsEditorContent (
257+ testData . expected . runtimeMappingsEditorValueArr
258+ ) ;
259+ }
260+
171261 await transform . testExecution . logTestStep ( 'should load the index preview' ) ;
172262 await transform . wizard . assertIndexPreviewLoaded ( ) ;
173263
0 commit comments