You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by di...@apache.org on 2022/08/15 14:23:55 UTC

[superset] branch chore/drill-to-detail-modal-tests created (now d61570ecad)

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

diegopucci pushed a change to branch chore/drill-to-detail-modal-tests
in repository https://gitbox.apache.org/repos/asf/superset.git


      at d61570ecad Add DrillDetailModal test

This branch includes the following new commits:

     new 7b1f363a71 Merge branch 'codyml/sc-52488/apply-drill-to-detail-modal-filters-gathered' of https://github.com/codyml/superset into chore/drill-to-detail-modal-tests
     new d61570ecad Add DrillDetailModal test

The 2 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/02: Merge branch 'codyml/sc-52488/apply-drill-to-detail-modal-filters-gathered' of https://github.com/codyml/superset into chore/drill-to-detail-modal-tests

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

diegopucci pushed a commit to branch chore/drill-to-detail-modal-tests
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 7b1f363a71c76b20c7f5dd32f4581190a8060f6a
Merge: 394d62ee51 b21e132ec5
Author: geido <di...@gmail.com>
AuthorDate: Mon Aug 15 15:23:37 2022 +0300

    Merge branch 'codyml/sc-52488/apply-drill-to-detail-modal-filters-gathered' of https://github.com/codyml/superset into chore/drill-to-detail-modal-tests

 .../superset-ui-core/src/query/types/Query.ts      |  45 ++--
 .../src/components/Chart/ChartRenderer.jsx         |  26 ++-
 .../src/components/Chart/DrillDetailModal.tsx      | 100 ++++++++
 .../src/components/Chart/chartAction.js            |  23 +-
 .../components/DrillDetailPane/DrillDetailPane.tsx | 258 +++++++++++++++++++++
 .../components/DrillDetailPane/TableControls.tsx   | 138 +++++++++++
 .../dashboard/components/DrillDetailPane/index.ts  |  20 ++
 .../dashboard/components/DrillDetailPane/utils.ts  |  46 ++++
 .../components/SliceHeaderControls/index.tsx       | 112 +++++++--
 9 files changed, 723 insertions(+), 45 deletions(-)


[superset] 02/02: Add DrillDetailModal test

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

diegopucci pushed a commit to branch chore/drill-to-detail-modal-tests
in repository https://gitbox.apache.org/repos/asf/superset.git

commit d61570ecad01707ed761ad0d4bfa789accf24b14
Author: geido <di...@gmail.com>
AuthorDate: Mon Aug 15 17:23:30 2022 +0300

    Add DrillDetailModal test
---
 .../spec/fixtures/mockChartQueries.js              |   1 +
 superset-frontend/spec/fixtures/mockState.js       |   5 +
 .../src/components/Chart/DrillDetailModal.test.tsx | 105 +++++++++++++++++++++
 3 files changed, 111 insertions(+)

diff --git a/superset-frontend/spec/fixtures/mockChartQueries.js b/superset-frontend/spec/fixtures/mockChartQueries.js
index d25267392a..0175df981a 100644
--- a/superset-frontend/spec/fixtures/mockChartQueries.js
+++ b/superset-frontend/spec/fixtures/mockChartQueries.js
@@ -36,6 +36,7 @@ export default {
       datasource: datasourceId,
       viz_type: 'pie',
       slice_id: sliceId,
+      slice_name: 'Genders',
       granularity_sqla: null,
       time_grain_sqla: null,
       since: '100 years ago',
diff --git a/superset-frontend/spec/fixtures/mockState.js b/superset-frontend/spec/fixtures/mockState.js
index e492217e72..19fb268893 100644
--- a/superset-frontend/spec/fixtures/mockState.js
+++ b/superset-frontend/spec/fixtures/mockState.js
@@ -35,6 +35,11 @@ export default {
   sliceEntities: sliceEntitiesForChart,
   charts: chartQueries,
   nativeFilters: nativeFiltersInfo,
+  common: {
+    conf: {
+      SAMPLES_ROW_LIMIT: 100,
+    },
+  },
   dataMask: mockDataMaskInfo,
   dashboardInfo,
   dashboardFilters: emptyFilters,
diff --git a/superset-frontend/src/components/Chart/DrillDetailModal.test.tsx b/superset-frontend/src/components/Chart/DrillDetailModal.test.tsx
new file mode 100644
index 0000000000..42e1fd27e0
--- /dev/null
+++ b/superset-frontend/src/components/Chart/DrillDetailModal.test.tsx
@@ -0,0 +1,105 @@
+/**
+ * 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, waitFor } from 'spec/helpers/testing-library';
+import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore';
+import chartQueries, { sliceIdĀ } from 'spec/fixtures/mockChartQueries';
+import DrillDetailModal from './DrillDetailModal';
+import { QueryFormData } from '@superset-ui/core';
+import fetchMock from 'fetch-mock';
+import userEvent from '@testing-library/user-event';
+
+
+const chart = chartQueries[sliceId];
+const setup = (overrides: Record<string, any> = {}) => {
+  const store = getMockStoreWithNativeFilters();
+  const props = {
+  chartId: sliceId,
+  initialFilters: [],
+  formData: chart.form_data as unknown as QueryFormData,
+  ...overrides,
+}
+  return render(
+    <DrillDetailModal {...props} />, {
+    useRedux: true,
+    useRouter: true,
+    store
+  });
+};
+const waitForRender = (overrides: Record<string, any> = {}) => waitFor(() => setup(overrides));
+
+fetchMock.post(
+  'end:/datasource/samples?force=false&datasource_type=table&datasource_id=7&per_page=50&page=1',
+  {
+    result: {
+      data: [],
+      colnames: [],
+      coltypes: [],
+    },
+  },
+);
+
+const mockHistoryPush = jest.fn();
+jest.mock('react-router-dom', () => ({
+  ...jest.requireActual('react-router-dom'),
+  useHistory: () => ({
+    push: mockHistoryPush,
+  }),
+}));
+
+test('should render', async () => {
+  const { container } = await waitForRender();
+  expect(container).toBeInTheDocument();
+});
+
+test('should render the title', async () => {
+  await waitForRender();
+  expect(screen.getByText(`Drill to detail: ${chart.form_data.slice_name}`)).toBeInTheDocument();
+});
+
+test('should render the modal', async () => {
+  await waitForRender();
+  expect(screen.getByRole("dialog")).toBeInTheDocument();
+});
+
+test('should not render the modal', async () => {
+  await waitForRender({
+    initialFilters: undefined,
+  });
+  expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
+});
+
+test('should render the button', async () => {
+  await waitForRender();
+  expect(screen.getByRole("button", {name: "Edit chart"})).toBeInTheDocument();
+  expect(screen.getAllByRole("button", {name: "Close"})).toHaveLength(2);
+});
+
+test('should close the modal', async () => {
+  await waitForRender();
+  expect(screen.getByRole("dialog")).toBeInTheDocument();
+  userEvent.click(screen.getAllByRole("button", {name: "Close"})[1]);
+  expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
+});
+
+test('should forward to Explore', async () => {
+  await waitForRender();
+  userEvent.click(screen.getByRole("button", {name: "Edit chart"}));
+  expect(mockHistoryPush).toHaveBeenCalledWith(`/explore/?dashboard_page_id=&slice_id=${sliceId}`);
+});