-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Add functional tests for Field statistics embeddable in Dashboar…
…d, check for filters (#116774) * [ML] Add functional tests for dashboard embeddable, filters * [ML] Fix permissions * [ML] Update tests to use bulk api * [ML] Change to constants * [ML] Fix savedSearchTitle Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
735a286
commit 6fe0052
Showing
11 changed files
with
222 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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 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 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
122 changes: 122 additions & 0 deletions
122
x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer_grid_in_dashboard.ts
This file contains 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,122 @@ | ||
/* | ||
* 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 { FtrProviderContext } from '../../../ftr_provider_context'; | ||
import { TestData, MetricFieldVisConfig } from './types'; | ||
import { farequoteLuceneFiltersSearchTestData } from './index_test_data'; | ||
|
||
const SHOW_FIELD_STATISTICS = 'discover:showFieldStatistics'; | ||
export default function ({ getService, getPageObjects }: FtrProviderContext) { | ||
const esArchiver = getService('esArchiver'); | ||
const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'settings', 'dashboard']); | ||
const ml = getService('ml'); | ||
const retry = getService('retry'); | ||
const dashboardAddPanel = getService('dashboardAddPanel'); | ||
|
||
function runTests(testData: TestData) { | ||
const savedSearchTitle = `Field stats for ${testData.suiteTitle} ${Date.now()}`; | ||
const dashboardTitle = `Dashboard for ${testData.suiteTitle} ${Date.now()}`; | ||
const startTime = 'Jan 1, 2016 @ 00:00:00.000'; | ||
const endTime = 'Nov 1, 2020 @ 00:00:00.000'; | ||
|
||
describe(`with ${testData.suiteTitle}`, function () { | ||
after(async function () { | ||
await ml.testResources.deleteSavedSearchByTitle(savedSearchTitle); | ||
await ml.testResources.deleteDashboardByTitle(dashboardTitle); | ||
}); | ||
|
||
it(`saves search with Field statistics table in Discover`, async function () { | ||
await ml.testResources.setAdvancedSettingProperty(SHOW_FIELD_STATISTICS, true); | ||
|
||
await PageObjects.common.navigateToApp('discover'); | ||
if (testData.isSavedSearch) { | ||
await retry.tryForTime(2 * 1000, async () => { | ||
await PageObjects.discover.loadSavedSearch(testData.sourceIndexOrSavedSearch); | ||
}); | ||
} else { | ||
await ml.dashboardEmbeddables.selectDiscoverIndexPattern( | ||
testData.sourceIndexOrSavedSearch | ||
); | ||
} | ||
await PageObjects.timePicker.setAbsoluteRange(startTime, endTime); | ||
|
||
await PageObjects.discover.assertViewModeToggleExists(); | ||
await PageObjects.discover.clickViewModeFieldStatsButton(); | ||
await ml.testExecution.logTestStep('saves as new search'); | ||
await PageObjects.discover.saveSearch(savedSearchTitle, true); | ||
}); | ||
|
||
it(`displays Field statistics table in Dashboard when enabled`, async function () { | ||
await PageObjects.common.navigateToApp('dashboard'); | ||
await PageObjects.dashboard.gotoDashboardLandingPage(); | ||
await PageObjects.dashboard.clickNewDashboard(); | ||
await dashboardAddPanel.addSavedSearch(savedSearchTitle); | ||
await PageObjects.dashboard.waitForRenderComplete(); | ||
|
||
await PageObjects.timePicker.setAbsoluteRange(startTime, endTime); | ||
await PageObjects.dashboard.waitForRenderComplete(); | ||
|
||
for (const fieldRow of testData.expected.metricFields as Array< | ||
Required<MetricFieldVisConfig> | ||
>) { | ||
await ml.dataVisualizerTable.assertNumberFieldContents( | ||
fieldRow.fieldName, | ||
fieldRow.docCountFormatted, | ||
fieldRow.topValuesCount, | ||
fieldRow.viewableInLens | ||
); | ||
} | ||
|
||
for (const fieldRow of testData.expected.nonMetricFields!) { | ||
await ml.dataVisualizerTable.assertNonMetricFieldContents( | ||
fieldRow.type, | ||
fieldRow.fieldName!, | ||
fieldRow.docCountFormatted, | ||
fieldRow.exampleCount, | ||
fieldRow.viewableInLens, | ||
false, | ||
fieldRow.exampleContent | ||
); | ||
} | ||
|
||
await PageObjects.dashboard.saveDashboard(dashboardTitle); | ||
}); | ||
|
||
it(`doesn't display Field statistics table in Dashboard when disabled`, async function () { | ||
await ml.testResources.setAdvancedSettingProperty(SHOW_FIELD_STATISTICS, false); | ||
|
||
await PageObjects.common.navigateToApp('dashboard'); | ||
await PageObjects.dashboard.gotoDashboardEditMode(dashboardTitle); | ||
await PageObjects.dashboard.waitForRenderComplete(); | ||
|
||
await dashboardAddPanel.addSavedSearch(savedSearchTitle); | ||
await PageObjects.dashboard.waitForRenderComplete(); | ||
|
||
await PageObjects.timePicker.setAbsoluteRange(startTime, endTime); | ||
await PageObjects.dashboard.waitForRenderComplete(); | ||
|
||
await PageObjects.discover.assertFieldStatsTableNotExists(); | ||
await PageObjects.dashboard.saveDashboard(dashboardTitle); | ||
}); | ||
}); | ||
} | ||
|
||
describe('field statistics in Dashboard', function () { | ||
before(async function () { | ||
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); | ||
await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); | ||
await ml.testResources.createSavedSearchFarequoteFilterAndLuceneIfNeeded(); | ||
await ml.securityUI.loginAsMlPowerUser(); | ||
}); | ||
|
||
after(async function () { | ||
await ml.testResources.clearAdvancedSettingProperty(SHOW_FIELD_STATISTICS); | ||
}); | ||
|
||
runTests(farequoteLuceneFiltersSearchTestData); | ||
}); | ||
} |
This file contains 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 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 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 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.