Skip to content
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

[ML] Functional tests - stabilize anomaly charts embeddables test #97452

Merged
merged 3 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');
const PageObjects = getPageObjects(['common', 'timePicker', 'dashboard']);
const dashboardAddPanel = getService('dashboardAddPanel');
const a11y = getService('a11y'); /* this is the wrapping service around axe */

describe('machine learning embeddables anomaly charts', function () {
Expand Down Expand Up @@ -96,10 +95,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('can open job selection flyout', async () => {
await PageObjects.dashboard.clickCreateDashboardPrompt();
await ml.dashboardEmbeddables.assertDashboardIsEmpty();
await dashboardAddPanel.clickEditorMenuButton();
await dashboardAddPanel.clickEmbeddableFactoryGroupButton('ml');
await dashboardAddPanel.clickAddNewEmbeddableLink('ml_anomaly_charts');
await ml.dashboardJobSelectionTable.assertJobSelectionTableExists();
await ml.dashboardEmbeddables.openJobSelectionFlyout();
await a11y.testAppSnapshot();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');
const PageObjects = getPageObjects(['common', 'timePicker', 'dashboard']);
const dashboardAddPanel = getService('dashboardAddPanel');

describe('anomaly charts', function () {
this.tags(['mlqa']);
Expand Down Expand Up @@ -87,10 +86,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('can open job selection flyout', async () => {
await PageObjects.dashboard.clickCreateDashboardPrompt();
await ml.dashboardEmbeddables.assertDashboardIsEmpty();
await dashboardAddPanel.clickEditorMenuButton();
await dashboardAddPanel.clickEmbeddableFactoryGroupButton('ml');
await dashboardAddPanel.clickAddNewEmbeddableLink('ml_anomaly_charts');
await ml.dashboardJobSelectionTable.assertJobSelectionTableExists();
await ml.dashboardEmbeddables.openJobSelectionFlyout();
});

it('can select jobs', async () => {
Expand Down
17 changes: 16 additions & 1 deletion x-pack/test/functional/services/ml/dashboard_embeddables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
import { MlCommonUI } from './common_ui';
import { MlDashboardJobSelectionTable } from './dashboard_job_selection_table';

export function MachineLearningDashboardEmbeddablesProvider(
{ getService }: FtrProviderContext,
mlCommonUI: MlCommonUI
mlCommonUI: MlCommonUI,
mlDashboardJobSelectionTable: MlDashboardJobSelectionTable
) {
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const find = getService('find');
const dashboardAddPanel = getService('dashboardAddPanel');

return {
async assertAnomalyChartsEmbeddableInitializerExists() {
Expand Down Expand Up @@ -91,5 +94,17 @@ export function MachineLearningDashboardEmbeddablesProvider(
async assertAnomalyChartsExists() {
await testSubjects.existOrFail(`mlExplorerChartsContainer`);
},

async openJobSelectionFlyout() {
await retry.tryForTime(60 * 1000, async () => {
await dashboardAddPanel.clickEditorMenuButton();
await testSubjects.existOrFail('dashboardEditorContextMenu', { timeout: 2000 });

await dashboardAddPanel.clickEmbeddableFactoryGroupButton('ml');
await dashboardAddPanel.clickAddNewEmbeddableLink('ml_anomaly_charts');

await mlDashboardJobSelectionTable.assertJobSelectionTableExists();
});
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
*/

import expect from '@kbn/expect';
import { ProvidedType } from '@kbn/test/types/ftr';
import { FtrProviderContext } from '../../ftr_provider_context';

export type MlDashboardJobSelectionTable = ProvidedType<
typeof MachineLearningDashboardJobSelectionTableProvider
>;

export function MachineLearningDashboardJobSelectionTableProvider({
getService,
}: FtrProviderContext) {
Expand All @@ -16,8 +21,8 @@ export function MachineLearningDashboardJobSelectionTableProvider({

return {
async assertJobSelectionTableExists(): Promise<void> {
await retry.tryForTime(5000, async () => {
await testSubjects.existOrFail('mlCustomSelectionTable');
await retry.tryForTime(20 * 1000, async () => {
await testSubjects.existOrFail('mlCustomSelectionTable', { timeout: 2000 });
});
},

Expand Down
6 changes: 5 additions & 1 deletion x-pack/test/functional/services/ml/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export function MachineLearningProvider(context: FtrProviderContext) {
const customUrls = MachineLearningCustomUrlsProvider(context);

const dashboardJobSelectionTable = MachineLearningDashboardJobSelectionTableProvider(context);
const dashboardEmbeddables = MachineLearningDashboardEmbeddablesProvider(context, commonUI);
const dashboardEmbeddables = MachineLearningDashboardEmbeddablesProvider(
context,
commonUI,
dashboardJobSelectionTable
);

const dataFrameAnalytics = MachineLearningDataFrameAnalyticsProvider(context, api);
const dataFrameAnalyticsCreation = MachineLearningDataFrameAnalyticsCreationProvider(
Expand Down