From 485b0c275e6b274f2665a8f2da0c1f388447c87a Mon Sep 17 00:00:00 2001 From: michellethomas Date: Tue, 27 Mar 2018 17:54:24 -0700 Subject: [PATCH] Fixing label issue when columnType is null (#4700) --- .../javascripts/components/ColumnOption.jsx | 2 +- .../components/ColumnOption_spec.jsx | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/superset/assets/javascripts/components/ColumnOption.jsx b/superset/assets/javascripts/components/ColumnOption.jsx index 0a16db6869..11fca0088b 100644 --- a/superset/assets/javascripts/components/ColumnOption.jsx +++ b/superset/assets/javascripts/components/ColumnOption.jsx @@ -24,7 +24,7 @@ export default function ColumnOption({ column, showType }) { return ( - {showType && } + {showType && columnType && } {column.verbose_name || column.column_name} diff --git a/superset/assets/spec/javascripts/components/ColumnOption_spec.jsx b/superset/assets/spec/javascripts/components/ColumnOption_spec.jsx index 4768f16e94..d8f6ada663 100644 --- a/superset/assets/spec/javascripts/components/ColumnOption_spec.jsx +++ b/superset/assets/spec/javascripts/components/ColumnOption_spec.jsx @@ -47,8 +47,14 @@ describe('ColumnOption', () => { expect(wrapper.find('.option-label').first().text()).to.equal('foo'); }); it('shows a column type label when showType is true', () => { - props.showType = true; - wrapper = shallow(factory(props)); + wrapper = shallow(factory({ + ...props, + showType: true, + column: { + expression: null, + type: 'str', + }, + })); expect(wrapper.find(ColumnTypeLabel)).to.have.length(1); }); it('column with expression has correct column label if showType is true', () => { @@ -57,6 +63,17 @@ describe('ColumnOption', () => { expect(wrapper.find(ColumnTypeLabel)).to.have.length(1); expect(wrapper.find(ColumnTypeLabel).props().type).to.equal('expression'); }); + it('shows no column type label when type is null', () => { + wrapper = shallow(factory({ + ...props, + showType: true, + column: { + expression: null, + type: null, + }, + })); + expect(wrapper.find(ColumnTypeLabel)).to.have.length(0); + }); it('dttm column has correct column label if showType is true', () => { props.showType = true; props.column.is_dttm = true;