Skip to content

Commit

Permalink
[ML] functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darnautov committed Jun 2, 2020
1 parent 9a2f734 commit d74e5a2
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const PopoverForm: React.FC<Props> = ({ defaultData, otherAggNames, onCha
}

return (
<EuiForm style={{ width: '300px' }}>
<EuiForm style={{ width: '300px' }} data-test-subj={'transformAggPopoverForm_' + aggName}>
<EuiFormRow
error={!validAggName && [aggNameError]}
isInvalid={!validAggName}
Expand All @@ -200,6 +200,7 @@ export const PopoverForm: React.FC<Props> = ({ defaultData, otherAggNames, onCha
defaultValue={aggName}
isInvalid={!validAggName}
onChange={(e) => setAggName(e.target.value)}
data-test-subj="transformAggName"
/>
</EuiFormRow>
{availableFields.length > 0 && (
Expand All @@ -212,6 +213,7 @@ export const PopoverForm: React.FC<Props> = ({ defaultData, otherAggNames, onCha
options={availableFields}
value={field}
onChange={(e) => setField(e.target.value)}
data-test-subj="transformAggField"
/>
</EuiFormRow>
)}
Expand All @@ -225,6 +227,7 @@ export const PopoverForm: React.FC<Props> = ({ defaultData, otherAggNames, onCha
options={availableAggs}
value={agg}
onChange={(e) => updateAgg(e.target.value as PivotSupportedAggs)}
data-test-subj="transformAggType"
/>
</EuiFormRow>
)}
Expand Down Expand Up @@ -273,7 +276,11 @@ export const PopoverForm: React.FC<Props> = ({ defaultData, otherAggNames, onCha
/>
)}
<EuiFormRow hasEmptyLabelSpace>
<EuiButton isDisabled={!formValid} onClick={() => onChange(getUpdatedItem())}>
<EuiButton
isDisabled={!formValid}
onClick={() => onChange(getUpdatedItem())}
data-test-subj="applyTransformAggChanges"
>
{i18n.translate('xpack.transform.agg.popoverForm.submitButtonLabel', {
defaultMessage: 'Apply',
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const FilterAggForm: PivotAggsConfigFilter['AggFormComponent'] = ({
aggTypeConfig: getFilterAggTypeConfig(filterAgg),
});
}}
data-test-subj="filterAggTypeSelector"
/>
</EuiFormRow>
{filterAggTypeConfig?.FilterAggFormComponent && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const FilterTermForm: FilterAggConfigTerm['aggTypeConfig']['FilterAggForm
});
}}
onSearchChange={debounce(onSearchChange, 600)}
data-test-subj="filterTermValueSelection"
data-test-subj="filterTermValueSelector"
/>
</EuiFormRow>
);
Expand Down
31 changes: 30 additions & 1 deletion x-pack/test/functional/apps/transform/creation_index_pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ export default function ({ getService }: FtrProviderContext) {
identifier: 'avg(products.base_price)',
label: 'products.base_price.avg',
},
{
identifier: 'filter(geoip.city_name)',
label: 'geoip.city_name.filter',
form: {
filterAggTypeSelector: 'term',
filterTermValueSelector: 'New York',
},
},
],
transformId: `ec_1_${Date.now()}`,
transformDescription:
Expand Down Expand Up @@ -79,6 +87,13 @@ export default function ({ getService }: FtrProviderContext) {
field: 'products.base_price',
},
},
'geoip.city_name.filter': {
filter: {
term: {
'geoip.city_name': 'New York',
},
},
},
},
},
pivotPreview: {
Expand Down Expand Up @@ -110,6 +125,13 @@ export default function ({ getService }: FtrProviderContext) {
identifier: 'percentiles(products.base_price)',
label: 'products.base_price.percentiles',
},
{
identifier: 'filter(customer_phone)',
label: 'customer_phone.filter',
form: {
filterAggTypeSelector: 'exists',
},
},
],
transformId: `ec_2_${Date.now()}`,
transformDescription:
Expand All @@ -134,6 +156,13 @@ export default function ({ getService }: FtrProviderContext) {
percents: [1, 5, 25, 50, 75, 95, 99],
},
},
'customer_phone.filter': {
filter: {
exists: {
field: 'customer_phone',
},
},
},
},
},
pivotPreview: {
Expand Down Expand Up @@ -223,7 +252,7 @@ export default function ({ getService }: FtrProviderContext) {
for (const [index, agg] of testData.aggregationEntries.entries()) {
await transform.wizard.assertAggregationInputExists();
await transform.wizard.assertAggregationInputValue([]);
await transform.wizard.addAggregationEntry(index, agg.identifier, agg.label);
await transform.wizard.addAggregationEntry(index, agg.identifier, agg.label, agg.form);
}
});

Expand Down
40 changes: 39 additions & 1 deletion x-pack/test/functional/services/transform/wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,48 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
);
},

async addAggregationEntry(index: number, identifier: string, expectedLabel: string) {
async addAggregationEntry(
index: number,
identifier: string,
expectedLabel: string,
formData?: Record<string, any>
) {
await comboBox.set('transformAggregationSelection > comboBoxInput', identifier);
await this.assertAggregationInputValue([]);
await this.assertAggregationEntryExists(index, expectedLabel);

if (formData !== undefined) {
await this.fillPopoverForm(identifier, expectedLabel, formData);
}
},

async fillPopoverForm(
identifier: string,
expectedLabel: string,
formData: Record<string, any>
) {
await testSubjects.existOrFail(`transformAggPopoverForm_${expectedLabel}`);

for (const [testObj, value] of Object.entries(formData)) {
switch (testObj) {
case 'filterAggTypeSelector':
await this.selectFilerAggType(value);
break;
case 'filterTermValueSelector':
await this.fillFilterTermValue(value);
break;
}
}
await testSubjects.clickWhenNotDisabled('applyTransformAggChanges');
await testSubjects.missingOrFail(`transformAggPopoverForm_${expectedLabel}`);
},

async selectFilerAggType(value: string) {
await testSubjects.selectValue('filterAggTypeSelector', value);
},

async fillFilterTermValue(value: string) {
await comboBox.set('filterTermValueSelector', value);
},

async assertAdvancedPivotEditorContent(expectedValue: string[]) {
Expand Down

0 comments on commit d74e5a2

Please sign in to comment.