diff --git a/src/plugins/embeddable/public/embeddable_panel/panel_actions/customize_panel_action/can_inherit_time_range.ts b/src/plugins/embeddable/public/embeddable_panel/panel_actions/customize_panel_action/can_inherit_time_range.ts index 139933c8d9390..f2c1a3b7a9aac 100644 --- a/src/plugins/embeddable/public/embeddable_panel/panel_actions/customize_panel_action/can_inherit_time_range.ts +++ b/src/plugins/embeddable/public/embeddable_panel/panel_actions/customize_panel_action/can_inherit_time_range.ts @@ -8,8 +8,8 @@ import type { TimeRange } from '@kbn/es-query'; -import { TimeRangeInput } from './customize_panel_action'; import { Embeddable, IContainer, ContainerInput } from '../../..'; +import { TimeRangeInput } from './time_range_helpers'; interface ContainerTimeRangeInput extends ContainerInput { timeRange: TimeRange; diff --git a/src/plugins/embeddable/public/embeddable_panel/panel_actions/customize_panel_action/customize_panel_editor.test.tsx b/src/plugins/embeddable/public/embeddable_panel/panel_actions/customize_panel_action/customize_panel_editor.test.tsx index d6cccfe0c0684..a2ccf9782deba 100644 --- a/src/plugins/embeddable/public/embeddable_panel/panel_actions/customize_panel_action/customize_panel_editor.test.tsx +++ b/src/plugins/embeddable/public/embeddable_panel/panel_actions/customize_panel_action/customize_panel_editor.test.tsx @@ -64,11 +64,11 @@ describe('panel title / description', () => { expect(customizePanelForm).not.toContainElement(titleDescriptionComponent); }); - test('title input receives focus when `titleFocus` is `true`', async () => { + test('title input receives focus when `focusOnTitle` is `true`', async () => { const mockEmbeddable = await createEmbeddable({ viewMode: ViewMode.EDIT }); render( - + ); @@ -76,11 +76,11 @@ describe('panel title / description', () => { expect(customTitleComponent).toHaveFocus(); }); - test('title input does not receive focus when `titleFocus` is `false`', async () => { + test('title input does not receive focus when `focusOnTitle` is `false`', async () => { const mockEmbeddable = await createEmbeddable({ viewMode: ViewMode.EDIT }); render( - + ); diff --git a/src/plugins/embeddable/public/embeddable_panel/panel_actions/customize_panel_action/does_inherit_time_range.ts b/src/plugins/embeddable/public/embeddable_panel/panel_actions/customize_panel_action/does_inherit_time_range.ts index a14ca031c9fb1..7d21a79ab9425 100644 --- a/src/plugins/embeddable/public/embeddable_panel/panel_actions/customize_panel_action/does_inherit_time_range.ts +++ b/src/plugins/embeddable/public/embeddable_panel/panel_actions/customize_panel_action/does_inherit_time_range.ts @@ -6,8 +6,8 @@ * Side Public License, v 1. */ -import { Embeddable, IContainer, ContainerInput } from '../../../lib'; -import { TimeRangeInput } from './customize_panel_action'; +import { ContainerInput, Embeddable, IContainer } from '../../../lib'; +import { TimeRangeInput } from './time_range_helpers'; export function doesInheritTimeRange(embeddable: Embeddable) { if (!embeddable.parent) { diff --git a/src/plugins/embeddable/public/embeddable_panel/panel_header/embeddable_panel_header.test.tsx b/src/plugins/embeddable/public/embeddable_panel/panel_header/embeddable_panel_header.test.tsx index b070837ce7ad9..770ca76edbc33 100644 --- a/src/plugins/embeddable/public/embeddable_panel/panel_header/embeddable_panel_header.test.tsx +++ b/src/plugins/embeddable/public/embeddable_panel/panel_header/embeddable_panel_header.test.tsx @@ -8,13 +8,10 @@ import React from 'react'; -import { overlayServiceMock } from '@kbn/core-overlays-browser-mocks'; -import { themeServiceMock } from '@kbn/core-theme-browser-mocks'; import '@testing-library/jest-dom'; import { render, screen } from '@testing-library/react'; -// import userEvent from '@testing-library/user-event'; -// import { ViewMode } from '../../lib'; +import { applicationServiceMock } from '@kbn/core-application-browser-mocks'; import userEvent from '@testing-library/user-event'; import { ViewMode } from '../../../common'; import { @@ -22,16 +19,16 @@ import { ContactCardEmbeddableFactory, ContactCardEmbeddableInput, } from '../../lib/test_samples'; -import { CustomizePanelAction, EditPanelAction } from '../panel_actions'; +import { EditPanelAction } from '../panel_actions'; +import * as openCustomizePanel from '../panel_actions/customize_panel_action/open_customize_panel'; import { EmbeddablePanelHeader } from './embeddable_panel_header'; -const overlays = overlayServiceMock.createStartContract(); -const theme = themeServiceMock.createStartContract(); -const editPanelActionMock = { execute: jest.fn() } as unknown as EditPanelAction; +const getEmbeddableFactory = jest.fn(); +const application = applicationServiceMock.createStartContract(); +const editPanelAction = new EditPanelAction(getEmbeddableFactory, application); const mockEmbeddableFactory = new ContactCardEmbeddableFactory((() => null) as any, {} as any); -const customizePanelAction = new CustomizePanelAction(overlays, theme, editPanelActionMock); -customizePanelAction.execute = jest.fn(); +editPanelAction.execute = jest.fn(); const DEFAULT_PANEL_TITLE = 'Panel title'; @@ -130,10 +127,10 @@ describe('edit mode', () => { ); - const titleComponent = await screen.findByTestId('dashboardPanelTitle'); + const titleComponent = await screen.findByTestId('embeddablePanelTitleInner'); expect(titleComponent).toHaveTextContent('[No Title]'); }); @@ -146,10 +143,9 @@ describe('edit mode', () => { ); - screen.debug(); const titleComponent = await screen.findByTestId('embeddablePanelHeading-'); const innerTitleComponent = await screen.findByTestId('embeddablePanelTitleInner'); expect(innerTitleComponent).toBeEmptyDOMElement(); @@ -157,18 +153,19 @@ describe('edit mode', () => { expect(titleComponent).toContainElement(menuComponent); }); - test('clicking title calls customize panel action', async () => { + test('clicking title opens customize panel flyout', async () => { const mockEmbeddable = await createEmbeddable({ viewMode: ViewMode.EDIT }); render( ); - screen.debug(); const titleComponent = await screen.findByTestId('embeddablePanelTitleLink'); + + const spy = jest.spyOn(openCustomizePanel, 'openCustomizePanelFlyout'); userEvent.click(titleComponent); - expect(customizePanelAction.execute).toBeCalled(); + expect(spy).toHaveBeenCalled(); }); });