Skip to content

Commit

Permalink
♻️ Refactor configureDimension function
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 committed Sep 24, 2020
1 parent cb75149 commit 3626d3e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 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 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
5 changes: 5 additions & 0 deletions 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 Down

0 comments on commit 3626d3e

Please sign in to comment.