michael-s-molina commented on a change in pull request #14371:
URL: https://github.com/apache/superset/pull/14371#discussion_r621138106



##########
File path: 
superset-frontend/src/dashboard/components/gridComponents/ChartHolder.test.tsx
##########
@@ -0,0 +1,92 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React from 'react';
+import { render, screen } from 'spec/helpers/testing-library';
+import { Provider } from 'react-redux';
+import { getMockStore, mockStore } from 'spec/fixtures/mockStore';
+import { sliceId as chartId } from 'spec/fixtures/mockChartQueries';
+import newComponentFactory from 'src/dashboard/util/newComponentFactory';
+import { DndProvider } from 'react-dnd';
+import { HTML5Backend } from 'react-dnd-html5-backend';
+import userEvent from '@testing-library/user-event';
+import { waitFor } from '@testing-library/react';
+import { ChartHolder } from './index';
+import { CHART_TYPE, ROW_TYPE } from '../../util/componentTypes';
+
+describe('ChartHolder', () => {
+  const defaultProps = {
+    component: {
+      ...newComponentFactory(CHART_TYPE),
+      id: 'CHART_ID',
+      parents: ['ROOT_ID', 'TABS_ID', 'TAB_ID', 'ROW_ID'],
+      meta: {
+        chartId,
+        width: 3,
+        height: 10,
+        chartName: 'Mock chart name',
+      },
+    },
+    parentComponent: {
+      ...newComponentFactory(ROW_TYPE),
+      id: 'ROW_ID',
+      children: ['COLUMN_ID'],
+    },
+    index: 0,
+    depth: 0,
+    id: 'CHART_ID',
+    parentId: 'ROW_ID',
+    availableColumnCount: 12,
+    columnWidth: 300,
+    onResizeStart: () => {},
+    onResize: () => {},
+    onResizeStop: () => {},
+    handleComponentDrop: () => {},
+    deleteComponent: () => {},
+    updateComponents: () => {},
+    editMode: false,
+    isComponentVisible: true,
+    dashboardId: 123,
+  };
+
+  const renderWrapper = (props = defaultProps, state?: object) =>

Review comment:
       You can use:
   
   ```
   const renderWrapper = (props = defaultProps, state?: object) =>
       render(<ChartHolder {...props} />, { useRedux: true, initialState: 
state, useDnd: true });
   ```

##########
File path: 
superset-frontend/src/dashboard/components/gridComponents/ChartHolder.test.tsx
##########
@@ -0,0 +1,92 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React from 'react';
+import { render, screen } from 'spec/helpers/testing-library';
+import { Provider } from 'react-redux';
+import { getMockStore, mockStore } from 'spec/fixtures/mockStore';
+import { sliceId as chartId } from 'spec/fixtures/mockChartQueries';
+import newComponentFactory from 'src/dashboard/util/newComponentFactory';
+import { DndProvider } from 'react-dnd';
+import { HTML5Backend } from 'react-dnd-html5-backend';
+import userEvent from '@testing-library/user-event';
+import { waitFor } from '@testing-library/react';
+import { ChartHolder } from './index';
+import { CHART_TYPE, ROW_TYPE } from '../../util/componentTypes';
+
+describe('ChartHolder', () => {
+  const defaultProps = {
+    component: {
+      ...newComponentFactory(CHART_TYPE),
+      id: 'CHART_ID',
+      parents: ['ROOT_ID', 'TABS_ID', 'TAB_ID', 'ROW_ID'],
+      meta: {
+        chartId,
+        width: 3,
+        height: 10,
+        chartName: 'Mock chart name',
+      },
+    },
+    parentComponent: {
+      ...newComponentFactory(ROW_TYPE),
+      id: 'ROW_ID',
+      children: ['COLUMN_ID'],
+    },
+    index: 0,
+    depth: 0,
+    id: 'CHART_ID',
+    parentId: 'ROW_ID',
+    availableColumnCount: 12,
+    columnWidth: 300,
+    onResizeStart: () => {},
+    onResize: () => {},
+    onResizeStop: () => {},
+    handleComponentDrop: () => {},
+    deleteComponent: () => {},
+    updateComponents: () => {},
+    editMode: false,
+    isComponentVisible: true,
+    dashboardId: 123,
+  };
+
+  const renderWrapper = (props = defaultProps, state?: object) =>
+    render(
+      <Provider store={state ? getMockStore(state) : mockStore}>
+        <DndProvider backend={HTML5Backend}>
+          <ChartHolder {...props} />
+        </DndProvider>
+      </Provider>,
+    );
+
+  it('toggle full size', async () => {
+    renderWrapper();
+    // @ts-ignore
+    let chart = screen.getByTestId('slice-container')?.firstChild?.style;

Review comment:
       You can use the `!` (exclamation) to indicate to typescript that `chart` 
will not be `null`. So you don't need to add the `?` (question mark) every time 
`chart` is involved. 
   
   `let chart = screen.getByTestId('slice-container')?.firstChild?.style!; <-- 
exclamation here`
   
   I think it would also be nice to rename `chart` to `chartStyle`.

##########
File path: 
superset-frontend/src/dashboard/components/SliceHeaderControls/index.jsx
##########
@@ -32,6 +32,7 @@ import getDashboardUrl from 
'src/dashboard/util/getDashboardUrl';
 import { getActiveFilters } from 'src/dashboard/util/activeDashboardFilters';
 import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags';
 import CrossFilterScopingModal from 
'src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingModal';
+import { FullscreenExitOutlined } from '@ant-design/icons';

Review comment:
       Can you use the `src/components/Icons` instead of importing directly 
from AntD? All icons are available there.
   
   ```
   import Icons from 'src/components/Icons';
   
   <Icons.FullscreenExitOutlined ... />
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to