Skip to content

Commit

Permalink
change interaction with 'select' element
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlemeshko committed Sep 18, 2019
1 parent 70d2777 commit 69d1ce1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
3 changes: 1 addition & 2 deletions test/functional/apps/visualize/_point_series_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ export default function ({ getService, getPageObjects }) {
});

describe('multiple chart types', function () {
// FLAKY: https://github.com/elastic/kibana/issues/45970
it.skip('should change average series type to histogram', async function () {
it('should change average series type to histogram', async function () {
await pointSeriesVis.setSeriesType(1, 'histogram');
await PageObjects.visualize.clickGo();
const length = await pointSeriesVis.getHistogramSeries();
Expand Down
21 changes: 10 additions & 11 deletions test/functional/page_objects/point_series_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export function PointSeriesPageProvider({ getService }) {

class PointSeriesVis {
async clickOptions() {
return await find.clickByPartialLinkText('Panel settings');
return await testSubjects.click('visEditorTaboptions');
}

async clickAxisOptions() {
return await find.clickByPartialLinkText('Metrics & axes');
return await testSubjects.click('visEditorTabadvanced');
}

async clickAddAxis() {
Expand All @@ -50,17 +50,16 @@ export function PointSeriesPageProvider({ getService }) {
}

async getGridLines() {
const gridLines = await find.allByCssSelector('g.grid > path');

return await Promise.all(gridLines.map(async (gridLine) => {
const dAttribute = await gridLine.getAttribute('d');

const grid = await find.byCssSelector('g.grid');
const $ = await grid.parseDomContent();
return $('path').toArray().map(line => {
const dAttribute = $(line).attr('d');
const firstPoint = dAttribute.split('L')[0].replace('M', '').split(',');
return {
x: parseFloat(firstPoint[0]),
y: parseFloat(firstPoint[1]),
};
}));
});
}

async toggleGridCategoryLines() {
Expand All @@ -69,15 +68,15 @@ export function PointSeriesPageProvider({ getService }) {

async setGridValueAxis(axis) {
log.debug(`setGridValueAxis(${axis})`);
return await find.clickByCssSelector(`select#gridAxis option[value="${axis}"]`);
await find.selectValue('select#gridAxis', axis);
}

async setSeriesAxis(series, axis) {
await find.clickByCssSelector(`select#seriesValueAxis${series} option[value="${axis}"]`);
await find.selectValue(`select#seriesValueAxis${series}`, axis);
}

async setSeriesType(series, type) {
await find.clickByCssSelector(`select#seriesType${series} option[value="${type}"]`);
await find.selectValue(`select#seriesType${series}`, type);
}
}

Expand Down
4 changes: 1 addition & 3 deletions test/functional/page_objects/visualize_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,7 @@ export function VisualizePageProvider({ getService, getPageObjects, updateBaseli
}

async selectAggregateWith(fieldValue) {
const sortSelect = await testSubjects.find(`visDefaultEditorAggregateWith`);
const sortMetric = await sortSelect.findByCssSelector(`option[value="${fieldValue}"]`);
await sortMetric.click();
await testSubjects.selectValue('visDefaultEditorAggregateWith', fieldValue);
}

async getInterval() {
Expand Down
8 changes: 8 additions & 0 deletions test/functional/services/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ export async function FindProvider({ getService }: FtrProviderContext) {
});
}

public async selectValue(selector: string, value: string): Promise<void> {
log.debug(`Find.selectValue('${selector}', option[value="${value}"]')`);
const combobox = await this.byCssSelector(selector);
const $ = await combobox.parseDomContent();
const text = $(`option[value="${value}"]`).text();
await combobox.type(text);
}

public async filterElementIsDisplayed(elements: WebElementWrapper[]) {
if (elements.length === 0) {
return [];
Expand Down
4 changes: 4 additions & 0 deletions test/functional/services/test_subjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) {
});
}

public async selectValue(selector: string, value: string): Promise<void> {
await find.selectValue(`[data-test-subj="${selector}"]`, value);
}

public async isEnabled(selector: string): Promise<boolean> {
return await retry.try(async () => {
log.debug(`TestSubjects.isEnabled(${selector})`);
Expand Down
4 changes: 1 addition & 3 deletions x-pack/test/functional/page_objects/gis_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,7 @@ export function GisPageProvider({ getService, getPageObjects }) {

async setIndexType(indexType) {
log.debug(`Set index type to: ${indexType}`);
await find.clickByCssSelector(
`select[data-test-subj="fileImportIndexSelect"] > option[value="${indexType}"]`
);
await testSubjects.selectValue('fileImportIndexSelect', indexType);
}

async indexTypeOptionExists(indexType) {
Expand Down

0 comments on commit 69d1ce1

Please sign in to comment.