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



##########
File path: 
superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/HeaderActionsDropdown.test.tsx
##########
@@ -0,0 +1,162 @@
+/**
+ * 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 fetchMock from 'fetch-mock';
+import HeaderActionsDropdown from '.';
+
+const mockedProps = {
+  addSuccessToast: jest.fn(),
+  addDangerToast: jest.fn(),
+  customCss: '#save-dash-split-button{margin-left: 100px;}',
+  dashboardId: 1,
+  dashboardInfo: {},
+  dashboardTitle: 'Title',
+  editMode: true,
+  expandedSlices: {},
+  filters: {},
+  forceRefreshAllCharts: jest.fn(),
+  hasUnsavedChanges: false,
+  isLoading: false,
+  layout: {},
+  onChange: jest.fn(),
+  onSave: jest.fn(),
+  refreshFrequency: 200,
+  setRefreshFrequency: jest.fn(),
+  shouldPersistRefreshFrequency: true,
+  showPropertiesModal: jest.fn(),
+  startPeriodicRender: jest.fn(),
+  updateCss: jest.fn(),
+  userCanEdit: true,
+  userCanSave: true,
+  lastModifiedTime: 0,
+};
+
+const editModeOffProps = {
+  ...mockedProps,
+  editMode: false,
+};
+
+fetchMock.get('glob:*/csstemplateasyncmodelview/api/read', {});
+
+async function openDropdown() {
+  const btn = screen.getByRole('button');
+  userEvent.click(btn);
+  expect(await screen.findByRole('menu')).toBeInTheDocument();
+}
+
+test('should render', () => {
+  const { container } = render(<HeaderActionsDropdown {...mockedProps} />);
+  expect(container).toBeInTheDocument();
+});
+
+test('should render the dropdown button', () => {
+  render(<HeaderActionsDropdown {...mockedProps} />);
+  expect(screen.getByRole('button')).toBeInTheDocument();
+});
+
+test('should render the dropdown icon', () => {
+  render(<HeaderActionsDropdown {...mockedProps} />);
+  expect(screen.getByRole('img', { name: 'more-horiz' })).toBeInTheDocument();
+});
+
+test('should open the dropdown', async () => {
+  render(<HeaderActionsDropdown {...mockedProps} />);
+  await openDropdown();
+  expect(await screen.findByRole('menu')).toBeInTheDocument();
+});
+
+test('should render the menu items in edit mode', async () => {
+  render(<HeaderActionsDropdown {...mockedProps} />);
+  await openDropdown();

Review comment:
       I agree. This is handled in the test above `should render the menu 
items`. It's basically the opposite state. I'll check if I missed this 
elsewhere. Thanks!




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