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] DF Analytics: adds functional tests for edit form #73885

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 @@ -133,7 +133,7 @@ export const EditButtonFlyout: FC<Required<EditAction>> = ({ closeFlyout, item }
onClose={closeFlyout}
hideCloseButton
aria-labelledby="analyticsEditFlyoutTitle"
data-test-subj="analyticsEditFlyout"
data-test-subj="mlAnalyticsEditFlyout"
>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="m">
Expand Down Expand Up @@ -297,7 +297,7 @@ export const EditButtonFlyout: FC<Required<EditAction>> = ({ closeFlyout, item }
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
data-test-subj="analyticsEditFlyoutUpdateButton"
data-test-subj="mlAnalyticsEditFlyoutUpdateButton"
onClick={onSubmit}
fill
isDisabled={updateButtonDisabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ export const useColumns = (
}),
actions,
width: isManagementTable === true ? '100px' : '150px',
'data-test-subj': 'mlAnalyticsTableColumnActions',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');
const editedDescription = 'Edited description';

describe('classification creation', function () {
before(async () => {
Expand Down Expand Up @@ -179,6 +180,36 @@ export default function ({ getService }: FtrProviderContext) {
});
});

it('should open the edit form for the created job in the analytics table', async () => {
await ml.dataFrameAnalyticsTable.openEditFlyout(testData.jobId);
});

it('should input the description in the edit form', async () => {
await ml.dataFrameAnalyticsEdit.assertJobDescriptionEditInputExists();
await ml.dataFrameAnalyticsEdit.setJobDescriptionEdit(editedDescription);
});

it('should input the model memory limit in the edit form', async () => {
await ml.dataFrameAnalyticsEdit.assertJobMmlEditInputExists();
await ml.dataFrameAnalyticsEdit.setJobMmlEdit('21mb');
});

it('should submit the edit job form', async () => {
await ml.dataFrameAnalyticsEdit.updateAnalyticsJob();
});

it('displays details for the edited job in the analytics table', async () => {
await ml.dataFrameAnalyticsTable.assertAnalyticsRowFields(testData.jobId, {
id: testData.jobId,
description: editedDescription,
sourceIndex: testData.source,
destinationIndex: testData.destinationIndex,
type: testData.expected.row.type,
status: testData.expected.row.status,
progress: testData.expected.row.progress,
});
});

it('creates the destination index and writes results to it', async () => {
await ml.api.assertIndicesExist(testData.destinationIndex);
await ml.api.assertIndicesNotEmpty(testData.destinationIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');
const editedDescription = 'Edited description';

describe('outlier detection creation', function () {
before(async () => {
Expand Down Expand Up @@ -197,6 +198,36 @@ export default function ({ getService }: FtrProviderContext) {
});
});

it('should open the edit form for the created job in the analytics table', async () => {
await ml.dataFrameAnalyticsTable.openEditFlyout(testData.jobId);
});

it('should input the description in the edit form', async () => {
await ml.dataFrameAnalyticsEdit.assertJobDescriptionEditInputExists();
await ml.dataFrameAnalyticsEdit.setJobDescriptionEdit(editedDescription);
});

it('should input the model memory limit in the edit form', async () => {
await ml.dataFrameAnalyticsEdit.assertJobMmlEditInputExists();
await ml.dataFrameAnalyticsEdit.setJobMmlEdit('21mb');
});

it('should submit the edit job form', async () => {
await ml.dataFrameAnalyticsEdit.updateAnalyticsJob();
});

it('displays details for the edited job in the analytics table', async () => {
await ml.dataFrameAnalyticsTable.assertAnalyticsRowFields(testData.jobId, {
id: testData.jobId,
description: editedDescription,
sourceIndex: testData.source,
destinationIndex: testData.destinationIndex,
type: testData.expected.row.type,
status: testData.expected.row.status,
progress: testData.expected.row.progress,
});
});

it('creates the destination index and writes results to it', async () => {
await ml.api.assertIndicesExist(testData.destinationIndex);
await ml.api.assertIndicesNotEmpty(testData.destinationIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');
const editedDescription = 'Edited description';

describe('regression creation', function () {
before(async () => {
Expand Down Expand Up @@ -179,6 +180,36 @@ export default function ({ getService }: FtrProviderContext) {
});
});

it('should open the edit form for the created job in the analytics table', async () => {
await ml.dataFrameAnalyticsTable.openEditFlyout(testData.jobId);
});

it('should input the description in the edit form', async () => {
await ml.dataFrameAnalyticsEdit.assertJobDescriptionEditInputExists();
await ml.dataFrameAnalyticsEdit.setJobDescriptionEdit(editedDescription);
});

it('should input the model memory limit in the edit form', async () => {
await ml.dataFrameAnalyticsEdit.assertJobMmlEditInputExists();
await ml.dataFrameAnalyticsEdit.setJobMmlEdit('21mb');
});

it('should submit the edit job form', async () => {
await ml.dataFrameAnalyticsEdit.updateAnalyticsJob();
});

it('displays details for the edited job in the analytics table', async () => {
await ml.dataFrameAnalyticsTable.assertAnalyticsRowFields(testData.jobId, {
id: testData.jobId,
description: editedDescription,
sourceIndex: testData.source,
destinationIndex: testData.destinationIndex,
type: testData.expected.row.type,
status: testData.expected.row.status,
progress: testData.expected.row.progress,
});
});

it('creates the destination index and writes results to it', async () => {
await ml.api.assertIndicesExist(testData.destinationIndex);
await ml.api.assertIndicesNotEmpty(testData.destinationIndex);
Expand Down
71 changes: 71 additions & 0 deletions x-pack/test/functional/services/ml/data_frame_analytics_edit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import expect from '@kbn/expect';

import { FtrProviderContext } from '../../ftr_provider_context';
import { MlCommon } from './common';

export function MachineLearningDataFrameAnalyticsEditProvider(
{ getService }: FtrProviderContext,
mlCommon: MlCommon
) {
const testSubjects = getService('testSubjects');
const retry = getService('retry');

return {
async assertJobDescriptionEditInputExists() {
await testSubjects.existOrFail('mlAnalyticsEditFlyoutDescriptionInput');
},
async assertJobDescriptionEditValue(expectedValue: string) {
const actualJobDescription = await testSubjects.getAttribute(
'mlAnalyticsEditFlyoutDescriptionInput',
'value'
);
expect(actualJobDescription).to.eql(
expectedValue,
`Job description edit should be '${expectedValue}' (got '${actualJobDescription}')`
);
},
async assertJobMmlEditInputExists() {
await testSubjects.existOrFail('mlAnalyticsEditFlyoutmodelMemoryLimitInput');
},
async assertJobMmlEditValue(expectedValue: string) {
const actualMml = await testSubjects.getAttribute(
'mlAnalyticsEditFlyoutmodelMemoryLimitInput',
'value'
);
expect(actualMml).to.eql(
expectedValue,
`Job model memory limit edit should be '${expectedValue}' (got '${actualMml}')`
);
},
async setJobDescriptionEdit(jobDescription: string) {
await mlCommon.setValueWithChecks('mlAnalyticsEditFlyoutDescriptionInput', jobDescription, {
clearWithKeyboard: true,
});
await this.assertJobDescriptionEditValue(jobDescription);
},

async setJobMmlEdit(mml: string) {
await mlCommon.setValueWithChecks('mlAnalyticsEditFlyoutmodelMemoryLimitInput', mml, {
clearWithKeyboard: true,
});
await this.assertJobMmlEditValue(mml);
},

async assertAnalyticsEditFlyoutMissing() {
await testSubjects.missingOrFail('mlAnalyticsEditFlyout');
},

async updateAnalyticsJob() {
await testSubjects.existOrFail('mlAnalyticsEditFlyoutUpdateButton');
await testSubjects.click('mlAnalyticsEditFlyoutUpdateButton');
await retry.tryForTime(5000, async () => {
await this.assertAnalyticsEditFlyoutMissing();
});
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ export function MachineLearningDataFrameAnalyticsTableProvider({ getService }: F
await testSubjects.existOrFail('mlAnalyticsJobViewButton');
}

public async openEditFlyout(analyticsId: string) {
await this.openRowActions(analyticsId);
await testSubjects.click('mlAnalyticsJobEditButton');
await testSubjects.existOrFail('mlAnalyticsEditFlyout', { timeout: 5000 });
}

async assertAnalyticsSearchInputValue(expectedSearchValue: string) {
const searchBarInput = await this.getAnalyticsSearchInput();
const actualSearchValue = await searchBarInput.getAttribute('value');
Expand Down
3 changes: 3 additions & 0 deletions x-pack/test/functional/services/ml/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { MachineLearningCommonProvider } from './common';
import { MachineLearningCustomUrlsProvider } from './custom_urls';
import { MachineLearningDataFrameAnalyticsProvider } from './data_frame_analytics';
import { MachineLearningDataFrameAnalyticsCreationProvider } from './data_frame_analytics_creation';
import { MachineLearningDataFrameAnalyticsEditProvider } from './data_frame_analytics_edit';
import { MachineLearningDataFrameAnalyticsTableProvider } from './data_frame_analytics_table';
import { MachineLearningDataVisualizerProvider } from './data_visualizer';
import { MachineLearningDataVisualizerFileBasedProvider } from './data_visualizer_file_based';
Expand Down Expand Up @@ -47,6 +48,7 @@ export function MachineLearningProvider(context: FtrProviderContext) {
common,
api
);
const dataFrameAnalyticsEdit = MachineLearningDataFrameAnalyticsEditProvider(context, common);
const dataFrameAnalyticsTable = MachineLearningDataFrameAnalyticsTableProvider(context);
const dataVisualizer = MachineLearningDataVisualizerProvider(context);
const dataVisualizerFileBased = MachineLearningDataVisualizerFileBasedProvider(context, common);
Expand Down Expand Up @@ -76,6 +78,7 @@ export function MachineLearningProvider(context: FtrProviderContext) {
customUrls,
dataFrameAnalytics,
dataFrameAnalyticsCreation,
dataFrameAnalyticsEdit,
dataFrameAnalyticsTable,
dataVisualizer,
dataVisualizerFileBased,
Expand Down