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

[Maps] add functional test for category autocomplete #61386

Merged
merged 2 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export class ColorMapSelect extends Component {
{
value: CUSTOM_COLOR_MAP,
inputDisplay: this.props.customOptionLabel,
'data-test-subj': `colorMapSelectOption_${CUSTOM_COLOR_MAP}`,
},
...this.props.colorMapOptions,
];
Expand Down Expand Up @@ -150,6 +151,7 @@ export class ColorMapSelect extends Component {
onChange={this._onColorMapSelect}
valueOfSelected={valueOfSelected}
hasDividers={true}
data-test-subj={`colorMapSelect_${this.props.styleProperty.getStyleName()}`}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const ColorStopsCategorical = ({
getValueSuggestions={getValueSuggestions}
value={stopValue}
onChange={onStopChange}
dataTestSubj={`colorStopInput${index}`}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export function DynamicColorForm({
</EuiFlexItem>
<EuiFlexItem>
<FieldSelect
styleName={styleProperty.getStyleName()}
fields={fields}
selectedFieldName={styleProperty.getFieldName()}
onChange={onFieldChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function groupFieldsByOrigin(fields) {
return optionGroups;
}

export function FieldSelect({ fields, selectedFieldName, onChange, ...rest }) {
export function FieldSelect({ fields, selectedFieldName, onChange, styleName, ...rest }) {
const onFieldChange = selectedFields => {
onChange({
field: selectedFields.length > 0 ? selectedFields[0].value : null,
Expand All @@ -98,6 +98,7 @@ export function FieldSelect({ fields, selectedFieldName, onChange, ...rest }) {
defaultMessage: 'Select a field',
})}
renderOption={renderOption}
data-test-subj={`styleFieldSelect_${styleName}`}
{...rest}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function DynamicLabelForm({
</EuiFlexItem>
<EuiFlexItem>
<FieldSelect
styleName={styleProperty.getStyleName()}
fields={fields}
selectedFieldName={styleProperty.getFieldName()}
onChange={onFieldChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function DynamicOrientationForm({
</EuiFlexItem>
<EuiFlexItem>
<FieldSelect
styleName={styleProperty.getStyleName()}
fields={fields}
selectedFieldName={styleProperty.getFieldName()}
onChange={onFieldChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function DynamicSizeForm({
</EuiFlexItem>
<EuiFlexItem>
<FieldSelect
styleName={styleProperty.getStyleName()}
fields={fields}
selectedFieldName={styleProperty.getFieldName()}
onChange={onFieldChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export class StopInput extends Component {
isClearable={false}
isLoading={this.state.isLoadingSuggestions}
onFocus={this._onFocus}
data-test-subj={this.props.dataTestSubj}
compressed
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class StylePropEditor extends Component {
defaultMessage: 'Select to style by fixed value or by data value',
})}
compressed
data-test-subj={`staticDynamicSelect_${this.props.styleProperty.getStyleName()}`}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function DynamicIconForm({
</EuiFlexItem>
<EuiFlexItem>
<FieldSelect
styleName={styleProperty.getStyleName()}
fields={fields}
selectedFieldName={_.get(styleOptions, 'field.name')}
onChange={onFieldChange}
Expand Down
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/maps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function({ loadTestFile, getService }) {
this.tags('ciGroup7');
loadTestFile(require.resolve('./documents_source'));
loadTestFile(require.resolve('./blended_vector_layer'));
loadTestFile(require.resolve('./vector_styling'));
loadTestFile(require.resolve('./saved_object_management'));
loadTestFile(require.resolve('./sample_data'));
loadTestFile(require.resolve('./feature_controls/maps_security'));
Expand Down
35 changes: 35 additions & 0 deletions x-pack/test/functional/apps/maps/vector_styling.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';

export default function({ getPageObjects }) {
const PageObjects = getPageObjects(['maps']);

describe('vector styling', () => {
before(async () => {
await PageObjects.maps.loadSavedMap('document example');
});

describe('categorical styling', () => {
before(async () => {
await PageObjects.maps.openLayerPanel('logstash');
});

it('should provide auto complete suggestions', async () => {
await PageObjects.maps.setStyleByValue('fillColor', 'machine.os.raw');
await PageObjects.maps.selectCustomColorRamp('fillColor');
const suggestions = await PageObjects.maps.getCategorySuggestions();
expect(
suggestions
.trim()
.split('\n')
.join()
).to.equal('win 8,win xp,win 7,ios,osx');
});
});
});
}
16 changes: 16 additions & 0 deletions x-pack/test/functional/page_objects/gis_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,22 @@ export function GisPageProvider({ getService, getPageObjects }) {
}
});
}

async setStyleByValue(styleName, fieldName) {
await testSubjects.selectValue(`staticDynamicSelect_${styleName}`, 'DYNAMIC');
await comboBox.set(`styleFieldSelect_${styleName}`, fieldName);
}

async selectCustomColorRamp(styleName) {
// open super select menu
await testSubjects.click(`colorMapSelect_${styleName}`);
// Click option
await testSubjects.click(`colorMapSelectOption_CUSTOM_COLOR_MAP`);
}

async getCategorySuggestions() {
return await comboBox.getOptionsList(`colorStopInput1`);
}
}
return new GisPage();
}