Skip to content

Commit 3f5aa49

Browse files
[ML] DF Analytics: adds functional tests for edit form (#73885)
* add edit analytics functional test * adds edit test service * update edit test wording for clarity * check flyout closes after edit * rename testSubj for consitency
1 parent 94efd1e commit 3f5aa49

8 files changed

Lines changed: 176 additions & 2 deletions

File tree

x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_edit/edit_button_flyout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export const EditButtonFlyout: FC<Required<EditAction>> = ({ closeFlyout, item }
133133
onClose={closeFlyout}
134134
hideCloseButton
135135
aria-labelledby="analyticsEditFlyoutTitle"
136-
data-test-subj="analyticsEditFlyout"
136+
data-test-subj="mlAnalyticsEditFlyout"
137137
>
138138
<EuiFlyoutHeader hasBorder>
139139
<EuiTitle size="m">
@@ -297,7 +297,7 @@ export const EditButtonFlyout: FC<Required<EditAction>> = ({ closeFlyout, item }
297297
</EuiFlexItem>
298298
<EuiFlexItem grow={false}>
299299
<EuiButton
300-
data-test-subj="analyticsEditFlyoutUpdateButton"
300+
data-test-subj="mlAnalyticsEditFlyoutUpdateButton"
301301
onClick={onSubmit}
302302
fill
303303
isDisabled={updateButtonDisabled}

x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_columns.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ export const useColumns = (
258258
}),
259259
actions,
260260
width: isManagementTable === true ? '100px' : '150px',
261+
'data-test-subj': 'mlAnalyticsTableColumnActions',
261262
},
262263
];
263264

x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
1010
export default function ({ getService }: FtrProviderContext) {
1111
const esArchiver = getService('esArchiver');
1212
const ml = getService('ml');
13+
const editedDescription = 'Edited description';
1314

1415
describe('classification creation', function () {
1516
before(async () => {
@@ -179,6 +180,36 @@ export default function ({ getService }: FtrProviderContext) {
179180
});
180181
});
181182

183+
it('should open the edit form for the created job in the analytics table', async () => {
184+
await ml.dataFrameAnalyticsTable.openEditFlyout(testData.jobId);
185+
});
186+
187+
it('should input the description in the edit form', async () => {
188+
await ml.dataFrameAnalyticsEdit.assertJobDescriptionEditInputExists();
189+
await ml.dataFrameAnalyticsEdit.setJobDescriptionEdit(editedDescription);
190+
});
191+
192+
it('should input the model memory limit in the edit form', async () => {
193+
await ml.dataFrameAnalyticsEdit.assertJobMmlEditInputExists();
194+
await ml.dataFrameAnalyticsEdit.setJobMmlEdit('21mb');
195+
});
196+
197+
it('should submit the edit job form', async () => {
198+
await ml.dataFrameAnalyticsEdit.updateAnalyticsJob();
199+
});
200+
201+
it('displays details for the edited job in the analytics table', async () => {
202+
await ml.dataFrameAnalyticsTable.assertAnalyticsRowFields(testData.jobId, {
203+
id: testData.jobId,
204+
description: editedDescription,
205+
sourceIndex: testData.source,
206+
destinationIndex: testData.destinationIndex,
207+
type: testData.expected.row.type,
208+
status: testData.expected.row.status,
209+
progress: testData.expected.row.progress,
210+
});
211+
});
212+
182213
it('creates the destination index and writes results to it', async () => {
183214
await ml.api.assertIndicesExist(testData.destinationIndex);
184215
await ml.api.assertIndicesNotEmpty(testData.destinationIndex);

x-pack/test/functional/apps/ml/data_frame_analytics/outlier_detection_creation.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
1010
export default function ({ getService }: FtrProviderContext) {
1111
const esArchiver = getService('esArchiver');
1212
const ml = getService('ml');
13+
const editedDescription = 'Edited description';
1314

1415
describe('outlier detection creation', function () {
1516
before(async () => {
@@ -197,6 +198,36 @@ export default function ({ getService }: FtrProviderContext) {
197198
});
198199
});
199200

201+
it('should open the edit form for the created job in the analytics table', async () => {
202+
await ml.dataFrameAnalyticsTable.openEditFlyout(testData.jobId);
203+
});
204+
205+
it('should input the description in the edit form', async () => {
206+
await ml.dataFrameAnalyticsEdit.assertJobDescriptionEditInputExists();
207+
await ml.dataFrameAnalyticsEdit.setJobDescriptionEdit(editedDescription);
208+
});
209+
210+
it('should input the model memory limit in the edit form', async () => {
211+
await ml.dataFrameAnalyticsEdit.assertJobMmlEditInputExists();
212+
await ml.dataFrameAnalyticsEdit.setJobMmlEdit('21mb');
213+
});
214+
215+
it('should submit the edit job form', async () => {
216+
await ml.dataFrameAnalyticsEdit.updateAnalyticsJob();
217+
});
218+
219+
it('displays details for the edited job in the analytics table', async () => {
220+
await ml.dataFrameAnalyticsTable.assertAnalyticsRowFields(testData.jobId, {
221+
id: testData.jobId,
222+
description: editedDescription,
223+
sourceIndex: testData.source,
224+
destinationIndex: testData.destinationIndex,
225+
type: testData.expected.row.type,
226+
status: testData.expected.row.status,
227+
progress: testData.expected.row.progress,
228+
});
229+
});
230+
200231
it('creates the destination index and writes results to it', async () => {
201232
await ml.api.assertIndicesExist(testData.destinationIndex);
202233
await ml.api.assertIndicesNotEmpty(testData.destinationIndex);

x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
1010
export default function ({ getService }: FtrProviderContext) {
1111
const esArchiver = getService('esArchiver');
1212
const ml = getService('ml');
13+
const editedDescription = 'Edited description';
1314

1415
describe('regression creation', function () {
1516
before(async () => {
@@ -179,6 +180,36 @@ export default function ({ getService }: FtrProviderContext) {
179180
});
180181
});
181182

183+
it('should open the edit form for the created job in the analytics table', async () => {
184+
await ml.dataFrameAnalyticsTable.openEditFlyout(testData.jobId);
185+
});
186+
187+
it('should input the description in the edit form', async () => {
188+
await ml.dataFrameAnalyticsEdit.assertJobDescriptionEditInputExists();
189+
await ml.dataFrameAnalyticsEdit.setJobDescriptionEdit(editedDescription);
190+
});
191+
192+
it('should input the model memory limit in the edit form', async () => {
193+
await ml.dataFrameAnalyticsEdit.assertJobMmlEditInputExists();
194+
await ml.dataFrameAnalyticsEdit.setJobMmlEdit('21mb');
195+
});
196+
197+
it('should submit the edit job form', async () => {
198+
await ml.dataFrameAnalyticsEdit.updateAnalyticsJob();
199+
});
200+
201+
it('displays details for the edited job in the analytics table', async () => {
202+
await ml.dataFrameAnalyticsTable.assertAnalyticsRowFields(testData.jobId, {
203+
id: testData.jobId,
204+
description: editedDescription,
205+
sourceIndex: testData.source,
206+
destinationIndex: testData.destinationIndex,
207+
type: testData.expected.row.type,
208+
status: testData.expected.row.status,
209+
progress: testData.expected.row.progress,
210+
});
211+
});
212+
182213
it('creates the destination index and writes results to it', async () => {
183214
await ml.api.assertIndicesExist(testData.destinationIndex);
184215
await ml.api.assertIndicesNotEmpty(testData.destinationIndex);
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
import expect from '@kbn/expect';
7+
8+
import { FtrProviderContext } from '../../ftr_provider_context';
9+
import { MlCommon } from './common';
10+
11+
export function MachineLearningDataFrameAnalyticsEditProvider(
12+
{ getService }: FtrProviderContext,
13+
mlCommon: MlCommon
14+
) {
15+
const testSubjects = getService('testSubjects');
16+
const retry = getService('retry');
17+
18+
return {
19+
async assertJobDescriptionEditInputExists() {
20+
await testSubjects.existOrFail('mlAnalyticsEditFlyoutDescriptionInput');
21+
},
22+
async assertJobDescriptionEditValue(expectedValue: string) {
23+
const actualJobDescription = await testSubjects.getAttribute(
24+
'mlAnalyticsEditFlyoutDescriptionInput',
25+
'value'
26+
);
27+
expect(actualJobDescription).to.eql(
28+
expectedValue,
29+
`Job description edit should be '${expectedValue}' (got '${actualJobDescription}')`
30+
);
31+
},
32+
async assertJobMmlEditInputExists() {
33+
await testSubjects.existOrFail('mlAnalyticsEditFlyoutmodelMemoryLimitInput');
34+
},
35+
async assertJobMmlEditValue(expectedValue: string) {
36+
const actualMml = await testSubjects.getAttribute(
37+
'mlAnalyticsEditFlyoutmodelMemoryLimitInput',
38+
'value'
39+
);
40+
expect(actualMml).to.eql(
41+
expectedValue,
42+
`Job model memory limit edit should be '${expectedValue}' (got '${actualMml}')`
43+
);
44+
},
45+
async setJobDescriptionEdit(jobDescription: string) {
46+
await mlCommon.setValueWithChecks('mlAnalyticsEditFlyoutDescriptionInput', jobDescription, {
47+
clearWithKeyboard: true,
48+
});
49+
await this.assertJobDescriptionEditValue(jobDescription);
50+
},
51+
52+
async setJobMmlEdit(mml: string) {
53+
await mlCommon.setValueWithChecks('mlAnalyticsEditFlyoutmodelMemoryLimitInput', mml, {
54+
clearWithKeyboard: true,
55+
});
56+
await this.assertJobMmlEditValue(mml);
57+
},
58+
59+
async assertAnalyticsEditFlyoutMissing() {
60+
await testSubjects.missingOrFail('mlAnalyticsEditFlyout');
61+
},
62+
63+
async updateAnalyticsJob() {
64+
await testSubjects.existOrFail('mlAnalyticsEditFlyoutUpdateButton');
65+
await testSubjects.click('mlAnalyticsEditFlyoutUpdateButton');
66+
await retry.tryForTime(5000, async () => {
67+
await this.assertAnalyticsEditFlyoutMissing();
68+
});
69+
},
70+
};
71+
}

x-pack/test/functional/services/ml/data_frame_analytics_table.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ export function MachineLearningDataFrameAnalyticsTableProvider({ getService }: F
8888
await testSubjects.existOrFail('mlAnalyticsJobViewButton');
8989
}
9090

91+
public async openEditFlyout(analyticsId: string) {
92+
await this.openRowActions(analyticsId);
93+
await testSubjects.click('mlAnalyticsJobEditButton');
94+
await testSubjects.existOrFail('mlAnalyticsEditFlyout', { timeout: 5000 });
95+
}
96+
9197
async assertAnalyticsSearchInputValue(expectedSearchValue: string) {
9298
const searchBarInput = await this.getAnalyticsSearchInput();
9399
const actualSearchValue = await searchBarInput.getAttribute('value');

x-pack/test/functional/services/ml/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { MachineLearningCommonProvider } from './common';
1313
import { MachineLearningCustomUrlsProvider } from './custom_urls';
1414
import { MachineLearningDataFrameAnalyticsProvider } from './data_frame_analytics';
1515
import { MachineLearningDataFrameAnalyticsCreationProvider } from './data_frame_analytics_creation';
16+
import { MachineLearningDataFrameAnalyticsEditProvider } from './data_frame_analytics_edit';
1617
import { MachineLearningDataFrameAnalyticsTableProvider } from './data_frame_analytics_table';
1718
import { MachineLearningDataVisualizerProvider } from './data_visualizer';
1819
import { MachineLearningDataVisualizerFileBasedProvider } from './data_visualizer_file_based';
@@ -47,6 +48,7 @@ export function MachineLearningProvider(context: FtrProviderContext) {
4748
common,
4849
api
4950
);
51+
const dataFrameAnalyticsEdit = MachineLearningDataFrameAnalyticsEditProvider(context, common);
5052
const dataFrameAnalyticsTable = MachineLearningDataFrameAnalyticsTableProvider(context);
5153
const dataVisualizer = MachineLearningDataVisualizerProvider(context);
5254
const dataVisualizerFileBased = MachineLearningDataVisualizerFileBasedProvider(context, common);
@@ -76,6 +78,7 @@ export function MachineLearningProvider(context: FtrProviderContext) {
7678
customUrls,
7779
dataFrameAnalytics,
7880
dataFrameAnalyticsCreation,
81+
dataFrameAnalyticsEdit,
7982
dataFrameAnalyticsTable,
8083
dataVisualizer,
8184
dataVisualizerFileBased,

0 commit comments

Comments
 (0)