[visualize/_tsvb_time_series] fix flaky test (#44505) (#44971)

This commit is contained in:
Dmitry Lemeshko 2019-09-06 12:56:02 +02:00 committed by GitHub
parent de666a6984
commit a5a834a3d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 16 deletions

View file

@ -108,7 +108,6 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
expect(actualCount).to.be(expectedLegendValue);
});
// FLAKY: https://github.com/elastic/kibana/issues/40458
it('should show the correct count in the legend with "Human readable" duration formatter', async () => {
await visualBuilder.clickSeriesOption();
await visualBuilder.changeDataFormatter('Duration');

View file

@ -239,7 +239,7 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
formatter: 'Bytes' | 'Number' | 'Percent' | 'Duration' | 'Custom'
) {
const formatterEl = await find.byCssSelector('[id$="row"] .euiComboBox');
await comboBox.setElement(formatterEl, formatter);
await comboBox.setElement(formatterEl, formatter, { clickWithMouse: true });
}
/**
@ -260,11 +260,11 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
}) {
if (from) {
const fromCombobox = await find.byCssSelector('[id$="from-row"] .euiComboBox');
await comboBox.setElement(fromCombobox, from);
await comboBox.setElement(fromCombobox, from, { clickWithMouse: true });
}
if (to) {
const toCombobox = await find.byCssSelector('[id$="to-row"] .euiComboBox');
await comboBox.setElement(toCombobox, to);
await comboBox.setElement(toCombobox, to, { clickWithMouse: true });
}
if (decimalPlaces) {
const decimalPlacesInput = await find.byCssSelector('[id$="decimal"]');

View file

@ -46,13 +46,21 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont
await this.setElement(comboBox, value);
}
private async clickOption(isMouseClick: boolean, element: WebElementWrapper) {
return isMouseClick ? await browser.clickMouseButton(element) : await element.click();
}
/**
* set value inside combobox element
*
* @param comboBoxElement
* @param value
*/
public async setElement(comboBoxElement: WebElementWrapper, value: string): Promise<void> {
public async setElement(
comboBoxElement: WebElementWrapper,
value: string,
options = { clickWithMouse: false }
): Promise<void> {
log.debug(`comboBox.setElement, value: ${value}`);
const isOptionSelected = await this.isOptionSelected(comboBoxElement, value);
@ -65,21 +73,22 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont
await this.openOptionsList(comboBoxElement);
if (value !== undefined) {
const options = await find.allByCssSelector(
const selectOptions = await find.allByCssSelector(
`.euiFilterSelectItem[title^="${value.toString().trim()}"]`,
WAIT_FOR_EXISTS_TIME
);
if (options.length > 0) {
await options[0].click();
if (selectOptions.length > 0) {
await this.clickOption(options.clickWithMouse, selectOptions[0]);
} else {
// if it doesn't find the item which text starts with value, it will choose the first option
await find.clickByCssSelector('.euiFilterSelectItem');
const firstOption = await find.byCssSelector('.euiFilterSelectItem');
await this.clickOption(options.clickWithMouse, firstOption);
}
} else {
await find.clickByCssSelector('.euiFilterSelectItem');
const firstOption = await find.byCssSelector('.euiFilterSelectItem');
await this.clickOption(options.clickWithMouse, firstOption);
}
await this.closeOptionsList(comboBoxElement);
}
@ -241,11 +250,11 @@ export function ComboBoxProvider({ getService, getPageObjects }: FtrProviderCont
value: string
): Promise<boolean> {
log.debug(`comboBox.isOptionSelected, value: ${value}`);
const selectedOptions = await comboBoxElement.findAllByClassName(
'euiComboBoxPill',
WAIT_FOR_EXISTS_TIME
);
return selectedOptions.length === 1 && (await selectedOptions[0].getVisibleText()) === value;
const $ = await comboBoxElement.parseDomContent();
const selectedOptions = $('.euiComboBoxPill')
.toArray()
.map(option => $(option).text());
return selectedOptions.length === 1 && selectedOptions[0] === value;
}
}