-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Time to Visualize] Library Notification Popover #79581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ThomThomson
merged 11 commits into
elastic:master
from
ThomThomson:feature/libraryNotificationExecute
Oct 14, 2020
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
149a4cc
Added popover to the library notification which acts as an unlink sho…
ThomThomson 75950b0
Type fix
ThomThomson 2ea287d
Merge branch 'master' of github.com:elastic/kibana into feature/libra…
ThomThomson a626fac
Added toasts to unlink and add actions. Changed unlink popover
ThomThomson ebc9a9d
Added toasts to tests
ThomThomson b877b80
Added aria label
ThomThomson aa267a6
Merge branch 'master' into feature/libraryNotificationExecute
kibanamachine c006624
Merge branch 'master' of github.com:elastic/kibana into feature/libra…
ThomThomson a9a92a9
fixed copy, implemented suggestions
ThomThomson 6b6c0e6
Merge branch 'master' of github.com:elastic/kibana into feature/libra…
ThomThomson 76046e6
implemented review suggestions
ThomThomson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
src/plugins/dashboard/public/application/actions/library_notification_popover.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. 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. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { DashboardContainer } from '..'; | ||
| import { isErrorEmbeddable } from '../../embeddable_plugin'; | ||
| import { mountWithIntl } from '../../../../../test_utils/public/enzyme_helpers'; | ||
| import { embeddablePluginMock } from '../../../../embeddable/public/mocks'; | ||
| import { getSampleDashboardInput } from '../test_helpers'; | ||
| import { | ||
| CONTACT_CARD_EMBEDDABLE, | ||
| ContactCardEmbeddableFactory, | ||
| ContactCardEmbeddable, | ||
| ContactCardEmbeddableInput, | ||
| ContactCardEmbeddableOutput, | ||
| } from '../../embeddable_plugin_test_samples'; | ||
| import { | ||
| LibraryNotificationPopover, | ||
| LibraryNotificationProps, | ||
| } from './library_notification_popover'; | ||
| import { CoreStart } from '../../../../../core/public'; | ||
| import { coreMock } from '../../../../../core/public/mocks'; | ||
| import { findTestSubject } from '@elastic/eui/lib/test'; | ||
| import { EuiPopover } from '@elastic/eui'; | ||
|
|
||
| describe('LibraryNotificationPopover', () => { | ||
| const { setup, doStart } = embeddablePluginMock.createInstance(); | ||
| setup.registerEmbeddableFactory( | ||
| CONTACT_CARD_EMBEDDABLE, | ||
| new ContactCardEmbeddableFactory((() => null) as any, {} as any) | ||
| ); | ||
| const start = doStart(); | ||
|
|
||
| let container: DashboardContainer; | ||
| let defaultProps: LibraryNotificationProps; | ||
| let coreStart: CoreStart; | ||
|
|
||
| beforeEach(async () => { | ||
| coreStart = coreMock.createStart(); | ||
|
|
||
| const containerOptions = { | ||
| ExitFullScreenButton: () => null, | ||
| SavedObjectFinder: () => null, | ||
| application: {} as any, | ||
| embeddable: start, | ||
| inspector: {} as any, | ||
| notifications: {} as any, | ||
| overlays: coreStart.overlays, | ||
| savedObjectMetaData: {} as any, | ||
| uiActions: {} as any, | ||
| }; | ||
|
|
||
| container = new DashboardContainer(getSampleDashboardInput(), containerOptions); | ||
| const contactCardEmbeddable = await container.addNewEmbeddable< | ||
| ContactCardEmbeddableInput, | ||
| ContactCardEmbeddableOutput, | ||
| ContactCardEmbeddable | ||
| >(CONTACT_CARD_EMBEDDABLE, { | ||
| firstName: 'Kibanana', | ||
| }); | ||
|
|
||
| if (isErrorEmbeddable(contactCardEmbeddable)) { | ||
| throw new Error('Failed to create embeddable'); | ||
| } | ||
|
|
||
| defaultProps = { | ||
| unlinkAction: ({ | ||
| execute: jest.fn(), | ||
| getDisplayName: () => 'test unlink', | ||
| } as unknown) as LibraryNotificationProps['unlinkAction'], | ||
| displayName: 'test display', | ||
| context: { embeddable: contactCardEmbeddable }, | ||
| icon: 'testIcon', | ||
| id: 'testId', | ||
| }; | ||
| }); | ||
|
|
||
| function mountComponent(props?: Partial<LibraryNotificationProps>) { | ||
| return mountWithIntl(<LibraryNotificationPopover {...{ ...defaultProps, ...props }} />); | ||
| } | ||
|
|
||
| test('click library notification badge should open and close popover', () => { | ||
| const component = mountComponent(); | ||
| const btn = findTestSubject(component, `embeddablePanelNotification-${defaultProps.id}`); | ||
| btn.simulate('click'); | ||
| let popover = component.find(EuiPopover); | ||
| expect(popover.prop('isOpen')).toBe(true); | ||
| btn.simulate('click'); | ||
| popover = component.find(EuiPopover); | ||
| expect(popover.prop('isOpen')).toBe(false); | ||
| }); | ||
|
|
||
| test('popover should contain button with unlink action display name', () => { | ||
| const component = mountComponent(); | ||
| const btn = findTestSubject(component, `embeddablePanelNotification-${defaultProps.id}`); | ||
| btn.simulate('click'); | ||
| const popover = component.find(EuiPopover); | ||
| const unlinkButton = findTestSubject(popover, 'libraryNotificationUnlinkButton'); | ||
| expect(unlinkButton.text()).toEqual('test unlink'); | ||
| }); | ||
|
|
||
| test('clicking unlink executes unlink action', () => { | ||
| const component = mountComponent(); | ||
| const btn = findTestSubject(component, `embeddablePanelNotification-${defaultProps.id}`); | ||
| btn.simulate('click'); | ||
| const popover = component.find(EuiPopover); | ||
| const unlinkButton = findTestSubject(popover, 'libraryNotificationUnlinkButton'); | ||
| unlinkButton.simulate('click'); | ||
| expect(defaultProps.unlinkAction.execute).toHaveBeenCalled(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.