Skip to content

Commit

Permalink
add edit analytics functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Aug 3, 2020
1 parent 7099a6d commit 00ad323
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 3 deletions.
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 @@ -167,10 +168,37 @@ export default function ({ getService }: FtrProviderContext) {
);
});

it('should open the edit form for the created job in the analytics table', async () => {
await ml.dataFrameAnalyticsTable.filterWithSearchString(testData.jobId);
const rows = await ml.dataFrameAnalyticsTable.parseAnalyticsTable();
const filteredRows = rows.filter((row) => row.id === testData.jobId);
expect(filteredRows).to.have.length(
1,
`Filtered analytics table should have 1 row for job id '${testData.jobId}' (got matching items '${filteredRows}')`
);
if (filteredRows?.length) {
await ml.dataFrameAnalyticsTable.openEditFlyout();
}
});

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

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

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

it('displays details for the created job in the analytics table', async () => {
await ml.dataFrameAnalyticsTable.assertAnalyticsRowFields(testData.jobId, {
id: testData.jobId,
description: testData.jobDescription,
description: editedDescription,
sourceIndex: testData.source,
destinationIndex: testData.destinationIndex,
type: testData.expected.row.type,
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 @@ -185,10 +186,37 @@ export default function ({ getService }: FtrProviderContext) {
);
});

it('should open the edit form for the created job in the analytics table', async () => {
await ml.dataFrameAnalyticsTable.filterWithSearchString(testData.jobId);
const rows = await ml.dataFrameAnalyticsTable.parseAnalyticsTable();
const filteredRows = rows.filter((row) => row.id === testData.jobId);
expect(filteredRows).to.have.length(
1,
`Filtered analytics table should have 1 row for job id '${testData.jobId}' (got matching items '${filteredRows}')`
);
if (filteredRows?.length) {
await ml.dataFrameAnalyticsTable.openEditFlyout();
}
});

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

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

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

it('displays details for the created job in the analytics table', async () => {
await ml.dataFrameAnalyticsTable.assertAnalyticsRowFields(testData.jobId, {
id: testData.jobId,
description: testData.jobDescription,
description: editedDescription,
sourceIndex: testData.source,
destinationIndex: testData.destinationIndex,
type: testData.expected.row.type,
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 @@ -167,10 +168,37 @@ export default function ({ getService }: FtrProviderContext) {
);
});

it('should open the edit form for the created job in the analytics table', async () => {
await ml.dataFrameAnalyticsTable.filterWithSearchString(testData.jobId);
const rows = await ml.dataFrameAnalyticsTable.parseAnalyticsTable();
const filteredRows = rows.filter((row) => row.id === testData.jobId);
expect(filteredRows).to.have.length(
1,
`Filtered analytics table should have 1 row for job id '${testData.jobId}' (got matching items '${filteredRows}')`
);
if (filteredRows?.length) {
await ml.dataFrameAnalyticsTable.openEditFlyout();
}
});

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

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

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

it('displays details for the created job in the analytics table', async () => {
await ml.dataFrameAnalyticsTable.assertAnalyticsRowFields(testData.jobId, {
id: testData.jobId,
description: testData.jobDescription,
description: editedDescription,
sourceIndex: testData.source,
destinationIndex: testData.destinationIndex,
type: testData.expected.row.type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
await testSubjects.existOrFail('mlDFAnalyticsJobCreationJobDescription');
},

async assertJobDescriptionEditInputExists() {
await testSubjects.existOrFail('mlAnalyticsEditFlyoutDescriptionInput');
},

async assertJobMmlEditInputExists() {
await testSubjects.existOrFail('mlAnalyticsEditFlyoutmodelMemoryLimitInput');
},

async assertJobIdValue(expectedValue: string) {
const actualJobId = await testSubjects.getAttribute(
'mlAnalyticsCreateJobFlyoutJobIdInput',
Expand All @@ -110,6 +118,28 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
);
},

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 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 setJobId(jobId: string) {
await mlCommon.setValueWithChecks('mlAnalyticsCreateJobFlyoutJobIdInput', jobId, {
clearWithKeyboard: true,
Expand All @@ -124,6 +154,20 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
await this.assertJobDescriptionValue(jobDescription);
},

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 assertSourceDataPreviewExists() {
await testSubjects.existOrFail('mlAnalyticsCreationDataGrid loaded', { timeout: 5000 });
},
Expand Down Expand Up @@ -481,6 +525,11 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
await testSubjects.existOrFail('mlAnalyticsCreateJobWizardCreateButton');
},

async updateAnalyticsJob() {
await testSubjects.existOrFail('analyticsEditFlyoutUpdateButton');
await testSubjects.click('analyticsEditFlyoutUpdateButton');
},

async isCreateButtonDisabled() {
const isEnabled = await testSubjects.isEnabled('mlAnalyticsCreateJobWizardCreateButton');
return !isEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ export function MachineLearningDataFrameAnalyticsTableProvider({ getService }: F
await testSubjects.existOrFail('mlAnalyticsJobViewButton');
}

public async openEditFlyout() {
await testSubjects.existOrFail('euiCollapsedItemActionsButton', { timeout: 5000 });
await testSubjects.click('euiCollapsedItemActionsButton');
await testSubjects.existOrFail('mlAnalyticsJobEditButton', { timeout: 5000 });
await testSubjects.click('mlAnalyticsJobEditButton');
await testSubjects.existOrFail('analyticsEditFlyout', { timeout: 5000 });
}

async assertAnalyticsSearchInputValue(expectedSearchValue: string) {
const searchBarInput = await this.getAnalyticsSearchInput();
const actualSearchValue = await searchBarInput.getAttribute('value');
Expand Down

0 comments on commit 00ad323

Please sign in to comment.