diff --git a/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/LeftPanel.test.tsx b/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/LeftPanel.test.tsx
index 9027b232af..3b2ef18181 100644
--- a/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/LeftPanel.test.tsx
+++ b/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/LeftPanel.test.tsx
@@ -17,216 +17,224 @@
* under the License.
*/
import React from 'react';
-import { SupersetClient } from '@superset-ui/core';
+import fetchMock from 'fetch-mock';
import userEvent from '@testing-library/user-event';
import { render, screen, waitFor } from 'spec/helpers/testing-library';
import LeftPanel from 'src/views/CRUD/data/dataset/AddDataset/LeftPanel';
-describe('LeftPanel', () => {
- const mockFun = jest.fn();
+const databasesEndpoint = 'glob:*/api/v1/database/?q*';
+const schemasEndpoint = 'glob:*/api/v1/database/*/schemas*';
+const tablesEndpoint = 'glob:*/superset/tables*';
- const SupersetClientGet = jest.spyOn(SupersetClient, 'get');
+fetchMock.get(databasesEndpoint, {
+ count: 2,
+ description_columns: {},
+ ids: [1, 2],
+ label_columns: {
+ allow_file_upload: 'Allow Csv Upload',
+ allow_ctas: 'Allow Ctas',
+ allow_cvas: 'Allow Cvas',
+ allow_dml: 'Allow Dml',
+ allow_multi_schema_metadata_fetch: 'Allow Multi Schema Metadata Fetch',
+ allow_run_async: 'Allow Run Async',
+ allows_cost_estimate: 'Allows Cost Estimate',
+ allows_subquery: 'Allows Subquery',
+ allows_virtual_table_explore: 'Allows Virtual Table Explore',
+ disable_data_preview: 'Disables SQL Lab Data Preview',
+ backend: 'Backend',
+ changed_on: 'Changed On',
+ changed_on_delta_humanized: 'Changed On Delta Humanized',
+ 'created_by.first_name': 'Created By First Name',
+ 'created_by.last_name': 'Created By Last Name',
+ database_name: 'Database Name',
+ explore_database_id: 'Explore Database Id',
+ expose_in_sqllab: 'Expose In Sqllab',
+ force_ctas_schema: 'Force Ctas Schema',
+ id: 'Id',
+ },
+ list_columns: [
+ 'allow_file_upload',
+ 'allow_ctas',
+ 'allow_cvas',
+ 'allow_dml',
+ 'allow_multi_schema_metadata_fetch',
+ 'allow_run_async',
+ 'allows_cost_estimate',
+ 'allows_subquery',
+ 'allows_virtual_table_explore',
+ 'disable_data_preview',
+ 'backend',
+ 'changed_on',
+ 'changed_on_delta_humanized',
+ 'created_by.first_name',
+ 'created_by.last_name',
+ 'database_name',
+ 'explore_database_id',
+ 'expose_in_sqllab',
+ 'force_ctas_schema',
+ 'id',
+ ],
+ list_title: 'List Database',
+ order_columns: [
+ 'allow_file_upload',
+ 'allow_dml',
+ 'allow_run_async',
+ 'changed_on',
+ 'changed_on_delta_humanized',
+ 'created_by.first_name',
+ 'database_name',
+ 'expose_in_sqllab',
+ ],
+ result: [
+ {
+ allow_file_upload: false,
+ allow_ctas: false,
+ allow_cvas: false,
+ allow_dml: false,
+ allow_multi_schema_metadata_fetch: false,
+ allow_run_async: false,
+ allows_cost_estimate: null,
+ allows_subquery: true,
+ allows_virtual_table_explore: true,
+ disable_data_preview: false,
+ backend: 'postgresql',
+ changed_on: '2021-03-09T19:02:07.141095',
+ changed_on_delta_humanized: 'a day ago',
+ created_by: null,
+ database_name: 'test-postgres',
+ explore_database_id: 1,
+ expose_in_sqllab: true,
+ force_ctas_schema: null,
+ id: 1,
+ },
+ {
+ allow_csv_upload: false,
+ allow_ctas: false,
+ allow_cvas: false,
+ allow_dml: false,
+ allow_multi_schema_metadata_fetch: false,
+ allow_run_async: false,
+ allows_cost_estimate: null,
+ allows_subquery: true,
+ allows_virtual_table_explore: true,
+ disable_data_preview: false,
+ backend: 'mysql',
+ changed_on: '2021-03-09T19:02:07.141095',
+ changed_on_delta_humanized: 'a day ago',
+ created_by: null,
+ database_name: 'test-mysql',
+ explore_database_id: 1,
+ expose_in_sqllab: true,
+ force_ctas_schema: null,
+ id: 2,
+ },
+ ],
+});
- beforeEach(() => {
- jest.resetAllMocks();
- SupersetClientGet.mockImplementation(
- async ({ endpoint }: { endpoint: string }) => {
- if (endpoint.includes('schemas')) {
- return {
- json: { result: ['information_schema', 'public'] },
- } as any;
- }
- return {
- json: {
- count: 2,
- description_columns: {},
- ids: [1, 2],
- label_columns: {
- allow_file_upload: 'Allow Csv Upload',
- allow_ctas: 'Allow Ctas',
- allow_cvas: 'Allow Cvas',
- allow_dml: 'Allow Dml',
- allow_multi_schema_metadata_fetch:
- 'Allow Multi Schema Metadata Fetch',
- allow_run_async: 'Allow Run Async',
- allows_cost_estimate: 'Allows Cost Estimate',
- allows_subquery: 'Allows Subquery',
- allows_virtual_table_explore: 'Allows Virtual Table Explore',
- disable_data_preview: 'Disables SQL Lab Data Preview',
- backend: 'Backend',
- changed_on: 'Changed On',
- changed_on_delta_humanized: 'Changed On Delta Humanized',
- 'created_by.first_name': 'Created By First Name',
- 'created_by.last_name': 'Created By Last Name',
- database_name: 'Database Name',
- explore_database_id: 'Explore Database Id',
- expose_in_sqllab: 'Expose In Sqllab',
- force_ctas_schema: 'Force Ctas Schema',
- id: 'Id',
- },
- list_columns: [
- 'allow_file_upload',
- 'allow_ctas',
- 'allow_cvas',
- 'allow_dml',
- 'allow_multi_schema_metadata_fetch',
- 'allow_run_async',
- 'allows_cost_estimate',
- 'allows_subquery',
- 'allows_virtual_table_explore',
- 'disable_data_preview',
- 'backend',
- 'changed_on',
- 'changed_on_delta_humanized',
- 'created_by.first_name',
- 'created_by.last_name',
- 'database_name',
- 'explore_database_id',
- 'expose_in_sqllab',
- 'force_ctas_schema',
- 'id',
- ],
- list_title: 'List Database',
- order_columns: [
- 'allow_file_upload',
- 'allow_dml',
- 'allow_run_async',
- 'changed_on',
- 'changed_on_delta_humanized',
- 'created_by.first_name',
- 'database_name',
- 'expose_in_sqllab',
- ],
- result: [
- {
- allow_file_upload: false,
- allow_ctas: false,
- allow_cvas: false,
- allow_dml: false,
- allow_multi_schema_metadata_fetch: false,
- allow_run_async: false,
- allows_cost_estimate: null,
- allows_subquery: true,
- allows_virtual_table_explore: true,
- disable_data_preview: false,
- backend: 'postgresql',
- changed_on: '2021-03-09T19:02:07.141095',
- changed_on_delta_humanized: 'a day ago',
- created_by: null,
- database_name: 'test-postgres',
- explore_database_id: 1,
- expose_in_sqllab: true,
- force_ctas_schema: null,
- id: 1,
- },
- {
- allow_csv_upload: false,
- allow_ctas: false,
- allow_cvas: false,
- allow_dml: false,
- allow_multi_schema_metadata_fetch: false,
- allow_run_async: false,
- allows_cost_estimate: null,
- allows_subquery: true,
- allows_virtual_table_explore: true,
- disable_data_preview: false,
- backend: 'mysql',
- changed_on: '2021-03-09T19:02:07.141095',
- changed_on_delta_humanized: 'a day ago',
- created_by: null,
- database_name: 'test-mysql',
- explore_database_id: 1,
- expose_in_sqllab: true,
- force_ctas_schema: null,
- id: 2,
- },
- ],
- },
- } as any;
- },
- );
+fetchMock.get(schemasEndpoint, {
+ result: ['information_schema', 'public'],
+});
+
+fetchMock.get(tablesEndpoint, {
+ tableLength: 3,
+ options: [
+ { value: 'Sheet1', type: 'table', extra: null },
+ { value: 'Sheet2', type: 'table', extra: null },
+ { value: 'Sheet3', type: 'table', extra: null },
+ ],
+});
+
+const mockFun = jest.fn();
+
+test('should render', async () => {
+ render(
{inline}
+{inline}