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] Advanced wizard functional UI tests #49480

Merged
merged 15 commits into from
Oct 29, 2019

Conversation

pheyos
Copy link
Member

@pheyos pheyos commented Oct 28, 2019

Summary

This PR adds tests for the ML advanced wizard.

High level test steps

  • Create a new advanced job, validate wizards controls on the way
  • Run the job and wait for job processing to finish
  • Validate job details in the job list
  • Clone that job, validate pre-filled wizard fields
  • Run the clone job and wait for job processing to finish
  • Validate clone job details in the job list

These steps are executed for two jobs:

  1. one with a couple metric detectors to cover some functions and the different the usage of field / by field / over field / partition field

    • high_count
    • mean("products.base_price") by "category.keyword
    • sum("products.discount_amount") over customer_id
    • median(total_quantity) partition_field_name=customer_gender
    • max(total_quantity) by "geoip.continent_name" over customer_id partition_field_name=customer_gender
  2. one with a categorization field and a corresponding detector count by mlcategory

Other changes

  • Add a couple data-test-subj attributes to the ML UI
  • Add detector result validation all existing anomaly detection job tests
  • Adjust tests to handle the changed empty combo boxes correctly
  • Add needed service methods
  • A couple stability fixes

@pheyos pheyos added :ml test_ui_functional v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.5.0 labels Oct 28, 2019
@pheyos pheyos requested a review from a team as a code owner October 28, 2019 14:04
@pheyos pheyos self-assigned this Oct 28, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@@ -166,3 +172,7 @@ const DuplicateDetectorsWarning: FC<{ validation: Validation }> = ({ validation
</Fragment>
);
};

const DetectorIdentifier: FC<{ detector: Detector }> = ({ detector }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure about the name DetectorIdentifier.
It's not obvious what it'll produce.
The component produces a string describing the detector. something like StringifiedDetector is closer to what it's doing, but that's not great either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed in f32ca31

@@ -8,10 +8,24 @@ import expect from '@kbn/expect';
import { isEmpty } from 'lodash';
import { FtrProviderContext } from '../../ftr_provider_context';

export enum JobState {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are const enums in ML which could be used instead of defining your own.
https://github.com/elastic/kibana/blob/master/x-pack/legacy/plugins/ml/common/constants/states.ts

If it's not possible to import from ML like that, i'd suggest you copy the style and make these constants upper case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great hint, thanks! Changed it in f32ca31

@@ -8,10 +8,24 @@ import expect from '@kbn/expect';
import { isEmpty } from 'lodash';
import { FtrProviderContext } from '../../ftr_provider_context';

export enum JobState {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are const enums in ML which could be used instead of defining your own.
https://github.com/elastic/kibana/blob/master/x-pack/legacy/plugins/ml/common/constants/states.ts

If it's not possible to import from ML like that, i'd suggest you copy the style and make these constants upper case.

.then((res: any) => res.body);

expect(jobStats.jobs).to.have.length(1);
const state = jobStats.jobs[0].state as JobState;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type assertion isn't needed here. this could be:
const state: JobState = jobStats.jobs[0].state;
or const state: JOB_STATE = jobStats.jobs[0].state; if the previous suggested change is made.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f32ca31

.then((res: any) => res.body);

expect(datafeedStats.datafeeds).to.have.length(1);
const state = datafeedStats.datafeeds[0].state as DatafeedState;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same suggestion as before about removing the as

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f32ca31

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, LGTM - approving to avoid being a blocker once the enum and typescript changes have been done.

Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just added suggestions/questions about some subject namings.

<EuiPanel paddingSize="m">
<EuiFlexGroup>
<EuiFlexItem>
{d.detector_description !== undefined ? (
<div style={{ fontWeight: 'bold' }}>{d.detector_description}</div>
<div style={{ fontWeight: 'bold' }} data-test-subj="detectorDescription">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this subject be mlDetectorDescription?

Copy link
Member Author

@pheyos pheyos Oct 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was originally planned to be nested subject only as it's not necessarily unique on its own, i.e. it's currently used as

mlAdvancedDetector ${detectorIndex} > detectorIdentifier

but it makes sense to keep our ml namespace here as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed in dfe2e17

@@ -166,3 +172,7 @@ const DuplicateDetectorsWarning: FC<{ validation: Validation }> = ({ validation
</Fragment>
);
};

const StringifiedDetector: FC<{ detector: Detector }> = ({ detector }) => {
return <div data-test-subj="detectorIdentifier">{detectorToString(detector)}</div>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this subject be mlDetectorIdentifier?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above, renamed in dfe2e17

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@pheyos pheyos merged commit 75384e1 into elastic:master Oct 29, 2019
@pheyos pheyos deleted the advanced_wizard_tests branch October 29, 2019 12:36
pheyos added a commit to pheyos/kibana that referenced this pull request Oct 29, 2019
This PR adds tests for the ML advanced wizard.
pheyos added a commit to pheyos/kibana that referenced this pull request Oct 29, 2019
This PR adds tests for the ML advanced wizard.
pheyos added a commit that referenced this pull request Oct 29, 2019
This PR adds tests for the ML advanced wizard.
pheyos added a commit that referenced this pull request Oct 29, 2019
This PR adds tests for the ML advanced wizard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:ml release_note:skip Skip the PR/issue when compiling release notes test_ui_functional v7.5.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants