-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Lens][Unified Field list] Add functional tests to fields lists and summary popover #143747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
394ae92
:recycle: Add testId handlers
dej611 5d13f06
:white_check_mark: Add functional tests
dej611 dd7600c
Merge remote-tracking branch 'upstream/main' into tests/138724
dej611 3628752
Merge remote-tracking branch 'upstream/main' into tests/138724
dej611 d1ba1f1
Merge remote-tracking branch 'upstream/main' into tests/138724
dej611 ea021d6
:lipstick: Wrap unsupported messages with testId
dej611 54d11bc
:wrench: Enable creation of dataViews without timefield
dej611 9a004c5
:white_check_mark: Extends tests for other dataview types + runtime f…
dej611 c675ab8
:white_check_mark: Add more checks on top values charts
dej611 01e1f1f
Merge branch 'main' into tests/138724
dej611 5f235c1
:ok_hand: Integrated feedback
dej611 ef89830
Merge branch 'main' into tests/138724
dej611 d4d0593
:bug: Fix testIds and added some logging
dej611 9057915
Merge branch 'tests/138724' of github.com:dej611/kibana into tests/13…
dej611 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,233 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import expect from '@kbn/expect'; | ||
| import { FtrProviderContext } from '../../../ftr_provider_context'; | ||
|
|
||
| export default function ({ getService, getPageObjects }: FtrProviderContext) { | ||
| const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); | ||
| const find = getService('find'); | ||
| const log = getService('log'); | ||
| const testSubjects = getService('testSubjects'); | ||
| const filterBar = getService('filterBar'); | ||
| const fieldEditor = getService('fieldEditor'); | ||
| const retry = getService('retry'); | ||
|
|
||
| describe('lens fields list tests', () => { | ||
| for (const datasourceType of ['form-based', 'ad-hoc', 'ad-hoc-no-timefield']) { | ||
| describe(`${datasourceType} datasource`, () => { | ||
| before(async () => { | ||
| await PageObjects.visualize.navigateToNewVisualization(); | ||
| await PageObjects.visualize.clickVisType('lens'); | ||
|
|
||
| if (datasourceType !== 'form-based') { | ||
| await PageObjects.lens.createAdHocDataView( | ||
| '*stash*', | ||
| datasourceType !== 'ad-hoc-no-timefield' | ||
| ); | ||
| retry.try(async () => { | ||
| const selectedPattern = await PageObjects.lens.getDataPanelIndexPattern(); | ||
| expect(selectedPattern).to.eql('*stash*'); | ||
| }); | ||
| } | ||
|
|
||
| if (datasourceType !== 'ad-hoc-no-timefield') { | ||
| await PageObjects.lens.goToTimeRange(); | ||
| } | ||
|
|
||
| await retry.try(async () => { | ||
| await PageObjects.lens.clickAddField(); | ||
| await fieldEditor.setName('runtime_string'); | ||
| await fieldEditor.enableValue(); | ||
| await fieldEditor.typeScript("emit('abc')"); | ||
| await fieldEditor.save(); | ||
| await PageObjects.header.waitUntilLoadingHasFinished(); | ||
| }); | ||
| }); | ||
|
|
||
| it('should show all fields as available', async () => { | ||
| expect( | ||
| await (await testSubjects.find('lnsIndexPatternAvailableFields-count')).getVisibleText() | ||
| ).to.eql(53); | ||
| }); | ||
|
|
||
| it('should show a histogram and top values popover for numeric field', async () => { | ||
| const [fieldId] = await PageObjects.lens.findFieldIdsByType('number'); | ||
| await log.debug(`Opening field stats for ${fieldId}`); | ||
| await testSubjects.click(fieldId); | ||
| // check for popover | ||
| await testSubjects.exists('lnsFieldListPanel-title'); | ||
| // check for top values chart | ||
| await testSubjects.existOrFail('lnsFieldListPanel-topValues'); | ||
| const topValuesRows = await testSubjects.findAll('lnsFieldListPanel-topValues-bucket'); | ||
| expect(topValuesRows.length).to.eql(11); | ||
| // check for the Other entry | ||
| expect(await topValuesRows[10].getVisibleText()).to.eql('Other\n96.7%'); | ||
| // switch to date histogram | ||
| await testSubjects.click('lnsFieldListPanel-buttonGroup-distributionButton'); | ||
| // check for date histogram chart | ||
| expect( | ||
| await find.existsByCssSelector( | ||
| '[data-test-subj="lnsFieldListPanelFieldContent"] .echChart' | ||
| ) | ||
| ).to.eql(true); | ||
| }); | ||
|
|
||
| it('should show a top values popover for a keyword field', async () => { | ||
| const [fieldId] = await PageObjects.lens.findFieldIdsByType('string'); | ||
| await log.debug(`Opening field stats for ${fieldId}`); | ||
| await testSubjects.click(fieldId); | ||
| // check for popover | ||
| await testSubjects.exists('lnsFieldListPanel-title'); | ||
| // check for top values chart | ||
| await testSubjects.existOrFail('lnsFieldListPanel-topValues'); | ||
| const topValuesRows = await testSubjects.findAll('lnsFieldListPanel-topValues-bucket'); | ||
| expect(topValuesRows.length).to.eql(11); | ||
| // check for the Other entry | ||
| expect(await topValuesRows[10].getVisibleText()).to.eql('Other\n99.9%'); | ||
| // check no date histogram | ||
| expect( | ||
| await find.existsByCssSelector( | ||
| '[data-test-subj="lnsFieldListPanelFieldContent"] .echChart' | ||
| ) | ||
| ).to.eql(false); | ||
| }); | ||
|
|
||
| it('should show a date histogram popover for a date field', async () => { | ||
| const [fieldId] = await PageObjects.lens.findFieldIdsByType('date'); | ||
| await log.debug(`Opening field stats for ${fieldId}`); | ||
| await testSubjects.click(fieldId); | ||
| // check for popover | ||
| await testSubjects.exists('lnsFieldListPanel-title'); | ||
| // check for date histogram chart | ||
| expect( | ||
| await find.existsByCssSelector( | ||
| '[data-test-subj="lnsFieldListPanelFieldContent"] .echChart' | ||
| ) | ||
| ).to.eql(true); | ||
| // check no top values chart | ||
| await testSubjects.missingOrFail('lnsFieldListPanel-buttonGroup-topValuesButton'); | ||
| }); | ||
|
|
||
| it('should show a placeholder message about geo points field', async () => { | ||
| const [fieldId] = await PageObjects.lens.findFieldIdsByType('geo_point'); | ||
| await log.debug(`Opening field stats for ${fieldId}`); | ||
| await testSubjects.click(fieldId); | ||
| const message = await testSubjects.getVisibleText('lnsFieldListPanel-missingFieldStats'); | ||
| expect(message).to.eql('Analysis is not available for this field.'); | ||
| }); | ||
|
|
||
| it('should show stats for a numeric runtime field', async () => { | ||
| await PageObjects.lens.searchField('runtime'); | ||
| await PageObjects.lens.waitForField('runtime_number'); | ||
| const [fieldId] = await PageObjects.lens.findFieldIdsByType('number'); | ||
| await log.debug(`Opening field stats for ${fieldId}`); | ||
| await testSubjects.click(fieldId); | ||
| // check for popover | ||
| await testSubjects.exists('lnsFieldListPanel-title'); | ||
| // check for top values chart | ||
| await testSubjects.existOrFail('lnsFieldListPanel-topValues'); | ||
| // check values | ||
| const topValuesRows = await testSubjects.findAll('lnsFieldListPanel-topValues-bucket'); | ||
| expect(topValuesRows.length).to.eql(11); | ||
| // check for the Other entry | ||
| expect(await topValuesRows[10].getVisibleText()).to.eql('Other\n96.7%'); | ||
| // switch to date histogram | ||
| await testSubjects.click('lnsFieldListPanel-buttonGroup-distributionButton'); | ||
| // check for date histogram chart | ||
| expect( | ||
| await find.existsByCssSelector( | ||
| '[data-test-subj="lnsFieldListPanelFieldContent"] .echChart' | ||
| ) | ||
| ).to.eql(true); | ||
| }); | ||
|
|
||
| it('should show stats for a keyword runtime field', async () => { | ||
| await PageObjects.lens.searchField('runtime'); | ||
| await PageObjects.lens.waitForField('runtime_string'); | ||
| const [fieldId] = await PageObjects.lens.findFieldIdsByType('string'); | ||
| await log.debug(`Opening field stats for ${fieldId}`); | ||
| await testSubjects.click(fieldId); | ||
| // check for popover | ||
| await testSubjects.exists('lnsFieldListPanel-title'); | ||
| // check for top values chart | ||
| await testSubjects.existOrFail('lnsFieldListPanel-topValues'); | ||
| // check no date histogram | ||
| expect( | ||
| await find.existsByCssSelector( | ||
| '[data-test-subj="lnsFieldListPanelFieldContent"] .echChart' | ||
| ) | ||
| ).to.eql(false); | ||
| await PageObjects.lens.searchField(''); | ||
| }); | ||
|
|
||
| it('should change popover content if user defines a filter that affects field values', async () => { | ||
| // check the current records count for stats | ||
| const [fieldId] = await PageObjects.lens.findFieldIdsByType('string'); | ||
| await log.debug(`Opening field stats for ${fieldId}`); | ||
| await testSubjects.click(fieldId); | ||
| const valuesCount = parseInt( | ||
| (await testSubjects.getVisibleText('lnsFieldListPanel-statsFooter')) | ||
| .replaceAll(/(Calculated from | records\.)/g, '') | ||
| .replace(',', ''), | ||
| 10 | ||
| ); | ||
| // define a filter | ||
| await filterBar.addFilter('geo.src', 'is', 'CN'); | ||
| await retry.waitFor('Wait for the filter to take effect', async () => { | ||
| await testSubjects.click(fieldId); | ||
| // check for top values chart has changed compared to the previous test | ||
| const newValuesCount = parseInt( | ||
| (await testSubjects.getVisibleText('lnsFieldListPanel-statsFooter')) | ||
| .replaceAll(/(Calculated from | records\.)/g, '') | ||
| .replace(',', ''), | ||
| 10 | ||
| ); | ||
| return newValuesCount < valuesCount; | ||
| }); | ||
| }); | ||
|
|
||
| // One Fields cap's limitation is to not know when an index has no fields based on filters | ||
| it('should detect fields have no data in popup if filter excludes them', async () => { | ||
| await filterBar.removeAllFilters(); | ||
| await filterBar.addFilter('bytes', 'is', '-1'); | ||
| // check via popup fields have no data | ||
| const [fieldId] = await PageObjects.lens.findFieldIdsByType('string'); | ||
| await log.debug(`Opening field stats for ${fieldId}`); | ||
| await retry.try(async () => { | ||
| await testSubjects.click(fieldId); | ||
| expect(await testSubjects.find('lnsFieldListPanel-missingFieldStats')).to.be.ok(); | ||
| // close the popover | ||
| await testSubjects.click(fieldId); | ||
| }); | ||
| }); | ||
|
|
||
| if (datasourceType !== 'ad-hoc-no-timefield') { | ||
| it('should move some fields as empty when the time range excludes them', async () => { | ||
| // remove the filter | ||
| await filterBar.removeAllFilters(); | ||
| // tweak the time range to 17 Sept 2015 to 18 Sept 2015 | ||
| await PageObjects.lens.goToTimeRange( | ||
| 'Sep 17, 2015 @ 06:31:44.000', | ||
| 'Sep 18, 2015 @ 06:31:44.000' | ||
| ); | ||
| // check all fields are empty now | ||
| expect( | ||
| await (await testSubjects.find('lnsIndexPatternEmptyFields-count')).getVisibleText() | ||
| ).to.eql(52); | ||
| // check avaialble count is 0 | ||
| expect( | ||
| await ( | ||
| await testSubjects.find('lnsIndexPatternAvailableFields-count') | ||
| ).getVisibleText() | ||
| ).to.eql(1); | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.