Skip to content

Commit

Permalink
Merge branch 'master' into elizabeth/cache-for-csv
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Oct 25, 2021
2 parents f0c9c05 + ef3afbd commit 45e6d48
Show file tree
Hide file tree
Showing 74 changed files with 461 additions and 416 deletions.
8 changes: 2 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@
# limitations under the License.
#
repos:
- repo: https://github.com/asottile/seed-isort-config
rev: v1.9.3
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/docs/installation/kubernetes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ Data source definitions can be automatically declared by providing key/value yam
extraConfigs:
datasources-init.yaml: |
databases:
- allow_csv_upload: true
- allow_file_upload: true
allow_ctas: true
allow_cvas: true
database_name: example-db
extra: "{\r\n \"metadata_params\": {},\r\n \"engine_params\": {},\r\n \"\
metadata_cache_timeout\": {},\r\n \"schemas_allowed_for_csv_upload\": []\r\n\
metadata_cache_timeout\": {},\r\n \"schemas_allowed_for_file_upload\": []\r\n\
}"
sqlalchemy_uri: example://example-db.local
tables: []
Expand Down
2 changes: 1 addition & 1 deletion helm/superset/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ maintainers:
- name: craig-rueda
email: craig@craigrueda.com
url: https://github.com/craig-rueda
version: 0.3.10
version: 0.3.11
dependencies:
- name: postgresql
version: 10.2.0
Expand Down
4 changes: 2 additions & 2 deletions helm/superset/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ extraSecretEnv: {}
extraConfigs: {}
# datasources-init.yaml: |
# databases:
# - allow_csv_upload: true
# - allow_file_upload: true
# allow_ctas: true
# allow_cvas: true
# database_name: example-db
# extra: "{\r\n \"metadata_params\": {},\r\n \"engine_params\": {},\r\n \"\
# metadata_cache_timeout\": {},\r\n \"schemas_allowed_for_csv_upload\": []\r\n\
# metadata_cache_timeout\": {},\r\n \"schemas_allowed_for_file_upload\": []\r\n\
# }"
# sqlalchemy_uri: example://example-db.local
# tables: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ beforeEach(() => {
description_columns: {},
ids: [1, 2],
label_columns: {
allow_csv_upload: 'Allow Csv Upload',
allow_file_upload: 'Allow Csv Upload',
allow_ctas: 'Allow Ctas',
allow_cvas: 'Allow Cvas',
allow_dml: 'Allow Dml',
Expand All @@ -88,7 +88,7 @@ beforeEach(() => {
id: 'Id',
},
list_columns: [
'allow_csv_upload',
'allow_file_upload',
'allow_ctas',
'allow_cvas',
'allow_dml',
Expand All @@ -110,7 +110,7 @@ beforeEach(() => {
],
list_title: 'List Database',
order_columns: [
'allow_csv_upload',
'allow_file_upload',
'allow_dml',
'allow_run_async',
'changed_on',
Expand All @@ -121,7 +121,7 @@ beforeEach(() => {
],
result: [
{
allow_csv_upload: false,
allow_file_upload: false,
allow_ctas: false,
allow_cvas: false,
allow_dml: false,
Expand Down
52 changes: 52 additions & 0 deletions superset-frontend/src/components/Menu/Menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,32 @@
* under the License.
*/
import React from 'react';
import * as reactRedux from 'react-redux';
import { render, screen } from 'spec/helpers/testing-library';
import userEvent from '@testing-library/user-event';
import { Menu } from './Menu';
import { dropdownItems } from './MenuRight';

const user = {
createdOn: '2021-04-27T18:12:38.952304',
email: 'admin',
firstName: 'admin',
isActive: true,
lastName: 'admin',
permissions: {},
roles: {
Admin: [
['can_sqllab', 'Superset'],
['can_write', 'Dashboard'],
['can_write', 'Chart'],
],
},
userId: 1,
username: 'admin',
};

const mockedProps = {
user,
data: {
menu: [
{
Expand Down Expand Up @@ -136,17 +156,27 @@ const notanonProps = {
},
};

const useSelectorMock = jest.spyOn(reactRedux, 'useSelector');

beforeEach(() => {
// setup a DOM element as a render target
useSelectorMock.mockClear();
});

test('should render', () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
const { container } = render(<Menu {...mockedProps} />);
expect(container).toBeInTheDocument();
});

test('should render the navigation', () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
render(<Menu {...mockedProps} />);
expect(screen.getByRole('navigation')).toBeInTheDocument();
});

test('should render the brand', () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
const {
data: {
brand: { alt, icon },
Expand All @@ -158,6 +188,7 @@ test('should render the brand', () => {
});

test('should render all the top navbar menu items', () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
const {
data: { menu },
} = mockedProps;
Expand All @@ -168,6 +199,7 @@ test('should render all the top navbar menu items', () => {
});

test('should render the top navbar child menu items', async () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
const {
data: { menu },
} = mockedProps;
Expand All @@ -184,6 +216,7 @@ test('should render the top navbar child menu items', async () => {
});

test('should render the dropdown items', async () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
render(<Menu {...notanonProps} />);
const dropdown = screen.getByTestId('new-dropdown-icon');
userEvent.hover(dropdown);
Expand Down Expand Up @@ -211,19 +244,22 @@ test('should render the dropdown items', async () => {
});

test('should render the Settings', async () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
render(<Menu {...mockedProps} />);
const settings = await screen.findByText('Settings');
expect(settings).toBeInTheDocument();
});

test('should render the Settings menu item', async () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
render(<Menu {...mockedProps} />);
userEvent.hover(screen.getByText('Settings'));
const label = await screen.findByText('Security');
expect(label).toBeInTheDocument();
});

test('should render the Settings dropdown child menu items', async () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
const {
data: { settings },
} = mockedProps;
Expand All @@ -234,16 +270,19 @@ test('should render the Settings dropdown child menu items', async () => {
});

test('should render the plus menu (+) when user is not anonymous', () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
render(<Menu {...notanonProps} />);
expect(screen.getByTestId('new-dropdown')).toBeInTheDocument();
});

test('should NOT render the plus menu (+) when user is anonymous', () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
render(<Menu {...mockedProps} />);
expect(screen.queryByTestId('new-dropdown')).not.toBeInTheDocument();
});

test('should render the user actions when user is not anonymous', async () => {
useSelectorMock.mockReturnValue({ roles: mockedProps.user.roles });
const {
data: {
navbar_right: { user_info_url, user_logout_url },
Expand All @@ -263,11 +302,13 @@ test('should render the user actions when user is not anonymous', async () => {
});

test('should NOT render the user actions when user is anonymous', () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
render(<Menu {...mockedProps} />);
expect(screen.queryByText('User')).not.toBeInTheDocument();
});

test('should render the Profile link when available', async () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
const {
data: {
navbar_right: { user_profile_url },
Expand All @@ -282,6 +323,7 @@ test('should render the Profile link when available', async () => {
});

test('should render the About section and version_string, sha or build_number when available', async () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
const {
data: {
navbar_right: { version_sha, version_string, build_number },
Expand All @@ -301,6 +343,7 @@ test('should render the About section and version_string, sha or build_number wh
});

test('should render the Documentation link when available', async () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
const {
data: {
navbar_right: { documentation_url },
Expand All @@ -313,6 +356,7 @@ test('should render the Documentation link when available', async () => {
});

test('should render the Bug Report link when available', async () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
const {
data: {
navbar_right: { bug_report_url },
Expand All @@ -325,6 +369,7 @@ test('should render the Bug Report link when available', async () => {
});

test('should render the Login link when user is anonymous', () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
const {
data: {
navbar_right: { user_login_url },
Expand All @@ -337,6 +382,13 @@ test('should render the Login link when user is anonymous', () => {
});

test('should render the Language Picker', () => {
useSelectorMock.mockReturnValue({ roles: user.roles });
render(<Menu {...mockedProps} />);
expect(screen.getByLabelText('Languages')).toBeInTheDocument();
});

test('should hide create button without proper roles', () => {
useSelectorMock.mockReturnValue({ roles: [] });
render(<Menu {...notanonProps} />);
expect(screen.queryByTestId('new-dropdown')).not.toBeInTheDocument();
});

0 comments on commit 45e6d48

Please sign in to comment.