mirror of https://github.com/apache/superset.git
parent
22d52eadb2
commit
6bf5d2c06d
|
@ -0,0 +1,34 @@
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
class Worker {
|
||||||
|
url: string;
|
||||||
|
|
||||||
|
onMessage: Function;
|
||||||
|
|
||||||
|
constructor(stringUrl: string) {
|
||||||
|
this.url = stringUrl;
|
||||||
|
this.onMessage = () => {};
|
||||||
|
}
|
||||||
|
|
||||||
|
postMessage(msg: string) {
|
||||||
|
this.onMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Worker };
|
|
@ -24,7 +24,7 @@ import jQuery from 'jquery';
|
||||||
import { configure } from 'enzyme';
|
import { configure } from 'enzyme';
|
||||||
import Adapter from 'enzyme-adapter-react-16';
|
import Adapter from 'enzyme-adapter-react-16';
|
||||||
import { configure as configureTranslation } from '@superset-ui/core';
|
import { configure as configureTranslation } from '@superset-ui/core';
|
||||||
|
import { Worker } from './Worker';
|
||||||
import setupSupersetClient from './setupSupersetClient';
|
import setupSupersetClient from './setupSupersetClient';
|
||||||
|
|
||||||
configure({ adapter: new Adapter() });
|
configure({ adapter: new Adapter() });
|
||||||
|
@ -42,10 +42,12 @@ if (defaultView != null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const g = global as any;
|
const g = global as any;
|
||||||
|
|
||||||
g.window = g.window || {};
|
g.window = g.window || {};
|
||||||
g.window.location = { href: 'about:blank' };
|
g.window.location = { href: 'about:blank' };
|
||||||
g.window.performance = { now: () => new Date().getTime() };
|
g.window.performance = { now: () => new Date().getTime() };
|
||||||
|
g.window.Worker = Worker;
|
||||||
|
g.URL.createObjectURL = () => '';
|
||||||
|
|
||||||
Object.defineProperty(window, 'matchMedia', {
|
Object.defineProperty(window, 'matchMedia', {
|
||||||
writable: true,
|
writable: true,
|
||||||
value: jest.fn().mockImplementation(query => ({
|
value: jest.fn().mockImplementation(query => ({
|
||||||
|
|
|
@ -24,6 +24,9 @@ import URLShortLinkModal from 'src/components/URLShortLinkModal';
|
||||||
import HeaderActionsDropdown from 'src/dashboard/components/HeaderActionsDropdown';
|
import HeaderActionsDropdown from 'src/dashboard/components/HeaderActionsDropdown';
|
||||||
import SaveModal from 'src/dashboard/components/SaveModal';
|
import SaveModal from 'src/dashboard/components/SaveModal';
|
||||||
import CssEditor from 'src/dashboard/components/CssEditor';
|
import CssEditor from 'src/dashboard/components/CssEditor';
|
||||||
|
import fetchMock from 'fetch-mock';
|
||||||
|
|
||||||
|
fetchMock.get('glob:*/csstemplateasyncmodelview/api/read', {});
|
||||||
|
|
||||||
describe('HeaderActionsDropdown', () => {
|
describe('HeaderActionsDropdown', () => {
|
||||||
const props = {
|
const props = {
|
||||||
|
@ -50,6 +53,7 @@ describe('HeaderActionsDropdown', () => {
|
||||||
updateCss: () => {},
|
updateCss: () => {},
|
||||||
userCanEdit: false,
|
userCanEdit: false,
|
||||||
userCanSave: false,
|
userCanSave: false,
|
||||||
|
lastModifiedTime: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
function setup(overrideProps) {
|
function setup(overrideProps) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ describe('Header', () => {
|
||||||
const props = {
|
const props = {
|
||||||
addSuccessToast: () => {},
|
addSuccessToast: () => {},
|
||||||
addDangerToast: () => {},
|
addDangerToast: () => {},
|
||||||
|
addWarningToast: () => {},
|
||||||
dashboardInfo: {
|
dashboardInfo: {
|
||||||
id: 1,
|
id: 1,
|
||||||
dash_edit_perm: true,
|
dash_edit_perm: true,
|
||||||
|
@ -46,7 +47,12 @@ describe('Header', () => {
|
||||||
filters: {},
|
filters: {},
|
||||||
expandedSlices: {},
|
expandedSlices: {},
|
||||||
css: '',
|
css: '',
|
||||||
|
customCss: '',
|
||||||
isStarred: false,
|
isStarred: false,
|
||||||
|
isLoading: false,
|
||||||
|
lastModifiedTime: 0,
|
||||||
|
refreshFrequency: 0,
|
||||||
|
shouldPersistRefreshFrequency: false,
|
||||||
onSave: () => {},
|
onSave: () => {},
|
||||||
onChange: () => {},
|
onChange: () => {},
|
||||||
fetchFaveStar: () => {},
|
fetchFaveStar: () => {},
|
||||||
|
@ -59,6 +65,9 @@ describe('Header', () => {
|
||||||
setEditMode: () => {},
|
setEditMode: () => {},
|
||||||
showBuilderPane: () => {},
|
showBuilderPane: () => {},
|
||||||
updateCss: () => {},
|
updateCss: () => {},
|
||||||
|
setColorSchemeAndUnsavedChanges: () => {},
|
||||||
|
logEvent: () => {},
|
||||||
|
setRefreshFrequency: () => {},
|
||||||
hasUnsavedChanges: false,
|
hasUnsavedChanges: false,
|
||||||
maxUndoHistoryExceeded: false,
|
maxUndoHistoryExceeded: false,
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,12 @@ import React from 'react';
|
||||||
import { styledMount as mount } from 'spec/helpers/theming';
|
import { styledMount as mount } from 'spec/helpers/theming';
|
||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
import ReactMarkdown from 'react-markdown';
|
import ReactMarkdown from 'react-markdown';
|
||||||
|
import { act } from 'react-dom/test-utils';
|
||||||
import { MarkdownEditor } from 'src/components/AsyncAceEditor';
|
import { MarkdownEditor } from 'src/components/AsyncAceEditor';
|
||||||
import Markdown from 'src/dashboard/components/gridComponents/Markdown';
|
import Markdown from 'src/dashboard/components/gridComponents/Markdown';
|
||||||
import MarkdownModeDropdown from 'src/dashboard/components/menu/MarkdownModeDropdown';
|
import MarkdownModeDropdown from 'src/dashboard/components/menu/MarkdownModeDropdown';
|
||||||
import DeleteComponentButton from 'src/dashboard/components/DeleteComponentButton';
|
import DeleteComponentButton from 'src/dashboard/components/DeleteComponentButton';
|
||||||
|
import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint';
|
||||||
import DragDroppable from 'src/dashboard/components/dnd/DragDroppable';
|
import DragDroppable from 'src/dashboard/components/dnd/DragDroppable';
|
||||||
import WithPopoverMenu from 'src/dashboard/components/menu/WithPopoverMenu';
|
import WithPopoverMenu from 'src/dashboard/components/menu/WithPopoverMenu';
|
||||||
import ResizableContainer from 'src/dashboard/components/resizable/ResizableContainer';
|
import ResizableContainer from 'src/dashboard/components/resizable/ResizableContainer';
|
||||||
|
@ -45,6 +46,8 @@ describe('Markdown', () => {
|
||||||
editMode: false,
|
editMode: false,
|
||||||
availableColumnCount: 12,
|
availableColumnCount: 12,
|
||||||
columnWidth: 50,
|
columnWidth: 50,
|
||||||
|
redoLength: 0,
|
||||||
|
undoLength: 0,
|
||||||
onResizeStart() {},
|
onResizeStart() {},
|
||||||
onResize() {},
|
onResize() {},
|
||||||
onResizeStop() {},
|
onResizeStop() {},
|
||||||
|
@ -52,6 +55,7 @@ describe('Markdown', () => {
|
||||||
updateComponents() {},
|
updateComponents() {},
|
||||||
deleteComponent() {},
|
deleteComponent() {},
|
||||||
logEvent() {},
|
logEvent() {},
|
||||||
|
addDangerToast() {},
|
||||||
};
|
};
|
||||||
|
|
||||||
function setup(overrideProps) {
|
function setup(overrideProps) {
|
||||||
|
@ -109,11 +113,14 @@ describe('Markdown', () => {
|
||||||
expect(wrapper.find(ReactMarkdown)).toExist();
|
expect(wrapper.find(ReactMarkdown)).toExist();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render an AceEditor when focused and editMode=true and editorMode=edit', () => {
|
it('should render an AceEditor when focused and editMode=true and editorMode=edit', async () => {
|
||||||
const wrapper = setup({ editMode: true });
|
const wrapper = setup({ editMode: true });
|
||||||
expect(wrapper.find(MarkdownEditor)).not.toExist();
|
expect(wrapper.find(MarkdownEditor)).not.toExist();
|
||||||
expect(wrapper.find(ReactMarkdown)).toExist();
|
expect(wrapper.find(ReactMarkdown)).toExist();
|
||||||
wrapper.find(WithPopoverMenu).simulate('click'); // focus + edit
|
act(() => {
|
||||||
|
wrapper.find(WithPopoverMenu).simulate('click'); // focus + edit
|
||||||
|
});
|
||||||
|
await waitForComponentToPaint(wrapper);
|
||||||
expect(wrapper.find(MarkdownEditor)).toExist();
|
expect(wrapper.find(MarkdownEditor)).toExist();
|
||||||
expect(wrapper.find(ReactMarkdown)).not.toExist();
|
expect(wrapper.find(ReactMarkdown)).not.toExist();
|
||||||
});
|
});
|
||||||
|
|
|
@ -147,6 +147,7 @@ describe('AnnotationList', () => {
|
||||||
act(() => {
|
act(() => {
|
||||||
wrapper.find('button').last().props().onClick();
|
wrapper.find('button').last().props().onClick();
|
||||||
});
|
});
|
||||||
|
await waitForComponentToPaint(wrapper);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows/hides bulk actions when bulk actions is clicked', async () => {
|
it('shows/hides bulk actions when bulk actions is clicked', async () => {
|
||||||
|
|
Loading…
Reference in New Issue