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

Fix Lens smokescreen flaky tests #78566

Merged
merged 4 commits into from
Sep 28, 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 @@ -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 All @@ -76,6 +72,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 @@ -107,14 +104,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 @@ -129,7 +124,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
1
);

await PageObjects.lens.closeDimensionEditor();
await PageObjects.lens.configureDimension(
{
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
Expand All @@ -139,7 +133,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 @@ -168,8 +161,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 @@ -186,14 +177,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 @@ -205,7 +194,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
1
);

await PageObjects.lens.closeDimensionEditor();
await PageObjects.lens.configureDimension(
{
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
Expand All @@ -215,7 +203,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 @@ -301,15 +288,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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this fixes the issue, what was the race condition? Can we fix that some other way?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dej611 Are you aware of the queryInput service which is used for dashboard tests? I think it might simplify this whole test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've improved the comment here to explain the context of the bug.
Perhaps some other fix is possible, but the double Tab one is the most consistent from tests, as it safely closes the dropdown without auto-completing the query field.

// 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