Skip to content

Commit 8c051c8

Browse files
committed
fix: Do not reset formatting when switching between custom ranges and auto histogram #82694
1 parent 11ce62b commit 8c051c8

File tree

1 file changed

+5
-33
lines changed
  • x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges

1 file changed

+5
-33
lines changed

x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -748,17 +748,6 @@ describe('ranges', () => {
748748

749749
it('should not reset formatters when switching between custom ranges and auto histogram', () => {
750750
const setStateSpy = jest.fn();
751-
(state.layers.first.columns.col1 as RangeIndexPatternColumn).params.ranges.push({
752-
from: null,
753-
to: null,
754-
label: '',
755-
});
756-
757-
// set a default formatter for the sourceField used
758-
state.indexPatterns['1'].fieldFormatMap = {
759-
MyField: { id: 'custom', params: {} },
760-
};
761-
762751
// now set a format on the range operation
763752
(state.layers.first.columns.col1 as RangeIndexPatternColumn).params.format = {
764753
id: 'custom',
@@ -778,29 +767,12 @@ describe('ranges', () => {
778767

779768
// This series of act closures are made to make it work properly the update flush
780769
act(() => {
781-
instance.find('.euiLink').first().prop('onClick')!({} as ReactMouseEvent);
770+
instance.find(EuiLink).first().prop('onClick')!({} as ReactMouseEvent);
771+
});
782772

783-
expect(setStateSpy).toHaveBeenCalledWith({
784-
...state,
785-
layers: {
786-
first: {
787-
...state.layers.first,
788-
columns: {
789-
...state.layers.first.columns,
790-
col1: {
791-
...state.layers.first.columns.col1,
792-
params: {
793-
...state.layers.first.columns.col1.params,
794-
format: {
795-
id: 'custom',
796-
params: { decimals: 3 },
797-
},
798-
},
799-
},
800-
},
801-
},
802-
},
803-
});
773+
expect(setStateSpy.mock.calls[1][0].layers.first.columns.col1.params.format).toEqual({
774+
id: 'custom',
775+
params: { decimals: 3 },
804776
});
805777
});
806778
});

0 commit comments

Comments
 (0)