[8.8] [ML] Stabilize and reenable classification tests (#158555) (#158576)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[ML] Stabilize and reenable classification tests
(#158555)](https://github.com/elastic/kibana/pull/158555)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Robert
Oskamp","email":"robert.oskamp@elastic.co"},"sourceCommit":{"committedDate":"2023-05-26T15:31:57Z","message":"[ML]
Stabilize and reenable classification tests (#158555)\n\n##
Summary\r\n\r\nThis PR stabilizes ML classification creation tests by
closing the\r\ndependent variable combo box earlier. It also reenables
the test suite.\r\n\r\n### Other changes\r\n\r\n- Remove the unused
parameter `testSubj` from\r\n`assertFieldStatContentByType` in the field
stats flyout service\r\n- Remove the unused parameter `fieldType` from
`assertTopValuesContent`\r\nin the field stats flyout
service","sha":"8d54e42bc9bda0d5f32c73a11e23e2a93db80605","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":[":ml","test_ui_functional","release_note:skip","backport:prev-minor","v8.9.0","v8.8.1"],"number":158555,"url":"https://github.com/elastic/kibana/pull/158555","mergeCommit":{"message":"[ML]
Stabilize and reenable classification tests (#158555)\n\n##
Summary\r\n\r\nThis PR stabilizes ML classification creation tests by
closing the\r\ndependent variable combo box earlier. It also reenables
the test suite.\r\n\r\n### Other changes\r\n\r\n- Remove the unused
parameter `testSubj` from\r\n`assertFieldStatContentByType` in the field
stats flyout service\r\n- Remove the unused parameter `fieldType` from
`assertTopValuesContent`\r\nin the field stats flyout
service","sha":"8d54e42bc9bda0d5f32c73a11e23e2a93db80605"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/158555","number":158555,"mergeCommit":{"message":"[ML]
Stabilize and reenable classification tests (#158555)\n\n##
Summary\r\n\r\nThis PR stabilizes ML classification creation tests by
closing the\r\ndependent variable combo box earlier. It also reenables
the test suite.\r\n\r\n### Other changes\r\n\r\n- Remove the unused
parameter `testSubj` from\r\n`assertFieldStatContentByType` in the field
stats flyout service\r\n- Remove the unused parameter `fieldType` from
`assertTopValuesContent`\r\nin the field stats flyout
service","sha":"8d54e42bc9bda0d5f32c73a11e23e2a93db80605"}},{"branch":"8.8","label":"v8.8.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Robert Oskamp <robert.oskamp@elastic.co>
This commit is contained in:
Kibana Machine 2023-05-26 12:29:21 -04:00 committed by GitHub
parent ec17499aa8
commit eabb7daf21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 20 deletions

View file

@ -14,8 +14,7 @@ export default function ({ getService }: FtrProviderContext) {
const ml = getService('ml');
const editedDescription = 'Edited description';
// FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/153798
describe.skip('classification creation', function () {
describe('classification creation', function () {
before(async () => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/bm_classification');
await ml.testResources.createIndexPatternIfNeeded('ft_bank_marketing');

View file

@ -402,6 +402,14 @@ export function MachineLearningCommonUIProvider({
});
},
async ensureComboBoxClosed() {
await retry.tryForTime(5000, async () => {
await browser.pressKeys(browser.keys.ESCAPE);
const comboBoxOpen = await testSubjects.exists('~comboBoxOptionsList', { timeout: 50 });
expect(comboBoxOpen).to.eql(false, 'Combo box should be closed');
});
},
async invokeTableRowAction(
rowSelector: string,
actionTestSubject: string,

View file

@ -283,12 +283,8 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
);
},
async assertFieldStatTopValuesContent(
fieldName: string,
fieldType: 'keyword' | 'date' | 'number',
expectedContent: string[]
) {
await mlCommonFieldStatsFlyout.assertTopValuesContent(fieldName, fieldType, expectedContent);
async assertFieldStatTopValuesContent(fieldName: string, expectedContent: string[]) {
await mlCommonFieldStatsFlyout.assertTopValuesContent(fieldName, expectedContent);
},
async assertDependentVariableInputMissing() {

View file

@ -8,11 +8,14 @@
import { ProvidedType } from '@kbn/test';
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
import { MlCommonUI } from './common_ui';
export type MlCommonFieldStatsFlyout = ProvidedType<typeof MachineLearningFieldStatsFlyoutProvider>;
export function MachineLearningFieldStatsFlyoutProvider({ getService }: FtrProviderContext) {
const browser = getService('browser');
export function MachineLearningFieldStatsFlyoutProvider(
{ getService }: FtrProviderContext,
mlCommonUI: MlCommonUI
) {
const comboBox = getService('comboBox');
const find = getService('find');
const retry = getService('retry');
@ -20,14 +23,10 @@ export function MachineLearningFieldStatsFlyoutProvider({ getService }: FtrProvi
return {
async assertFieldStatContentByType(
testSubj: string,
fieldName: string,
fieldType: 'keyword' | 'date' | 'number'
) {
await retry.tryForTime(2000, async () => {
// escape popover
await browser.pressKeys(browser.keys.ESCAPE);
if (fieldType === 'date') {
await testSubjects.existOrFail(`mlFieldStatsFlyoutContent ${fieldName}-histogram`);
}
@ -73,14 +72,16 @@ export function MachineLearningFieldStatsFlyoutProvider({ getService }: FtrProvi
await retry.tryForTime(10 * 1000, async () => {
await testSubjects.existOrFail(selector);
await testSubjects.click(selector);
await mlCommonUI.ensureComboBoxClosed();
await testSubjects.existOrFail('mlFieldStatsFlyout', { timeout: 500 });
await testSubjects.existOrFail(`mlFieldStatsFlyoutContent ${fieldName}-title`, {
timeout: 500,
});
});
await this.assertFieldStatContentByType(testSubj, fieldName, fieldType);
await this.assertFieldStatContentByType(fieldName, fieldType);
if (Array.isArray(expectedTopValuesContent)) {
await this.assertTopValuesContent(fieldName, fieldType, expectedTopValuesContent);
await this.assertTopValuesContent(fieldName, expectedTopValuesContent);
}
await this.ensureFieldStatsFlyoutClosed();
},
@ -98,21 +99,23 @@ export function MachineLearningFieldStatsFlyoutProvider({ getService }: FtrProvi
await testSubjects.existOrFail(selector);
await testSubjects.click(selector);
await mlCommonUI.ensureComboBoxClosed();
await testSubjects.existOrFail('mlFieldStatsFlyout', { timeout: 500 });
await testSubjects.existOrFail(`mlFieldStatsFlyoutContent ${fieldName}-title`, {
timeout: 500,
});
await this.assertFieldStatContentByType(parentComboBoxSelector, fieldName, fieldType);
await this.assertFieldStatContentByType(fieldName, fieldType);
if (Array.isArray(expectedTopValuesContent)) {
await this.assertTopValuesContent(fieldName, fieldType, expectedTopValuesContent);
await this.assertTopValuesContent(fieldName, expectedTopValuesContent);
}
await this.ensureFieldStatsFlyoutClosed();
});
},
async assertTopValuesContent(fieldName: string, fieldType: string, expectedValues: string[]) {
async assertTopValuesContent(fieldName: string, expectedValues: string[]) {
await retry.tryForTime(2000, async () => {
// check for top values rows
await testSubjects.existOrFail(`mlFieldStatsFlyoutContent ${fieldName}-topValues`);

View file

@ -68,7 +68,7 @@ export function MachineLearningProvider(context: FtrProviderContext) {
const commonAPI = MachineLearningCommonAPIProvider(context);
const commonUI = MachineLearningCommonUIProvider(context);
const commonDataGrid = MachineLearningCommonDataGridProvider(context);
const commonFieldStatsFlyout = MachineLearningFieldStatsFlyoutProvider(context);
const commonFieldStatsFlyout = MachineLearningFieldStatsFlyoutProvider(context, commonUI);
const anomaliesTable = MachineLearningAnomaliesTableProvider(context);
const anomalyCharts = AnomalyChartsProvider(context);