This is an automated email from the ASF dual-hosted git repository.

graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 1f8fccc  [explore] fix missing CacheLabel (#4326)
1f8fccc is described below

commit 1f8fccc0f923de0b119b22303e504e9efeeff417
Author: Maxime Beauchemin <maximebeauche...@gmail.com>
AuthorDate: Fri Feb 2 10:28:38 2018 -0800

    [explore] fix missing CacheLabel (#4326)
    
    Also adding a basic unit test.
---
 .../explore/components/ExploreChartHeader.jsx      | 21 +++++-------
 .../explore/components/ExploreChartHeader_spec.jsx | 40 ++++++++++++++++++++++
 2 files changed, 48 insertions(+), 13 deletions(-)

diff --git 
a/superset/assets/javascripts/explore/components/ExploreChartHeader.jsx 
b/superset/assets/javascripts/explore/components/ExploreChartHeader.jsx
index 30b4799..0faf164 100644
--- a/superset/assets/javascripts/explore/components/ExploreChartHeader.jsx
+++ b/superset/assets/javascripts/explore/components/ExploreChartHeader.jsx
@@ -74,7 +74,7 @@ class ExploreChartHeader extends React.PureComponent {
       json_endpoint: getExploreUrl(formData, 'json'),
       standalone_endpoint: getExploreUrl(formData, 'standalone'),
     };
-
+    const chartSucceeded = ['success', 
'rendered'].indexOf(this.props.chart.chartStatus) > 0;
     return (
       <div
         id="slice-header"
@@ -115,21 +115,16 @@ class ExploreChartHeader extends React.PureComponent {
           />
         }
         <div className="pull-right">
-          {this.props.chart.chartStatus === 'success' && queryResponse &&
+          {chartSucceeded && queryResponse &&
             <RowCountLabel
               rowcount={queryResponse.rowcount}
               limit={formData.row_limit}
-            />
-          }
-          {this.props.chart.chartStatus === 'success' &&
-          queryResponse &&
-          queryResponse.is_cached &&
-
-          <CachedLabel
-            onClick={this.runQuery.bind(this)}
-            cachedTimestamp={queryResponse.cached_dttm}
-          />
-          }
+            />}
+          {chartSucceeded && queryResponse && queryResponse.is_cached &&
+            <CachedLabel
+              onClick={this.runQuery.bind(this)}
+              cachedTimestamp={queryResponse.cached_dttm}
+            />}
           <Timer
             startTime={this.props.chart.chartUpdateStartTime}
             endTime={this.props.chart.chartUpdateEndTime}
diff --git 
a/superset/assets/spec/javascripts/explore/components/ExploreChartHeader_spec.jsx
 
b/superset/assets/spec/javascripts/explore/components/ExploreChartHeader_spec.jsx
new file mode 100644
index 0000000..2875e83
--- /dev/null
+++ 
b/superset/assets/spec/javascripts/explore/components/ExploreChartHeader_spec.jsx
@@ -0,0 +1,40 @@
+import React from 'react';
+import { expect } from 'chai';
+import { describe, it } from 'mocha';
+import { shallow } from 'enzyme';
+
+import ExploreChartHeader from 
'../../../../javascripts/explore/components/ExploreChartHeader';
+import ExploreActionButtons from 
'../../../../javascripts/explore/components/ExploreActionButtons';
+import EditableTitle from '../../../../javascripts/components/EditableTitle';
+
+const mockProps = {
+  actions: {},
+  can_overwrite: true,
+  can_download: true,
+  isStarred: true,
+  slice: {},
+  table_name: 'foo',
+  form_data: {},
+  timeout: 1000,
+  chart: {
+    queryResponse: {},
+  },
+};
+
+describe('ExploreChartHeader', () => {
+  let wrapper;
+  beforeEach(() => {
+    wrapper = shallow(<ExploreChartHeader {...mockProps} />);
+  });
+
+  it('is valid', () => {
+    expect(
+      React.isValidElement(<ExploreChartHeader {...mockProps} />),
+    ).to.equal(true);
+  });
+
+  it('renders', () => {
+    expect(wrapper.find(EditableTitle)).to.have.lengthOf(1);
+    expect(wrapper.find(ExploreActionButtons)).to.have.lengthOf(1);
+  });
+});

-- 
To stop receiving notification emails like this one, please contact
grace...@apache.org.

Reply via email to