mirror of
https://github.com/apache/superset.git
synced 2026-04-18 07:35:09 +00:00
User profile pages (favorites, created content, recent activity, security & access) (#1615)
* Super * User profile page * Fixing python style * Python unit tests * Touchups and js tests * Addressing comments
This commit is contained in:
committed by
GitHub
parent
5ae98bc7c9
commit
7e1852ee88
27
superset/assets/spec/javascripts/profile/App_spec.jsx
Normal file
27
superset/assets/spec/javascripts/profile/App_spec.jsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import React from 'react';
|
||||
import App from '../../../javascripts/profile/components/App';
|
||||
import { Col, Row, Tab } from 'react-bootstrap';
|
||||
import { mount } from 'enzyme';
|
||||
import { describe, it } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { user } from './fixtures';
|
||||
|
||||
describe('App', () => {
|
||||
const mockedProps = {
|
||||
user,
|
||||
};
|
||||
it('is valid', () => {
|
||||
expect(
|
||||
React.isValidElement(<App {...mockedProps} />)
|
||||
).to.equal(true);
|
||||
});
|
||||
it('renders 2 Col', () => {
|
||||
const wrapper = mount(<App {...mockedProps} />);
|
||||
expect(wrapper.find(Row)).to.have.length(1);
|
||||
expect(wrapper.find(Col)).to.have.length(2);
|
||||
});
|
||||
it('renders 4 Tabs', () => {
|
||||
const wrapper = mount(<App {...mockedProps} />);
|
||||
expect(wrapper.find(Tab)).to.have.length(4);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import React from 'react';
|
||||
import CreatedContent from '../../../javascripts/profile/components/CreatedContent';
|
||||
import TableLoader from '../../../javascripts/profile/components/TableLoader';
|
||||
import { mount } from 'enzyme';
|
||||
import { describe, it } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { user } from './fixtures';
|
||||
|
||||
|
||||
describe('CreatedContent', () => {
|
||||
const mockedProps = {
|
||||
user,
|
||||
};
|
||||
it('is valid', () => {
|
||||
expect(
|
||||
React.isValidElement(<CreatedContent {...mockedProps} />)
|
||||
).to.equal(true);
|
||||
});
|
||||
it('renders 2 TableLoader', () => {
|
||||
const wrapper = mount(<CreatedContent {...mockedProps} />);
|
||||
expect(wrapper.find(TableLoader)).to.have.length(2);
|
||||
});
|
||||
it('renders 2 titles', () => {
|
||||
const wrapper = mount(<CreatedContent {...mockedProps} />);
|
||||
expect(wrapper.find('h3')).to.have.length(2);
|
||||
});
|
||||
});
|
||||
26
superset/assets/spec/javascripts/profile/Favorites_spec.jsx
Normal file
26
superset/assets/spec/javascripts/profile/Favorites_spec.jsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import React from 'react';
|
||||
import Favorites from '../../../javascripts/profile/components/Favorites';
|
||||
import TableLoader from '../../../javascripts/profile/components/TableLoader';
|
||||
import { mount } from 'enzyme';
|
||||
import { describe, it } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { user } from './fixtures';
|
||||
|
||||
describe('Favorites', () => {
|
||||
const mockedProps = {
|
||||
user,
|
||||
};
|
||||
it('is valid', () => {
|
||||
expect(
|
||||
React.isValidElement(<Favorites {...mockedProps} />)
|
||||
).to.equal(true);
|
||||
});
|
||||
it('renders 2 TableLoader', () => {
|
||||
const wrapper = mount(<Favorites {...mockedProps} />);
|
||||
expect(wrapper.find(TableLoader)).to.have.length(2);
|
||||
});
|
||||
it('renders 2 titles', () => {
|
||||
const wrapper = mount(<Favorites {...mockedProps} />);
|
||||
expect(wrapper.find('h3')).to.have.length(2);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import React from 'react';
|
||||
import RecentActivity from '../../../javascripts/profile/components/RecentActivity';
|
||||
import TableLoader from '../../../javascripts/profile/components/TableLoader';
|
||||
import { mount } from 'enzyme';
|
||||
import { describe, it } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { user } from './fixtures';
|
||||
|
||||
|
||||
describe('RecentActivity', () => {
|
||||
const mockedProps = {
|
||||
user,
|
||||
};
|
||||
it('is valid', () => {
|
||||
expect(
|
||||
React.isValidElement(<RecentActivity {...mockedProps} />)
|
||||
).to.equal(true);
|
||||
});
|
||||
it('renders a TableLoader', () => {
|
||||
const wrapper = mount(<RecentActivity {...mockedProps} />);
|
||||
expect(wrapper.find(TableLoader)).to.have.length(1);
|
||||
});
|
||||
});
|
||||
35
superset/assets/spec/javascripts/profile/Security_spec.jsx
Normal file
35
superset/assets/spec/javascripts/profile/Security_spec.jsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import React from 'react';
|
||||
import Security from '../../../javascripts/profile/components/Security';
|
||||
import { mount } from 'enzyme';
|
||||
import { describe, it } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { user, userNoPerms } from './fixtures';
|
||||
|
||||
|
||||
describe('Security', () => {
|
||||
const mockedProps = {
|
||||
user,
|
||||
};
|
||||
it('is valid', () => {
|
||||
expect(
|
||||
React.isValidElement(<Security {...mockedProps} />)
|
||||
).to.equal(true);
|
||||
});
|
||||
it('renders 2 role labels', () => {
|
||||
const wrapper = mount(<Security {...mockedProps} />);
|
||||
expect(wrapper.find('.roles').find('.label')).to.have.length(2);
|
||||
});
|
||||
it('renders 2 datasource labels', () => {
|
||||
const wrapper = mount(<Security {...mockedProps} />);
|
||||
expect(wrapper.find('.datasources').find('.label')).to.have.length(2);
|
||||
});
|
||||
it('renders 3 database labels', () => {
|
||||
const wrapper = mount(<Security {...mockedProps} />);
|
||||
expect(wrapper.find('.databases').find('.label')).to.have.length(3);
|
||||
});
|
||||
it('renders no permission label when empty', () => {
|
||||
const wrapper = mount(<Security user={userNoPerms} />);
|
||||
expect(wrapper.find('.datasources').find('.label')).to.have.length(0);
|
||||
expect(wrapper.find('.databases').find('.label')).to.have.length(0);
|
||||
});
|
||||
});
|
||||
40
superset/assets/spec/javascripts/profile/UserInfo_spec.jsx
Normal file
40
superset/assets/spec/javascripts/profile/UserInfo_spec.jsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import React from 'react';
|
||||
import UserInfo from '../../../javascripts/profile/components/UserInfo';
|
||||
import Gravatar from 'react-gravatar';
|
||||
import { Panel } from 'react-bootstrap';
|
||||
import { mount } from 'enzyme';
|
||||
import { describe, it } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { user } from './fixtures';
|
||||
|
||||
|
||||
describe('UserInfo', () => {
|
||||
const mockedProps = {
|
||||
user,
|
||||
};
|
||||
it('is valid', () => {
|
||||
expect(
|
||||
React.isValidElement(<UserInfo {...mockedProps} />)
|
||||
).to.equal(true);
|
||||
});
|
||||
it('renders a Gravatar', () => {
|
||||
const wrapper = mount(<UserInfo {...mockedProps} />);
|
||||
expect(wrapper.find(Gravatar)).to.have.length(1);
|
||||
});
|
||||
it('renders a Panel', () => {
|
||||
const wrapper = mount(<UserInfo {...mockedProps} />);
|
||||
expect(wrapper.find(Panel)).to.have.length(1);
|
||||
});
|
||||
it('renders 5 icons', () => {
|
||||
const wrapper = mount(<UserInfo {...mockedProps} />);
|
||||
expect(wrapper.find('i')).to.have.length(5);
|
||||
});
|
||||
it('renders roles information', () => {
|
||||
const wrapper = mount(<UserInfo {...mockedProps} />);
|
||||
expect(wrapper.find('.roles').text()).to.equal(' Alpha, sql_lab');
|
||||
});
|
||||
it('shows the right user-id', () => {
|
||||
const wrapper = mount(<UserInfo {...mockedProps} />);
|
||||
expect(wrapper.find('.user-id').text()).to.equal('5');
|
||||
});
|
||||
});
|
||||
52
superset/assets/spec/javascripts/profile/fixtures.jsx
Normal file
52
superset/assets/spec/javascripts/profile/fixtures.jsx
Normal file
@@ -0,0 +1,52 @@
|
||||
export const user = {
|
||||
username: 'alpha',
|
||||
roles: {
|
||||
Alpha: [
|
||||
[
|
||||
'can_this_form_post',
|
||||
'ResetMyPasswordView',
|
||||
],
|
||||
[
|
||||
'can_this_form_get',
|
||||
'ResetMyPasswordView',
|
||||
],
|
||||
[
|
||||
'can_this_form_post',
|
||||
'UserInfoEditView',
|
||||
],
|
||||
[
|
||||
'can_this_form_get',
|
||||
'UserInfoEditView',
|
||||
],
|
||||
],
|
||||
sql_lab: [
|
||||
[
|
||||
'menu_access',
|
||||
'SQL Lab',
|
||||
],
|
||||
[
|
||||
'can_sql_json',
|
||||
'Superset',
|
||||
],
|
||||
[
|
||||
'can_search_queries',
|
||||
'Superset',
|
||||
],
|
||||
[
|
||||
'can_csv',
|
||||
'Superset',
|
||||
],
|
||||
],
|
||||
},
|
||||
firstName: 'alpha',
|
||||
lastName: 'alpha',
|
||||
createdOn: '2016-11-11T12:34:17',
|
||||
userId: 5,
|
||||
email: 'alpha@alpha.com',
|
||||
isActive: true,
|
||||
permissions: {
|
||||
datasource_access: ['table1', 'table2'],
|
||||
database_access: ['db1', 'db2', 'db3'],
|
||||
},
|
||||
};
|
||||
export const userNoPerms = Object.assign({}, user, { permissions: {} });
|
||||
Reference in New Issue
Block a user