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



##########
File path: 
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterSets/FilterSetUnit.test.tsx
##########
@@ -0,0 +1,95 @@
+/**
+ * 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 { mockStore } from 'spec/fixtures/mockStore';
+import { Provider } from 'react-redux';
+import userEvent from '@testing-library/user-event';
+import FilterSetUnit, { FilterSetUnitProps } from './FilterSetUnit';
+
+const mockedProps = {
+  editMode: true,
+  setFilterSetName: jest.fn(),
+  onDelete: jest.fn(),
+  onEdit: jest.fn(),
+  onRebuild: jest.fn(),
+};
+
+function openDropdown() {
+  const dropdownIcon = screen.getByRole('img', { name: 'ellipsis' });
+  userEvent.click(dropdownIcon);
+}
+
+const setup = (props: FilterSetUnitProps) => (
+  <Provider store={mockStore}>
+    <FilterSetUnit {...props} />
+  </Provider>
+);
+
+test('should render', () => {
+  const { container } = render(setup(mockedProps));
+  expect(container).toBeInTheDocument();
+});
+
+test('should render the edit button', () => {
+  const editModeOffProps = {
+    ...mockedProps,
+    editMode: false,
+  };
+  render(setup(editModeOffProps));
+  const editButton = screen.getAllByRole('button')[0];

Review comment:
       Can you use `getByRole('button', { name: 'Edit' })`? If not, can you use 
`getByLabelText('Edit')`?

##########
File path: 
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Header/Header.test.tsx
##########
@@ -0,0 +1,103 @@
+/**
+ * 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 Header from './index';
+
+const mockedProps = {
+  toggleFiltersBar: jest.fn(),
+  onApply: jest.fn(),
+  setDataMaskSelected: jest.fn(),
+  dataMaskSelected: {
+    DefaultsID: {
+      currentState: {
+        value: null,
+      },
+    },
+  },
+  dataMaskApplied: {
+    DefaultsID: {
+      id: 'DefaultsID',
+      currentState: {
+        value: null,
+      },
+    },
+  },
+  isApplyDisabled: false,
+};
+
+test('should render', () => {
+  const { container } = render(<Header {...mockedProps} />, { useRedux: true 
});
+  expect(container).toBeInTheDocument();
+});
+
+test('should render the "Filters" heading', () => {
+  render(<Header {...mockedProps} />, { useRedux: true });
+  expect(screen.getByText('Filters')).toBeInTheDocument();
+});
+
+test('should render the "Clear all" option', () => {
+  render(<Header {...mockedProps} />, { useRedux: true });
+  expect(screen.getByText('Clear all')).toBeInTheDocument();
+});
+
+test('should render the "Apply" button', () => {
+  render(<Header {...mockedProps} />, { useRedux: true });
+  expect(screen.getByText('Apply')).toBeInTheDocument();
+  expect(screen.getByText('Apply').parentElement).toBeEnabled();
+});
+
+test('should render the "Clear all" button as disabled', () => {
+  render(<Header {...mockedProps} />, { useRedux: true });
+  const clearBtn = screen.getByText('Clear all');
+  expect(clearBtn.parentElement).toBeDisabled();
+});
+
+test('should render the "Apply" button as disabled', () => {
+  const applyDisabledProps = {
+    ...mockedProps,
+    isApplyDisabled: true,
+  };
+  render(<Header {...applyDisabledProps} />, { useRedux: true });
+  const applyBtn = screen.getByText('Apply');
+  expect(applyBtn.parentElement).toBeDisabled();
+  userEvent.click(applyBtn);
+  expect(mockedProps.onApply).not.toHaveBeenCalled();
+});
+
+test('should apply', () => {
+  render(<Header {...mockedProps} />, { useRedux: true });
+  const applyBtn = screen.getByText('Apply');
+  userEvent.click(applyBtn);

Review comment:
       ```suggestion
     expect(mockedProps.onApply).not.toHaveBeenCalled();
     userEvent.click(applyBtn);
   ```




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