@@ -242,14 +242,20 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
242242 await this . assertGroupByEntryExists ( index , expectedLabel , expectedIntervalLabel ) ;
243243 } ,
244244
245- async assertAggregationInputExists ( ) {
246- await testSubjects . existOrFail ( 'transformAggregationSelection > comboBoxInput' ) ;
245+ getComboBoxInputSelector ( parentSelector = '' ) : string {
246+ return `${ parentSelector && `${ parentSelector } > ` } ${
247+ parentSelector ? 'transformSubAggregationSelection' : 'transformAggregationSelection'
248+ } > comboBoxInput`;
247249 } ,
248250
249- async assertAggregationInputValue ( expectedIdentifier : string [ ] ) {
251+ async assertAggregationInputExists ( parentSelector ?: string ) {
252+ await testSubjects . existOrFail ( this . getComboBoxInputSelector ( parentSelector ) ) ;
253+ } ,
254+
255+ async assertAggregationInputValue ( expectedIdentifier : string [ ] , parentSelector ?: string ) {
250256 await retry . tryForTime ( 2000 , async ( ) => {
251257 const comboBoxSelectedOptions = await comboBox . getComboBoxSelectedOptions (
252- 'transformAggregationSelection > comboBoxInput'
258+ this . getComboBoxInputSelector ( parentSelector )
253259 ) ;
254260 expect ( comboBoxSelectedOptions ) . to . eql (
255261 expectedIdentifier ,
@@ -258,27 +264,43 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
258264 } ) ;
259265 } ,
260266
261- async assertAggregationEntryExists ( index : number , expectedLabel : string ) {
262- await testSubjects . existOrFail ( `transformAggregationEntry ${ index } ` ) ;
267+ async assertAggregationEntryExists ( index : number , expectedLabel : string , parentSelector = '' ) {
268+ const aggEntryPanelSelector = `${
269+ parentSelector && `${ parentSelector } > `
270+ } transformAggregationEntry_${ index } `;
271+ await testSubjects . existOrFail ( aggEntryPanelSelector ) ;
263272
264273 const actualLabel = await testSubjects . getVisibleText (
265- `transformAggregationEntry ${ index } > transformAggregationEntryLabel`
274+ `${ aggEntryPanelSelector } > transformAggregationEntryLabel`
266275 ) ;
267276 expect ( actualLabel ) . to . eql (
268277 expectedLabel ,
269278 `Label for aggregation entry '${ index } ' should be '${ expectedLabel } ' (got '${ actualLabel } ')`
270279 ) ;
271280 } ,
272281
282+ async addAggregationEntries ( aggregationEntries : any [ ] , parentSelector ?: string ) {
283+ for ( const [ index , agg ] of aggregationEntries . entries ( ) ) {
284+ await this . assertAggregationInputExists ( parentSelector ) ;
285+ await this . assertAggregationInputValue ( [ ] , parentSelector ) ;
286+ await this . addAggregationEntry ( index , agg . identifier , agg . label , agg . form , parentSelector ) ;
287+
288+ if ( agg . subAggs ) {
289+ await this . addAggregationEntries ( agg . subAggs , `transformAggregationEntry_${ index } ` ) ;
290+ }
291+ }
292+ } ,
293+
273294 async addAggregationEntry (
274295 index : number ,
275296 identifier : string ,
276297 expectedLabel : string ,
277- formData ?: Record < string , any >
298+ formData ?: Record < string , any > ,
299+ parentSelector = ''
278300 ) {
279- await comboBox . set ( 'transformAggregationSelection > comboBoxInput' , identifier ) ;
280- await this . assertAggregationInputValue ( [ ] ) ;
281- await this . assertAggregationEntryExists ( index , expectedLabel ) ;
301+ await comboBox . set ( this . getComboBoxInputSelector ( parentSelector ) , identifier ) ;
302+ await this . assertAggregationInputValue ( [ ] , parentSelector ) ;
303+ await this . assertAggregationEntryExists ( index , expectedLabel , parentSelector ) ;
282304
283305 if ( formData !== undefined ) {
284306 await this . fillPopoverForm ( identifier , expectedLabel , formData ) ;
0 commit comments