[ML] Functional tests - stabilize outlier saved search tests (#131225)

This PR stabilizes the outlier detection with saved searches functional tests.
This commit is contained in:
Robert Oskamp 2022-05-05 11:24:03 +02:00 committed by GitHub
parent a0294e59f1
commit 0650bd3819
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 20 deletions

View file

@ -251,8 +251,7 @@ export default function ({ getService }: FtrProviderContext) {
await ml.dataFrameAnalyticsCreation.selectJobType(dfaJobType);
await ml.testExecution.logTestStep('displays the source data preview');
await ml.dataFrameAnalyticsCreation.assertSourceDataPreviewExists();
await ml.testExecution.logTestStep('enables the source data preview histogram charts');
await ml.dataFrameAnalyticsCreation.enableSourceDataPreviewHistogramCharts(true);
await ml.dataFrameAnalyticsCreation.assertSourceDataPreviewHistogramChartEnabled(true);
await ml.testExecution.logTestStep('displays the include fields selection');
await ml.dataFrameAnalyticsCreation.assertIncludeFieldsSelectionExists();
await a11y.testAppSnapshot();

View file

@ -160,12 +160,10 @@ export default function ({ getService }: FtrProviderContext) {
await ml.testExecution.logTestStep('displays the source data preview');
await ml.dataFrameAnalyticsCreation.assertSourceDataPreviewExists();
await ml.testExecution.logTestStep('enables the source data preview histogram charts');
await ml.dataFrameAnalyticsCreation.enableSourceDataPreviewHistogramCharts(true);
await ml.dataFrameAnalyticsCreation.assertSourceDataPreviewHistogramChartEnabled(true);
await ml.testExecution.logTestStep('displays the source data preview histogram charts');
await ml.dataFrameAnalyticsCreation.assertSourceDataPreviewHistogramCharts(
await ml.dataFrameAnalyticsCreation.enableAndAssertSourceDataPreviewHistogramCharts(
testData.expected.histogramCharts
);

View file

@ -217,12 +217,10 @@ export default function ({ getService }: FtrProviderContext) {
await ml.testExecution.logTestStep('displays the source data preview');
await ml.dataFrameAnalyticsCreation.assertSourceDataPreviewExists();
await ml.testExecution.logTestStep('enables the source data preview histogram charts');
await ml.dataFrameAnalyticsCreation.enableSourceDataPreviewHistogramCharts(true);
await ml.dataFrameAnalyticsCreation.assertSourceDataPreviewHistogramChartEnabled(true);
await ml.testExecution.logTestStep('displays the source data preview histogram charts');
await ml.dataFrameAnalyticsCreation.assertSourceDataPreviewHistogramCharts(
await ml.dataFrameAnalyticsCreation.enableAndAssertSourceDataPreviewHistogramCharts(
testData.expected.histogramCharts
);

View file

@ -49,6 +49,7 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
const jobTypeAttribute = `mlAnalyticsCreation-${jobType}-option`;
await testSubjects.click(jobTypeAttribute);
await this.assertJobTypeSelection(jobTypeAttribute);
await headerPage.waitUntilLoadingHasFinished();
},
async assertAdvancedEditorSwitchExists() {
@ -127,29 +128,41 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
await testSubjects.existOrFail('mlAnalyticsCreationDataGridHistogramButton');
},
async enableSourceDataPreviewHistogramCharts(expectedDefaultButtonState: boolean) {
await this.assertSourceDataPreviewHistogramChartButtonCheckState(expectedDefaultButtonState);
if (expectedDefaultButtonState === false) {
async enableSourceDataPreviewHistogramCharts(shouldBeEnabled: boolean) {
const isEnabled = await this.getSourceDataPreviewHistogramChartButtonCheckState();
if (isEnabled !== shouldBeEnabled) {
await testSubjects.click('mlAnalyticsCreationDataGridHistogramButton');
await this.assertSourceDataPreviewHistogramChartButtonCheckState(true);
await this.assertSourceDataPreviewHistogramChartEnabled(shouldBeEnabled);
}
},
async assertSourceDataPreviewHistogramChartButtonCheckState(expectedCheckState: boolean) {
const actualCheckState =
async assertSourceDataPreviewHistogramChartEnabled(shouldBeEnabled: boolean) {
const isEnabled = await this.getSourceDataPreviewHistogramChartButtonCheckState();
expect(isEnabled).to.eql(
shouldBeEnabled,
`Source data preview histogram charts should be '${
shouldBeEnabled ? 'enabled' : 'disabled'
}' (got '${isEnabled ? 'enabled' : 'disabled'}')`
);
},
async getSourceDataPreviewHistogramChartButtonCheckState(): Promise<boolean> {
return (
(await testSubjects.getAttribute(
'mlAnalyticsCreationDataGridHistogramButton',
'aria-pressed'
)) === 'true';
expect(actualCheckState).to.eql(
expectedCheckState,
`Chart histogram button check state should be '${expectedCheckState}' (got '${actualCheckState}')`
)) === 'true'
);
},
async scrollSourceDataPreviewIntoView() {
await testSubjects.scrollIntoView('mlAnalyticsCreationDataGrid loaded');
},
async assertSourceDataPreviewHistogramCharts(
expectedHistogramCharts: Array<{ chartAvailable: boolean; id: string; legend: string }>
) {
await this.scrollSourceDataPreviewIntoView();
// For each chart, get the content of each header cell and assert
// the legend text and column id and if the chart should be present or not.
await retry.tryForTime(10000, async () => {
@ -178,6 +191,17 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
});
},
async enableAndAssertSourceDataPreviewHistogramCharts(
expectedHistogramCharts: Array<{ chartAvailable: boolean; id: string; legend: string }>
) {
await retry.tryForTime(20 * 1000, async () => {
// turn histogram charts off and on before checking
await this.enableSourceDataPreviewHistogramCharts(false);
await this.enableSourceDataPreviewHistogramCharts(true);
await this.assertSourceDataPreviewHistogramCharts(expectedHistogramCharts);
});
},
async assertIncludeFieldsSelectionExists() {
await testSubjects.existOrFail('mlAnalyticsCreateJobWizardIncludesTable', { timeout: 8000 });