mirror of
https://github.com/apache/superset.git
synced 2026-04-18 15:44:57 +00:00
fix: pivot v2 charts created before GENERIC_CHART_AXES is enabled (#23731)
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { TimeGranularity } from '@superset-ui/core';
|
||||
import * as supersetCoreModule from '@superset-ui/core';
|
||||
import buildQuery from '../../src/plugin/buildQuery';
|
||||
import { PivotTableQueryFormData } from '../../src/types';
|
||||
|
||||
@@ -55,4 +57,29 @@ describe('PivotTableChart buildQuery', () => {
|
||||
const [query] = queryContext.queries;
|
||||
expect(query.columns).toEqual(['col1', 'col2', 'row1', 'row2']);
|
||||
});
|
||||
|
||||
it('should work with old charts after GENERIC_CHART_AXES is enabled', () => {
|
||||
Object.defineProperty(supersetCoreModule, 'hasGenericChartAxes', {
|
||||
value: true,
|
||||
});
|
||||
const modifiedFormData = {
|
||||
...formData,
|
||||
time_grain_sqla: TimeGranularity.MONTH,
|
||||
granularity_sqla: 'col1',
|
||||
};
|
||||
const queryContext = buildQuery(modifiedFormData);
|
||||
const [query] = queryContext.queries;
|
||||
expect(query.columns).toEqual([
|
||||
{
|
||||
timeGrain: 'P1M',
|
||||
columnType: 'BASE_AXIS',
|
||||
sqlExpression: 'col1',
|
||||
label: 'col1',
|
||||
expressionType: 'SQL',
|
||||
},
|
||||
'col2',
|
||||
'row1',
|
||||
'row2',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user