|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License |
| 4 | + * 2.0; you may not use this file except in compliance with the Elastic License |
| 5 | + * 2.0. |
| 6 | + */ |
| 7 | + |
| 8 | +import expect from '@kbn/expect'; |
| 9 | +import { FtrProviderContext } from '../../../../../ftr_provider_context'; |
| 10 | + |
| 11 | +export default function ({ getPageObjects, getService }: FtrProviderContext) { |
| 12 | + const { visualize, visEditor, lens, timePicker, header } = getPageObjects([ |
| 13 | + 'visualize', |
| 14 | + 'lens', |
| 15 | + 'visEditor', |
| 16 | + 'timePicker', |
| 17 | + 'header', |
| 18 | + ]); |
| 19 | + |
| 20 | + const testSubjects = getService('testSubjects'); |
| 21 | + |
| 22 | + describe('Table', function describeIndexTests() { |
| 23 | + const isNewChartsLibraryEnabled = true; |
| 24 | + |
| 25 | + before(async () => { |
| 26 | + await visualize.initTests(isNewChartsLibraryEnabled); |
| 27 | + }); |
| 28 | + |
| 29 | + beforeEach(async () => { |
| 30 | + await visualize.navigateToNewAggBasedVisualization(); |
| 31 | + await visualize.clickDataTable(); |
| 32 | + await visualize.clickNewSearch(); |
| 33 | + await timePicker.setDefaultAbsoluteRange(); |
| 34 | + }); |
| 35 | + |
| 36 | + it('should not allow converting of unsupported aggregations', async () => { |
| 37 | + await visEditor.clickMetricEditor(); |
| 38 | + await visEditor.selectAggregation('Serial diff', 'metrics'); |
| 39 | + await visEditor.clickBucket('Split rows'); |
| 40 | + await visEditor.selectAggregation('Date histogram'); |
| 41 | + await visEditor.clickGo(); |
| 42 | + await header.waitUntilLoadingHasFinished(); |
| 43 | + const button = await testSubjects.exists('visualizeEditInLensButton'); |
| 44 | + expect(button).to.eql(false); |
| 45 | + }); |
| 46 | + |
| 47 | + it('should show the "Edit Visualization in Lens" menu item', async () => { |
| 48 | + const button = await testSubjects.exists('visualizeEditInLensButton'); |
| 49 | + expect(button).to.eql(true); |
| 50 | + }); |
| 51 | + |
| 52 | + it('should convert aggregation with params', async () => { |
| 53 | + await visEditor.clickMetricEditor(); |
| 54 | + await visEditor.selectAggregation('Average', 'metrics'); |
| 55 | + await visEditor.selectField('machine.ram', 'metrics'); |
| 56 | + await visEditor.clickGo(); |
| 57 | + await header.waitUntilLoadingHasFinished(); |
| 58 | + |
| 59 | + const button = await testSubjects.find('visualizeEditInLensButton'); |
| 60 | + await button.click(); |
| 61 | + await lens.waitForVisualization('lnsDataTable'); |
| 62 | + |
| 63 | + expect(await lens.getLayerCount()).to.be(1); |
| 64 | + |
| 65 | + const dimensions = await testSubjects.findAll('lns-dimensionTrigger'); |
| 66 | + expect(dimensions).to.have.length(1); |
| 67 | + expect(await dimensions[0].getVisibleText()).to.be('Average machine.ram'); |
| 68 | + }); |
| 69 | + |
| 70 | + it('should convert total function to summary row', async () => { |
| 71 | + await visEditor.clickMetricEditor(); |
| 72 | + await visEditor.selectAggregation('Average', 'metrics'); |
| 73 | + await visEditor.selectField('machine.ram', 'metrics'); |
| 74 | + await visEditor.clickOptionsTab(); |
| 75 | + const showTotalSwitch = await testSubjects.find('showTotal'); |
| 76 | + await showTotalSwitch.click(); |
| 77 | + await visEditor.clickGo(); |
| 78 | + await header.waitUntilLoadingHasFinished(); |
| 79 | + |
| 80 | + const button = await testSubjects.find('visualizeEditInLensButton'); |
| 81 | + await button.click(); |
| 82 | + await lens.waitForVisualization('lnsDataTable'); |
| 83 | + |
| 84 | + expect(await lens.getLayerCount()).to.be(1); |
| 85 | + |
| 86 | + const dimensions = await testSubjects.findAll('lns-dimensionTrigger'); |
| 87 | + expect(dimensions).to.have.length(1); |
| 88 | + expect(await dimensions[0].getVisibleText()).to.be('Average machine.ram'); |
| 89 | + |
| 90 | + await lens.openDimensionEditor('lnsDatatable_metrics > lns-dimensionTrigger'); |
| 91 | + const summaryRowFunction = await testSubjects.find('lnsDatatable_summaryrow_function'); |
| 92 | + expect(await summaryRowFunction.getVisibleText()).to.be('Sum'); |
| 93 | + }); |
| 94 | + |
| 95 | + it('should convert sibling pipeline aggregation', async () => { |
| 96 | + await visEditor.clickMetricEditor(); |
| 97 | + await visEditor.selectAggregation('Max Bucket', 'metrics'); |
| 98 | + await visEditor.clickGo(); |
| 99 | + await header.waitUntilLoadingHasFinished(); |
| 100 | + |
| 101 | + const button = await testSubjects.find('visualizeEditInLensButton'); |
| 102 | + await button.click(); |
| 103 | + await lens.waitForVisualization('lnsDataTable'); |
| 104 | + |
| 105 | + expect(await lens.getLayerCount()).to.be(1); |
| 106 | + |
| 107 | + const metricText = await lens.getDimensionTriggerText('lnsDatatable_metrics', 0); |
| 108 | + const splitRowText = await lens.getDimensionTriggerText('lnsDatatable_rows', 0); |
| 109 | + |
| 110 | + const dimensions = await testSubjects.findAll('lns-dimensionTrigger'); |
| 111 | + expect(dimensions).to.have.length(2); |
| 112 | + expect(metricText).to.be('Overall Max of Count'); |
| 113 | + expect(splitRowText).to.be('@timestamp'); |
| 114 | + }); |
| 115 | + |
| 116 | + it('should convert parent pipeline aggregation', async () => { |
| 117 | + await visEditor.clickMetricEditor(); |
| 118 | + await visEditor.selectAggregation('Cumulative sum', 'metrics'); |
| 119 | + await visEditor.clickBucket('Split rows'); |
| 120 | + await visEditor.selectAggregation('Date histogram'); |
| 121 | + await visEditor.clickGo(); |
| 122 | + await header.waitUntilLoadingHasFinished(); |
| 123 | + |
| 124 | + const button = await testSubjects.find('visualizeEditInLensButton'); |
| 125 | + await button.click(); |
| 126 | + await lens.waitForVisualization('lnsDataTable'); |
| 127 | + |
| 128 | + expect(await lens.getLayerCount()).to.be(1); |
| 129 | + |
| 130 | + const metricText = await lens.getDimensionTriggerText('lnsDatatable_metrics', 0); |
| 131 | + const splitRowText = await lens.getDimensionTriggerText('lnsDatatable_rows', 0); |
| 132 | + |
| 133 | + const dimensions = await testSubjects.findAll('lns-dimensionTrigger'); |
| 134 | + expect(dimensions).to.have.length(2); |
| 135 | + expect(metricText).to.be('Cumulative Sum of Count'); |
| 136 | + expect(splitRowText).to.be('@timestamp'); |
| 137 | + }); |
| 138 | + |
| 139 | + it('should convert split rows and split table to split table rows', async () => { |
| 140 | + await visEditor.clickBucket('Split rows'); |
| 141 | + await visEditor.selectAggregation('Date histogram'); |
| 142 | + await visEditor.clickBucket('Split table'); |
| 143 | + await visEditor.selectAggregation('Terms', 'buckets', false, 1); |
| 144 | + await visEditor.selectField('bytes', 'buckets', false, 1); |
| 145 | + await visEditor.clickGo(); |
| 146 | + await header.waitUntilLoadingHasFinished(); |
| 147 | + |
| 148 | + const button = await testSubjects.find('visualizeEditInLensButton'); |
| 149 | + await button.click(); |
| 150 | + await lens.waitForVisualization('lnsDataTable'); |
| 151 | + |
| 152 | + expect(await lens.getLayerCount()).to.be(1); |
| 153 | + |
| 154 | + const metricText = await lens.getDimensionTriggerText('lnsDatatable_metrics', 0); |
| 155 | + const splitRowText1 = await lens.getDimensionTriggerText('lnsDatatable_rows', 0); |
| 156 | + const splitRowText2 = await lens.getDimensionTriggerText('lnsDatatable_rows', 1); |
| 157 | + |
| 158 | + const dimensions = await testSubjects.findAll('lns-dimensionTrigger'); |
| 159 | + expect(dimensions).to.have.length(3); |
| 160 | + expect(metricText).to.be('Count'); |
| 161 | + expect(splitRowText1).to.be('@timestamp'); |
| 162 | + expect(splitRowText2).to.be('bytes: Descending'); |
| 163 | + }); |
| 164 | + |
| 165 | + it('should convert percentage column', async () => { |
| 166 | + await visEditor.clickOptionsTab(); |
| 167 | + await visEditor.setSelectByOptionText('datatableVisualizationPercentageCol', 'Count'); |
| 168 | + await visEditor.clickGo(); |
| 169 | + await header.waitUntilLoadingHasFinished(); |
| 170 | + |
| 171 | + const button = await testSubjects.find('visualizeEditInLensButton'); |
| 172 | + await button.click(); |
| 173 | + await lens.waitForVisualization('lnsDataTable'); |
| 174 | + |
| 175 | + expect(await lens.getLayerCount()).to.be(1); |
| 176 | + |
| 177 | + const metricText = await lens.getDimensionTriggerText('lnsDatatable_metrics', 0); |
| 178 | + const percentageColumnText = await lens.getDimensionTriggerText('lnsDatatable_metrics', 1); |
| 179 | + |
| 180 | + await lens.openDimensionEditor('lnsDatatable_metrics > lns-dimensionTrigger', 0, 1); |
| 181 | + const format = await testSubjects.find('indexPattern-dimension-format'); |
| 182 | + expect(await format.getVisibleText()).to.be('Percent'); |
| 183 | + |
| 184 | + const dimensions = await testSubjects.findAll('lns-dimensionTrigger'); |
| 185 | + expect(dimensions).to.have.length(2); |
| 186 | + expect(metricText).to.be('Count'); |
| 187 | + expect(percentageColumnText).to.be('Count percentages'); |
| 188 | + }); |
| 189 | + }); |
| 190 | +} |
0 commit comments