mirror of
https://github.com/apache/superset.git
synced 2026-04-17 23:25:05 +00:00
Re-add dashboard short links (#5398)
* Re-add dashboard short links * Make the short link available to all users * Include filters in the short link for dashboards * Remove duplicate key causing linter error * Change URL Short link button into a menu item with Modal * Split out tests, bind URL short link in constructor
This commit is contained in:
committed by
Maxime Beauchemin
parent
0aff8659d8
commit
aa9b30cf55
@@ -0,0 +1,141 @@
|
||||
import React from 'react';
|
||||
import { describe, it } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { shallow } from 'enzyme';
|
||||
import { DropdownButton, MenuItem } from 'react-bootstrap';
|
||||
import RefreshIntervalModal from '../../../../src/dashboard/components/RefreshIntervalModal';
|
||||
import URLShortLinkModal from '../../../../src/components/URLShortLinkModal';
|
||||
import HeaderActionsDropdown from '../../../../src/dashboard/components/HeaderActionsDropdown';
|
||||
import SaveModal from '../../../../src/dashboard/components/SaveModal';
|
||||
import CssEditor from '../../../../src/dashboard/components/CssEditor';
|
||||
|
||||
describe('HeaderActionsDropdown', () => {
|
||||
const props = {
|
||||
addSuccessToast: () => {},
|
||||
addDangerToast: () => {},
|
||||
dashboardId: 1,
|
||||
dashboardTitle: 'Title',
|
||||
hasUnsavedChanges: false,
|
||||
css: '',
|
||||
onChange: () => {},
|
||||
updateCss: () => {},
|
||||
forceRefreshAllCharts: () => {},
|
||||
startPeriodicRender: () => {},
|
||||
editMode: false,
|
||||
userCanEdit: false,
|
||||
userCanSave: false,
|
||||
layout: {},
|
||||
filters: {},
|
||||
expandedSlices: {},
|
||||
onSave: () => {},
|
||||
};
|
||||
|
||||
function setup(overrideProps) {
|
||||
const wrapper = shallow(
|
||||
<HeaderActionsDropdown {...props} {...overrideProps} />,
|
||||
);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
describe('readonly-user', () => {
|
||||
const overrideProps = { userCanSave: false };
|
||||
|
||||
it('should render the DropdownButton', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(DropdownButton)).to.have.lengthOf(1);
|
||||
});
|
||||
|
||||
it('should not render the SaveModal', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(SaveModal)).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('should render one MenuItem', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(MenuItem)).to.have.lengthOf(1);
|
||||
});
|
||||
|
||||
it('should render the RefreshIntervalModal', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(RefreshIntervalModal)).to.have.lengthOf(1);
|
||||
});
|
||||
|
||||
it('should render the URLShortLinkModal', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(URLShortLinkModal)).to.have.lengthOf(1);
|
||||
});
|
||||
|
||||
it('should not render the CssEditor', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(CssEditor)).to.have.lengthOf(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('write-user', () => {
|
||||
const overrideProps = { userCanSave: true };
|
||||
|
||||
it('should render the DropdownButton', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(DropdownButton)).to.have.lengthOf(1);
|
||||
});
|
||||
|
||||
it('should render the SaveModal', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(SaveModal)).to.have.lengthOf(1);
|
||||
});
|
||||
|
||||
it('should render two MenuItems', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(MenuItem)).to.have.lengthOf(2);
|
||||
});
|
||||
|
||||
it('should render the RefreshIntervalModal', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(RefreshIntervalModal)).to.have.lengthOf(1);
|
||||
});
|
||||
|
||||
it('should render the URLShortLinkModal', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(URLShortLinkModal)).to.have.lengthOf(1);
|
||||
});
|
||||
|
||||
it('should not render the CssEditor', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(CssEditor)).to.have.lengthOf(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('write-user-with-edit-mode', () => {
|
||||
const overrideProps = { userCanSave: true, editMode: true };
|
||||
|
||||
it('should render the DropdownButton', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(DropdownButton)).to.have.lengthOf(1);
|
||||
});
|
||||
|
||||
it('should render the SaveModal', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(SaveModal)).to.have.lengthOf(1);
|
||||
});
|
||||
|
||||
it('should render three MenuItems', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(MenuItem)).to.have.lengthOf(3);
|
||||
});
|
||||
|
||||
it('should render the RefreshIntervalModal', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(RefreshIntervalModal)).to.have.lengthOf(1);
|
||||
});
|
||||
|
||||
it('should render the URLShortLinkModal', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(URLShortLinkModal)).to.have.lengthOf(1);
|
||||
});
|
||||
|
||||
it('should render the CssEditor', () => {
|
||||
const wrapper = setup(overrideProps);
|
||||
expect(wrapper.find(CssEditor)).to.have.lengthOf(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user