You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ly...@apache.org on 2023/01/30 23:42:42 UTC

[superset] branch lyndsi/clean-up-adhocfilteroption-test created (now f80125f126)

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

lyndsi pushed a change to branch lyndsi/clean-up-adhocfilteroption-test
in repository https://gitbox.apache.org/repos/asf/superset.git


      at f80125f126 Clean up AdhocFilterOption test

This branch includes the following new commits:

     new f80125f126 Clean up AdhocFilterOption test

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[superset] 01/01: Clean up AdhocFilterOption test

Posted by ly...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lyndsi pushed a commit to branch lyndsi/clean-up-adhocfilteroption-test
in repository https://gitbox.apache.org/repos/asf/superset.git

commit f80125f1269b94c29bfb2f869a10cec120dbc1f2
Author: lyndsiWilliams <kc...@gmail.com>
AuthorDate: Mon Jan 30 17:27:27 2023 -0600

    Clean up AdhocFilterOption test
---
 .../AdhocFilterOption/AdhocFilterOption.test.tsx   | 42 ++++++++++++++++------
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterOption/AdhocFilterOption.test.tsx b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterOption/AdhocFilterOption.test.tsx
index 888eb5a8c3..73671dd1b1 100644
--- a/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterOption/AdhocFilterOption.test.tsx
+++ b/superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterOption/AdhocFilterOption.test.tsx
@@ -19,14 +19,35 @@
 import React from 'react';
 import { render, screen, waitFor } 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, { AdhocFilterOptionProps } from '.';
 
+jest.mock('src/components/Icons/Icon', () => ({
+  __esModule: true,
+  default: ({
+    fileName,
+    role,
+    iconColor,
+    ...rest
+  }: {
+    fileName: string;
+    role: string;
+    iconColor: string;
+  }) => (
+    <span
+      role={role ?? 'img'}
+      aria-label={fileName.replace('_', '-')}
+      // @ts-ignore
+      iconcolor={iconColor ?? 'green'}
+      {...rest}
+    />
+  ),
+  StyledIcon: () => <span />,
+}));
+
 const simpleAdhocFilter = new AdhocFilter({
   expressionType: EXPRESSION_TYPES.SIMPLE,
   subject: 'value',
@@ -56,36 +77,37 @@ const mockedProps = {
 };
 
 const setup = (props: AdhocFilterOptionProps) => (
-  <DndProvider backend={HTML5Backend}>
-    <AdhocFilterOption {...props} />
-  </DndProvider>
+  <AdhocFilterOption {...props} />
 );
 
 test('should render', async () => {
-  const { container } = render(setup(mockedProps));
+  const { container } = render(setup(mockedProps), {
+    useDnd: true,
+    useRedux: true,
+  });
   await waitFor(() => expect(container).toBeInTheDocument());
 });
 
 test('should render the control label', async () => {
-  render(setup(mockedProps));
+  render(setup(mockedProps), { useDnd: true, useRedux: true });
   expect(await screen.findByText('value > 10')).toBeInTheDocument();
 });
 
 test('should render the remove button', async () => {
-  render(setup(mockedProps));
+  render(setup(mockedProps), { useDnd: true, useRedux: true });
   const removeBtn = await screen.findByRole('button');
   expect(removeBtn).toBeInTheDocument();
 });
 
 test('should render the right caret', async () => {
-  render(setup(mockedProps));
+  render(setup(mockedProps), { useDnd: true, useRedux: true });
   expect(
     await screen.findByRole('img', { name: 'caret-right' }),
   ).toBeInTheDocument();
 });
 
 test('should render the Popover on clicking the right caret', async () => {
-  render(setup(mockedProps));
+  render(setup(mockedProps), { useDnd: true, useRedux: true });
   const rightCaret = await screen.findByRole('img', { name: 'caret-right' });
   userEvent.click(rightCaret);
   expect(screen.getByRole('tooltip')).toBeInTheDocument();