Skip to content

Commit

Permalink
[Lens] Add drag drop tests (#88660) (#89100)
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 authored Jan 25, 2021
1 parent ddcd8a2 commit 0eee355
Show file tree
Hide file tree
Showing 3 changed files with 674 additions and 59 deletions.
153 changes: 94 additions & 59 deletions x-pack/test/functional/apps/lens/drag_and_drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,73 +11,108 @@ export default function ({ getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']);

describe('lens drag and drop tests', () => {
it('should construct the basic split xy chart', async () => {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVisType('lens');
await PageObjects.lens.goToTimeRange();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.lens.dragFieldToWorkspace('@timestamp');
describe('basic drag and drop', () => {
it('should construct the basic split xy chart', async () => {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVisType('lens');
await PageObjects.lens.goToTimeRange();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.lens.dragFieldToWorkspace('@timestamp');

expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql(
'@timestamp'
);
});
expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql(
'@timestamp'
);
});

it('should allow dropping fields to existing and empty dimension triggers', async () => {
await PageObjects.lens.switchToVisualization('lnsDatatable');
it('should allow dropping fields to existing and empty dimension triggers', async () => {
await PageObjects.lens.switchToVisualization('lnsDatatable');

await PageObjects.lens.dragFieldToDimensionTrigger(
'clientip',
'lnsDatatable_column > lns-dimensionTrigger'
);
expect(await PageObjects.lens.getDimensionTriggerText('lnsDatatable_column')).to.eql(
'Top values of clientip'
);
await PageObjects.lens.dragFieldToDimensionTrigger(
'clientip',
'lnsDatatable_column > lns-dimensionTrigger'
);
expect(await PageObjects.lens.getDimensionTriggerText('lnsDatatable_column')).to.eql(
'Top values of clientip'
);

await PageObjects.lens.dragFieldToDimensionTrigger(
'bytes',
'lnsDatatable_column > lns-empty-dimension'
);
expect(await PageObjects.lens.getDimensionTriggerText('lnsDatatable_column', 1)).to.eql(
'bytes'
);
await PageObjects.lens.dragFieldToDimensionTrigger(
'@message.raw',
'lnsDatatable_column > lns-empty-dimension'
);
expect(await PageObjects.lens.getDimensionTriggerText('lnsDatatable_column', 2)).to.eql(
'Top values of @message.raw'
);
});
await PageObjects.lens.dragFieldToDimensionTrigger(
'bytes',
'lnsDatatable_column > lns-empty-dimension'
);
expect(await PageObjects.lens.getDimensionTriggerText('lnsDatatable_column', 1)).to.eql(
'bytes'
);
await PageObjects.lens.dragFieldToDimensionTrigger(
'@message.raw',
'lnsDatatable_column > lns-empty-dimension'
);
expect(await PageObjects.lens.getDimensionTriggerText('lnsDatatable_column', 2)).to.eql(
'Top values of @message.raw'
);
});

it('should reorder the elements for the table', async () => {
await PageObjects.lens.reorderDimensions('lnsDatatable_column', 2, 0);
await PageObjects.header.waitUntilLoadingHasFinished();
expect(await PageObjects.lens.getDimensionTriggersTexts('lnsDatatable_column')).to.eql([
'Top values of @message.raw',
'Top values of clientip',
'bytes',
]);
});
it('should reorder the elements for the table', async () => {
await PageObjects.lens.reorderDimensions('lnsDatatable_column', 2, 0);
await PageObjects.header.waitUntilLoadingHasFinished();
expect(await PageObjects.lens.getDimensionTriggersTexts('lnsDatatable_column')).to.eql([
'Top values of @message.raw',
'Top values of clientip',
'bytes',
]);
});

it('should move the column to compatible dimension group', async () => {
await PageObjects.lens.switchToVisualization('bar');
expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql([
'Top values of @message.raw',
]);
expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')).to.eql([
'Top values of clientip',
]);
it('should move the column to compatible dimension group', async () => {
await PageObjects.lens.switchToVisualization('bar');
expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql([
'Top values of @message.raw',
]);
expect(
await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')
).to.eql(['Top values of clientip']);

await PageObjects.lens.dragDimensionToDimension(
'lnsXY_xDimensionPanel > lns-dimensionTrigger',
'lnsXY_splitDimensionPanel > lns-dimensionTrigger'
);

expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql(
[]
);
expect(
await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')
).to.eql(['Top values of @message.raw']);
});
});

await PageObjects.lens.dragDimensionToDimension(
'lnsXY_xDimensionPanel > lns-dimensionTrigger',
'lnsXY_splitDimensionPanel > lns-dimensionTrigger'
);
describe('workspace drop', () => {
it('should always nest time dimension in categorical dimension', async () => {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVisType('lens');
await PageObjects.lens.goToTimeRange();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.lens.dragFieldToWorkspace('@timestamp');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.lens.dragFieldToWorkspace('clientip');
await PageObjects.header.waitUntilLoadingHasFinished();
expect(
await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')
).to.eql(['Top values of clientip']);
await PageObjects.lens.openDimensionEditor(
'lnsXY_splitDimensionPanel > lns-dimensionTrigger'
);
expect(await PageObjects.lens.isTopLevelAggregation()).to.be(true);
await PageObjects.lens.closeDimensionEditor();
});

expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql([]);
expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')).to.eql([
'Top values of @message.raw',
]);
it('overwrite existing time dimension if one exists already', async () => {
await PageObjects.lens.dragFieldToWorkspace('utc_time');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.lens.dragFieldToWorkspace('clientip');
await PageObjects.header.waitUntilLoadingHasFinished();
expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql([
'utc_time',
]);
});
});
});
}
Loading

0 comments on commit 0eee355

Please sign in to comment.