Skip to content

Commit

Permalink
[Lens] Fix transition from unique count to last value
Browse files Browse the repository at this point in the history
  • Loading branch information
wylieconlon committed Jan 20, 2021
1 parent f4f6cb6 commit bb690db
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,7 @@ describe('state_helpers', () => {
expect(errors).toHaveLength(1);
});

it('should consider incompleteColumns before layer columns', () => {
it('should ignore incompleteColumns when checking for errors', () => {
const savedRef = jest.fn().mockReturnValue(['error 1']);
const incompleteRef = jest.fn();
operationDefinitionMap.testReference.getErrorMessage = savedRef;
Expand All @@ -2197,9 +2197,9 @@ describe('state_helpers', () => {
col1: { operationType: 'testIncompleteReference' },
},
});
expect(savedRef).not.toHaveBeenCalled();
expect(incompleteRef).toHaveBeenCalled();
expect(errors).toBeUndefined();
expect(savedRef).toHaveBeenCalled();
expect(incompleteRef).not.toHaveBeenCalled();
expect(errors).toHaveLength(1);

delete operationDefinitionMap.testIncompleteReference;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,11 +867,7 @@ export function updateLayerIndexPattern(
export function getErrorMessages(layer: IndexPatternLayer): string[] | undefined {
const errors: string[] = [];
Object.entries(layer.columns).forEach(([columnId, column]) => {
// If we're transitioning to another operation, check for "new" incompleteColumns rather
// than "old" saved operation on the layer
const columnFinalRef =
layer.incompleteColumns?.[columnId]?.operationType || column.operationType;
const def = operationDefinitionMap[columnFinalRef];
const def = operationDefinitionMap[column.operationType];
if (def.getErrorMessage) {
errors.push(...(def.getErrorMessage(layer, columnId) ?? []));
}
Expand Down
21 changes: 21 additions & 0 deletions x-pack/test/functional/apps/lens/smokescreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
);
});

it('should transition from unique count to last value', async () => {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVisType('lens');
await PageObjects.lens.goToTimeRange();

await PageObjects.lens.configureDimension({
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
operation: 'cardinality',
field: 'ip',
});
await PageObjects.lens.configureDimension({
dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger',
operation: 'last_value',
field: 'bytes',
});

expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql(
'Last value of bytes'
);
});

it('should allow to change index pattern', async () => {
await PageObjects.lens.switchFirstLayerIndexPattern('log*');
expect(await PageObjects.lens.getFirstLayerIndexPattern()).to.equal('log*');
Expand Down

0 comments on commit bb690db

Please sign in to comment.