feat: add generic type to column payload (#14547)

* feat: add generic type to column payload

* feat: add generic type to column payload

* xit flaky test
This commit is contained in:
Ville Brofeldt
2021-05-13 09:36:09 +03:00
committed by GitHub
parent ad699e8b48
commit 3f6bd1e4a4
15 changed files with 466 additions and 357 deletions

View File

@@ -20,10 +20,11 @@ import React from 'react';
import { shallow } from 'enzyme';
import { ColumnTypeLabel } from '@superset-ui/chart-controls';
import { GenericDataType } from '@superset-ui/core';
describe('ColumnOption', () => {
const defaultProps = {
type: 'string',
type: GenericDataType.STRING,
};
const props = { ...defaultProps };
@@ -44,12 +45,16 @@ describe('ColumnOption', () => {
expect(lbl.first().text()).toBe('ABC');
});
it('int type shows # icon', () => {
const lbl = getWrapper({ type: 'int(164)' }).find('.type-label');
const lbl = getWrapper({
type: GenericDataType.NUMERIC,
}).find('.type-label');
expect(lbl).toHaveLength(1);
expect(lbl.first().text()).toBe('#');
});
it('bool type shows T/F icon', () => {
const lbl = getWrapper({ type: 'BOOL' }).find('.type-label');
const lbl = getWrapper({
type: GenericDataType.BOOLEAN,
}).find('.type-label');
expect(lbl).toHaveLength(1);
expect(lbl.first().text()).toBe('T/F');
});
@@ -64,7 +69,9 @@ describe('ColumnOption', () => {
expect(lbl.first().text()).toBe('?');
});
it('datetime type displays', () => {
const lbl = getWrapper({ type: 'datetime' }).find('.fa-clock-o');
const lbl = getWrapper({
type: GenericDataType.TEMPORAL,
}).find('.fa-clock-o');
expect(lbl).toHaveLength(1);
});
});

View File

@@ -17,7 +17,7 @@
* under the License.
*/
import { ColumnMeta } from '@superset-ui/chart-controls';
import { ColumnType } from '@superset-ui/core';
import { GenericDataType } from '@superset-ui/core';
export const columns: ColumnMeta[] = [
{
@@ -29,7 +29,8 @@ export const columns: ColumnMeta[] = [
id: 516,
is_dttm: false,
python_date_format: null,
type: ColumnType.DOUBLE,
type: 'DOUBLE',
type_generic: GenericDataType.NUMERIC,
verbose_name: null,
},
{
@@ -42,7 +43,8 @@ export const columns: ColumnMeta[] = [
id: 477,
is_dttm: false,
python_date_format: null,
type: ColumnType.STRING,
type: 'VARCHAR',
type_generic: GenericDataType.STRING,
verbose_name: null,
},
{
@@ -54,7 +56,8 @@ export const columns: ColumnMeta[] = [
id: 516,
is_dttm: false,
python_date_format: null,
type: ColumnType.DOUBLE,
type: 'INT',
type_generic: GenericDataType.NUMERIC,
verbose_name: null,
},
];