Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lens] Do not reset formatting when switching between custom ranges and auto histogram #82694

Merged
merged 8 commits into from
Nov 10, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,36 @@ describe('ranges', () => {
/^Bytes format:/
);
});

it('should not reset formatters when switching between custom ranges and auto histogram', () => {
const setStateSpy = jest.fn();
// now set a format on the range operation
(state.layers.first.columns.col1 as RangeIndexPatternColumn).params.format = {
id: 'custom',
params: { decimals: 3 },
};

const instance = mount(
<InlineOptions
{...defaultOptions}
state={state}
setState={setStateSpy}
columnId="col1"
currentColumn={state.layers.first.columns.col1 as RangeIndexPatternColumn}
layerId="first"
/>
);

// This series of act closures are made to make it work properly the update flush
act(() => {
instance.find(EuiLink).first().prop('onClick')!({} as ReactMouseEvent);
});

expect(setStateSpy.mock.calls[1][0].layers.first.columns.col1.params.format).toEqual({
id: 'custom',
params: { decimals: 3 },
});
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export const rangeOperation: OperationDefinition<RangeIndexPatternColumn, 'field
type: newMode,
ranges: [{ from: 0, to: DEFAULT_INTERVAL, label: '' }],
maxBars: maxBarsDefaultValue,
format: undefined,
format: currentColumn.params.format,
parentFormat,
},
},
Expand Down