diff --git a/e2e-tests/cypress/tests/integration/playbooks/channels/channel_header_spec.js b/e2e-tests/cypress/tests/integration/playbooks/channels/channel_header_spec.js index 330f51014d..63d445bd9c 100644 --- a/e2e-tests/cypress/tests/integration/playbooks/channels/channel_header_spec.js +++ b/e2e-tests/cypress/tests/integration/playbooks/channels/channel_header_spec.js @@ -91,7 +91,7 @@ describe('channels > channel header', {testIsolation: true}, () => { }); // * Verify tooltip text - cy.get('#pluginTooltip').contains('Playbooks'); + cy.get('#playbooksChannelHeaderButton').contains('Playbooks'); }); it('webapp should make the Playbook channel header button active when opened', () => { diff --git a/webapp/channels/src/components/channel_header/__snapshots__/channel_header.test.tsx.snap b/webapp/channels/src/components/channel_header/__snapshots__/channel_header.test.tsx.snap index 37511f78c6..484fad673a 100644 --- a/webapp/channels/src/components/channel_header/__snapshots__/channel_header.test.tsx.snap +++ b/webapp/channels/src/components/channel_header/__snapshots__/channel_header.test.tsx.snap @@ -72,7 +72,6 @@ exports[`components/ChannelHeader should match snapshot with last active display className="channel-header__icons" > } onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="channelMembers" + tooltip="Members" /> } onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="channelMembers" + tooltip="Members" /> } onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="channelMembers" + tooltip="Members" /> } onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="channelMembers" + tooltip="Members" /> } onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="channelMembers" + tooltip="Members" /> } onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="channelMembers" + tooltip="Members" /> } onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="channelMembers" + tooltip="Members" /> } onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="channelMembers" + tooltip="Members" /> } onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="channelMembers" + tooltip="Members" /> } onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="channelMembers" + tooltip="Members" /> } onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="channelMembers" + tooltip="Members" /> } onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
} onClick={[Function]} - tooltipKey="channelMembers" + tooltip="Members" /> } onClick={[Function]} - tooltipKey="pinnedPosts" + tooltip="Pinned messages" /> } onClick={[Function]} - tooltipKey="channelFiles" + tooltip="Channel files" />
{ memberListButton = ( ); } @@ -607,20 +606,18 @@ class ChannelHeader extends React.PureComponent { {memberListButton} {this.props.isFileAttachmentsEnabled && }
diff --git a/webapp/channels/src/components/channel_header/channel_info_button.tsx b/webapp/channels/src/components/channel_header/channel_info_button.tsx index 7de1039b3d..d7b3a70f33 100644 --- a/webapp/channels/src/components/channel_header/channel_info_button.tsx +++ b/webapp/channels/src/components/channel_header/channel_info_button.tsx @@ -2,6 +2,7 @@ // See LICENSE.txt for license information. import React, {useCallback} from 'react'; +import {useIntl} from 'react-intl'; import {useDispatch, useSelector} from 'react-redux'; import styled from 'styled-components'; @@ -30,6 +31,7 @@ const Icon = styled.i` const ChannelInfoButton = ({channel}: Props) => { const dispatch = useDispatch(); + const intl = useIntl(); const rhsState: RhsState = useSelector(getRhsState); const isRhsOpen: boolean = useSelector(getIsRhsOpen); @@ -48,7 +50,12 @@ const ChannelInfoButton = ({channel}: Props) => { } }, [buttonActive, channel.id, isChannelInfo, dispatch]); - const tooltipKey = buttonActive ? 'closeChannelInfo' : 'openChannelInfo'; + let tooltip; + if (buttonActive) { + tooltip = intl.formatMessage({id: 'channel_header.closeChannelInfo', defaultMessage: 'Close info'}); + } else { + tooltip = intl.formatMessage({id: 'channel_header.openChannelInfo', defaultMessage: 'View Info'}); + } let buttonClass = 'channel-header__icon'; if (buttonActive) { @@ -60,9 +67,8 @@ const ChannelInfoButton = ({channel}: Props) => { buttonClass={buttonClass} buttonId='channel-info-btn' onClick={toggleRHS} - ariaLabel={true} iconComponent={} - tooltipKey={tooltipKey} + tooltip={tooltip} /> ); }; diff --git a/webapp/channels/src/components/channel_header/components/__snapshots__/header_icon_wrapper.test.tsx.snap b/webapp/channels/src/components/channel_header/components/__snapshots__/header_icon_wrapper.test.tsx.snap deleted file mode 100644 index 19a582620e..0000000000 --- a/webapp/channels/src/components/channel_header/components/__snapshots__/header_icon_wrapper.test.tsx.snap +++ /dev/null @@ -1,260 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`components/channel_header/components/HeaderIconWrapper should match snapshot, on ChannelFilesIcon 1`] = ` -
- - - - } - placement="bottom" - trigger={ - Array [ - "hover", - "focus", - ] - } - > - - -
-`; - -exports[`components/channel_header/components/HeaderIconWrapper should match snapshot, on FlagIcon 1`] = ` -
- - - - } - placement="bottom" - trigger={ - Array [ - "hover", - "focus", - ] - } - > - - -
-`; - -exports[`components/channel_header/components/HeaderIconWrapper should match snapshot, on MentionsIcon 1`] = ` -
- - - - - } - placement="bottom" - trigger={ - Array [ - "hover", - "focus", - ] - } - > - - -
-`; - -exports[`components/channel_header/components/HeaderIconWrapper should match snapshot, on PinIcon 1`] = ` -
- - - - } - placement="bottom" - trigger={ - Array [ - "hover", - "focus", - ] - } - > - - -
-`; - -exports[`components/channel_header/components/HeaderIconWrapper should match snapshot, on PluginIcon with tooltipText 1`] = ` -
- - - plugin_tooltip_text - - - } - placement="bottom" - trigger={ - Array [ - "hover", - "focus", - ] - } - > - - -
-`; - -exports[`components/channel_header/components/HeaderIconWrapper should match snapshot, on PluginIcon without tooltipText 1`] = ` - -
- -
-
-`; - -exports[`components/channel_header/components/HeaderIconWrapper should match snapshot, on SearchIcon 1`] = ` -
- - - - } - placement="bottom" - trigger={ - Array [ - "hover", - "focus", - ] - } - > - - -
-`; diff --git a/webapp/channels/src/components/channel_header/components/header_icon_wrapper.test.tsx b/webapp/channels/src/components/channel_header/components/header_icon_wrapper.test.tsx index e98f299226..86dc064b99 100644 --- a/webapp/channels/src/components/channel_header/components/header_icon_wrapper.test.tsx +++ b/webapp/channels/src/components/channel_header/components/header_icon_wrapper.test.tsx @@ -1,17 +1,14 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {shallow} from 'enzyme'; import React from 'react'; import HeaderIconWrapper from 'components/channel_header/components/header_icon_wrapper'; -import FlagIcon from 'components/widgets/icons/flag_icon'; import MentionsIcon from 'components/widgets/icons/mentions_icon'; -import PinIcon from 'components/widgets/icons/pin_icon'; -import SearchIcon from 'components/widgets/icons/search_icon'; + +import {renderWithContext, screen, userEvent, waitFor} from 'tests/react_testing_utils'; describe('components/channel_header/components/HeaderIconWrapper', () => { - function emptyFunction() {} //eslint-disable-line no-empty-function const mentionsIcon = ( { iconComponent: mentionsIcon, buttonClass: 'button_class', buttonId: 'button_id', - onClick: emptyFunction, - tooltipKey: 'recentMentions', + onClick: jest.fn(), + tooltip: 'Recent mentions', }; - test('should match snapshot, on MentionsIcon', () => { - const wrapper = shallow( - , + test('should be accessible', async () => { + renderWithContext( + , ); - expect(wrapper).toMatchSnapshot(); + expect(screen.getByLabelText('Recent mentions')).toBeVisible(); + expect(screen.queryByText('Recent mentions')).not.toBeInTheDocument(); + + userEvent.hover(screen.getByLabelText('Recent mentions')); + + await waitFor(() => { + expect(screen.queryByText('Recent mentions')).toBeInTheDocument(); + }); }); - test('should match snapshot, on FlagIcon', () => { - const flagIcon = ( -