mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
fix(charts): add X Axis Number Format control for numeric X-axis columns (#38809)
Co-authored-by: codeant-ai-for-open-source[bot] <244253245+codeant-ai-for-open-source[bot]@users.noreply.github.com>
(cherry picked from commit e0a0a22542)
This commit is contained in:
committed by
Michael S. Molina
parent
850c33fa6b
commit
ddb285b4c3
@@ -407,6 +407,119 @@ describe('ControlPanelsContainer', () => {
|
||||
getChartControlPanelRegistry().remove('line');
|
||||
});
|
||||
|
||||
test('should stash control value when visibility is false and disableStash is not set', async () => {
|
||||
getChartControlPanelRegistry().remove('table');
|
||||
getChartControlPanelRegistry().registerValue('table', {
|
||||
controlPanelSections: [
|
||||
{
|
||||
label: t('Query'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
[
|
||||
{
|
||||
name: 'x_axis_time_format',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('Time Format'),
|
||||
default: 'smart_date',
|
||||
choices: [['smart_date', 'Adaptive Formatting']],
|
||||
visibility: () => false,
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const props = getDefaultProps();
|
||||
props.form_data = {
|
||||
...props.form_data,
|
||||
x_axis_time_format: 'smart_date',
|
||||
};
|
||||
|
||||
const { getByTestId } = render(
|
||||
<>
|
||||
<ControlPanelsContainer {...props} />
|
||||
<FormDataMock />
|
||||
</>,
|
||||
{
|
||||
useRedux: true,
|
||||
initialState: {
|
||||
explore: {
|
||||
form_data: {
|
||||
...defaultState.form_data,
|
||||
x_axis_time_format: 'smart_date',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(getByTestId('mock-formdata')).not.toHaveTextContent(
|
||||
'x_axis_time_format',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('should preserve control value when visibility is false and disableStash is true', async () => {
|
||||
getChartControlPanelRegistry().remove('table');
|
||||
getChartControlPanelRegistry().registerValue('table', {
|
||||
controlPanelSections: [
|
||||
{
|
||||
label: t('Query'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
[
|
||||
{
|
||||
name: 'x_axis_time_format',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('Time Format'),
|
||||
default: 'smart_date',
|
||||
choices: [['smart_date', 'Adaptive Formatting']],
|
||||
visibility: () => false,
|
||||
disableStash: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const props = getDefaultProps();
|
||||
props.form_data = {
|
||||
...props.form_data,
|
||||
x_axis_time_format: 'smart_date',
|
||||
};
|
||||
|
||||
const { getByTestId } = render(
|
||||
<>
|
||||
<ControlPanelsContainer {...props} />
|
||||
<FormDataMock />
|
||||
</>,
|
||||
{
|
||||
useRedux: true,
|
||||
initialState: {
|
||||
explore: {
|
||||
form_data: {
|
||||
...defaultState.form_data,
|
||||
x_axis_time_format: 'smart_date',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(getByTestId('mock-formdata')).toHaveTextContent(
|
||||
'x_axis_time_format',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('should not show Matrixify tab for table chart types', async () => {
|
||||
// Enable Matrixify feature flag
|
||||
mockIsFeatureEnabled.mockImplementation(
|
||||
|
||||
Reference in New Issue
Block a user