Skip to content

Commit

Permalink
Fix Lens smokescreen flaky tests (#78566)
Browse files Browse the repository at this point in the history
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
dej611 and elasticmachine authored Sep 28, 2020
1 parent 37d49b0 commit c285287
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,18 @@ export default function ({ getPageObjects, getService }) {
operation: 'date_histogram',
field: '@timestamp',
});
await PageObjects.lens.closeDimensionEditor();

await PageObjects.lens.configureDimension({
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
operation: 'avg',
field: 'bytes',
});
await PageObjects.lens.closeDimensionEditor();

await PageObjects.lens.configureDimension({
dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension',
operation: 'terms',
field: 'ip',
});
await PageObjects.lens.closeDimensionEditor();
await PageObjects.lens.save(title, saveAsNew, redirectToOrigin);
}

Expand Down
3 changes: 0 additions & 3 deletions x-pack/test/functional/apps/lens/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
operation: 'date_histogram',
field: '@timestamp',
});
await PageObjects.lens.closeDimensionEditor();

await PageObjects.lens.configureDimension({
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
operation: 'sum',
field: 'bytes',
});
await PageObjects.lens.closeDimensionEditor();

await PageObjects.lens.configureDimension({
dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension',
operation: 'terms',
field: 'geo.src',
});
await PageObjects.lens.closeDimensionEditor();
expect(await find.allByCssSelector('.echLegendItem')).to.have.length(2);

await PageObjects.lens.save('Afancilenstest');
Expand Down
17 changes: 1 addition & 16 deletions x-pack/test/functional/apps/lens/smokescreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
operation: 'date_histogram',
field: '@timestamp',
});
await PageObjects.lens.closeDimensionEditor();

await PageObjects.lens.configureDimension({
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
operation: 'avg',
field: 'bytes',
});
await PageObjects.lens.closeDimensionEditor();

await PageObjects.lens.configureDimension({
dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension',
operation: 'terms',
field: '@message.raw',
});
await PageObjects.lens.closeDimensionEditor();

await PageObjects.lens.switchToVisualization('lnsDatatable');
await PageObjects.lens.removeDimension('lnsDatatable_column');
Expand All @@ -50,7 +47,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
operation: 'terms',
field: 'ip',
});
await PageObjects.lens.closeDimensionEditor();

await PageObjects.lens.save('Afancilenstest');

Expand Down Expand Up @@ -78,6 +74,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
dimension: 'lnsXY_splitDimensionPanel > lns-dimensionTrigger',
operation: 'filters',
isPreviousIncompatible: true,
keepOpen: true,
});
await PageObjects.lens.addFilterToAgg(`geo.src : CN`);

Expand Down Expand Up @@ -110,14 +107,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
field: '@timestamp',
});

await PageObjects.lens.closeDimensionEditor();
await PageObjects.lens.configureDimension({
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
operation: 'avg',
field: 'bytes',
});

await PageObjects.lens.closeDimensionEditor();
await PageObjects.lens.createLayer();

expect(await PageObjects.lens.hasChartSwitchWarning('line')).to.eql(false);
Expand All @@ -132,7 +127,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
1
);

await PageObjects.lens.closeDimensionEditor();
await PageObjects.lens.configureDimension(
{
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
Expand All @@ -142,7 +136,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
1
);

await PageObjects.lens.closeDimensionEditor();
expect(await PageObjects.lens.getLayerCount()).to.eql(2);
await testSubjects.click('lnsLayerRemove');
await testSubjects.click('lnsLayerRemove');
Expand Down Expand Up @@ -171,8 +164,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

await testSubjects.existOrFail('indexPattern-dimension-formatDecimals');

await PageObjects.lens.closeDimensionEditor();

expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql(
'Test of label'
);
Expand All @@ -189,14 +180,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
field: 'geo.dest',
});

await PageObjects.lens.closeDimensionEditor();
await PageObjects.lens.configureDimension({
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
operation: 'avg',
field: 'bytes',
});

await PageObjects.lens.closeDimensionEditor();
await PageObjects.lens.createLayer();

await PageObjects.lens.configureDimension(
Expand All @@ -208,7 +197,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
1
);

await PageObjects.lens.closeDimensionEditor();
await PageObjects.lens.configureDimension(
{
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
Expand All @@ -218,7 +206,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
1
);

await PageObjects.lens.closeDimensionEditor();
await PageObjects.lens.save('twolayerchart');
await testSubjects.click('lnsSuggestion-asDonut > lnsSuggestion');

Expand Down Expand Up @@ -304,15 +291,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
operation: 'date_histogram',
field: '@timestamp',
});
await PageObjects.lens.closeDimensionEditor();

await PageObjects.lens.configureDimension({
dimension: 'lnsPie_sizeByDimensionPanel > lns-empty-dimension',
operation: 'avg',
field: 'bytes',
});

await PageObjects.lens.closeDimensionEditor();
expect(await PageObjects.lens.hasChartSwitchWarning('lnsDatatable')).to.eql(false);
await PageObjects.lens.switchToVisualization('lnsDatatable');

Expand Down
16 changes: 15 additions & 1 deletion x-pack/test/functional/page_objects/lens_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
operation: string;
field?: string;
isPreviousIncompatible?: boolean;
keepOpen?: boolean;
},
layerIndex = 0
) {
Expand All @@ -107,6 +108,10 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
await comboBox.openOptionsList(target);
await comboBox.setElement(target, opts.field);
}

if (!opts.keepOpen) {
this.closeDimensionEditor();
}
},

// closes the dimension editor flyout
Expand All @@ -127,7 +132,16 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
await testSubjects.click('lns-newBucket-add');
const queryInput = await testSubjects.find('indexPattern-filters-queryStringInput');
await queryInput.type(queryString);
await PageObjects.common.pressEnterKey();
// Problem here is that after typing in the queryInput a dropdown will fetch the server
// with suggestions and show up. Depending on the cursor position and some other factors
// pressing Enter at this point may lead to auto-complete the queryInput with random stuff from the
// dropdown which was not intended originally.
// To close the Filter popover we need to move to the label input and then press Enter:
// solution is to press Tab 2 twice (first Tab will close the dropdown) instead of Enter to avoid
// race condition with the dropdown
await PageObjects.common.pressTabKey();
await PageObjects.common.pressTabKey();
// Now it is safe to press Enter as we're in the label input
await PageObjects.common.pressEnterKey();
await PageObjects.common.sleep(1000); // give time for debounced components to rerender
},
Expand Down

0 comments on commit c285287

Please sign in to comment.