Skip to content

Commit

Permalink
Fixed embeds test
Browse files Browse the repository at this point in the history
  • Loading branch information
cqliu1 committed Mar 13, 2020
1 parent d694ed8 commit d487046
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { EmbeddableInput } from '../../expression_types';
import { RendererHandlers } from '../../../types';
import { canUserWrite, getFullscreen } from '../../../public/state/selectors/app';
import { isWriteable } from '../../../public/state/selectors/workpad';
import { CANVAS_EMBEDDABLE_CLASSNAME } from '../../../common/lib';

const { embeddable: strings } = RendererStrings;

Expand All @@ -40,7 +41,7 @@ const embeddablesRegistry: {
const renderEmbeddable = (embeddableObject: IEmbeddable, domNode: HTMLElement) => {
return (
<div
className="canvasEmbeddable"
className={CANVAS_EMBEDDABLE_CLASSNAME}
style={{ width: domNode.offsetWidth, height: domNode.offsetHeight, cursor: 'auto' }}
>
<I18nContext>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('input to expression', () => {
const expression = embeddableInputToExpression(input, EmbeddableTypes.map);
const ast = fromExpression(expression);

expect(ast.chain[0].arguments).toHaveProperty('title', input.title);
expect(ast.chain[0].arguments).toHaveProperty('title', [input.title]);
expect(ast.chain[0].arguments).toHaveProperty('timerange');

const timerangeExpression = ast.chain[0].arguments.timerange[0] as Ast;
Expand Down
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/canvas/common/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ export const API_ROUTE_SHAREABLE_BASE = '/public/canvas';
export const API_ROUTE_SHAREABLE_ZIP = '/public/canvas/zip';
export const API_ROUTE_SHAREABLE_RUNTIME = '/public/canvas/runtime';
export const API_ROUTE_SHAREABLE_RUNTIME_DOWNLOAD = `/public/canvas/${SHAREABLE_RUNTIME_NAME}.js`;
export const CANVAS_EMBEDDABLE_CLASSNAME = `canvasEmbeddable`;
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from '../../../state/actions/elements';
import { selectToplevelNodes } from '../../../state/actions/transient';
import { crawlTree, globalStateUpdater, shapesForNodes } from '../integration_utils';
import { CANVAS_EMBEDDABLE_CLASSNAME } from '../../../../common/lib';
import { InteractiveWorkpadPage as InteractiveComponent } from './interactive_workpad_page';
import { eventHandlers } from './event_handlers';

Expand Down Expand Up @@ -79,9 +80,14 @@ const isEmbeddableBody = element => {
const hasClosest = typeof element.closest === 'function';

if (hasClosest) {
return element.closest('.embeddable') && !element.closest('.embPanel__header');
return (
element.closest(`.${CANVAS_EMBEDDABLE_CLASSNAME}`) && !element.closest('.embPanel__header')
);
} else {
return closest.call(element, '.embeddable') && !closest.call(element, '.embPanel__header');
return (
closest.call(element, `.${CANVAS_EMBEDDABLE_CLASSNAME}`) &&
!closest.call(element, '.embPanel__header')
);
}
};

Expand Down

0 comments on commit d487046

Please sign in to comment.