You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/09/01 09:29:46 UTC

[GitHub] [superset] geido commented on a change in pull request #16510: chore: Select component refactoring - SelectControl - Iteration 5

geido commented on a change in pull request #16510:
URL: https://github.com/apache/superset/pull/16510#discussion_r699335114



##########
File path: superset-frontend/spec/javascripts/explore/components/SelectControl_spec.jsx
##########
@@ -48,58 +48,27 @@ describe('SelectControl', () => {
     wrapper = shallow(<SelectControl {...defaultProps} />);
   });
 
-  it('uses Select in onPasteSelect when freeForm=false', () => {

Review comment:
       The OnPasteSelect is not used with the new Select component. These tests are included later checking whether `allowNewOptions` is `true` or `false` based on the SelectControl `freeForm` option.

##########
File path: superset-frontend/spec/javascripts/explore/components/SelectControl_spec.jsx
##########
@@ -48,58 +48,27 @@ describe('SelectControl', () => {
     wrapper = shallow(<SelectControl {...defaultProps} />);
   });
 
-  it('uses Select in onPasteSelect when freeForm=false', () => {
-    wrapper = shallow(<SelectControl {...defaultProps} multi />);
-    const select = wrapper.find(OnPasteSelect);
-    expect(select.props().selectWrap).toBe(Select);
-  });
-
-  it('uses Creatable in onPasteSelect when freeForm=true', () => {
-    wrapper = shallow(<SelectControl {...defaultProps} multi freeForm />);
-    const select = wrapper.find(OnPasteSelect);
-    expect(select.props().selectWrap).toBe(CreatableSelect);
-  });
-
   it('calls props.onChange when select', () => {
     const select = wrapper.instance();
-    select.onChange({ value: 50 });
+    select.onChange(50);
     expect(defaultProps.onChange.calledWith(50)).toBe(true);
   });
 
-  it('returns all options on select all', () => {

Review comment:
       The "Select all" option has been removed as agreed with design and all the related tests have been removed as well

##########
File path: superset-frontend/spec/javascripts/explore/components/SelectControl_spec.jsx
##########
@@ -161,16 +130,6 @@ describe('SelectControl', () => {
         );
         expect(wrapper.html()).not.toContain('add something');
       });
-      it('shows numbers of options as a placeholder by default', () => {

Review comment:
       The number of options and remaining options has been removed as agreed with design and all the related tests have been removed as well

##########
File path: superset-frontend/spec/javascripts/explore/components/SelectControl_spec.jsx
##########
@@ -186,82 +145,12 @@ describe('SelectControl', () => {
     });
   });
 
-  describe('optionsRemaining', () => {
-    describe('isMulti', () => {
-      it('returns the options minus selected values', () => {
-        const wrapper = mount(
-          <SelectControl {...defaultProps} multi value={['today']} />,
-        );
-        expect(wrapper.instance().optionsRemaining()).toEqual(1);
-      });
-    });
-    describe('is not multi', () => {
-      it('returns the length of all options', () => {
-        wrapper = mount(
-          <SelectControl
-            {...defaultProps}
-            value={50}
-            placeholder="add something"
-          />,
-        );
-        expect(wrapper.instance().optionsRemaining()).toEqual(2);
-      });
-    });
-    describe('with Select all', () => {
-      it('does not count it', () => {
-        const props = { ...defaultProps, multi: true, allowAll: true };
-        const wrapper = mount(<SelectControl {...props} />);
-        expect(wrapper.instance().getOptions(props).length).toEqual(3);
-        expect(wrapper.instance().optionsRemaining()).toEqual(2);
-      });
-    });
-  });
-
   describe('getOptions', () => {
     it('returns the correct options', () => {
       wrapper.setProps(defaultProps);
       expect(wrapper.instance().getOptions(defaultProps)).toEqual(options);
     });
-
-    it('shows Select-All when enabled', () => {
-      const selectAllProps = {
-        choices: ['one', 'two'],
-        name: 'name',
-        freeForm: true,
-        allowAll: true,
-        multi: true,
-        valueKey: 'value',
-      };
-      wrapper.setProps(selectAllProps);
-      expect(wrapper.instance().getOptions(selectAllProps)).toContainEqual({
-        label: 'Select all',
-        meta: true,
-        value: 'Select all',
-      });
-    });
-
-    it('returns the correct options when freeform is set to true', () => {

Review comment:
       This test is not necessary with the new Select component as it is a standard behavior

##########
File path: superset-frontend/src/explore/components/controls/SelectControl.jsx
##########
@@ -18,22 +18,21 @@
  */
 import React from 'react';
 import PropTypes from 'prop-types';
-import { t, css } from '@superset-ui/core';
-import { Select, CreatableSelect, OnPasteSelect } from 'src/components/Select';
+import { css } from '@superset-ui/core';
+import { Select } from 'src/components';
 import ControlHeader from 'src/explore/components/ControlHeader';
 
 const propTypes = {
+  ariaLabel: PropTypes.string,

Review comment:
       All props here are cleaned and then mapped with the Select ones. This is to minimize impact as the SelectControl component is used dynamically throughout Superset and Superset-ui




-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org