Skip to content

Commit

Permalink
[ML] Add single metric job wizard test (#42709)
Browse files Browse the repository at this point in the history
This PR adds functional UI tests to create a machine learning job using the single metric wizard.
  • Loading branch information
pheyos authored Aug 7, 2019
1 parent 4df31cf commit c9e6a2c
Show file tree
Hide file tree
Showing 39 changed files with 1,923 additions and 131 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ export const FullTimeRangeSelector: FC<Props> = ({ indexPattern, query, disabled
}
}
return (
<EuiButton fill isDisabled={disabled} onClick={() => setRange(indexPattern, query)}>
<EuiButton
fill
isDisabled={disabled}
onClick={() => setRange(indexPattern, query)}
data-test-subj="mlButtonUseFullData"
>
<FormattedMessage
id="xpack.ml.fullTimeRangeSelector.useFullDataButtonLabel"
defaultMessage="Use full {indexPatternTitle} data"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ml-new-job class="index-or-saved-search-selection">
<ml-message-bar></ml-message-bar>
<div class='kuiViewContent kuiViewContent--constrainedWidth kuiViewContentItem' >
<div ng-controller="MlNewJobStepIndexOrSearch" class="visWizard">
<div ng-controller="MlNewJobStepIndexOrSearch" class="visWizard" data-test-subj="mlPageSourceSelection">
<div class="visWizard__column visWizard__column--small">
<h3
class="kuiTitle kuiVerticalRhythm"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ml-nav-menu name="new_job" />
<ml-new-job class="job-type-gallery">
<ml-message-bar></ml-message-bar>
<div ng-controller="MlNewJobStepJobType">
<div ng-controller="MlNewJobStepJobType" data-test-subj="mlPageJobTypeSelection">
<!-- Presents the various options for creating a job -->
<div class="job-types-content">
<h1
Expand Down Expand Up @@ -214,7 +214,7 @@
</a>
</div>
<div class="euiFlexItem" ng-class='{disabled: isTimeBasedIndex===false}'>
<a ng-href="{{getUrl('#jobs/new_job/new_new_job/single_metric')}}" ng-class='{disabled: isTimeBasedIndex===false}' class="euiLink synopsis">
<a ng-href="{{getUrl('#jobs/new_job/new_new_job/single_metric')}}" ng-class='{disabled: isTimeBasedIndex===false}' class="euiLink synopsis" data-test-subj="mlJobTypeLinkSingleMetricJob">
<div class="euiPanel euiPanel--paddingMedium synopsisPanel">
<div class="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--responsive">
<div class="euiFlexItem euiFlexItem--flexGrowZero">
Expand Down Expand Up @@ -246,7 +246,7 @@
</a>
</div>
<div class="euiFlexItem" ng-class='{disabled: isTimeBasedIndex===false}'>
<a ng-href="{{getUrl('#jobs/new_job/new_new_job/multi_metric')}}" ng-class='{disabled: isTimeBasedIndex===false}' class="euiLink synopsis">
<a ng-href="{{getUrl('#jobs/new_job/new_new_job/multi_metric')}}" ng-class='{disabled: isTimeBasedIndex===false}' class="euiLink synopsis" data-test-subj="mlJobTypeLinkMultiMetricJob">
<div class="euiPanel euiPanel--paddingMedium synopsisPanel">
<div class="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--responsive">
<div class="euiFlexItem euiFlexItem--flexGrowZero">
Expand Down Expand Up @@ -278,7 +278,7 @@
</a>
</div>
<div class="euiFlexItem" ng-class='{disabled: isTimeBasedIndex===false}'>
<a ng-href="{{getUrl('#jobs/new_job/new_new_job/population')}}" ng-class='{disabled: isTimeBasedIndex===false}' class="euiLink synopsis">
<a ng-href="{{getUrl('#jobs/new_job/new_new_job/population')}}" ng-class='{disabled: isTimeBasedIndex===false}' class="euiLink synopsis" data-test-subj="mlJobTypeLinkPopulationJob">
<div class="euiPanel euiPanel--paddingMedium synopsisPanel">
<div class="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--responsive">
<div class="euiFlexItem euiFlexItem--flexGrowZero">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const AnomalyChart: FC<Props> = ({

const xDomain = getXRange(data);
return (
<div style={{ width, height }}>
<div style={{ width, height }} data-test-subj="mlAnomalyChart">
<Chart>
<Settings xDomain={xDomain} tooltip={TooltipType.None} />
<Axes chartData={data} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const SPEC_ID = 'event_rate';

export const EventRateChart: FC<Props> = ({ eventRateChartData, height, width, showAxis }) => {
return (
<div style={{ width, height }}>
<div style={{ width, height }} data-test-subj="mlEventRateChart">
<Chart>
{showAxis === true && <Axes />}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ export const AdvancedSection: FC<Props> = ({ advancedExpanded, setAdvancedExpand
buttonContent={ButtonContent}
onToggle={setAdvancedExpanded}
initialIsOpen={advancedExpanded}
data-test-subj="mlJobWizardToggleAdvancedSection"
>
<EuiSpacer />
<EuiFlexGroup gutterSize="xl" style={{ marginLeft: '0px', marginRight: '0px' }}>
<EuiFlexGroup
gutterSize="xl"
style={{ marginLeft: '0px', marginRight: '0px' }}
data-test-subj="mlJobWizardAdvancedSection"
>
<EuiFlexItem>
<ModelPlotSwitch />
<ModelMemoryLimitInput />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export const DedicatedIndexSwitch: FC = () => {

return (
<Description>
<EuiSwitch name="switch" checked={useDedicatedIndex} onChange={toggleModelPlot} />
<EuiSwitch
name="switch"
checked={useDedicatedIndex}
onChange={toggleModelPlot}
data-test-subj="mlJobWizardSwitchUseDedicatedIndex"
/>
</Description>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const ModelMemoryLimitInput: FC = () => {
value={modelMemoryLimit}
onChange={e => setModelMemoryLimit(e.target.value)}
isInvalid={validation.valid === false}
data-test-subj="mlJobWizardInputModelMemoryLimit"
/>
</Description>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export const ModelPlotSwitch: FC = () => {

return (
<Description>
<EuiSwitch name="switch" checked={modelPlotEnabled} onChange={toggleModelPlot} />
<EuiSwitch
name="switch"
checked={modelPlotEnabled}
onChange={toggleModelPlot}
data-test-subj="mlJobWizardSwitchModelPlot"
/>
</Description>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const GroupsInput: FC = () => {
onCreateOption={onCreateGroup}
isClearable={true}
isInvalid={validation.valid === false}
data-test-subj="mlJobWizardComboBoxJobGroups"
/>
</Description>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const JobDescriptionInput: FC = () => {
placeholder="Job description"
value={jobDescription}
onChange={e => setJobDescription(e.target.value)}
data-test-subj="mlJobWizardInputJobDescription"
/>
</Description>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const JobIdInput: FC = () => {
value={jobId}
onChange={e => setJobId(e.target.value)}
isInvalid={validation.valid === false}
data-test-subj="mlJobWizardInputJobId"
/>
</Description>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export const AggSelect: FC<Props> = ({ fields, changeHandler, selectedOptions, r
}, [jobValidatorUpdated]);

return (
<EuiFormRow error={validation.message} isInvalid={validation.valid === false}>
<EuiFormRow
error={validation.message}
isInvalid={validation.valid === false}
data-test-subj="mlJobWizardAggSelection"
>
<EuiComboBox
singleSelection={{ asPlainText: true }}
options={options}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const BucketSpanInput: FC<Props> = ({ bucketSpan, setBucketSpan, isInvali
value={bucketSpan}
onChange={e => setBucketSpan(e.target.value)}
isInvalid={isInvalid}
data-test-subj="mlJobWizardInputBucketSpan"
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,21 @@ export const SummaryStep: FC<StepProps> = ({ setCurrentStep, isCurrentStep }) =>
<EuiHorizontalRule />
{progress < 100 && (
<Fragment>
<EuiButton onClick={start} isDisabled={progress > 0} disabled={isValid === false}>
<EuiButton
onClick={start}
isDisabled={progress > 0}
disabled={isValid === false}
data-test-subj="mlJobWizardButtonCreateJob"
>
Create job
</EuiButton>
&emsp;
<EuiButtonEmpty size="s" onClick={toggleJsonFlyout} isDisabled={progress > 0}>
<EuiButtonEmpty
size="s"
onClick={toggleJsonFlyout}
isDisabled={progress > 0}
data-test-subj="mlJobWizardButtonPreviewJobJson"
>
Preview job JSON
</EuiButtonEmpty>
{showJsonFlyout && (
Expand All @@ -92,7 +102,9 @@ export const SummaryStep: FC<StepProps> = ({ setCurrentStep, isCurrentStep }) =>
)}
{progress > 0 && (
<Fragment>
<EuiButton onClick={viewResults}>View results</EuiButton>
<EuiButton onClick={viewResults} data-test-subj="mlJobWizardButtonViewResults">
View results
</EuiButton>
</Fragment>
)}
</Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ export const WizardNav: FC<StepsNavProps> = ({
<EuiFlexItem />
{previous && (
<EuiFlexItem grow={false}>
<EuiButton disabled={!previousActive} onClick={previous} iconType="arrowLeft" size="s">
<EuiButton
disabled={!previousActive}
onClick={previous}
iconType="arrowLeft"
size="s"
data-test-subj="mlJobWizardNavButtonPrevious"
>
{i18n.translate('xpack.ml.newJob.wizard.previousStepButton', {
defaultMessage: 'Previous',
})}
Expand All @@ -36,7 +42,13 @@ export const WizardNav: FC<StepsNavProps> = ({
)}
{next && (
<EuiFlexItem grow={false}>
<EuiButton disabled={!nextActive} onClick={next} iconType="arrowRight" size="s">
<EuiButton
disabled={!nextActive}
onClick={next}
iconType="arrowRight"
size="s"
data-test-subj="mlJobWizardNavButtonNext"
>
{i18n.translate('xpack.ml.newJob.wizard.nextStepButton', {
defaultMessage: 'Next',
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const Page: FC<PageProps> = ({ existingJobsAndGroups, jobType }) => {

return (
<Fragment>
<EuiPage style={{ backgroundColor: '#FFF' }}>
<EuiPage style={{ backgroundColor: '#FFF' }} data-test-subj="mlPageJobWizard">
<EuiPageBody>
<EuiPageContentBody>
<Wizard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export const Wizard: FC<Props> = ({

{currentStep === WIZARD_STEPS.TIME_RANGE && (
<Fragment>
<Title>Time range</Title>
<Title data-test-subj="mlJobWizardStepTitleTimeRange">Time range</Title>
<TimeRangeStep
isCurrentStep={currentStep === WIZARD_STEPS.TIME_RANGE}
setCurrentStep={setCurrentStep}
Expand All @@ -185,7 +185,7 @@ export const Wizard: FC<Props> = ({
)}
{currentStep === WIZARD_STEPS.PICK_FIELDS && (
<Fragment>
<Title>Pick fields</Title>
<Title data-test-subj="mlJobWizardStepTitlePickFields">Pick fields</Title>
<PickFieldsStep
isCurrentStep={currentStep === WIZARD_STEPS.PICK_FIELDS}
setCurrentStep={setCurrentStep}
Expand All @@ -194,7 +194,7 @@ export const Wizard: FC<Props> = ({
)}
{currentStep === WIZARD_STEPS.JOB_DETAILS && (
<Fragment>
<Title>Job details</Title>
<Title data-test-subj="mlJobWizardStepTitleJobDetails">Job details</Title>
<JobDetailsStep
isCurrentStep={currentStep === WIZARD_STEPS.JOB_DETAILS}
setCurrentStep={setCurrentStep}
Expand All @@ -207,7 +207,7 @@ export const Wizard: FC<Props> = ({
)}
{currentStep === WIZARD_STEPS.VALIDATION && (
<Fragment>
<Title>Validation</Title>
<Title data-test-subj="mlJobWizardStepTitleValidation">Validation</Title>
<ValidationStep
isCurrentStep={currentStep === WIZARD_STEPS.VALIDATION}
setCurrentStep={setCurrentStep}
Expand All @@ -216,7 +216,7 @@ export const Wizard: FC<Props> = ({
)}
{currentStep === WIZARD_STEPS.SUMMARY && (
<Fragment>
<Title>Summary</Title>
<Title data-test-subj="mlJobWizardStepTitleSummary">Summary</Title>
<SummaryStep
isCurrentStep={currentStep === WIZARD_STEPS.SUMMARY}
setCurrentStep={setCurrentStep}
Expand All @@ -227,11 +227,11 @@ export const Wizard: FC<Props> = ({
);
};

const Title: FC = ({ children }) => {
const Title: FC<{ 'data-test-subj': string }> = ({ 'data-test-subj': dataTestSubj, children }) => {
return (
<Fragment>
<EuiTitle>
<h2>{children}</h2>
<h2 data-test-subj={dataTestSubj}>{children}</h2>
</EuiTitle>
<EuiSpacer />
</Fragment>
Expand Down
Loading

0 comments on commit c9e6a2c

Please sign in to comment.