Skip to content

Commit

Permalink
[visualize/_tsvb_time_series] fix flaky test (#44505) (#44971)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlemeshko authored Sep 6, 2019
1 parent de666a6 commit a5a834a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
1 change: 0 additions & 1 deletion test/functional/apps/visualize/_tsvb_time_series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
6 changes: 3 additions & 3 deletions test/functional/page_objects/visual_builder_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}

/**
Expand All @@ -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"]');
Expand Down
33 changes: 21 additions & 12 deletions test/functional/services/combo_box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
}
}

Expand Down

0 comments on commit a5a834a

Please sign in to comment.