Unverified Commit 7a707a68 authored by Mattermost Build's avatar Mattermost Build Committed by GitHub
Browse files

Automated cherry pick of #5915 (#5932)

Automatic Merge
parent 00ebaf7b
......@@ -51,6 +51,7 @@ exports[`components/channel_header/components/UserGuideDropdown should match sna
<MenuGroup>
<MenuItemExternalLink
id="askTheCommunityLink"
onClick={[Function]}
show={true}
text="Ask the community"
url="https://mattermost.com/pl/default-ask-mattermost-community/"
......
......@@ -6,6 +6,7 @@ import React from 'react';
import {shallowWithIntl} from 'tests/helpers/intl-test-helper';
import MenuWrapper from 'components/widgets/menu/menu_wrapper';
import Menu from 'components/widgets/menu/menu';
import {trackEvent} from 'actions/diagnostics_actions.jsx';
import UserGuideDropdown from 'components/channel_header/components/user_guide_dropdown/user_guide_dropdown';
import * as GlobalActions from 'actions/global_actions.jsx';
......@@ -14,6 +15,15 @@ jest.mock('actions/global_actions', () => ({
toggleShortcutsModal: jest.fn(),
}));
jest.mock('actions/diagnostics_actions.jsx', () => {
const original = jest.requireActual('actions/diagnostics_actions.jsx');
return {
...original,
trackEvent: jest.fn(),
};
});
describe('components/channel_header/components/UserGuideDropdown', () => {
const baseProps = {
helpLink: 'helpLink',
......@@ -60,4 +70,13 @@ describe('components/channel_header/components/UserGuideDropdown', () => {
wrapper.find(Menu.ItemAction).prop('onClick')({preventDefault: jest.fn()});
expect(GlobalActions.toggleShortcutsModal).toHaveBeenCalled();
});
test('Should call for track event on click of askTheCommunityLink', () => {
const wrapper = shallowWithIntl(
<UserGuideDropdown {...baseProps}/>,
);
wrapper.find(Menu.ItemExternalLink).find('#askTheCommunityLink').prop('onClick')();
expect(trackEvent).toBeCalledWith('ui', 'help_ask_the_community');
});
});
......@@ -11,6 +11,7 @@ import UserGuideIcon from 'components/widgets/icons/user_guide_icon';
import Menu from 'components/widgets/menu/menu';
import OverlayTrigger from 'components/overlay_trigger';
import * as GlobalActions from 'actions/global_actions.jsx';
import {trackEvent} from 'actions/diagnostics_actions.jsx';
const askTheCommunityUrl = 'https://mattermost.com/pl/default-ask-mattermost-community/';
......@@ -44,6 +45,10 @@ class UserGuideDropdown extends React.PureComponent<Props, State> {
});
}
askTheCommunityClick = () => {
trackEvent('ui', 'help_ask_the_community');
}
renderDropdownItems = (): React.ReactNode => {
const {intl} = this.props;
......@@ -54,6 +59,7 @@ class UserGuideDropdown extends React.PureComponent<Props, State> {
id='askTheCommunityLink'
url={askTheCommunityUrl}
text={intl.formatMessage({id: 'userGuideHelp.askTheCommunity', defaultMessage: 'Ask the community'})}
onClick={this.askTheCommunityClick}
/>
)}
<Menu.ItemExternalLink
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment