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



##########
File path: 
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterOption/AdhocFilterOption.test.tsx
##########
@@ -0,0 +1,90 @@
+/**
+ * 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 userEvent from '@testing-library/user-event';
+import { HTML5Backend } from 'react-dnd-html5-backend';
+import { DndProvider } from 'react-dnd';
+import AdhocFilter, {
+  EXPRESSION_TYPES,
+  CLAUSES,
+} from 'src/explore/components/controls/FilterControl/AdhocFilter';
+import AdhocFilterOption from '.';
+
+const simpleAdhocFilter = new AdhocFilter({
+  expressionType: EXPRESSION_TYPES.SIMPLE,
+  subject: 'value',
+  operator: '>',
+  comparator: '10',
+  clause: CLAUSES.WHERE,
+});
+
+const options = [
+  { type: 'VARCHAR(255)', column_name: 'source', id: 1 },
+  { type: 'VARCHAR(255)', column_name: 'target', id: 2 },
+  { type: 'DOUBLE', column_name: 'value', id: 3 },
+];
+
+const mockedProps = {
+  adhocFilter: simpleAdhocFilter,
+  onFilterEdit: jest.fn(),
+  options,
+};
+
+const setup = (props: {
+  adhocFilter: typeof simpleAdhocFilter;
+  onFilterEdit: () => void;
+  options: {
+    type: string;
+    column_name: string;
+    id: number;
+  }[];
+}) => (
+  <DndProvider backend={HTML5Backend}>
+    <AdhocFilterOption {...props} />
+  </DndProvider>
+);
+
+test('should render', () => {
+  const { container } = render(setup(mockedProps));
+  expect(container).toBeInTheDocument();
+});
+
+test('should render the control label', () => {
+  render(setup(mockedProps));
+  expect(screen.getByText('value > 10')).toBeInTheDocument();
+});
+
+test('should render the remove button', () => {
+  render(setup(mockedProps));
+  const removeBtn = screen.getByRole('button');
+  expect(removeBtn).toBeInTheDocument();
+});
+
+test('should render the right caret', () => {
+  render(setup(mockedProps));
+  expect(screen.getByTestId('caret-right')).toBeInTheDocument();

Review comment:
       ```suggestion
     expect(screen.getByRole('img', { name: 'caret-right' 
})).toBeInTheDocument();
   ```

##########
File path: 
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterOption/index.jsx
##########
@@ -20,10 +20,10 @@ import React from 'react';
 import PropTypes from 'prop-types';
 import adhocMetricType from 
'src/explore/components/controls/MetricControl/adhocMetricType';
 import { OptionControlLabel } from 'src/explore/components/OptionControls';
-import columnType from './columnType';
-import AdhocFilterPopoverTrigger from './AdhocFilterPopoverTrigger';
-import AdhocFilter from './AdhocFilter';
-import { DndItemType } from '../../DndItemType';
+import AdhocFilterPopoverTrigger from 
'src/explore/components/controls/FilterControl/AdhocFilterPopoverTrigger';
+import AdhocFilter from 
'src/explore/components/controls/FilterControl/AdhocFilter';
+import columnType from 
'src/explore/components/controls/FilterControl/columnType';
+import { DndItemType } from '../../../DndItemType';

Review comment:
       ```suggestion
   import { DndItemType } from 'src/explore/components/DndItemType';
   ```

##########
File path: 
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterOption/AdhocFilterOption.test.tsx
##########
@@ -0,0 +1,90 @@
+/**
+ * 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 userEvent from '@testing-library/user-event';
+import { HTML5Backend } from 'react-dnd-html5-backend';
+import { DndProvider } from 'react-dnd';
+import AdhocFilter, {
+  EXPRESSION_TYPES,
+  CLAUSES,
+} from 'src/explore/components/controls/FilterControl/AdhocFilter';
+import AdhocFilterOption from '.';
+
+const simpleAdhocFilter = new AdhocFilter({
+  expressionType: EXPRESSION_TYPES.SIMPLE,
+  subject: 'value',
+  operator: '>',
+  comparator: '10',
+  clause: CLAUSES.WHERE,
+});
+
+const options = [
+  { type: 'VARCHAR(255)', column_name: 'source', id: 1 },
+  { type: 'VARCHAR(255)', column_name: 'target', id: 2 },
+  { type: 'DOUBLE', column_name: 'value', id: 3 },
+];
+
+const mockedProps = {
+  adhocFilter: simpleAdhocFilter,
+  onFilterEdit: jest.fn(),
+  options,
+};
+
+const setup = (props: {
+  adhocFilter: typeof simpleAdhocFilter;
+  onFilterEdit: () => void;
+  options: {
+    type: string;
+    column_name: string;
+    id: number;
+  }[];
+}) => (
+  <DndProvider backend={HTML5Backend}>
+    <AdhocFilterOption {...props} />
+  </DndProvider>
+);
+
+test('should render', () => {
+  const { container } = render(setup(mockedProps));
+  expect(container).toBeInTheDocument();
+});
+
+test('should render the control label', () => {
+  render(setup(mockedProps));
+  expect(screen.getByText('value > 10')).toBeInTheDocument();
+});
+
+test('should render the remove button', () => {
+  render(setup(mockedProps));
+  const removeBtn = screen.getByRole('button');
+  expect(removeBtn).toBeInTheDocument();
+});
+
+test('should render the right caret', () => {
+  render(setup(mockedProps));
+  expect(screen.getByTestId('caret-right')).toBeInTheDocument();
+});
+
+test('should render the Popover on clicking the right caret', () => {
+  render(setup(mockedProps));
+  const rightCaret = screen.getByTestId('caret-right');

Review comment:
       ```suggestion
     const rightCaret = screen.getByRole('img', { name: 'caret-right' });
   ```




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