Skip to content

Commit

Permalink
fix transition issue (#132956) (#133714)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit b02b172)

Co-authored-by: Joe Reuter <johannes.reuter@elastic.co>
  • Loading branch information
kibanamachine and flash1293 authored Jun 7, 2022
1 parent b093f0f commit 70ed6c7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,39 @@ describe('state_helpers', () => {
);
});

it('should set incompleteColumns without crashing when switching to a field-based operation from managed reference column with custom label', () => {
expect(
replaceColumn({
layer: {
indexPatternId: '1',
columnOrder: ['col1'],
columns: {
col1: {
label: 'My formula',
dataType: 'number',
isBucketed: false,
customLabel: true,

// Private
operationType: 'formula',
} as FormulaIndexPatternColumn,
},
},
columnId: 'col1',
indexPattern,
op: 'median',
visualizationGroups: [],
})
).toEqual(
expect.objectContaining({
columns: { col1: expect.objectContaining({ operationType: 'formula' }) },
incompleteColumns: {
col1: { operationType: 'median' },
},
})
);
});

it('should carry over params from old column if switching fields', () => {
expect(
replaceColumn({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ export function replaceColumn({
if (
!shouldResetLabel &&
previousColumn.customLabel &&
hypotheticalLayer.columns[columnId] &&
previousColumn.label !==
previousDefinition.getDefaultLabel(previousColumn, indexPattern, tempLayer.columns)
) {
Expand Down

0 comments on commit 70ed6c7

Please sign in to comment.