From 964678fc45ffeec84f123f0b84f0be3e71cc788e Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Mon, 14 Apr 2025 14:18:26 -0400 Subject: [PATCH] MM-62005 Remove FloatingFocusManager from PluginLinkTooltip (#30663) * MM-62005 Remove FloatingFocusManager from PluginLinkTooltip * Update tests to define more realistic plugin components * Revert "Update tests to define more realistic plugin components" This reverts commit c23307112c2bc5091b931980885cc79e4b945ff8. * Revert changes to DeepPartial * Use class component for test component --- .../plugin_link_tooltip/index.test.tsx | 135 ++++++++++++++++++ .../components/plugin_link_tooltip/index.tsx | 29 ++-- 2 files changed, 148 insertions(+), 16 deletions(-) create mode 100644 webapp/channels/src/components/plugin_link_tooltip/index.test.tsx diff --git a/webapp/channels/src/components/plugin_link_tooltip/index.test.tsx b/webapp/channels/src/components/plugin_link_tooltip/index.test.tsx new file mode 100644 index 0000000000..f8acfb3e8a --- /dev/null +++ b/webapp/channels/src/components/plugin_link_tooltip/index.test.tsx @@ -0,0 +1,135 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import React from 'react'; + +import {act, renderWithContext, screen, userEvent, waitFor} from 'tests/react_testing_utils'; +import {RootHtmlPortalId} from 'utils/constants'; + +import PluginLinkTooltip from '.'; + +class TestLinkTooltip extends React.PureComponent<{href: string}> { + render() { + if (this.props.href.includes('tooltip')) { + return
{'This is a link tooltip'}
; + } + + return null; + } +} + +describe('PluginLinkTooltip', () => { + const baseState = { + plugins: { + components: { + LinkTooltip: [ + { + id: 'test', + pluginId: 'example.test', + component: TestLinkTooltip, + }, + ], + }, + }, + }; + + test('should show tooltip on hover', async () => { + renderWithContext( + <> + + {'This is a link'} + +
+ , + baseState, + ); + + expect(screen.queryByText('This is a link tooltip')).not.toBeInTheDocument(); + + userEvent.hover(screen.getByText('This is a link')); + await waitFor(() => { + expect(screen.queryByText('This is a link tooltip')).toBeVisible(); + }); + + act(() => { + userEvent.unhover(screen.getByText('This is a link')); + }); + await waitFor(() => { + expect(screen.queryByText('This is a link tooltip')).not.toBeInTheDocument(); + }); + }); + + test('should not take focus when the tooltip appears', async () => { + renderWithContext( + <> +