level_0
int64 0
10k
| index
int64 0
0
| repo_id
stringlengths 22
152
| file_path
stringlengths 41
203
| content
stringlengths 11
11.5M
|
---|---|---|---|---|
3,493 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_profile/user.test.ts | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import ColorContrastChecker from 'color-contrast-checker';
import {cachedUserNameColors, generateColor} from './utils';
const CONSTRAST_CHECKER = new ColorContrastChecker();
const BACKGROUND_COLOR = '#ACC8E5';
describe('components/user_profile/utils', () => {
test.each([
['Ross_Bednar', '#432dd2', 4.5],
['Geovany95', '#2d3086', 4.5],
['Madisen25', '#52783a', 2.9],
['Gerard17', '#783a54', 4.5],
['Alia30', '#392d86', 4.5],
['Darien.Prosacco97', '#862d6d', 4.5],
['Alf48', '#4053bf', 3.7],
['Darron_Orn-Walsh49', '#742d86', 4.5],
])('should generate best color contrast', (userName, expected, ratio) => {
cachedUserNameColors.clear();
const actual = generateColor(userName, BACKGROUND_COLOR);
expect(actual).toBe(expected);
expect(
CONSTRAST_CHECKER.isLevelCustom(actual, BACKGROUND_COLOR, ratio),
).toBeTruthy();
});
});
|
3,494 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_profile/user_profile.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import type {UserProfile as UserProfileType} from '@mattermost/types/users';
import {Preferences} from 'mattermost-redux/constants';
import UserProfile from './user_profile';
describe('components/UserProfile', () => {
const baseProps = {
displayName: 'nickname',
isBusy: false,
isMobileView: false,
user: {username: 'username'} as UserProfileType,
userId: 'user_id',
theme: Preferences.THEMES.onyx,
};
test('should match snapshot', () => {
const wrapper = shallow(<UserProfile {...baseProps}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, with colorization', () => {
const props = {
...baseProps,
colorize: true,
};
const wrapper = shallow(<UserProfile {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, when user is shared', () => {
const props = {
...baseProps,
isShared: true,
};
const wrapper = shallow(<UserProfile {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, when popover is disabled', () => {
const wrapper = shallow(
<UserProfile
{...baseProps}
disablePopover={true}
/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, when displayUsername is enabled', () => {
const wrapper = shallow(
<UserProfile
{...baseProps}
displayUsername={true}
/>,
);
expect(wrapper).toMatchSnapshot();
});
});
|
3,497 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_profile | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_profile/__snapshots__/user_profile.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/UserProfile should match snapshot 1`] = `
<Fragment>
<OverlayTrigger
defaultOverlayShown={false}
overlay={
<Memo(Connect(injectIntl(ProfilePopover)))
className="user-profile-popover"
hasMention={false}
hide={[Function]}
hideStatus={false}
isBusy={false}
overwriteName=""
src="/api/v4/users/undefined/image?_=0"
userId="user_id"
/>
}
placement="right"
rootClose={true}
trigger={
Array [
"click",
]
}
>
<button
aria-label="nickname"
className="user-popover style--none"
>
nickname
</button>
</OverlayTrigger>
</Fragment>
`;
exports[`components/UserProfile should match snapshot, when displayUsername is enabled 1`] = `
<Fragment>
<OverlayTrigger
defaultOverlayShown={false}
overlay={
<Memo(Connect(injectIntl(ProfilePopover)))
className="user-profile-popover"
hasMention={false}
hide={[Function]}
hideStatus={false}
isBusy={false}
overwriteName=""
src="/api/v4/users/undefined/image?_=0"
userId="user_id"
/>
}
placement="right"
rootClose={true}
trigger={
Array [
"click",
]
}
>
<button
aria-label="@username"
className="user-popover style--none"
>
@username
</button>
</OverlayTrigger>
</Fragment>
`;
exports[`components/UserProfile should match snapshot, when popover is disabled 1`] = `
<div
className="user-popover"
>
nickname
</div>
`;
exports[`components/UserProfile should match snapshot, when user is shared 1`] = `
<Fragment>
<OverlayTrigger
defaultOverlayShown={false}
overlay={
<Memo(Connect(injectIntl(ProfilePopover)))
className="user-profile-popover"
hasMention={false}
hide={[Function]}
hideStatus={false}
isBusy={false}
overwriteName=""
src="/api/v4/users/undefined/image?_=0"
userId="user_id"
/>
}
placement="right"
rootClose={true}
trigger={
Array [
"click",
]
}
>
<button
aria-label="nickname"
className="user-popover style--none"
>
nickname
</button>
</OverlayTrigger>
<SharedUserIndicator
className="shared-user-icon"
withTooltip={true}
/>
</Fragment>
`;
exports[`components/UserProfile should match snapshot, with colorization 1`] = `
<Fragment>
<OverlayTrigger
defaultOverlayShown={false}
overlay={
<Memo(Connect(injectIntl(ProfilePopover)))
className="user-profile-popover"
hasMention={false}
hide={[Function]}
hideStatus={false}
isBusy={false}
overwriteName=""
src="/api/v4/users/undefined/image?_=0"
userId="user_id"
/>
}
placement="right"
rootClose={true}
trigger={
Array [
"click",
]
}
>
<button
aria-label="nickname"
className="user-popover style--none"
style={
Object {
"color": "#bbd279",
}
}
>
nickname
</button>
</OverlayTrigger>
</Fragment>
`;
|
3,498 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/import_theme_modal.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {setThemeDefaults} from 'mattermost-redux/utils/theme_utils';
import {mountWithIntl, shallowWithIntl} from 'tests/helpers/intl-test-helper';
import ImportThemeModal from './import_theme_modal';
describe('components/user_settings/ImportThemeModal', () => {
const props = {
intl: {} as any,
onExited: jest.fn(),
callback: jest.fn(),
};
it('should match snapshot', () => {
const wrapper = shallowWithIntl(<ImportThemeModal {...props}/>);
expect(wrapper).toMatchSnapshot();
});
it('should correctly parse a Slack theme', () => {
const theme = setThemeDefaults({
type: 'custom',
sidebarBg: '#1d2229',
sidebarText: '#ffffff',
sidebarUnreadText: '#ffffff',
sidebarTextHoverBg: '#313843',
sidebarTextActiveBorder: '#537aa6',
sidebarTextActiveColor: '#ffffff',
sidebarHeaderBg: '#0b161e',
sidebarTeamBarBg: '#081118',
sidebarHeaderTextColor: '#ffffff',
onlineIndicator: '#94e864',
mentionBg: '#78af8f',
});
const themeString = '#1d2229,#0b161e,#537aa6,#ffffff,#313843,#ffffff,#94e864,#78af8f,#0b161e,#ffffff';
const wrapper = mountWithIntl(<ImportThemeModal {...props}/>);
const instance = wrapper.instance();
instance.setState({show: true});
wrapper.update();
wrapper.find('input').simulate('change', {target: {value: themeString}});
wrapper.find('#submitButton').simulate('click');
expect(props.callback).toHaveBeenCalledWith(theme);
});
});
|
3,502 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/__snapshots__/import_theme_modal.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/user_settings/ImportThemeModal should match snapshot 1`] = `
<span>
<Modal
animation={true}
aria-labelledby="importThemeModalLabel"
autoFocus={true}
backdrop={true}
bsClass="modal"
dialogClassName="a11y__modal"
dialogComponentClass={[Function]}
enforceFocus={true}
keyboard={true}
manager={
ModalManager {
"add": [Function],
"containers": Array [],
"data": Array [],
"handleContainerOverflow": true,
"hideSiblingNodes": true,
"isTopModal": [Function],
"modals": Array [],
"remove": [Function],
}
}
onExited={[MockFunction]}
onHide={[Function]}
renderBackdrop={[Function]}
restoreFocus={true}
role="dialog"
show={true}
>
<ModalHeader
bsClass="modal-header"
closeButton={true}
closeLabel="Close"
>
<ModalTitle
bsClass="modal-title"
componentClass="h1"
id="importThemeModalLabel"
>
<MemoizedFormattedMessage
defaultMessage="Import Slack Theme"
id="user.settings.import_theme.importHeader"
/>
</ModalTitle>
</ModalHeader>
<form
className="form-horizontal"
role="form"
>
<ModalBody
bsClass="modal-body"
componentClass="div"
>
<p>
<MemoizedFormattedMessage
defaultMessage="To import a theme, go to a Slack team and look for \\"Preferences -> Themes\\". Open the custom theme option, copy the theme color values and paste them here:"
id="user.settings.import_theme.importBody"
/>
</p>
<div
className="form-group less"
>
<div
className="col-sm-12"
>
<input
className="form-control"
id="themeVector"
onChange={[Function]}
type="text"
value=""
/>
<div
className="input__help"
/>
</div>
</div>
</ModalBody>
<ModalFooter
bsClass="modal-footer"
componentClass="div"
>
<button
className="btn btn-tertiary"
id="cancelButton"
onClick={[Function]}
type="button"
>
<MemoizedFormattedMessage
defaultMessage="Cancel"
id="user.settings.import_theme.cancel"
/>
</button>
<button
className="btn btn-primary"
id="submitButton"
onClick={[Function]}
type="submit"
>
<MemoizedFormattedMessage
defaultMessage="Submit"
id="user.settings.import_theme.submit"
/>
</button>
</ModalFooter>
</form>
</Modal>
</span>
`;
|
3,504 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/advanced/user_settings_advanced.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import type {ComponentProps} from 'react';
import AdvancedSettingsDisplay from 'components/user_settings/advanced/user_settings_advanced';
import {Preferences} from 'utils/constants';
import {TestHelper} from 'utils/test_helper';
import {isMac} from 'utils/user_agent';
jest.mock('actions/global_actions');
jest.mock('utils/user_agent');
describe('components/user_settings/display/UserSettingsDisplay', () => {
const user = TestHelper.getUserMock({
id: 'user_id',
username: 'username',
locale: 'en',
timezone: {
useAutomaticTimezone: 'true',
automaticTimezone: 'America/New_York',
manualTimezone: '',
},
});
const requiredProps: ComponentProps<typeof AdvancedSettingsDisplay> = {
currentUser: user,
updateSection: jest.fn(),
activeSection: '',
closeModal: jest.fn(),
collapseModal: jest.fn(),
actions: {
savePreferences: jest.fn(),
updateUserActive: jest.fn().mockResolvedValue({data: true}),
revokeAllSessionsForUser: jest.fn().mockResolvedValue({data: true}),
},
advancedSettingsCategory: [],
sendOnCtrlEnter: '',
formatting: '',
joinLeave: '',
syncDrafts: '',
unreadScrollPosition: Preferences.UNREAD_SCROLL_POSITION_START_FROM_LEFT,
codeBlockOnCtrlEnter: 'false',
enablePreviewFeatures: false,
enableUserDeactivation: false,
syncedDraftsAreAllowed: true,
};
test('should have called handleSubmit', async () => {
const updateSection = jest.fn();
const props = {...requiredProps, updateSection};
const wrapper = shallow<AdvancedSettingsDisplay>(<AdvancedSettingsDisplay {...props}/>);
await wrapper.instance().handleSubmit([]);
expect(updateSection).toHaveBeenCalledWith('');
});
test('should have called updateSection', () => {
const updateSection = jest.fn();
const props = {...requiredProps, updateSection};
const wrapper = shallow<AdvancedSettingsDisplay>(<AdvancedSettingsDisplay {...props}/>);
wrapper.instance().handleUpdateSection('');
expect(updateSection).toHaveBeenCalledWith('');
wrapper.instance().handleUpdateSection('linkpreview');
expect(updateSection).toHaveBeenCalledWith('linkpreview');
});
test('should have called updateUserActive', () => {
const updateUserActive = jest.fn(() => Promise.resolve({}));
const props = {...requiredProps, actions: {...requiredProps.actions, updateUserActive}};
const wrapper = shallow<AdvancedSettingsDisplay>(<AdvancedSettingsDisplay {...props}/>);
wrapper.instance().handleDeactivateAccountSubmit();
expect(updateUserActive).toHaveBeenCalled();
expect(updateUserActive).toHaveBeenCalledWith(requiredProps.currentUser.id, false);
});
test('handleDeactivateAccountSubmit() should have called revokeAllSessions', () => {
const wrapper = shallow<AdvancedSettingsDisplay>(<AdvancedSettingsDisplay {...requiredProps}/>);
wrapper.instance().handleDeactivateAccountSubmit();
expect(requiredProps.actions.revokeAllSessionsForUser).toHaveBeenCalled();
expect(requiredProps.actions.revokeAllSessionsForUser).toHaveBeenCalledWith(requiredProps.currentUser.id);
});
test('handleDeactivateAccountSubmit() should have updated state.serverError', async () => {
const error = {message: 'error'};
const revokeAllSessionsForUser = () => Promise.resolve({error});
const props = {...requiredProps, actions: {...requiredProps.actions, revokeAllSessionsForUser}};
const wrapper = shallow<AdvancedSettingsDisplay>(<AdvancedSettingsDisplay {...props}/>);
await wrapper.instance().handleDeactivateAccountSubmit();
expect(wrapper.state().serverError).toEqual(error.message);
});
test('function getCtrlSendText should return correct value for Mac', () => {
(isMac as jest.Mock).mockReturnValue(true);
const props = {...requiredProps};
const wrapper = shallow<AdvancedSettingsDisplay>(<AdvancedSettingsDisplay {...props}/>);
expect(wrapper.instance().getCtrlSendText().ctrlSendTitle.defaultMessage).toEqual('Send Messages on ⌘+ENTER');
});
test('function getCtrlSendText should return correct value for Windows', () => {
(isMac as jest.Mock).mockReturnValue(false);
const props = {...requiredProps};
const wrapper = shallow<AdvancedSettingsDisplay>(<AdvancedSettingsDisplay {...props}/>);
expect(wrapper.instance().getCtrlSendText().ctrlSendTitle.defaultMessage).toEqual('Send Messages on CTRL+ENTER');
});
});
|
3,507 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/advanced | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/advanced/join_leave_section/join_leave_section.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import {Preferences} from 'mattermost-redux/constants';
import {getPreferenceKey} from 'mattermost-redux/utils/preference_utils';
import SettingItemMax from 'components/setting_item_max';
import SettingItemMin from 'components/setting_item_min';
import JoinLeaveSection from 'components/user_settings/advanced/join_leave_section/join_leave_section';
import mergeObjects from 'packages/mattermost-redux/test/merge_objects';
import {AdvancedSections} from 'utils/constants';
import type {GlobalState} from 'types/store';
describe('components/user_settings/advanced/JoinLeaveSection', () => {
const defaultProps = {
active: false,
areAllSectionsInactive: false,
currentUserId: 'current_user_id',
joinLeave: 'true',
onUpdateSection: jest.fn(),
renderOnOffLabel: jest.fn(),
actions: {
savePreferences: jest.fn(() => {
return new Promise<void>((resolve) => {
process.nextTick(() => resolve());
});
}),
},
};
test('should match snapshot', () => {
const wrapper = shallow(
<JoinLeaveSection {...defaultProps}/>,
);
expect(wrapper).toMatchSnapshot();
expect(wrapper.find(SettingItemMax).exists()).toEqual(false);
expect(wrapper.find(SettingItemMin).exists()).toEqual(true);
wrapper.setProps({active: true});
expect(wrapper).toMatchSnapshot();
expect(wrapper.find(SettingItemMax).exists()).toEqual(true);
expect(wrapper.find(SettingItemMin).exists()).toEqual(false);
});
test('should match state on handleOnChange', () => {
const wrapper = shallow<JoinLeaveSection>(
<JoinLeaveSection {...defaultProps}/>,
);
wrapper.setState({joinLeaveState: 'true'});
let value = 'false';
wrapper.instance().handleOnChange({currentTarget: {value}} as any);
expect(wrapper.state('joinLeaveState')).toEqual('false');
value = 'true';
wrapper.instance().handleOnChange({currentTarget: {value}} as any);
expect(wrapper.state('joinLeaveState')).toEqual('true');
});
test('should call props.actions.savePreferences and props.onUpdateSection on handleSubmit', () => {
const actions = {
savePreferences: jest.fn().mockImplementation(() => Promise.resolve({data: true})),
};
const onUpdateSection = jest.fn();
const wrapper = shallow<JoinLeaveSection>(
<JoinLeaveSection
{...defaultProps}
actions={actions}
onUpdateSection={onUpdateSection}
/>,
);
const joinLeavePreference = {
category: 'advanced_settings',
name: 'join_leave',
user_id: 'current_user_id',
value: 'true',
};
const instance = wrapper.instance();
instance.handleSubmit();
expect(actions.savePreferences).toHaveBeenCalledTimes(1);
expect(actions.savePreferences).toHaveBeenCalledWith('current_user_id', [joinLeavePreference]);
expect(onUpdateSection).toHaveBeenCalledTimes(1);
wrapper.setState({joinLeaveState: 'false'});
joinLeavePreference.value = 'false';
instance.handleSubmit();
expect(actions.savePreferences).toHaveBeenCalledTimes(2);
expect(actions.savePreferences).toHaveBeenCalledWith('current_user_id', [joinLeavePreference]);
});
test('should match state and call props.onUpdateSection on handleUpdateSection', () => {
const onUpdateSection = jest.fn();
const wrapper = shallow<JoinLeaveSection>(
<JoinLeaveSection
{...defaultProps}
onUpdateSection={onUpdateSection}
/>,
);
wrapper.setState({joinLeaveState: 'false'});
const instance = wrapper.instance();
instance.handleUpdateSection();
expect(wrapper.state('joinLeaveState')).toEqual(defaultProps.joinLeave);
expect(onUpdateSection).toHaveBeenCalledTimes(1);
wrapper.setState({joinLeaveState: 'false'});
instance.handleUpdateSection(AdvancedSections.JOIN_LEAVE);
expect(onUpdateSection).toHaveBeenCalledTimes(2);
expect(onUpdateSection).toBeCalledWith(AdvancedSections.JOIN_LEAVE);
});
});
import {mapStateToProps} from './index';
describe('mapStateToProps', () => {
const currentUserId = 'user-id';
const initialState = {
currentUserId,
entities: {
general: {
config: {
EnableJoinLeaveMessageByDefault: 'true',
},
},
preferences: {
myPreferences: {},
},
users: {
currentUserId,
profiles: {
[currentUserId]: {
id: currentUserId,
},
},
},
},
} as unknown as GlobalState;
test('configuration default to true', () => {
const props = mapStateToProps(initialState);
expect(props.joinLeave).toEqual('true');
});
test('configuration default to false', () => {
const testState = mergeObjects(initialState, {
entities: {
general: {
config: {
EnableJoinLeaveMessageByDefault: 'false',
},
},
},
});
const props = mapStateToProps(testState);
expect(props.joinLeave).toEqual('false');
});
test('user setting takes presidence', () => {
const testState = mergeObjects(initialState, {
entities: {
general: {
config: {
EnableJoinDefault: 'false',
},
},
preferences: {
myPreferences: {
[getPreferenceKey(Preferences.CATEGORY_ADVANCED_SETTINGS, Preferences.ADVANCED_FILTER_JOIN_LEAVE)]: {
category: Preferences.CATEGORY_ADVANCED_SETTINGS,
name: Preferences.ADVANCED_FILTER_JOIN_LEAVE,
value: 'true',
},
},
},
},
});
const props = mapStateToProps(testState);
expect(props.joinLeave).toEqual('true');
});
test('user setting takes presidence opposite', () => {
const testState = mergeObjects(initialState, {
entities: {
preferences: {
myPreferences: {
[getPreferenceKey(Preferences.CATEGORY_ADVANCED_SETTINGS, Preferences.ADVANCED_FILTER_JOIN_LEAVE)]: {
category: Preferences.CATEGORY_ADVANCED_SETTINGS,
name: Preferences.ADVANCED_FILTER_JOIN_LEAVE,
value: 'false',
},
},
},
},
});
const props = mapStateToProps(testState);
expect(props.joinLeave).toEqual('false');
});
});
|
3,509 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/advanced/join_leave_section | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/advanced/join_leave_section/__snapshots__/join_leave_section.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/user_settings/advanced/JoinLeaveSection should match snapshot 1`] = `
<SettingItemMin
section="joinLeave"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Enable Join/Leave Messages"
id="user.settings.advance.joinLeaveTitle"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/advanced/JoinLeaveSection should match snapshot 2`] = `
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<fieldset>
<legend
className="form-legend hidden-label"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Enable Join/Leave Messages"
id="user.settings.advance.joinLeaveTitle"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={true}
id="joinLeaveOn"
name="joinLeave"
onChange={[Function]}
type="radio"
value="true"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.advance.on"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
id="joinLeaveOff"
name="joinLeave"
onChange={[Function]}
type="radio"
value="false"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Off"
id="user.settings.advance.off"
/>
</label>
<br />
</div>
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="When \\"On\\", System Messages saying a user has joined or left a channel will be visible. When \\"Off\\", the System Messages about joining or leaving a channel will be hidden. A message will still show up when you are added to a channel, so you can receive a notification."
id="user.settings.advance.joinLeaveDesc"
/>
</div>
</fieldset>,
]
}
saving={false}
section=""
setting="joinLeave"
submit={[Function]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Enable Join/Leave Messages"
id="user.settings.advance.joinLeaveTitle"
/>
}
updateSection={[Function]}
/>
`;
|
3,513 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/user_settings_display.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import {Provider} from 'react-redux';
import type {UserProfile} from '@mattermost/types/users';
import configureStore from 'store';
import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import UserSettingsDisplay from './user_settings_display';
describe('components/user_settings/display/UserSettingsDisplay', () => {
const user = {
id: 'user_id',
username: 'username',
locale: 'en',
timezone: {
useAutomaticTimezone: 'true',
automaticTimezone: 'America/New_York',
manualTimezone: '',
},
};
const requiredProps = {
user: user as UserProfile,
updateSection: jest.fn(),
activeSection: '',
closeModal: jest.fn(),
collapseModal: jest.fn(),
setRequireConfirm: jest.fn(),
setEnforceFocus: jest.fn(),
enableLinkPreviews: true,
enableThemeSelection: false,
defaultClientLocale: 'en',
canCreatePublicChannel: true,
canCreatePrivateChannel: true,
timezoneLabel: '',
timezones: [
{
value: 'Caucasus Standard Time',
abbr: 'CST',
offset: 4,
isdst: false,
text: '(UTC+04:00) Yerevan',
utc: [
'Asia/Yerevan',
],
},
{
value: 'Afghanistan Standard Time',
abbr: 'AST',
offset: 4.5,
isdst: false,
text: '(UTC+04:30) Kabul',
utc: [
'Asia/Kabul',
],
},
],
userTimezone: {
useAutomaticTimezone: 'true',
automaticTimezone: 'America/New_York',
manualTimezone: '',
},
actions: {
autoUpdateTimezone: jest.fn(),
savePreferences: jest.fn(),
updateMe: jest.fn(),
},
configTeammateNameDisplay: '',
currentUserTimezone: 'America/New_York',
shouldAutoUpdateTimezone: true,
lockTeammateNameDisplay: false,
collapsedReplyThreads: '',
collapsedReplyThreadsAllowUserPreference: true,
allowCustomThemes: true,
availabilityStatusOnPosts: '',
militaryTime: '',
teammateNameDisplay: '',
channelDisplayMode: '',
messageDisplay: '',
colorizeUsernames: '',
collapseDisplay: '',
linkPreviewDisplay: '',
globalHeaderDisplay: '',
globalHeaderAllowed: true,
lastActiveDisplay: true,
oneClickReactionsOnPosts: '',
emojiPickerEnabled: true,
clickToReply: '',
lastActiveTimeEnabled: true,
};
let store: ReturnType<typeof configureStore>;
beforeEach(() => {
store = configureStore();
});
test('should match snapshot, no active section', () => {
const wrapper = shallow(<UserSettingsDisplay {...requiredProps}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, collapse section', () => {
const props = {...requiredProps, activeSection: 'collapse'};
const wrapper = shallow(<UserSettingsDisplay {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, link preview section with EnableLinkPreviews is false', () => {
const props = {
...requiredProps,
activeSection: 'linkpreview',
enableLinkPreviews: false,
};
const wrapper = shallow(<UserSettingsDisplay {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, link preview section with EnableLinkPreviews is true', () => {
const props = {
...requiredProps,
activeSection: 'linkpreview',
enableLinkPreviews: true,
};
const wrapper = shallow(<UserSettingsDisplay {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, clock section', () => {
const props = {...requiredProps, activeSection: 'clock'};
const wrapper = shallow(<UserSettingsDisplay {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, teammate name display section', () => {
const props = {...requiredProps, activeSection: 'teammate_name_display'};
const wrapper = shallow(<UserSettingsDisplay {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, timezone section', () => {
const props = {...requiredProps, activeSection: 'timezone'};
const wrapper = shallow(<UserSettingsDisplay {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, message display section', () => {
const props = {...requiredProps, activeSection: 'message_display'};
const wrapper = shallow(<UserSettingsDisplay {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, channel display mode section', () => {
const props = {...requiredProps, activeSection: 'channel_display_mode'};
const wrapper = shallow(<UserSettingsDisplay {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, languages section', () => {
const props = {...requiredProps, activeSection: 'languages'};
const wrapper = shallow(<UserSettingsDisplay {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, theme section with EnableThemeSelection is false', () => {
const props = {
...requiredProps,
activeSection: 'theme',
enableThemeSelection: false,
};
const wrapper = shallow(<UserSettingsDisplay {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, theme section with EnableThemeSelection is true', () => {
const props = {
...requiredProps,
activeSection: 'theme',
enableThemeSelection: true,
};
const wrapper = shallow(<UserSettingsDisplay {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, clickToReply section', () => {
const props = {...requiredProps, activeSection: 'click_to_reply'};
const wrapper = shallow(<UserSettingsDisplay {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should have called handleSubmit', async () => {
const updateSection = jest.fn();
const props = {...requiredProps, updateSection};
const wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsDisplay {...props}/>
</Provider>,
).find(UserSettingsDisplay);
await (wrapper.instance() as UserSettingsDisplay).handleSubmit();
expect(updateSection).toHaveBeenCalledWith('');
});
test('should have called updateSection', () => {
const updateSection = jest.fn();
const props = {...requiredProps, updateSection};
const wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsDisplay {...props}/>
</Provider>,
).find(UserSettingsDisplay);
(wrapper.instance() as UserSettingsDisplay).updateSection('');
expect(updateSection).toHaveBeenCalledWith('');
(wrapper.instance() as UserSettingsDisplay).updateSection('linkpreview');
expect(updateSection).toHaveBeenCalledWith('linkpreview');
});
test('should have called closeModal', () => {
const closeModal = jest.fn();
const props = {...requiredProps, closeModal};
const wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsDisplay {...props}/>
</Provider>,
).find(UserSettingsDisplay);
wrapper.find('#closeButton').simulate('click');
expect(closeModal).toHaveBeenCalled();
});
test('should have called collapseModal', () => {
const collapseModal = jest.fn();
const props = {...requiredProps, collapseModal};
const wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsDisplay {...props}/>
</Provider>,
).find(UserSettingsDisplay);
wrapper.find('.fa-angle-left').simulate('click');
expect(collapseModal).toHaveBeenCalled();
});
test('should update militaryTime state', () => {
const wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsDisplay {...requiredProps}/>
</Provider>,
).find(UserSettingsDisplay);
(wrapper.instance() as UserSettingsDisplay).handleClockRadio('false');
expect(wrapper.state('militaryTime')).toBe('false');
(wrapper.instance() as UserSettingsDisplay).handleClockRadio('true');
expect(wrapper.state('militaryTime')).toBe('true');
});
test('should update teammateNameDisplay state', () => {
const wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsDisplay {...requiredProps}/>
</Provider>,
).find(UserSettingsDisplay);
(wrapper.instance() as UserSettingsDisplay).handleTeammateNameDisplayRadio('username');
expect(wrapper.state('teammateNameDisplay')).toBe('username');
(wrapper.instance() as UserSettingsDisplay).handleTeammateNameDisplayRadio('nickname_full_name');
expect(wrapper.state('teammateNameDisplay')).toBe('nickname_full_name');
(wrapper.instance() as UserSettingsDisplay).handleTeammateNameDisplayRadio('full_name');
expect(wrapper.state('teammateNameDisplay')).toBe('full_name');
});
test('should update channelDisplayMode state', () => {
const wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsDisplay {...requiredProps}/>
</Provider>,
).find(UserSettingsDisplay);
(wrapper.instance() as UserSettingsDisplay).handleChannelDisplayModeRadio('full');
expect(wrapper.state('channelDisplayMode')).toBe('full');
(wrapper.instance() as UserSettingsDisplay).handleChannelDisplayModeRadio('centered');
expect(wrapper.state('channelDisplayMode')).toBe('centered');
});
test('should update messageDisplay state', () => {
const wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsDisplay {...requiredProps}/>
</Provider>,
).find(UserSettingsDisplay);
(wrapper.instance() as UserSettingsDisplay).handlemessageDisplayRadio('clean');
expect(wrapper.state('messageDisplay')).toBe('clean');
(wrapper.instance() as UserSettingsDisplay).handlemessageDisplayRadio('compact');
expect(wrapper.state('messageDisplay')).toBe('compact');
});
test('should update collapseDisplay state', () => {
const wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsDisplay {...requiredProps}/>
</Provider>,
).find(UserSettingsDisplay);
(wrapper.instance() as UserSettingsDisplay).handleCollapseRadio('false');
expect(wrapper.state('collapseDisplay')).toBe('false');
(wrapper.instance() as UserSettingsDisplay).handleCollapseRadio('true');
expect(wrapper.state('collapseDisplay')).toBe('true');
});
test('should update linkPreviewDisplay state', () => {
const wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsDisplay {...requiredProps}/>
</Provider>,
).find(UserSettingsDisplay);
(wrapper.instance() as UserSettingsDisplay).handleLinkPreviewRadio('false');
expect(wrapper.state('linkPreviewDisplay')).toBe('false');
(wrapper.instance() as UserSettingsDisplay).handleLinkPreviewRadio('true');
expect(wrapper.state('linkPreviewDisplay')).toBe('true');
});
test('should update display state', () => {
const wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsDisplay {...requiredProps}/>
</Provider>,
).find(UserSettingsDisplay);
(wrapper.instance() as UserSettingsDisplay).handleOnChange({} as React.ChangeEvent, {display: 'linkPreviewDisplay'});
expect(wrapper.state('display')).toBe('linkPreviewDisplay');
(wrapper.instance() as UserSettingsDisplay).handleOnChange({} as React.ChangeEvent, {display: 'collapseDisplay'});
expect(wrapper.state('display')).toBe('collapseDisplay');
});
test('should update collapsed reply threads state', () => {
const wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsDisplay {...requiredProps}/>
</Provider>,
).find(UserSettingsDisplay);
(wrapper.instance() as UserSettingsDisplay).handleCollapseReplyThreadsRadio('off');
expect(wrapper.state('collapsedReplyThreads')).toBe('off');
(wrapper.instance() as UserSettingsDisplay).handleCollapseReplyThreadsRadio('on');
expect(wrapper.state('collapsedReplyThreads')).toBe('on');
});
test('should update last active state', () => {
const wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsDisplay {...requiredProps}/>
</Provider>,
).find(UserSettingsDisplay);
(wrapper.instance() as UserSettingsDisplay).handleLastActiveRadio('false');
expect(wrapper.state('lastActiveDisplay')).toBe('false');
(wrapper.instance() as UserSettingsDisplay).handleLastActiveRadio('true');
expect(wrapper.state('lastActiveDisplay')).toBe('true');
});
test('should not show last active section', () => {
const wrapper = shallow(
<UserSettingsDisplay
{...requiredProps}
lastActiveTimeEnabled={false}
/>,
);
expect(wrapper).toMatchSnapshot();
});
});
|
3,515 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/__snapshots__/user_settings_display.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, channel display mode section 1`] = `
<div
id="displaySettings"
>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
id="closeButton"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<span
onClick={[MockFunction]}
>
<BackIcon />
</span>
</div>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
id="displaySettingsTitle"
>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h3>
<div
className="divider-dark first"
/>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapsed_reply_threads"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Collapsed Reply Threads"
id="user.settings.display.collapsedReplyThreadsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="clock"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show first and last name"
id="user.settings.display.teammateNameDisplayFullname"
/>
}
max={null}
section="name_format"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Teammate Name Display"
id="user.settings.display.teammateNameDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="availabilityStatus"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show user availability on posts"
id="user.settings.display.availabilityStatusOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.lastActiveOn"
/>
}
max={null}
section="lastactive"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Share last active time"
id="user.settings.display.lastActiveDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="linkpreview"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapse"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="message_display"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="click_to_reply"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={true}
areAllSectionsInactive={false}
max={
<SettingItemMax
containerStyle=""
extraInfo={null}
infoPosition="bottom"
inputs={
Array [
<fieldset>
<legend
className="form-legend hidden-label"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
id="channel_display_modeFormatA"
name="channel_display_modeFormat"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Full width"
id="user.settings.display.fullScreen"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
id="channel_display_modeFormatB"
name="channel_display_modeFormat"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Fixed width, centered"
id="user.settings.display.fixedWidthCentered"
/>
</label>
<br />
</div>
<div>
<br />
<Memo(MemoizedFormattedMessage)
defaultMessage="Select the width of the center channel."
id="user.settings.display.channeldisplaymode"
/>
</div>
</fieldset>,
]
}
saving={false}
section=""
submit={[Function]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
}
section="channel_display_mode"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="one_click_reactions_enabled"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Quick reactions on messages"
id="user.settings.display.oneClickReactionsOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe="English (US)"
max={
<Memo(Connect(injectIntl(ManageLanguage)))
locale="en"
updateSection={[Function]}
user={
Object {
"id": "user_id",
"locale": "en",
"timezone": Object {
"automaticTimezone": "America/New_York",
"manualTimezone": "",
"useAutomaticTimezone": "true",
},
"username": "username",
}
}
/>
}
section="languages"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Language"
id="user.settings.display.language"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, clickToReply section 1`] = `
<div
id="displaySettings"
>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
id="closeButton"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<span
onClick={[MockFunction]}
>
<BackIcon />
</span>
</div>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
id="displaySettingsTitle"
>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h3>
<div
className="divider-dark first"
/>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapsed_reply_threads"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Collapsed Reply Threads"
id="user.settings.display.collapsedReplyThreadsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="clock"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show first and last name"
id="user.settings.display.teammateNameDisplayFullname"
/>
}
max={null}
section="name_format"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Teammate Name Display"
id="user.settings.display.teammateNameDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="availabilityStatus"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show user availability on posts"
id="user.settings.display.availabilityStatusOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.lastActiveOn"
/>
}
max={null}
section="lastactive"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Share last active time"
id="user.settings.display.lastActiveDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="linkpreview"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapse"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="message_display"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={true}
areAllSectionsInactive={false}
max={
<SettingItemMax
containerStyle=""
extraInfo={null}
infoPosition="bottom"
inputs={
Array [
<fieldset>
<legend
className="form-legend hidden-label"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
id="click_to_replyFormatA"
name="click_to_replyFormat"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.sidebar.on"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
id="click_to_replyFormatB"
name="click_to_replyFormat"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Off"
id="user.settings.sidebar.off"
/>
</label>
<br />
</div>
<div>
<br />
<Memo(MemoizedFormattedMessage)
defaultMessage="When enabled, click anywhere on a message to open the reply thread."
id="user.settings.display.clickToReplyDescription"
/>
</div>
</fieldset>,
]
}
saving={false}
section=""
submit={[Function]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
}
section="click_to_reply"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="channel_display_mode"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="one_click_reactions_enabled"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Quick reactions on messages"
id="user.settings.display.oneClickReactionsOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe="English (US)"
max={
<Memo(Connect(injectIntl(ManageLanguage)))
locale="en"
updateSection={[Function]}
user={
Object {
"id": "user_id",
"locale": "en",
"timezone": Object {
"automaticTimezone": "America/New_York",
"manualTimezone": "",
"useAutomaticTimezone": "true",
},
"username": "username",
}
}
/>
}
section="languages"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Language"
id="user.settings.display.language"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, clock section 1`] = `
<div
id="displaySettings"
>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
id="closeButton"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<span
onClick={[MockFunction]}
>
<BackIcon />
</span>
</div>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
id="displaySettingsTitle"
>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h3>
<div
className="divider-dark first"
/>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapsed_reply_threads"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Collapsed Reply Threads"
id="user.settings.display.collapsedReplyThreadsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={true}
areAllSectionsInactive={false}
max={
<SettingItemMax
containerStyle=""
extraInfo={null}
infoPosition="bottom"
inputs={
Array [
<fieldset>
<legend
className="form-legend hidden-label"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
id="clockFormatA"
name="clockFormat"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="12-hour clock (example: 4:00 PM)"
id="user.settings.display.normalClock"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
id="clockFormatB"
name="clockFormat"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="24-hour clock (example: 16:00)"
id="user.settings.display.militaryClock"
/>
</label>
<br />
</div>
<div>
<br />
<Memo(MemoizedFormattedMessage)
defaultMessage="Select how you prefer time displayed."
id="user.settings.display.preferTime"
/>
</div>
</fieldset>,
]
}
saving={false}
section=""
submit={[Function]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
}
section="clock"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show first and last name"
id="user.settings.display.teammateNameDisplayFullname"
/>
}
max={null}
section="name_format"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Teammate Name Display"
id="user.settings.display.teammateNameDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="availabilityStatus"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show user availability on posts"
id="user.settings.display.availabilityStatusOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.lastActiveOn"
/>
}
max={null}
section="lastactive"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Share last active time"
id="user.settings.display.lastActiveDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="linkpreview"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapse"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="message_display"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="click_to_reply"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="channel_display_mode"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="one_click_reactions_enabled"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Quick reactions on messages"
id="user.settings.display.oneClickReactionsOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe="English (US)"
max={
<Memo(Connect(injectIntl(ManageLanguage)))
locale="en"
updateSection={[Function]}
user={
Object {
"id": "user_id",
"locale": "en",
"timezone": Object {
"automaticTimezone": "America/New_York",
"manualTimezone": "",
"useAutomaticTimezone": "true",
},
"username": "username",
}
}
/>
}
section="languages"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Language"
id="user.settings.display.language"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, collapse section 1`] = `
<div
id="displaySettings"
>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
id="closeButton"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<span
onClick={[MockFunction]}
>
<BackIcon />
</span>
</div>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
id="displaySettingsTitle"
>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h3>
<div
className="divider-dark first"
/>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapsed_reply_threads"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Collapsed Reply Threads"
id="user.settings.display.collapsedReplyThreadsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="clock"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show first and last name"
id="user.settings.display.teammateNameDisplayFullname"
/>
}
max={null}
section="name_format"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Teammate Name Display"
id="user.settings.display.teammateNameDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="availabilityStatus"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show user availability on posts"
id="user.settings.display.availabilityStatusOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.lastActiveOn"
/>
}
max={null}
section="lastactive"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Share last active time"
id="user.settings.display.lastActiveDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="linkpreview"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={true}
areAllSectionsInactive={false}
max={
<SettingItemMax
containerStyle=""
extraInfo={null}
infoPosition="bottom"
inputs={
Array [
<fieldset>
<legend
className="form-legend hidden-label"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
id="collapseFormatA"
name="collapseFormat"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.collapseOn"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
id="collapseFormatB"
name="collapseFormat"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Off"
id="user.settings.display.collapseOff"
/>
</label>
<br />
</div>
<div>
<br />
<Memo(MemoizedFormattedMessage)
defaultMessage="Set whether previews of image links and image attachment thumbnails show as expanded or collapsed by default. This setting can also be controlled using the slash commands /expand and /collapse."
id="user.settings.display.collapseDesc"
/>
</div>
</fieldset>,
]
}
saving={false}
section=""
submit={[Function]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
}
section="collapse"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="message_display"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="click_to_reply"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="channel_display_mode"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="one_click_reactions_enabled"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Quick reactions on messages"
id="user.settings.display.oneClickReactionsOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe="English (US)"
max={
<Memo(Connect(injectIntl(ManageLanguage)))
locale="en"
updateSection={[Function]}
user={
Object {
"id": "user_id",
"locale": "en",
"timezone": Object {
"automaticTimezone": "America/New_York",
"manualTimezone": "",
"useAutomaticTimezone": "true",
},
"username": "username",
}
}
/>
}
section="languages"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Language"
id="user.settings.display.language"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, languages section 1`] = `
<div
id="displaySettings"
>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
id="closeButton"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<span
onClick={[MockFunction]}
>
<BackIcon />
</span>
</div>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
id="displaySettingsTitle"
>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h3>
<div
className="divider-dark first"
/>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapsed_reply_threads"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Collapsed Reply Threads"
id="user.settings.display.collapsedReplyThreadsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="clock"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show first and last name"
id="user.settings.display.teammateNameDisplayFullname"
/>
}
max={null}
section="name_format"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Teammate Name Display"
id="user.settings.display.teammateNameDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="availabilityStatus"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show user availability on posts"
id="user.settings.display.availabilityStatusOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.lastActiveOn"
/>
}
max={null}
section="lastactive"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Share last active time"
id="user.settings.display.lastActiveDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="linkpreview"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapse"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="message_display"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="click_to_reply"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="channel_display_mode"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="one_click_reactions_enabled"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Quick reactions on messages"
id="user.settings.display.oneClickReactionsOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={true}
areAllSectionsInactive={false}
describe="English (US)"
max={
<Memo(Connect(injectIntl(ManageLanguage)))
locale="en"
updateSection={[Function]}
user={
Object {
"id": "user_id",
"locale": "en",
"timezone": Object {
"automaticTimezone": "America/New_York",
"manualTimezone": "",
"useAutomaticTimezone": "true",
},
"username": "username",
}
}
/>
}
section="languages"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Language"
id="user.settings.display.language"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, link preview section with EnableLinkPreviews is false 1`] = `
<div
id="displaySettings"
>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
id="closeButton"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<span
onClick={[MockFunction]}
>
<BackIcon />
</span>
</div>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
id="displaySettingsTitle"
>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h3>
<div
className="divider-dark first"
/>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapsed_reply_threads"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Collapsed Reply Threads"
id="user.settings.display.collapsedReplyThreadsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="clock"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show first and last name"
id="user.settings.display.teammateNameDisplayFullname"
/>
}
max={null}
section="name_format"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Teammate Name Display"
id="user.settings.display.teammateNameDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="availabilityStatus"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show user availability on posts"
id="user.settings.display.availabilityStatusOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.lastActiveOn"
/>
}
max={null}
section="lastactive"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Share last active time"
id="user.settings.display.lastActiveDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapse"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="message_display"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="click_to_reply"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="channel_display_mode"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="one_click_reactions_enabled"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Quick reactions on messages"
id="user.settings.display.oneClickReactionsOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe="English (US)"
max={
<Memo(Connect(injectIntl(ManageLanguage)))
locale="en"
updateSection={[Function]}
user={
Object {
"id": "user_id",
"locale": "en",
"timezone": Object {
"automaticTimezone": "America/New_York",
"manualTimezone": "",
"useAutomaticTimezone": "true",
},
"username": "username",
}
}
/>
}
section="languages"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Language"
id="user.settings.display.language"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, link preview section with EnableLinkPreviews is true 1`] = `
<div
id="displaySettings"
>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
id="closeButton"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<span
onClick={[MockFunction]}
>
<BackIcon />
</span>
</div>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
id="displaySettingsTitle"
>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h3>
<div
className="divider-dark first"
/>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapsed_reply_threads"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Collapsed Reply Threads"
id="user.settings.display.collapsedReplyThreadsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="clock"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show first and last name"
id="user.settings.display.teammateNameDisplayFullname"
/>
}
max={null}
section="name_format"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Teammate Name Display"
id="user.settings.display.teammateNameDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="availabilityStatus"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show user availability on posts"
id="user.settings.display.availabilityStatusOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.lastActiveOn"
/>
}
max={null}
section="lastactive"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Share last active time"
id="user.settings.display.lastActiveDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={true}
areAllSectionsInactive={false}
max={
<SettingItemMax
containerStyle=""
extraInfo={null}
infoPosition="bottom"
inputs={
Array [
<fieldset>
<legend
className="form-legend hidden-label"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
id="linkpreviewFormatA"
name="linkpreviewFormat"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.linkPreviewOn"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
id="linkpreviewFormatB"
name="linkpreviewFormat"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Off"
id="user.settings.display.linkPreviewOff"
/>
</label>
<br />
</div>
<div>
<br />
<Memo(MemoizedFormattedMessage)
defaultMessage="When available, the first web link in a message will show a preview of the website content below the message."
id="user.settings.display.linkPreviewDesc"
/>
</div>
</fieldset>,
]
}
saving={false}
section=""
submit={[Function]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
}
updateSection={[Function]}
/>
}
section="linkpreview"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapse"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="message_display"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="click_to_reply"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="channel_display_mode"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="one_click_reactions_enabled"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Quick reactions on messages"
id="user.settings.display.oneClickReactionsOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe="English (US)"
max={
<Memo(Connect(injectIntl(ManageLanguage)))
locale="en"
updateSection={[Function]}
user={
Object {
"id": "user_id",
"locale": "en",
"timezone": Object {
"automaticTimezone": "America/New_York",
"manualTimezone": "",
"useAutomaticTimezone": "true",
},
"username": "username",
}
}
/>
}
section="languages"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Language"
id="user.settings.display.language"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, message display section 1`] = `
<div
id="displaySettings"
>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
id="closeButton"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<span
onClick={[MockFunction]}
>
<BackIcon />
</span>
</div>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
id="displaySettingsTitle"
>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h3>
<div
className="divider-dark first"
/>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapsed_reply_threads"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Collapsed Reply Threads"
id="user.settings.display.collapsedReplyThreadsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="clock"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show first and last name"
id="user.settings.display.teammateNameDisplayFullname"
/>
}
max={null}
section="name_format"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Teammate Name Display"
id="user.settings.display.teammateNameDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="availabilityStatus"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show user availability on posts"
id="user.settings.display.availabilityStatusOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.lastActiveOn"
/>
}
max={null}
section="lastactive"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Share last active time"
id="user.settings.display.lastActiveDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="linkpreview"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapse"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={true}
areAllSectionsInactive={false}
max={
<SettingItemMax
containerStyle=""
extraInfo={null}
infoPosition="bottom"
inputs={
Array [
<fieldset>
<legend
className="form-legend hidden-label"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
id="message_displayFormatA"
name="message_displayFormat"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Standard"
id="user.settings.display.messageDisplayClean"
/>
:
<span
className="font-weight--normal"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Easy to scan and read."
id="user.settings.display.messageDisplayCleanDes"
/>
</span>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
id="message_displayFormatB"
name="message_displayFormat"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Compact"
id="user.settings.display.messageDisplayCompact"
/>
:
<span
className="font-weight--normal"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Fit as many messages on the screen as we can."
id="user.settings.display.messageDisplayCompactDes"
/>
</span>
</label>
<br />
</div>
<div>
<br />
<Memo(MemoizedFormattedMessage)
defaultMessage="Select how messages in a channel should be displayed."
id="user.settings.display.messageDisplayDescription"
/>
</div>
</fieldset>,
]
}
saving={false}
section=""
submit={[Function]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
}
section="message_display"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="click_to_reply"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="channel_display_mode"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="one_click_reactions_enabled"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Quick reactions on messages"
id="user.settings.display.oneClickReactionsOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe="English (US)"
max={
<Memo(Connect(injectIntl(ManageLanguage)))
locale="en"
updateSection={[Function]}
user={
Object {
"id": "user_id",
"locale": "en",
"timezone": Object {
"automaticTimezone": "America/New_York",
"manualTimezone": "",
"useAutomaticTimezone": "true",
},
"username": "username",
}
}
/>
}
section="languages"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Language"
id="user.settings.display.language"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, no active section 1`] = `
<div
id="displaySettings"
>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
id="closeButton"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<span
onClick={[MockFunction]}
>
<BackIcon />
</span>
</div>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
id="displaySettingsTitle"
>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h3>
<div
className="divider-dark first"
/>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="collapsed_reply_threads"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Collapsed Reply Threads"
id="user.settings.display.collapsedReplyThreadsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="clock"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show first and last name"
id="user.settings.display.teammateNameDisplayFullname"
/>
}
max={null}
section="name_format"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Teammate Name Display"
id="user.settings.display.teammateNameDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="availabilityStatus"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show user availability on posts"
id="user.settings.display.availabilityStatusOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.lastActiveOn"
/>
}
max={null}
section="lastactive"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Share last active time"
id="user.settings.display.lastActiveDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="linkpreview"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="collapse"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="message_display"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="click_to_reply"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="channel_display_mode"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="one_click_reactions_enabled"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Quick reactions on messages"
id="user.settings.display.oneClickReactionsOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
describe="English (US)"
max={
<Memo(Connect(injectIntl(ManageLanguage)))
locale="en"
updateSection={[Function]}
user={
Object {
"id": "user_id",
"locale": "en",
"timezone": Object {
"automaticTimezone": "America/New_York",
"manualTimezone": "",
"useAutomaticTimezone": "true",
},
"username": "username",
}
}
/>
}
section="languages"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Language"
id="user.settings.display.language"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, teammate name display section 1`] = `
<div
id="displaySettings"
>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
id="closeButton"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<span
onClick={[MockFunction]}
>
<BackIcon />
</span>
</div>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
id="displaySettingsTitle"
>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h3>
<div
className="divider-dark first"
/>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapsed_reply_threads"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Collapsed Reply Threads"
id="user.settings.display.collapsedReplyThreadsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="clock"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show first and last name"
id="user.settings.display.teammateNameDisplayFullname"
/>
}
max={null}
section="name_format"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Teammate Name Display"
id="user.settings.display.teammateNameDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="availabilityStatus"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show user availability on posts"
id="user.settings.display.availabilityStatusOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.lastActiveOn"
/>
}
max={null}
section="lastactive"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Share last active time"
id="user.settings.display.lastActiveDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="linkpreview"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapse"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="message_display"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="click_to_reply"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="channel_display_mode"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="one_click_reactions_enabled"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Quick reactions on messages"
id="user.settings.display.oneClickReactionsOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe="English (US)"
max={
<Memo(Connect(injectIntl(ManageLanguage)))
locale="en"
updateSection={[Function]}
user={
Object {
"id": "user_id",
"locale": "en",
"timezone": Object {
"automaticTimezone": "America/New_York",
"manualTimezone": "",
"useAutomaticTimezone": "true",
},
"username": "username",
}
}
/>
}
section="languages"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Language"
id="user.settings.display.language"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, theme section with EnableThemeSelection is false 1`] = `
<div
id="displaySettings"
>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
id="closeButton"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<span
onClick={[MockFunction]}
>
<BackIcon />
</span>
</div>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
id="displaySettingsTitle"
>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h3>
<div
className="divider-dark first"
/>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapsed_reply_threads"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Collapsed Reply Threads"
id="user.settings.display.collapsedReplyThreadsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="clock"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show first and last name"
id="user.settings.display.teammateNameDisplayFullname"
/>
}
max={null}
section="name_format"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Teammate Name Display"
id="user.settings.display.teammateNameDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="availabilityStatus"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show user availability on posts"
id="user.settings.display.availabilityStatusOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.lastActiveOn"
/>
}
max={null}
section="lastactive"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Share last active time"
id="user.settings.display.lastActiveDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="linkpreview"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapse"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="message_display"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="click_to_reply"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="channel_display_mode"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="one_click_reactions_enabled"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Quick reactions on messages"
id="user.settings.display.oneClickReactionsOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe="English (US)"
max={
<Memo(Connect(injectIntl(ManageLanguage)))
locale="en"
updateSection={[Function]}
user={
Object {
"id": "user_id",
"locale": "en",
"timezone": Object {
"automaticTimezone": "America/New_York",
"manualTimezone": "",
"useAutomaticTimezone": "true",
},
"username": "username",
}
}
/>
}
section="languages"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Language"
id="user.settings.display.language"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, theme section with EnableThemeSelection is true 1`] = `
<div
id="displaySettings"
>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
id="closeButton"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<span
onClick={[MockFunction]}
>
<BackIcon />
</span>
</div>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
id="displaySettingsTitle"
>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h3>
<div
className="divider-dark first"
/>
<div>
<Connect(ThemeSetting)
allowCustomThemes={true}
areAllSectionsInactive={false}
selected={true}
setEnforceFocus={[MockFunction]}
setRequireConfirm={[MockFunction]}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapsed_reply_threads"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Collapsed Reply Threads"
id="user.settings.display.collapsedReplyThreadsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="clock"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show first and last name"
id="user.settings.display.teammateNameDisplayFullname"
/>
}
max={null}
section="name_format"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Teammate Name Display"
id="user.settings.display.teammateNameDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="availabilityStatus"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show user availability on posts"
id="user.settings.display.availabilityStatusOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.lastActiveOn"
/>
}
max={null}
section="lastactive"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Share last active time"
id="user.settings.display.lastActiveDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="linkpreview"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapse"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="message_display"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="click_to_reply"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="channel_display_mode"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="one_click_reactions_enabled"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Quick reactions on messages"
id="user.settings.display.oneClickReactionsOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe="English (US)"
max={
<Memo(Connect(injectIntl(ManageLanguage)))
locale="en"
updateSection={[Function]}
user={
Object {
"id": "user_id",
"locale": "en",
"timezone": Object {
"automaticTimezone": "America/New_York",
"manualTimezone": "",
"useAutomaticTimezone": "true",
},
"username": "username",
}
}
/>
}
section="languages"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Language"
id="user.settings.display.language"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, timezone section 1`] = `
<div
id="displaySettings"
>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
id="closeButton"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<span
onClick={[MockFunction]}
>
<BackIcon />
</span>
</div>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
id="displaySettingsTitle"
>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h3>
<div
className="divider-dark first"
/>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapsed_reply_threads"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Collapsed Reply Threads"
id="user.settings.display.collapsedReplyThreadsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="clock"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show first and last name"
id="user.settings.display.teammateNameDisplayFullname"
/>
}
max={null}
section="name_format"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Teammate Name Display"
id="user.settings.display.teammateNameDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="availabilityStatus"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show user availability on posts"
id="user.settings.display.availabilityStatusOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.display.lastActiveOn"
/>
}
max={null}
section="lastactive"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Share last active time"
id="user.settings.display.lastActiveDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="linkpreview"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="collapse"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="message_display"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="click_to_reply"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="channel_display_mode"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="one_click_reactions_enabled"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Quick reactions on messages"
id="user.settings.display.oneClickReactionsOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe="English (US)"
max={
<Memo(Connect(injectIntl(ManageLanguage)))
locale="en"
updateSection={[Function]}
user={
Object {
"id": "user_id",
"locale": "en",
"timezone": Object {
"automaticTimezone": "America/New_York",
"manualTimezone": "",
"useAutomaticTimezone": "true",
},
"username": "username",
}
}
/>
}
section="languages"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Language"
id="user.settings.display.language"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should not show last active section 1`] = `
<div
id="displaySettings"
>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
id="closeButton"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<span
onClick={[MockFunction]}
>
<BackIcon />
</span>
</div>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
id="displaySettingsTitle"
>
<MemoizedFormattedMessage
defaultMessage="Display Settings"
id="user.settings.display.title"
/>
</h3>
<div
className="divider-dark first"
/>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="collapsed_reply_threads"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Collapsed Reply Threads"
id="user.settings.display.collapsedReplyThreadsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="clock"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Clock Display"
id="user.settings.display.clockDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show first and last name"
id="user.settings.display.teammateNameDisplayFullname"
/>
}
max={null}
section="name_format"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Teammate Name Display"
id="user.settings.display.teammateNameDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="availabilityStatus"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Show user availability on posts"
id="user.settings.display.availabilityStatusOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="linkpreview"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Website Link Previews"
id="user.settings.display.linkPreviewDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="collapse"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Default Appearance of Image Previews"
id="user.settings.display.collapseDisplay"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="message_display"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Message Display"
id="user.settings.display.messageDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="click_to_reply"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Click to open threads"
id="user.settings.display.clickToReply"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="channel_display_mode"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Channel Display"
id="user.settings.display.channelDisplayTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
max={null}
section="one_click_reactions_enabled"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Quick reactions on messages"
id="user.settings.display.oneClickReactionsOnPostsTitle"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
<div>
<SettingItem
active={false}
areAllSectionsInactive={true}
describe="English (US)"
max={
<Memo(Connect(injectIntl(ManageLanguage)))
locale="en"
updateSection={[Function]}
user={
Object {
"id": "user_id",
"locale": "en",
"timezone": Object {
"automaticTimezone": "America/New_York",
"manualTimezone": "",
"useAutomaticTimezone": "true",
},
"username": "username",
}
}
/>
}
section="languages"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Language"
id="user.settings.display.language"
/>
}
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
</div>
</div>
</div>
`;
|
3,517 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/manage_languages/manage_languages.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import type {UserProfile} from '@mattermost/types/users';
import {shallowWithIntl} from 'tests/helpers/intl-test-helper';
import ManageLanguages from './manage_languages';
import type {ManageLanguage as ManageLanguageClass} from './manage_languages';
describe('components/user_settings/display/manage_languages/manage_languages', () => {
const user = {
id: 'user_id',
};
const requiredProps = {
user: user as UserProfile,
locale: 'en',
updateSection: jest.fn(),
actions: {
updateMe: jest.fn(() => Promise.resolve({})),
},
};
test('submitUser() should have called updateMe', async () => {
const updateMe = jest.fn(() => Promise.resolve({data: true}));
const props = {...requiredProps, actions: {...requiredProps.actions, updateMe}};
const wrapper = shallowWithIntl(<ManageLanguages {...props}/>);
const instance = wrapper.instance() as ManageLanguageClass;
await instance.submitUser(requiredProps.user);
expect(props.actions.updateMe).toHaveBeenCalledTimes(1);
expect(props.actions.updateMe).toHaveBeenCalledWith(requiredProps.user);
});
});
|
3,520 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/manage_timezones/manage_timezones.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import type {UserProfile} from '@mattermost/types/users';
import ManageTimezones from './manage_timezones';
describe('components/user_settings/display/manage_timezones/manage_timezones', () => {
const user = {
id: 'user_id',
};
const requiredProps = {
user: user as UserProfile,
locale: '',
useAutomaticTimezone: true,
automaticTimezone: '',
manualTimezone: '',
timezoneLabel: '',
timezones: [],
updateSection: jest.fn(),
actions: {
updateMe: jest.fn(() => Promise.resolve({})),
},
};
test('submitUser() should have called [updateMe, updateSection]', async () => {
const updateMe = jest.fn(() => Promise.resolve({data: true}));
const props = {...requiredProps, actions: {...requiredProps.actions, updateMe}};
const wrapper = shallow(<ManageTimezones {...props}/>);
await (wrapper.instance() as ManageTimezones).submitUser();
const expected = {...props.user,
timezone: {
useAutomaticTimezone: props.useAutomaticTimezone.toString(),
manualTimezone: props.manualTimezone,
automaticTimezone: props.automaticTimezone,
}};
expect(props.actions.updateMe).toHaveBeenCalled();
expect(props.actions.updateMe).toHaveBeenCalledWith(expected);
expect(props.updateSection).toHaveBeenCalled();
expect(props.updateSection).toHaveBeenCalledWith('');
});
});
|
3,524 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/user_settings_theme/user_settings_theme.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import type {ComponentProps} from 'react';
import {Preferences} from 'mattermost-redux/constants';
import {fireEvent, renderWithContext, screen} from 'tests/react_testing_utils';
import UserSettingsTheme from './user_settings_theme';
jest.mock('utils/utils', () => ({
applyTheme: jest.fn(),
toTitleCase: jest.fn(),
a11yFocus: jest.fn(),
}));
describe('components/user_settings/display/user_settings_theme/user_settings_theme.jsx', () => {
const initialState = {
entities: {
general: {
config: {},
license: {
Cloud: 'false',
},
},
users: {
currentUserId: 'currentUserId',
},
},
};
const requiredProps: ComponentProps<typeof UserSettingsTheme> = {
theme: Preferences.THEMES.denim,
currentTeamId: 'teamId',
selected: false,
updateSection: jest.fn(),
setRequireConfirm: jest.fn(),
setEnforceFocus: jest.fn(),
actions: {
saveTheme: jest.fn().mockResolvedValue({data: true}),
deleteTeamSpecificThemes: jest.fn().mockResolvedValue({data: true}),
openModal: jest.fn(),
},
allowCustomThemes: true,
showAllTeamsCheckbox: true,
applyToAllTeams: true,
areAllSectionsInactive: false,
};
it('should match snapshot', () => {
const wrapper = shallow(
<UserSettingsTheme {...requiredProps}/>,
);
expect(wrapper).toMatchSnapshot();
});
it('should saveTheme', async () => {
const wrapper = shallow<UserSettingsTheme>(
<UserSettingsTheme {...requiredProps}/>,
);
await wrapper.instance().submitTheme();
expect(requiredProps.setRequireConfirm).toHaveBeenCalledTimes(1);
expect(requiredProps.setRequireConfirm).toHaveBeenCalledWith(false);
expect(requiredProps.updateSection).toHaveBeenCalledTimes(1);
expect(requiredProps.updateSection).toHaveBeenCalledWith('');
expect(requiredProps.actions.saveTheme).toHaveBeenCalled();
});
it('should deleteTeamSpecificThemes if applyToAllTeams is enabled', async () => {
const props = {
...requiredProps,
actions: {
saveTheme: jest.fn().mockResolvedValue({data: true}),
deleteTeamSpecificThemes: jest.fn().mockResolvedValue({data: true}),
openModal: jest.fn(),
},
};
const wrapper = shallow<UserSettingsTheme>(
<UserSettingsTheme {...props}/>,
);
wrapper.instance().setState({applyToAllTeams: true});
await wrapper.instance().submitTheme();
expect(props.actions.deleteTeamSpecificThemes).toHaveBeenCalled();
});
it('should call openModal when slack import theme button is clicked', async () => {
const props = {
...requiredProps,
allowCustomThemes: true,
selected: true,
};
renderWithContext(
<UserSettingsTheme {...props}/>,
initialState,
);
// Click the Slack Import button
fireEvent.click(screen.getByText('Import theme colors from Slack'));
expect(props.actions.openModal).toHaveBeenCalledTimes(1);
});
});
|
3,526 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/user_settings_theme | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/user_settings_theme/__snapshots__/user_settings_theme.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/user_settings/display/user_settings_theme/user_settings_theme.jsx should match snapshot 1`] = `
<SettingItemMin
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Open to manage your theme"
id="user.settings.display.theme.describe"
/>
}
section="theme"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Theme"
id="user.settings.display.theme.title"
/>
}
updateSection={[Function]}
/>
`;
|
3,527 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/user_settings_theme | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/user_settings_theme/color_chooser/color_chooser.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import ColorChooser from './color_chooser';
describe('components/user_settings/display/ColorChooser', () => {
it('should match, init', () => {
const wrapper = shallow(
<ColorChooser
label='Choose color'
id='choose-color'
value='#ffeec0'
/>,
);
expect(wrapper).toMatchSnapshot();
});
});
|
3,529 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/user_settings_theme/color_chooser | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/user_settings_theme/color_chooser/__snapshots__/color_chooser.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/user_settings/display/ColorChooser should match, init 1`] = `
<Fragment>
<label
className="custom-label"
>
Choose color
</label>
<ColorInput
id="choose-color"
onChange={[Function]}
value="#ffeec0"
/>
</Fragment>
`;
|
3,530 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/user_settings_theme | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/user_settings_theme/custom_theme_chooser/custom_theme_chooser.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import type {ChangeEvent} from 'react';
import {Preferences} from 'mattermost-redux/constants';
import CustomThemeChooser from 'components/user_settings/display/user_settings_theme/custom_theme_chooser/custom_theme_chooser';
describe('components/user_settings/display/CustomThemeChooser', () => {
const baseProps = {
theme: Preferences.THEMES.denim,
updateTheme: jest.fn(),
};
it('should match, init', () => {
const elementMock = {addEventListener: jest.fn()};
jest.spyOn(document, 'querySelector').mockImplementation(() => elementMock as unknown as HTMLElement);
const wrapper = shallow(
<CustomThemeChooser {...baseProps}/>,
);
expect(wrapper).toMatchSnapshot();
});
it('should create a custom theme when the code theme changes', () => {
const elementMock = {addEventListener: jest.fn()};
jest.spyOn(document, 'querySelector').mockImplementation(() => elementMock as unknown as HTMLElement);
const wrapper = shallow<CustomThemeChooser>(
<CustomThemeChooser {...baseProps}/>,
);
const event = {
target: {
value: 'monokai',
},
} as ChangeEvent<HTMLSelectElement>;
wrapper.instance().onCodeThemeChange(event);
expect(baseProps.updateTheme).toHaveBeenCalledTimes(1);
expect(baseProps.updateTheme).toHaveBeenCalledWith({
...baseProps.theme,
type: 'custom',
codeTheme: 'monokai',
});
});
});
|
3,532 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/user_settings_theme/custom_theme_chooser | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/display/user_settings_theme/custom_theme_chooser/__snapshots__/custom_theme_chooser.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/user_settings/display/CustomThemeChooser should match, init 1`] = `
<div
className="appearance-section pt-2"
>
<div
className="theme-elements row"
>
<div
className="theme-elements__header"
id="sidebarStyles"
onClick={[Function]}
>
<MemoizedFormattedMessage
defaultMessage="Sidebar Styles"
id="user.settings.custom_theme.sidebarTitle"
/>
<div
className="header__icon"
>
<LocalizedIcon
className="fa fa-plus"
title={
Object {
"defaultMessage": "Expand Icon",
"id": "generic_icons.expand",
}
}
/>
<LocalizedIcon
className="fa fa-minus"
title={
Object {
"defaultMessage": "Collapse Icon",
"id": "generic_icons.collapse",
}
}
/>
</div>
</div>
<div
className="theme-elements__body"
>
<div
className="col-sm-6 form-group element"
key="custom-theme-key0"
>
<ColorChooser
id="sidebarBg"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Sidebar BG"
id="user.settings.custom_theme.sidebarBg"
/>
}
onChange={[Function]}
value="#1e325c"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key1"
>
<ColorChooser
id="sidebarText"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Sidebar Text"
id="user.settings.custom_theme.sidebarText"
/>
}
onChange={[Function]}
value="#ffffff"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key2"
>
<ColorChooser
id="sidebarHeaderBg"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Sidebar Header BG"
id="user.settings.custom_theme.sidebarHeaderBg"
/>
}
onChange={[Function]}
value="#192a4d"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key3"
>
<ColorChooser
id="sidebarTeamBarBg"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Team Sidebar BG"
id="user.settings.custom_theme.sidebarTeamBarBg"
/>
}
onChange={[Function]}
value="#14213e"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key4"
>
<ColorChooser
id="sidebarHeaderTextColor"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Sidebar Header Text"
id="user.settings.custom_theme.sidebarHeaderTextColor"
/>
}
onChange={[Function]}
value="#ffffff"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key5"
>
<ColorChooser
id="sidebarUnreadText"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Sidebar Unread Text"
id="user.settings.custom_theme.sidebarUnreadText"
/>
}
onChange={[Function]}
value="#ffffff"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key6"
>
<ColorChooser
id="sidebarTextHoverBg"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Sidebar Text Hover BG"
id="user.settings.custom_theme.sidebarTextHoverBg"
/>
}
onChange={[Function]}
value="#28427b"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key7"
>
<ColorChooser
id="sidebarTextActiveBorder"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Sidebar Text Active Border"
id="user.settings.custom_theme.sidebarTextActiveBorder"
/>
}
onChange={[Function]}
value="#5d89ea"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key8"
>
<ColorChooser
id="sidebarTextActiveColor"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Sidebar Text Active Color"
id="user.settings.custom_theme.sidebarTextActiveColor"
/>
}
onChange={[Function]}
value="#ffffff"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key9"
>
<ColorChooser
id="onlineIndicator"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Online Indicator"
id="user.settings.custom_theme.onlineIndicator"
/>
}
onChange={[Function]}
value="#3db887"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key10"
>
<ColorChooser
id="awayIndicator"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Away Indicator"
id="user.settings.custom_theme.awayIndicator"
/>
}
onChange={[Function]}
value="#ffbc1f"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key11"
>
<ColorChooser
id="dndIndicator"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Do Not Disturb Indicator"
id="user.settings.custom_theme.dndIndicator"
/>
}
onChange={[Function]}
value="#d24b4e"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key12"
>
<ColorChooser
id="mentionBg"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Mention Jewel BG"
id="user.settings.custom_theme.mentionBg"
/>
}
onChange={[Function]}
value="#ffffff"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key13"
>
<ColorChooser
id="mentionColor"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Mention Jewel Text"
id="user.settings.custom_theme.mentionColor"
/>
}
onChange={[Function]}
value="#1e325c"
/>
</div>
</div>
</div>
<div
className="theme-elements row"
>
<div
className="theme-elements__header"
id="centerChannelStyles"
onClick={[Function]}
>
<MemoizedFormattedMessage
defaultMessage="Center Channel Styles"
id="user.settings.custom_theme.centerChannelTitle"
/>
<div
className="header__icon"
>
<LocalizedIcon
className="fa fa-plus"
title={
Object {
"defaultMessage": "Expand Icon",
"id": "generic_icons.expand",
}
}
/>
<LocalizedIcon
className="fa fa-minus"
title={
Object {
"defaultMessage": "Collapse Icon",
"id": "generic_icons.collapse",
}
}
/>
</div>
</div>
<div
className="theme-elements__body"
id="centerChannelStyles"
>
<div
className="col-sm-6 form-group element"
key="custom-theme-key14"
>
<ColorChooser
id="centerChannelBg"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Center Channel BG"
id="user.settings.custom_theme.centerChannelBg"
/>
}
onChange={[Function]}
value="#ffffff"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key15"
>
<ColorChooser
id="centerChannelColor"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Center Channel Text"
id="user.settings.custom_theme.centerChannelColor"
/>
}
onChange={[Function]}
value="#3f4350"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key16"
>
<ColorChooser
id="newMessageSeparator"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="New Message Separator"
id="user.settings.custom_theme.newMessageSeparator"
/>
}
onChange={[Function]}
value="#cc8f00"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key17"
>
<ColorChooser
id="errorTextColor"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Error Text Color"
id="user.settings.custom_theme.errorTextColor"
/>
}
onChange={[Function]}
value="#d24b4e"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key18"
>
<ColorChooser
id="mentionHighlightBg"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Mention Highlight BG"
id="user.settings.custom_theme.mentionHighlightBg"
/>
}
onChange={[Function]}
value="#ffd470"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key20"
>
<ColorChooser
id="mentionHighlightLink"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Mention Highlight Link"
id="user.settings.custom_theme.mentionHighlightLink"
/>
}
onChange={[Function]}
value="#1b1d22"
/>
</div>
<div
className="col-sm-6 form-group"
key="custom-theme-key23"
>
<label
className="custom-label"
>
<MemoizedFormattedMessage
defaultMessage="Code Theme"
id="user.settings.custom_theme.codeTheme"
/>
</label>
<div
className="input-group theme-group group--code dropdown"
id="codeTheme"
>
<select
className="form-control"
defaultValue="github"
id="codeThemeSelect"
onChange={[Function]}
>
<option
key="code-theme-key0"
value="solarized-dark"
>
Solarized Dark
</option>
<option
key="code-theme-key1"
value="solarized-light"
>
Solarized Light
</option>
<option
key="code-theme-key2"
value="github"
>
GitHub
</option>
<option
key="code-theme-key3"
value="monokai"
>
Monokai
</option>
</select>
<OverlayTrigger
defaultOverlayShown={false}
overlay={
<Popover
className="code-popover"
id="code-popover"
placement="right"
popoverSize="sm"
popoverStyle="info"
>
<img
alt="code theme image"
src={null}
width="200"
/>
</Popover>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<span
className="input-group-addon"
>
<img
alt="code theme image"
src={null}
/>
</span>
</OverlayTrigger>
</div>
</div>
</div>
</div>
<div
className="theme-elements row"
>
<div
className="theme-elements__header"
id="linkAndButtonsStyles"
onClick={[Function]}
>
<MemoizedFormattedMessage
defaultMessage="Link and Button Styles"
id="user.settings.custom_theme.linkButtonTitle"
/>
<div
className="header__icon"
>
<LocalizedIcon
className="fa fa-plus"
title={
Object {
"defaultMessage": "Expand Icon",
"id": "generic_icons.expand",
}
}
/>
<LocalizedIcon
className="fa fa-minus"
title={
Object {
"defaultMessage": "Collapse Icon",
"id": "generic_icons.collapse",
}
}
/>
</div>
</div>
<div
className="theme-elements__body"
>
<div
className="col-sm-6 form-group element"
key="custom-theme-key19"
>
<ColorChooser
id="linkColor"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Link Color"
id="user.settings.custom_theme.linkColor"
/>
}
onChange={[Function]}
value="#386fe5"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key21"
>
<ColorChooser
id="buttonBg"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Button BG"
id="user.settings.custom_theme.buttonBg"
/>
}
onChange={[Function]}
value="#1c58d9"
/>
</div>
<div
className="col-sm-6 form-group element"
key="custom-theme-key22"
>
<ColorChooser
id="buttonColor"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Button Text"
id="user.settings.custom_theme.buttonColor"
/>
}
onChange={[Function]}
value="#ffffff"
/>
</div>
</div>
</div>
<div
className="row mt-3"
>
<div
className="col-sm-12"
>
<label
className="custom-label"
>
<MemoizedFormattedMessage
defaultMessage="Copy to share or paste theme colors here:"
id="user.settings.custom_theme.copyPaste"
/>
</label>
<textarea
className="form-control"
id="pasteBox"
onChange={[Function]}
onClick={[Function]}
onCopy={[Function]}
onPaste={[Function]}
value="{\\"sidebarBg\\":\\"#1e325c\\",\\"sidebarText\\":\\"#ffffff\\",\\"sidebarUnreadText\\":\\"#ffffff\\",\\"sidebarTextHoverBg\\":\\"#28427b\\",\\"sidebarTextActiveBorder\\":\\"#5d89ea\\",\\"sidebarTextActiveColor\\":\\"#ffffff\\",\\"sidebarHeaderBg\\":\\"#192a4d\\",\\"sidebarHeaderTextColor\\":\\"#ffffff\\",\\"sidebarTeamBarBg\\":\\"#14213e\\",\\"onlineIndicator\\":\\"#3db887\\",\\"awayIndicator\\":\\"#ffbc1f\\",\\"dndIndicator\\":\\"#d24b4e\\",\\"mentionBg\\":\\"#ffffff\\",\\"mentionBj\\":\\"#ffffff\\",\\"mentionColor\\":\\"#1e325c\\",\\"centerChannelBg\\":\\"#ffffff\\",\\"centerChannelColor\\":\\"#3f4350\\",\\"newMessageSeparator\\":\\"#cc8f00\\",\\"linkColor\\":\\"#386fe5\\",\\"buttonBg\\":\\"#1c58d9\\",\\"buttonColor\\":\\"#ffffff\\",\\"errorTextColor\\":\\"#d24b4e\\",\\"mentionHighlightBg\\":\\"#ffd470\\",\\"mentionHighlightLink\\":\\"#1b1d22\\",\\"codeTheme\\":\\"github\\"}"
/>
<div
className="mt-3"
>
<button
className="btn btn-tertiary"
onClick={[Function]}
>
<MemoizedFormattedMessage
defaultMessage="Copy Theme Colors"
id="user.settings.custom_theme.copyThemeColors"
/>
</button>
<span
className="alert alert-success copy-theme-success"
role="alert"
style={
Object {
"display": "none",
}
}
>
<MemoizedFormattedMessage
defaultMessage="✔ Copied"
id="user.settings.custom_theme.copied"
/>
</span>
</div>
</div>
</div>
</div>
`;
|
3,536 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/general/user_settings_general.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {Provider} from 'react-redux';
import type {UserProfile} from '@mattermost/types/users';
import configureStore from 'store';
import {shallowWithIntl, mountWithIntl} from 'tests/helpers/intl-test-helper';
import {TestHelper} from 'utils/test_helper';
import UserSettingsGeneral from './user_settings_general';
import type {UserSettingsGeneralTab} from './user_settings_general';
describe('components/user_settings/general/UserSettingsGeneral', () => {
const user: UserProfile = TestHelper.getUserMock({
id: 'user_id',
username: 'user_name',
first_name: 'first_name',
last_name: 'last_name',
nickname: 'nickname',
position: '',
email: '',
password: '',
auth_service: '',
last_picture_update: 0,
});
const requiredProps = {
user,
updateSection: jest.fn(),
updateTab: jest.fn(),
activeSection: '',
closeModal: jest.fn(),
collapseModal: jest.fn(),
isMobileView: false,
actions: {
logError: jest.fn(),
clearErrors: jest.fn(),
updateMe: jest.fn(),
sendVerificationEmail: jest.fn(),
setDefaultProfileImage: jest.fn(),
uploadProfileImage: jest.fn(),
},
maxFileSize: 1024,
ldapPositionAttributeSet: false,
samlPositionAttributeSet: false,
ldapPictureAttributeSet: false,
};
let store: ReturnType<typeof configureStore>;
beforeEach(() => {
store = configureStore();
});
test('submitUser() should have called updateMe', () => {
const updateMe = jest.fn().mockResolvedValue({data: true});
const props = {...requiredProps, actions: {...requiredProps.actions, updateMe}};
const wrapper = shallowWithIntl(<UserSettingsGeneral {...props}/>);
(wrapper.instance() as UserSettingsGeneralTab).submitUser(requiredProps.user, false);
expect(updateMe).toHaveBeenCalledTimes(1);
expect(updateMe).toHaveBeenCalledWith(requiredProps.user);
});
test('submitPicture() should not have called uploadProfileImage', () => {
const uploadProfileImage = jest.fn().mockResolvedValue({});
const props = {...requiredProps, actions: {...requiredProps.actions, uploadProfileImage}};
const wrapper = shallowWithIntl(<UserSettingsGeneral {...props}/>);
(wrapper.instance() as UserSettingsGeneralTab).submitPicture();
expect(uploadProfileImage).toHaveBeenCalledTimes(0);
});
test('submitPicture() should have called uploadProfileImage', async () => {
const uploadProfileImage = jest.fn(() => Promise.resolve({data: true}));
const props = {...requiredProps, actions: {...requiredProps.actions, uploadProfileImage}};
const wrapper = shallowWithIntl(<UserSettingsGeneral {...props}/>);
const mockFile = {type: 'image/jpeg', size: requiredProps.maxFileSize};
const event: any = {target: {files: [mockFile]}};
(wrapper.instance() as UserSettingsGeneralTab).updatePicture(event);
expect(wrapper.state('pictureFile')).toBe(event.target.files[0]);
expect((wrapper.instance() as UserSettingsGeneralTab).submitActive).toBe(true);
await (wrapper.instance() as UserSettingsGeneralTab).submitPicture();
expect(uploadProfileImage).toHaveBeenCalledTimes(1);
expect(uploadProfileImage).toHaveBeenCalledWith(requiredProps.user.id, mockFile);
expect(wrapper.state('pictureFile')).toBe(null);
expect((wrapper.instance() as UserSettingsGeneralTab).submitActive).toBe(false);
expect(requiredProps.updateSection).toHaveBeenCalledTimes(1);
expect(requiredProps.updateSection).toHaveBeenCalledWith('');
});
test('should not show position input field when LDAP or SAML position attribute is set', () => {
const props = {...requiredProps};
props.user = {...user};
props.user.auth_service = 'ldap';
props.activeSection = 'position';
props.ldapPositionAttributeSet = false;
props.samlPositionAttributeSet = false;
let wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsGeneral {...props}/>
</Provider>,
);
expect(wrapper.find('#position').length).toBe(1);
expect(wrapper.find('#position').is('input')).toBeTruthy();
props.ldapPositionAttributeSet = true;
props.samlPositionAttributeSet = false;
wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsGeneral {...props}/>
</Provider>,
);
expect(wrapper.find('#position').length).toBe(0);
props.user.auth_service = 'saml';
props.ldapPositionAttributeSet = false;
props.samlPositionAttributeSet = true;
wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsGeneral {...props}/>
</Provider>,
);
expect(wrapper.find('#position').length).toBe(0);
});
test('should not show image field when LDAP picture attribute is set', () => {
const props = {...requiredProps};
props.user = {...user};
props.user.auth_service = 'ldap';
props.activeSection = 'picture';
props.ldapPictureAttributeSet = false;
let wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsGeneral {...props}/>
</Provider>,
);
expect(wrapper.find('.profile-img').exists()).toBeTruthy();
props.ldapPictureAttributeSet = true;
wrapper = mountWithIntl(
<Provider store={store}>
<UserSettingsGeneral {...props}/>
</Provider>,
);
expect(wrapper.find('.profile-img').exists()).toBeFalsy();
});
test('it should display an error about a username conflicting with a group name', async () => {
const updateMe = () => Promise.resolve({data: false, error: {server_error_id: 'app.user.group_name_conflict', message: ''}});
const props = {...requiredProps, actions: {...requiredProps.actions, updateMe}};
const wrapper = shallowWithIntl(<UserSettingsGeneral {...props}/>);
await (wrapper.instance() as UserSettingsGeneralTab).submitUser(requiredProps.user, false);
expect(wrapper.state('serverError')).toBe('This username conflicts with an existing group name.');
});
});
|
3,542 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications/user_settings_notifications.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {type IntlShape} from 'react-intl';
import {renderWithContext, screen} from 'tests/react_testing_utils';
import {TestHelper} from 'utils/test_helper';
import UserSettingsNotifications from './user_settings_notifications';
describe('components/user_settings/display/UserSettingsDisplay', () => {
const defaultProps = {
user: TestHelper.getUserMock({id: 'user_id'}),
updateSection: jest.fn(),
activeSection: '',
closeModal: jest.fn(),
collapseModal: jest.fn(),
updateMe: jest.fn(() => Promise.resolve({})),
isCollapsedThreadsEnabled: true,
sendPushNotifications: false,
enableAutoResponder: false,
isCallsRingingEnabled: true,
intl: {} as IntlShape,
isEnterpriseOrCloudOrSKUStarterFree: false,
isEnterpriseReady: true,
};
test('should match snapshot', () => {
const wrapper = renderWithContext(
<UserSettingsNotifications {...defaultProps}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot when its a starter free', () => {
const props = {...defaultProps, isEnterpriseOrCloudOrSKUStarterFree: true};
const wrapper = renderWithContext(
<UserSettingsNotifications {...props}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot when its team edition', () => {
const props = {...defaultProps, isEnterpriseReady: false};
const wrapper = renderWithContext(
<UserSettingsNotifications {...props}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should show reply notifications section when CRT off', () => {
const props = {...defaultProps, isCollapsedThreadsEnabled: false};
renderWithContext(<UserSettingsNotifications {...props}/>);
expect(screen.getByText('Reply notifications')).toBeInTheDocument();
});
});
|
3,544 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications/__snapshots__/user_settings_notifications.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot 1`] = `
Object {
"asFragment": [Function],
"baseElement": <body>
<div>
<div
id="notificationSettings"
>
<div
class="modal-header"
>
<button
class="close"
data-dismiss="modal"
id="closeButton"
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
class="modal-title"
>
<div
class="modal-back"
>
<i
aria-label="Collapse Icon"
class="fa fa-angle-left"
/>
</div>
Notification Settings
</h4>
</div>
<div
class="user-settings"
>
<div
class="notificationSettingsModalHeader"
>
<h3
class="tab-header"
id="notificationSettingsTitle"
>
Notifications
</h3>
<a
href="https://mattermost.com/pl/about-notifications?utm_source=mattermost&utm_medium=in-product&utm_content=&uid=&sid="
rel="noopener noreferrer"
target="_blank"
>
<svg
fill="currentColor"
height="1em"
version="1.1"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12,2A7,7 0 0,1 19,9C19,11.38 17.81,13.47 16,14.74V17A1,1 0 0,1 15,18H9A1,1 0 0,1 8,17V14.74C6.19,13.47 5,11.38 5,9A7,7 0 0,1 12,2M9,21V20H15V21A1,1 0 0,1 14,22H10A1,1 0 0,1 9,21M12,4A5,5 0 0,0 7,9C7,11.05 8.23,12.81 10,13.58V16H14V13.58C15.77,12.81 17,11.05 17,9A5,5 0 0,0 12,4Z"
/>
</svg>
<span>
Learn more about notifications
</span>
</a>
</div>
<div
class="divider-dark first"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="desktopTitle"
>
Desktop Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="desktopTitle desktopEdit"
class="color--link style--none section-min__edit"
id="desktopEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="desktopDesc"
>
For all activity, without sound
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="emailTitle"
>
Email Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="emailTitle emailEdit"
class="color--link style--none section-min__edit"
id="emailEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="emailDesc"
>
Email notifications are not enabled
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="pushTitle"
>
Mobile Push Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="pushTitle pushEdit"
class="color--link style--none section-min__edit"
id="pushEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="pushDesc"
>
Never
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="keysWithNotificationTitle"
>
Keywords That Trigger Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="keysWithNotificationTitle keysWithNotificationEdit"
class="color--link style--none section-min__edit"
id="keysWithNotificationEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="keysWithNotificationDesc"
>
"@some-user"
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="keysWithHighlightTitle"
>
Keywords That Get Highlighted (Without Notifications)
</h4>
<button
aria-expanded="false"
aria-labelledby="keysWithHighlightTitle keysWithHighlightEdit"
class="color--link style--none section-min__edit"
id="keysWithHighlightEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="keysWithHighlightDesc"
>
None
</div>
</div>
<div
class="divider-light"
/>
<div
class="divider-dark"
/>
</div>
</div>
</div>
</body>,
"container": <div>
<div
id="notificationSettings"
>
<div
class="modal-header"
>
<button
class="close"
data-dismiss="modal"
id="closeButton"
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
class="modal-title"
>
<div
class="modal-back"
>
<i
aria-label="Collapse Icon"
class="fa fa-angle-left"
/>
</div>
Notification Settings
</h4>
</div>
<div
class="user-settings"
>
<div
class="notificationSettingsModalHeader"
>
<h3
class="tab-header"
id="notificationSettingsTitle"
>
Notifications
</h3>
<a
href="https://mattermost.com/pl/about-notifications?utm_source=mattermost&utm_medium=in-product&utm_content=&uid=&sid="
rel="noopener noreferrer"
target="_blank"
>
<svg
fill="currentColor"
height="1em"
version="1.1"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12,2A7,7 0 0,1 19,9C19,11.38 17.81,13.47 16,14.74V17A1,1 0 0,1 15,18H9A1,1 0 0,1 8,17V14.74C6.19,13.47 5,11.38 5,9A7,7 0 0,1 12,2M9,21V20H15V21A1,1 0 0,1 14,22H10A1,1 0 0,1 9,21M12,4A5,5 0 0,0 7,9C7,11.05 8.23,12.81 10,13.58V16H14V13.58C15.77,12.81 17,11.05 17,9A5,5 0 0,0 12,4Z"
/>
</svg>
<span>
Learn more about notifications
</span>
</a>
</div>
<div
class="divider-dark first"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="desktopTitle"
>
Desktop Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="desktopTitle desktopEdit"
class="color--link style--none section-min__edit"
id="desktopEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="desktopDesc"
>
For all activity, without sound
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="emailTitle"
>
Email Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="emailTitle emailEdit"
class="color--link style--none section-min__edit"
id="emailEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="emailDesc"
>
Email notifications are not enabled
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="pushTitle"
>
Mobile Push Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="pushTitle pushEdit"
class="color--link style--none section-min__edit"
id="pushEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="pushDesc"
>
Never
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="keysWithNotificationTitle"
>
Keywords That Trigger Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="keysWithNotificationTitle keysWithNotificationEdit"
class="color--link style--none section-min__edit"
id="keysWithNotificationEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="keysWithNotificationDesc"
>
"@some-user"
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="keysWithHighlightTitle"
>
Keywords That Get Highlighted (Without Notifications)
</h4>
<button
aria-expanded="false"
aria-labelledby="keysWithHighlightTitle keysWithHighlightEdit"
class="color--link style--none section-min__edit"
id="keysWithHighlightEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="keysWithHighlightDesc"
>
None
</div>
</div>
<div
class="divider-light"
/>
<div
class="divider-dark"
/>
</div>
</div>
</div>,
"debug": [Function],
"findAllByAltText": [Function],
"findAllByDisplayValue": [Function],
"findAllByLabelText": [Function],
"findAllByPlaceholderText": [Function],
"findAllByRole": [Function],
"findAllByTestId": [Function],
"findAllByText": [Function],
"findAllByTitle": [Function],
"findByAltText": [Function],
"findByDisplayValue": [Function],
"findByLabelText": [Function],
"findByPlaceholderText": [Function],
"findByRole": [Function],
"findByTestId": [Function],
"findByText": [Function],
"findByTitle": [Function],
"getAllByAltText": [Function],
"getAllByDisplayValue": [Function],
"getAllByLabelText": [Function],
"getAllByPlaceholderText": [Function],
"getAllByRole": [Function],
"getAllByTestId": [Function],
"getAllByText": [Function],
"getAllByTitle": [Function],
"getByAltText": [Function],
"getByDisplayValue": [Function],
"getByLabelText": [Function],
"getByPlaceholderText": [Function],
"getByRole": [Function],
"getByTestId": [Function],
"getByText": [Function],
"getByTitle": [Function],
"queryAllByAltText": [Function],
"queryAllByDisplayValue": [Function],
"queryAllByLabelText": [Function],
"queryAllByPlaceholderText": [Function],
"queryAllByRole": [Function],
"queryAllByTestId": [Function],
"queryAllByText": [Function],
"queryAllByTitle": [Function],
"queryByAltText": [Function],
"queryByDisplayValue": [Function],
"queryByLabelText": [Function],
"queryByPlaceholderText": [Function],
"queryByRole": [Function],
"queryByTestId": [Function],
"queryByText": [Function],
"queryByTitle": [Function],
"replaceStoreState": [Function],
"rerender": [Function],
"unmount": [Function],
"updateStoreState": [Function],
}
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot when its a starter free 1`] = `
Object {
"asFragment": [Function],
"baseElement": <body>
<div>
<div
id="notificationSettings"
>
<div
class="modal-header"
>
<button
class="close"
data-dismiss="modal"
id="closeButton"
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
class="modal-title"
>
<div
class="modal-back"
>
<i
aria-label="Collapse Icon"
class="fa fa-angle-left"
/>
</div>
Notification Settings
</h4>
</div>
<div
class="user-settings"
>
<div
class="notificationSettingsModalHeader"
>
<h3
class="tab-header"
id="notificationSettingsTitle"
>
Notifications
</h3>
<a
href="https://mattermost.com/pl/about-notifications?utm_source=mattermost&utm_medium=in-product&utm_content=&uid=&sid="
rel="noopener noreferrer"
target="_blank"
>
<svg
fill="currentColor"
height="1em"
version="1.1"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12,2A7,7 0 0,1 19,9C19,11.38 17.81,13.47 16,14.74V17A1,1 0 0,1 15,18H9A1,1 0 0,1 8,17V14.74C6.19,13.47 5,11.38 5,9A7,7 0 0,1 12,2M9,21V20H15V21A1,1 0 0,1 14,22H10A1,1 0 0,1 9,21M12,4A5,5 0 0,0 7,9C7,11.05 8.23,12.81 10,13.58V16H14V13.58C15.77,12.81 17,11.05 17,9A5,5 0 0,0 12,4Z"
/>
</svg>
<span>
Learn more about notifications
</span>
</a>
</div>
<div
class="divider-dark first"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="desktopTitle"
>
Desktop Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="desktopTitle desktopEdit"
class="color--link style--none section-min__edit"
id="desktopEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="desktopDesc"
>
For all activity, without sound
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="emailTitle"
>
Email Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="emailTitle emailEdit"
class="color--link style--none section-min__edit"
id="emailEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="emailDesc"
>
Email notifications are not enabled
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="pushTitle"
>
Mobile Push Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="pushTitle pushEdit"
class="color--link style--none section-min__edit"
id="pushEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="pushDesc"
>
Never
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="keysWithNotificationTitle"
>
Keywords That Trigger Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="keysWithNotificationTitle keysWithNotificationEdit"
class="color--link style--none section-min__edit"
id="keysWithNotificationEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="keysWithNotificationDesc"
>
"@some-user"
</div>
</div>
<div
class="divider-light"
/>
<div
class="divider-light"
/>
<div
class="section-min isDisabled"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title isDisabled"
id="keysWithHighlightTitle"
>
Keywords That Get Highlighted (Without Notifications)
</h4>
<span
class="RestrictedIndicator__icon-tooltip-container"
>
<span>
<button
class="style--none RestrictedIndicator__button"
id="mattermost_feature_highlight_without_notification-restricted-indicator"
>
<i
class="RestrictedIndicator__icon-tooltip icon icon-key-variant"
/>
Professional
</button>
</span>
</span>
</div>
<div
class="section-min__describe isDisabled"
id="keysWithHighlightDesc"
>
None
</div>
</div>
<div
class="divider-dark"
/>
</div>
</div>
</div>
</body>,
"container": <div>
<div
id="notificationSettings"
>
<div
class="modal-header"
>
<button
class="close"
data-dismiss="modal"
id="closeButton"
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
class="modal-title"
>
<div
class="modal-back"
>
<i
aria-label="Collapse Icon"
class="fa fa-angle-left"
/>
</div>
Notification Settings
</h4>
</div>
<div
class="user-settings"
>
<div
class="notificationSettingsModalHeader"
>
<h3
class="tab-header"
id="notificationSettingsTitle"
>
Notifications
</h3>
<a
href="https://mattermost.com/pl/about-notifications?utm_source=mattermost&utm_medium=in-product&utm_content=&uid=&sid="
rel="noopener noreferrer"
target="_blank"
>
<svg
fill="currentColor"
height="1em"
version="1.1"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12,2A7,7 0 0,1 19,9C19,11.38 17.81,13.47 16,14.74V17A1,1 0 0,1 15,18H9A1,1 0 0,1 8,17V14.74C6.19,13.47 5,11.38 5,9A7,7 0 0,1 12,2M9,21V20H15V21A1,1 0 0,1 14,22H10A1,1 0 0,1 9,21M12,4A5,5 0 0,0 7,9C7,11.05 8.23,12.81 10,13.58V16H14V13.58C15.77,12.81 17,11.05 17,9A5,5 0 0,0 12,4Z"
/>
</svg>
<span>
Learn more about notifications
</span>
</a>
</div>
<div
class="divider-dark first"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="desktopTitle"
>
Desktop Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="desktopTitle desktopEdit"
class="color--link style--none section-min__edit"
id="desktopEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="desktopDesc"
>
For all activity, without sound
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="emailTitle"
>
Email Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="emailTitle emailEdit"
class="color--link style--none section-min__edit"
id="emailEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="emailDesc"
>
Email notifications are not enabled
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="pushTitle"
>
Mobile Push Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="pushTitle pushEdit"
class="color--link style--none section-min__edit"
id="pushEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="pushDesc"
>
Never
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="keysWithNotificationTitle"
>
Keywords That Trigger Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="keysWithNotificationTitle keysWithNotificationEdit"
class="color--link style--none section-min__edit"
id="keysWithNotificationEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="keysWithNotificationDesc"
>
"@some-user"
</div>
</div>
<div
class="divider-light"
/>
<div
class="divider-light"
/>
<div
class="section-min isDisabled"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title isDisabled"
id="keysWithHighlightTitle"
>
Keywords That Get Highlighted (Without Notifications)
</h4>
<span
class="RestrictedIndicator__icon-tooltip-container"
>
<span>
<button
class="style--none RestrictedIndicator__button"
id="mattermost_feature_highlight_without_notification-restricted-indicator"
>
<i
class="RestrictedIndicator__icon-tooltip icon icon-key-variant"
/>
Professional
</button>
</span>
</span>
</div>
<div
class="section-min__describe isDisabled"
id="keysWithHighlightDesc"
>
None
</div>
</div>
<div
class="divider-dark"
/>
</div>
</div>
</div>,
"debug": [Function],
"findAllByAltText": [Function],
"findAllByDisplayValue": [Function],
"findAllByLabelText": [Function],
"findAllByPlaceholderText": [Function],
"findAllByRole": [Function],
"findAllByTestId": [Function],
"findAllByText": [Function],
"findAllByTitle": [Function],
"findByAltText": [Function],
"findByDisplayValue": [Function],
"findByLabelText": [Function],
"findByPlaceholderText": [Function],
"findByRole": [Function],
"findByTestId": [Function],
"findByText": [Function],
"findByTitle": [Function],
"getAllByAltText": [Function],
"getAllByDisplayValue": [Function],
"getAllByLabelText": [Function],
"getAllByPlaceholderText": [Function],
"getAllByRole": [Function],
"getAllByTestId": [Function],
"getAllByText": [Function],
"getAllByTitle": [Function],
"getByAltText": [Function],
"getByDisplayValue": [Function],
"getByLabelText": [Function],
"getByPlaceholderText": [Function],
"getByRole": [Function],
"getByTestId": [Function],
"getByText": [Function],
"getByTitle": [Function],
"queryAllByAltText": [Function],
"queryAllByDisplayValue": [Function],
"queryAllByLabelText": [Function],
"queryAllByPlaceholderText": [Function],
"queryAllByRole": [Function],
"queryAllByTestId": [Function],
"queryAllByText": [Function],
"queryAllByTitle": [Function],
"queryByAltText": [Function],
"queryByDisplayValue": [Function],
"queryByLabelText": [Function],
"queryByPlaceholderText": [Function],
"queryByRole": [Function],
"queryByTestId": [Function],
"queryByText": [Function],
"queryByTitle": [Function],
"replaceStoreState": [Function],
"rerender": [Function],
"unmount": [Function],
"updateStoreState": [Function],
}
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot when its team edition 1`] = `
Object {
"asFragment": [Function],
"baseElement": <body>
<div>
<div
id="notificationSettings"
>
<div
class="modal-header"
>
<button
class="close"
data-dismiss="modal"
id="closeButton"
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
class="modal-title"
>
<div
class="modal-back"
>
<i
aria-label="Collapse Icon"
class="fa fa-angle-left"
/>
</div>
Notification Settings
</h4>
</div>
<div
class="user-settings"
>
<div
class="notificationSettingsModalHeader"
>
<h3
class="tab-header"
id="notificationSettingsTitle"
>
Notifications
</h3>
<a
href="https://mattermost.com/pl/about-notifications?utm_source=mattermost&utm_medium=in-product&utm_content=&uid=&sid="
rel="noopener noreferrer"
target="_blank"
>
<svg
fill="currentColor"
height="1em"
version="1.1"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12,2A7,7 0 0,1 19,9C19,11.38 17.81,13.47 16,14.74V17A1,1 0 0,1 15,18H9A1,1 0 0,1 8,17V14.74C6.19,13.47 5,11.38 5,9A7,7 0 0,1 12,2M9,21V20H15V21A1,1 0 0,1 14,22H10A1,1 0 0,1 9,21M12,4A5,5 0 0,0 7,9C7,11.05 8.23,12.81 10,13.58V16H14V13.58C15.77,12.81 17,11.05 17,9A5,5 0 0,0 12,4Z"
/>
</svg>
<span>
Learn more about notifications
</span>
</a>
</div>
<div
class="divider-dark first"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="desktopTitle"
>
Desktop Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="desktopTitle desktopEdit"
class="color--link style--none section-min__edit"
id="desktopEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="desktopDesc"
>
For all activity, without sound
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="emailTitle"
>
Email Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="emailTitle emailEdit"
class="color--link style--none section-min__edit"
id="emailEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="emailDesc"
>
Email notifications are not enabled
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="pushTitle"
>
Mobile Push Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="pushTitle pushEdit"
class="color--link style--none section-min__edit"
id="pushEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="pushDesc"
>
Never
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="keysWithNotificationTitle"
>
Keywords That Trigger Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="keysWithNotificationTitle keysWithNotificationEdit"
class="color--link style--none section-min__edit"
id="keysWithNotificationEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="keysWithNotificationDesc"
>
"@some-user"
</div>
</div>
<div
class="divider-light"
/>
<div
class="divider-dark"
/>
</div>
</div>
</div>
</body>,
"container": <div>
<div
id="notificationSettings"
>
<div
class="modal-header"
>
<button
class="close"
data-dismiss="modal"
id="closeButton"
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
class="modal-title"
>
<div
class="modal-back"
>
<i
aria-label="Collapse Icon"
class="fa fa-angle-left"
/>
</div>
Notification Settings
</h4>
</div>
<div
class="user-settings"
>
<div
class="notificationSettingsModalHeader"
>
<h3
class="tab-header"
id="notificationSettingsTitle"
>
Notifications
</h3>
<a
href="https://mattermost.com/pl/about-notifications?utm_source=mattermost&utm_medium=in-product&utm_content=&uid=&sid="
rel="noopener noreferrer"
target="_blank"
>
<svg
fill="currentColor"
height="1em"
version="1.1"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12,2A7,7 0 0,1 19,9C19,11.38 17.81,13.47 16,14.74V17A1,1 0 0,1 15,18H9A1,1 0 0,1 8,17V14.74C6.19,13.47 5,11.38 5,9A7,7 0 0,1 12,2M9,21V20H15V21A1,1 0 0,1 14,22H10A1,1 0 0,1 9,21M12,4A5,5 0 0,0 7,9C7,11.05 8.23,12.81 10,13.58V16H14V13.58C15.77,12.81 17,11.05 17,9A5,5 0 0,0 12,4Z"
/>
</svg>
<span>
Learn more about notifications
</span>
</a>
</div>
<div
class="divider-dark first"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="desktopTitle"
>
Desktop Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="desktopTitle desktopEdit"
class="color--link style--none section-min__edit"
id="desktopEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="desktopDesc"
>
For all activity, without sound
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="emailTitle"
>
Email Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="emailTitle emailEdit"
class="color--link style--none section-min__edit"
id="emailEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="emailDesc"
>
Email notifications are not enabled
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="pushTitle"
>
Mobile Push Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="pushTitle pushEdit"
class="color--link style--none section-min__edit"
id="pushEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="pushDesc"
>
Never
</div>
</div>
<div
class="divider-light"
/>
<div
class="section-min"
>
<div
class="secion-min__header"
>
<h4
class="section-min__title"
id="keysWithNotificationTitle"
>
Keywords That Trigger Notifications
</h4>
<button
aria-expanded="false"
aria-labelledby="keysWithNotificationTitle keysWithNotificationEdit"
class="color--link style--none section-min__edit"
id="keysWithNotificationEdit"
>
<i
class="icon-pencil-outline"
title="Edit Icon"
/>
Edit
</button>
</div>
<div
class="section-min__describe"
id="keysWithNotificationDesc"
>
"@some-user"
</div>
</div>
<div
class="divider-light"
/>
<div
class="divider-dark"
/>
</div>
</div>
</div>,
"debug": [Function],
"findAllByAltText": [Function],
"findAllByDisplayValue": [Function],
"findAllByLabelText": [Function],
"findAllByPlaceholderText": [Function],
"findAllByRole": [Function],
"findAllByTestId": [Function],
"findAllByText": [Function],
"findAllByTitle": [Function],
"findByAltText": [Function],
"findByDisplayValue": [Function],
"findByLabelText": [Function],
"findByPlaceholderText": [Function],
"findByRole": [Function],
"findByTestId": [Function],
"findByText": [Function],
"findByTitle": [Function],
"getAllByAltText": [Function],
"getAllByDisplayValue": [Function],
"getAllByLabelText": [Function],
"getAllByPlaceholderText": [Function],
"getAllByRole": [Function],
"getAllByTestId": [Function],
"getAllByText": [Function],
"getAllByTitle": [Function],
"getByAltText": [Function],
"getByDisplayValue": [Function],
"getByLabelText": [Function],
"getByPlaceholderText": [Function],
"getByRole": [Function],
"getByTestId": [Function],
"getByText": [Function],
"getByTitle": [Function],
"queryAllByAltText": [Function],
"queryAllByDisplayValue": [Function],
"queryAllByLabelText": [Function],
"queryAllByPlaceholderText": [Function],
"queryAllByRole": [Function],
"queryAllByTestId": [Function],
"queryAllByText": [Function],
"queryAllByTitle": [Function],
"queryByAltText": [Function],
"queryByDisplayValue": [Function],
"queryByLabelText": [Function],
"queryByPlaceholderText": [Function],
"queryByRole": [Function],
"queryByTestId": [Function],
"queryByText": [Function],
"queryByTitle": [Function],
"replaceStoreState": [Function],
"rerender": [Function],
"unmount": [Function],
"updateStoreState": [Function],
}
`;
|
3,545 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications/desktop_notification_setting/desktop_notification_settings.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import type {ComponentProps} from 'react';
import {NotificationLevels} from 'utils/constants';
import DesktopNotificationSettings from './desktop_notification_settings';
jest.mock('utils/notification_sounds', () => {
const original = jest.requireActual('utils/notification_sounds');
return {
...original,
hasSoundOptions: jest.fn(() => true),
};
});
describe('components/user_settings/notifications/DesktopNotificationSettings', () => {
const baseProps: ComponentProps<typeof DesktopNotificationSettings> = {
active: true,
updateSection: jest.fn(),
onSubmit: jest.fn(),
onCancel: jest.fn(),
saving: false,
error: '',
setParentState: jest.fn(),
areAllSectionsInactive: false,
isCollapsedThreadsEnabled: false,
activity: NotificationLevels.MENTION,
threads: NotificationLevels.ALL,
sound: 'false',
callsSound: 'false',
selectedSound: 'Bing',
callsSelectedSound: 'Dynamic',
isCallsRingingEnabled: false,
};
test('should match snapshot, on max setting', () => {
const wrapper = shallow(
<DesktopNotificationSettings {...baseProps}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, on max setting with sound enabled', () => {
const props = {...baseProps, sound: 'true'};
const wrapper = shallow(
<DesktopNotificationSettings {...props}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, on max setting with Calls enabled', () => {
const props = {...baseProps, isCallsRingingEnabled: true};
const wrapper = shallow(
<DesktopNotificationSettings {...props}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, on max setting with Calls enabled, calls sound true', () => {
const props = {...baseProps, isCallsRingingEnabled: true, callsSound: 'true'};
const wrapper = shallow(
<DesktopNotificationSettings {...props}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, on min setting', () => {
const props = {...baseProps, active: false};
const wrapper = shallow(
<DesktopNotificationSettings {...props}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should call props.updateSection and props.onCancel on handleMinUpdateSection', () => {
const props = {...baseProps, updateSection: jest.fn(), onCancel: jest.fn()};
const wrapper = shallow<DesktopNotificationSettings>(
<DesktopNotificationSettings {...props}/>,
);
wrapper.instance().handleMinUpdateSection('');
expect(props.updateSection).toHaveBeenCalledTimes(1);
expect(props.updateSection).toHaveBeenCalledWith('');
expect(props.onCancel).toHaveBeenCalledTimes(1);
expect(props.onCancel).toHaveBeenCalledWith();
wrapper.instance().handleMinUpdateSection('desktop');
expect(props.updateSection).toHaveBeenCalledTimes(2);
expect(props.updateSection).toHaveBeenCalledWith('desktop');
expect(props.onCancel).toHaveBeenCalledTimes(2);
expect(props.onCancel).toHaveBeenCalledWith();
});
test('should call props.updateSection on handleMaxUpdateSection', () => {
const props = {...baseProps, updateSection: jest.fn()};
const wrapper = shallow<DesktopNotificationSettings>(
<DesktopNotificationSettings {...props}/>,
);
wrapper.instance().handleMaxUpdateSection('');
expect(props.updateSection).toHaveBeenCalledTimes(1);
expect(props.updateSection).toHaveBeenCalledWith('');
wrapper.instance().handleMaxUpdateSection('desktop');
expect(props.updateSection).toHaveBeenCalledTimes(2);
expect(props.updateSection).toHaveBeenCalledWith('desktop');
});
test('should call props.setParentState on handleOnChange', () => {
const props = {...baseProps, setParentState: jest.fn()};
const wrapper = shallow<DesktopNotificationSettings>(
<DesktopNotificationSettings {...props}/>,
);
wrapper.instance().handleOnChange({
currentTarget: {getAttribute: (key: string) => {
return {'data-key': 'dataKey', 'data-value': 'dataValue'}[key];
}},
} as unknown as React.ChangeEvent<HTMLInputElement>);
expect(props.setParentState).toHaveBeenCalledTimes(1);
expect(props.setParentState).toHaveBeenCalledWith('dataKey', 'dataValue');
});
test('should match snapshot, on buildMaximizedSetting', () => {
const wrapper = shallow<DesktopNotificationSettings>(
<DesktopNotificationSettings {...baseProps}/>,
);
expect(wrapper.instance().buildMaximizedSetting()).toMatchSnapshot();
wrapper.setProps({activity: NotificationLevels.NONE});
expect(wrapper.instance().buildMaximizedSetting()).toMatchSnapshot();
});
test('should match snapshot, on buildMinimizedSetting', () => {
const wrapper = shallow<DesktopNotificationSettings>(
<DesktopNotificationSettings {...baseProps}/>,
);
expect(wrapper.instance().buildMinimizedSetting()).toMatchSnapshot();
wrapper.setProps({activity: NotificationLevels.NONE});
expect(wrapper.instance().buildMinimizedSetting()).toMatchSnapshot();
});
});
|
3,547 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications/desktop_notification_setting | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications/desktop_notification_setting/__snapshots__/desktop_notification_settings.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/user_settings/notifications/DesktopNotificationSettings should match snapshot, on buildMaximizedSetting 1`] = `
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<div>
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Send desktop notifications"
id="user.settings.notifications.desktop"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopActivity"
data-value="all"
id="desktopNotificationAllActivity"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="For all activity"
id="user.settings.notifications.allActivity"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-key="desktopActivity"
data-value="mention"
id="desktopNotificationMentions"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Only for mentions, direct messages, and group messages"
id="user.settings.notifications.onlyMentions"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopActivity"
data-value="none"
id="desktopNotificationNever"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Never"
id="user.settings.notifications.never"
/>
</label>
</div>
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop notifications are available on Edge, Firefox, Safari, Chrome and Mattermost Desktop Apps."
id="user.settings.notifications.info"
/>
</div>
</fieldset>
<hr />
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Notification sound"
id="user.settings.notifications.desktop.sound"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopSound"
data-value="true"
id="soundOn"
name="notificationSounds"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.notifications.on"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-key="desktopSound"
data-value="false"
id="soundOff"
name="notificationSounds"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Off"
id="user.settings.notifications.off"
/>
</label>
<br />
</div>
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Notification sounds are available on Firefox, Edge, Safari, Chrome and Mattermost Desktop Apps."
id="user.settings.notifications.sounds_info"
/>
</div>
</fieldset>
</div>,
]
}
saving={false}
section=""
serverError=""
submit={[MockFunction]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop Notifications"
id="user.settings.notifications.desktop.title"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/notifications/DesktopNotificationSettings should match snapshot, on buildMaximizedSetting 2`] = `
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<div>
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Send desktop notifications"
id="user.settings.notifications.desktop"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopActivity"
data-value="all"
id="desktopNotificationAllActivity"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="For all activity"
id="user.settings.notifications.allActivity"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopActivity"
data-value="mention"
id="desktopNotificationMentions"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Only for mentions, direct messages, and group messages"
id="user.settings.notifications.onlyMentions"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-key="desktopActivity"
data-value="none"
id="desktopNotificationNever"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Never"
id="user.settings.notifications.never"
/>
</label>
</div>
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop notifications are available on Edge, Firefox, Safari, Chrome and Mattermost Desktop Apps."
id="user.settings.notifications.info"
/>
</div>
</fieldset>
<hr />
</div>,
]
}
saving={false}
section=""
serverError=""
submit={[MockFunction]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop Notifications"
id="user.settings.notifications.desktop.title"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/notifications/DesktopNotificationSettings should match snapshot, on buildMinimizedSetting 1`] = `
<SettingItemMin
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="For mentions and direct messages, without sound"
id="user.settings.notifications.desktop.mentionsNoSound"
/>
}
section="desktop"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop Notifications"
id="user.settings.notifications.desktop.title"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/notifications/DesktopNotificationSettings should match snapshot, on buildMinimizedSetting 2`] = `
<SettingItemMin
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Off"
id="user.settings.notifications.off"
/>
}
section="desktop"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop Notifications"
id="user.settings.notifications.desktop.title"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/notifications/DesktopNotificationSettings should match snapshot, on max setting 1`] = `
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<div>
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Send desktop notifications"
id="user.settings.notifications.desktop"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopActivity"
data-value="all"
id="desktopNotificationAllActivity"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="For all activity"
id="user.settings.notifications.allActivity"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-key="desktopActivity"
data-value="mention"
id="desktopNotificationMentions"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Only for mentions, direct messages, and group messages"
id="user.settings.notifications.onlyMentions"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopActivity"
data-value="none"
id="desktopNotificationNever"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Never"
id="user.settings.notifications.never"
/>
</label>
</div>
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop notifications are available on Edge, Firefox, Safari, Chrome and Mattermost Desktop Apps."
id="user.settings.notifications.info"
/>
</div>
</fieldset>
<hr />
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Notification sound"
id="user.settings.notifications.desktop.sound"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopSound"
data-value="true"
id="soundOn"
name="notificationSounds"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.notifications.on"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-key="desktopSound"
data-value="false"
id="soundOff"
name="notificationSounds"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Off"
id="user.settings.notifications.off"
/>
</label>
<br />
</div>
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Notification sounds are available on Firefox, Edge, Safari, Chrome and Mattermost Desktop Apps."
id="user.settings.notifications.sounds_info"
/>
</div>
</fieldset>
</div>,
]
}
saving={false}
section=""
serverError=""
submit={[MockFunction]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop Notifications"
id="user.settings.notifications.desktop.title"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/notifications/DesktopNotificationSettings should match snapshot, on max setting with Calls enabled 1`] = `
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<div>
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Send desktop notifications"
id="user.settings.notifications.desktop"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopActivity"
data-value="all"
id="desktopNotificationAllActivity"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="For all activity"
id="user.settings.notifications.allActivity"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-key="desktopActivity"
data-value="mention"
id="desktopNotificationMentions"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Only for mentions, direct messages, and group messages"
id="user.settings.notifications.onlyMentions"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopActivity"
data-value="none"
id="desktopNotificationNever"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Never"
id="user.settings.notifications.never"
/>
</label>
</div>
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop notifications are available on Edge, Firefox, Safari, Chrome and Mattermost Desktop Apps."
id="user.settings.notifications.info"
/>
</div>
</fieldset>
<hr />
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Notification sound"
id="user.settings.notifications.desktop.sound"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopSound"
data-value="true"
id="soundOn"
name="notificationSounds"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.notifications.on"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-key="desktopSound"
data-value="false"
id="soundOff"
name="notificationSounds"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Off"
id="user.settings.notifications.off"
/>
</label>
<br />
</div>
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Notification sounds are available on Firefox, Edge, Safari, Chrome and Mattermost Desktop Apps."
id="user.settings.notifications.sounds_info"
/>
</div>
</fieldset>
<React.Fragment>
<hr />
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Notification sound for incoming calls"
id="user.settings.notifications.desktop.calls_sound"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="callsDesktopSound"
data-value="true"
id="callsSoundOn"
name="callsNotificationSounds"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.notifications.on"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-key="callsDesktopSound"
data-value="false"
id="soundOff"
name="callsNotificationSounds"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Off"
id="user.settings.notifications.off"
/>
</label>
<br />
</div>
</fieldset>
</React.Fragment>
</div>,
]
}
saving={false}
section=""
serverError=""
submit={[MockFunction]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop Notifications"
id="user.settings.notifications.desktop.title"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/notifications/DesktopNotificationSettings should match snapshot, on max setting with Calls enabled, calls sound true 1`] = `
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<div>
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Send desktop notifications"
id="user.settings.notifications.desktop"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopActivity"
data-value="all"
id="desktopNotificationAllActivity"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="For all activity"
id="user.settings.notifications.allActivity"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-key="desktopActivity"
data-value="mention"
id="desktopNotificationMentions"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Only for mentions, direct messages, and group messages"
id="user.settings.notifications.onlyMentions"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopActivity"
data-value="none"
id="desktopNotificationNever"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Never"
id="user.settings.notifications.never"
/>
</label>
</div>
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop notifications are available on Edge, Firefox, Safari, Chrome and Mattermost Desktop Apps."
id="user.settings.notifications.info"
/>
</div>
</fieldset>
<hr />
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Notification sound"
id="user.settings.notifications.desktop.sound"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopSound"
data-value="true"
id="soundOn"
name="notificationSounds"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.notifications.on"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-key="desktopSound"
data-value="false"
id="soundOff"
name="notificationSounds"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Off"
id="user.settings.notifications.off"
/>
</label>
<br />
</div>
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Notification sounds are available on Firefox, Edge, Safari, Chrome and Mattermost Desktop Apps."
id="user.settings.notifications.sounds_info"
/>
</div>
</fieldset>
<React.Fragment>
<hr />
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Notification sound for incoming calls"
id="user.settings.notifications.desktop.calls_sound"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={true}
data-key="callsDesktopSound"
data-value="true"
id="callsSoundOn"
name="callsNotificationSounds"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.notifications.on"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="callsDesktopSound"
data-value="false"
id="soundOff"
name="callsNotificationSounds"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Off"
id="user.settings.notifications.off"
/>
</label>
<br />
</div>
<div
className="pt-2"
>
<StateManager
className="react-select notification-sound-dropdown"
classNamePrefix="react-select"
clearable={false}
components={
Object {
"SingleValue": [Function],
}
}
defaultInputValue=""
defaultMenuIsOpen={false}
defaultValue={null}
id="displayCallsSoundNotification"
isSearchable={false}
onChange={[Function]}
options={
Array [
Object {
"label": "Dynamic",
"value": "Dynamic",
},
Object {
"label": "Calm",
"value": "Calm",
},
Object {
"label": "Urgent",
"value": "Urgent",
},
Object {
"label": "Cheerful",
"value": "Cheerful",
},
]
}
value={
Object {
"label": "Dynamic",
"value": "Dynamic",
}
}
/>
</div>
</fieldset>
</React.Fragment>
</div>,
]
}
saving={false}
section=""
serverError=""
submit={[MockFunction]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop Notifications"
id="user.settings.notifications.desktop.title"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/notifications/DesktopNotificationSettings should match snapshot, on max setting with sound enabled 1`] = `
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<div>
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Send desktop notifications"
id="user.settings.notifications.desktop"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopActivity"
data-value="all"
id="desktopNotificationAllActivity"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="For all activity"
id="user.settings.notifications.allActivity"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-key="desktopActivity"
data-value="mention"
id="desktopNotificationMentions"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Only for mentions, direct messages, and group messages"
id="user.settings.notifications.onlyMentions"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopActivity"
data-value="none"
id="desktopNotificationNever"
name="desktopNotificationLevel"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Never"
id="user.settings.notifications.never"
/>
</label>
</div>
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop notifications are available on Edge, Firefox, Safari, Chrome and Mattermost Desktop Apps."
id="user.settings.notifications.info"
/>
</div>
</fieldset>
<hr />
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Notification sound"
id="user.settings.notifications.desktop.sound"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={true}
data-key="desktopSound"
data-value="true"
id="soundOn"
name="notificationSounds"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="On"
id="user.settings.notifications.on"
/>
</label>
<br />
</div>
<div
className="radio"
>
<label>
<input
checked={false}
data-key="desktopSound"
data-value="false"
id="soundOff"
name="notificationSounds"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Off"
id="user.settings.notifications.off"
/>
</label>
<br />
</div>
<div
className="pt-2"
>
<StateManager
className="react-select notification-sound-dropdown"
classNamePrefix="react-select"
clearable={false}
components={
Object {
"SingleValue": [Function],
}
}
defaultInputValue=""
defaultMenuIsOpen={false}
defaultValue={null}
id="displaySoundNotification"
isSearchable={false}
onChange={[Function]}
options={
Array [
Object {
"label": "Bing",
"value": "Bing",
},
Object {
"label": "Crackle",
"value": "Crackle",
},
Object {
"label": "Down",
"value": "Down",
},
Object {
"label": "Hello",
"value": "Hello",
},
Object {
"label": "Ripple",
"value": "Ripple",
},
Object {
"label": "Upstairs",
"value": "Upstairs",
},
]
}
value={
Object {
"label": "Bing",
"value": "Bing",
}
}
/>
</div>
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Notification sounds are available on Firefox, Edge, Safari, Chrome and Mattermost Desktop Apps."
id="user.settings.notifications.sounds_info"
/>
</div>
</fieldset>
</div>,
]
}
saving={false}
section=""
serverError=""
submit={[MockFunction]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop Notifications"
id="user.settings.notifications.desktop.title"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/notifications/DesktopNotificationSettings should match snapshot, on min setting 1`] = `
<SettingItemMin
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="For mentions and direct messages, without sound"
id="user.settings.notifications.desktop.mentionsNoSound"
/>
}
section="desktop"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Desktop Notifications"
id="user.settings.notifications.desktop.title"
/>
}
updateSection={[Function]}
/>
`;
|
3,548 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications/email_notification_setting/email_notification_setting.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import type {ComponentProps} from 'react';
import EmailNotificationSetting from 'components/user_settings/notifications/email_notification_setting/email_notification_setting';
import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {Preferences, NotificationLevels} from 'utils/constants';
describe('components/user_settings/notifications/EmailNotificationSetting', () => {
const requiredProps: ComponentProps<typeof EmailNotificationSetting> = {
active: true,
updateSection: jest.fn(),
onSubmit: jest.fn(),
onCancel: jest.fn(),
saving: false,
error: '',
setParentState: jest.fn(),
areAllSectionsInactive: false,
isCollapsedThreadsEnabled: false,
enableEmail: false,
onChange: jest.fn(),
threads: NotificationLevels.ALL,
currentUserId: 'current_user_id',
emailInterval: Preferences.INTERVAL_NEVER,
sendEmailNotifications: true,
enableEmailBatching: false,
actions: {
savePreferences: jest.fn(),
},
};
test('should match snapshot', () => {
const wrapper = mountWithIntl(<EmailNotificationSetting {...requiredProps}/>);
expect(wrapper).toMatchSnapshot();
expect(wrapper.find('#emailNotificationImmediately').exists()).toBe(true);
expect(wrapper.find('#emailNotificationNever').exists()).toBe(true);
expect(wrapper.find('#emailNotificationMinutes').exists()).toBe(false);
expect(wrapper.find('#emailNotificationHour').exists()).toBe(false);
});
test('should match snapshot, enabled email batching', () => {
const props = {
...requiredProps,
enableEmailBatching: true,
};
const wrapper = mountWithIntl(<EmailNotificationSetting {...props}/>);
expect(wrapper).toMatchSnapshot();
expect(wrapper.find('#emailNotificationMinutes').exists()).toBe(true);
expect(wrapper.find('#emailNotificationHour').exists()).toBe(true);
});
test('should match snapshot, not send email notifications', () => {
const props = {
...requiredProps,
sendEmailNotifications: false,
};
const wrapper = shallow(<EmailNotificationSetting {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, active section != email and SendEmailNotifications !== true', () => {
const props = {
...requiredProps,
sendEmailNotifications: false,
active: false,
};
const wrapper = shallow(<EmailNotificationSetting {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, active section != email and SendEmailNotifications = true', () => {
const props = {
...requiredProps,
sendEmailNotifications: true,
active: false,
};
const wrapper = shallow(<EmailNotificationSetting {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, active section != email, SendEmailNotifications = true and enableEmail = true', () => {
const props = {
...requiredProps,
sendEmailNotifications: true,
active: false,
enableEmail: true,
};
const wrapper = shallow(<EmailNotificationSetting {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, on serverError', () => {
const newServerError = 'serverError';
const props = {...requiredProps, error: newServerError};
const wrapper = shallow(<EmailNotificationSetting {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, when CRT on and email set to immediately', () => {
const props = {
...requiredProps,
enableEmail: true,
isCollapsedThreadsEnabled: true,
};
const wrapper = shallow(<EmailNotificationSetting {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, when CRT on and email set to never', () => {
const props = {
...requiredProps,
enableEmail: false,
isCollapsedThreadsEnabled: true,
};
const wrapper = shallow(<EmailNotificationSetting {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should pass handleChange', () => {
const wrapper = mountWithIntl(<EmailNotificationSetting {...requiredProps}/>);
wrapper.find('#emailNotificationImmediately').simulate('change');
expect(wrapper.state('enableEmail')).toBe(true);
expect(wrapper.state('newInterval')).toBe(Preferences.INTERVAL_IMMEDIATE);
expect(requiredProps.onChange).toBeCalledTimes(1);
});
test('should pass handleSubmit', async () => {
const newOnSubmit = jest.fn();
const newUpdateSection = jest.fn();
const newSavePreference = jest.fn();
const props = {
...requiredProps,
onSubmit: newOnSubmit,
updateSection: newUpdateSection,
actions: {savePreferences: newSavePreference},
};
const wrapper = mountWithIntl(<EmailNotificationSetting {...props}/>);
await (wrapper.instance() as EmailNotificationSetting).handleSubmit();
expect(wrapper.state('newInterval')).toBe(Preferences.INTERVAL_NEVER);
expect(newOnSubmit).toBeCalled();
expect(newUpdateSection).toHaveBeenCalledTimes(1);
expect(newUpdateSection).toBeCalledWith('');
const newInterval = Preferences.INTERVAL_IMMEDIATE;
wrapper.find('#emailNotificationImmediately').simulate('change');
await (wrapper.instance() as EmailNotificationSetting).handleSubmit();
expect(wrapper.state('newInterval')).toBe(newInterval);
expect(newOnSubmit).toBeCalled();
expect(newOnSubmit).toHaveBeenCalledTimes(2);
const expectedPref = [{
category: 'notifications',
name: 'email_interval',
user_id: 'current_user_id',
value: newInterval.toString(),
}];
expect(newSavePreference).toHaveBeenCalledTimes(1);
expect(newSavePreference).toBeCalledWith('current_user_id', expectedPref);
});
test('should pass handleUpdateSection', () => {
const newUpdateSection = jest.fn();
const newOnCancel = jest.fn();
const props = {...requiredProps, updateSection: newUpdateSection, onCancel: newOnCancel};
const wrapper = mountWithIntl(<EmailNotificationSetting {...props}/>);
(wrapper.instance() as EmailNotificationSetting).handleUpdateSection('email');
expect(newUpdateSection).toBeCalledWith('email');
expect(newUpdateSection).toHaveBeenCalledTimes(1);
expect(newOnCancel).not.toBeCalled();
(wrapper.instance() as EmailNotificationSetting).handleUpdateSection();
expect(newUpdateSection).toBeCalled();
expect(newUpdateSection).toHaveBeenCalledTimes(2);
expect(newUpdateSection).toBeCalledWith('');
expect(newOnCancel).toBeCalled();
});
test('should derived state from props', () => {
const nextProps = {
enableEmail: false,
emailInterval: Preferences.INTERVAL_IMMEDIATE,
enableEmailBatching: true,
sendEmailNotifications: true,
};
const wrapper = mountWithIntl(<EmailNotificationSetting {...requiredProps}/>);
expect(wrapper.state('emailInterval')).toBe(requiredProps.emailInterval);
expect(wrapper.state('enableEmailBatching')).toBe(requiredProps.enableEmailBatching);
expect(wrapper.state('sendEmailNotifications')).toBe(requiredProps.sendEmailNotifications);
expect(wrapper.state('newInterval')).toBe(Preferences.INTERVAL_NEVER);
wrapper.setProps(nextProps);
expect(wrapper.state('emailInterval')).toBe(nextProps.emailInterval);
expect(wrapper.state('enableEmailBatching')).toBe(nextProps.enableEmailBatching);
expect(wrapper.state('sendEmailNotifications')).toBe(nextProps.sendEmailNotifications);
expect(wrapper.state('newInterval')).toBe(Preferences.INTERVAL_NEVER);
nextProps.enableEmail = true;
nextProps.emailInterval = Preferences.INTERVAL_FIFTEEN_MINUTES;
wrapper.setProps(nextProps);
expect(wrapper.state('emailInterval')).toBe(nextProps.emailInterval);
expect(wrapper.state('enableEmail')).toBe(nextProps.enableEmail);
expect(wrapper.state('enableEmailBatching')).toBe(nextProps.enableEmailBatching);
expect(wrapper.state('sendEmailNotifications')).toBe(nextProps.sendEmailNotifications);
expect(wrapper.state('newInterval')).toBe(Preferences.INTERVAL_FIFTEEN_MINUTES);
});
});
|
3,551 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications/email_notification_setting | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications/email_notification_setting/__snapshots__/email_notification_setting.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot 1`] = `
<EmailNotificationSetting
actions={
Object {
"savePreferences": [MockFunction],
}
}
active={true}
areAllSectionsInactive={false}
currentUserId="current_user_id"
emailInterval={0}
enableEmail={false}
enableEmailBatching={false}
error=""
isCollapsedThreadsEnabled={false}
onCancel={[MockFunction]}
onChange={[MockFunction]}
onSubmit={[MockFunction]}
saving={false}
sendEmailNotifications={true}
setParentState={[MockFunction]}
threads="all"
updateSection={[MockFunction]}
>
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Send email notifications"
id="user.settings.notifications.email.send"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-email-interval={30}
data-enable-email="true"
id="emailNotificationImmediately"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Immediately"
id="user.settings.notifications.email.immediately"
/>
</label>
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-email-interval={0}
data-enable-email="false"
id="emailNotificationNever"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Never"
id="user.settings.notifications.email.never"
/>
</label>
</div>
<div
className="mt-3"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Email notifications are sent for mentions and direct messages when you are offline or away for more than 5 minutes."
id="user.settings.notifications.emailInfo"
/>
</div>
</fieldset>,
null,
]
}
saving={false}
section=""
serverError=""
submit={[Function]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Email Notifications"
id="user.settings.notifications.emailNotifications"
/>
}
updateSection={[Function]}
>
<section
className="section-max form-horizontal "
>
<h4
className="col-sm-12 section-title"
id="settingTitle"
>
<FormattedMessage
defaultMessage="Email Notifications"
id="user.settings.notifications.emailNotifications"
>
<span>
Email Notifications
</span>
</FormattedMessage>
</h4>
<div
className="col-sm-9 col-sm-offset-3"
>
<div
className="setting-list"
tabIndex={-1}
>
<div
className="setting-list-item"
>
<fieldset
key="userNotificationEmailOptions"
>
<legend
className="form-legend"
>
<FormattedMessage
defaultMessage="Send email notifications"
id="user.settings.notifications.email.send"
>
<span>
Send email notifications
</span>
</FormattedMessage>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-email-interval={30}
data-enable-email="true"
id="emailNotificationImmediately"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<FormattedMessage
defaultMessage="Immediately"
id="user.settings.notifications.email.immediately"
>
<span>
Immediately
</span>
</FormattedMessage>
</label>
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-email-interval={0}
data-enable-email="false"
id="emailNotificationNever"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<FormattedMessage
defaultMessage="Never"
id="user.settings.notifications.email.never"
>
<span>
Never
</span>
</FormattedMessage>
</label>
</div>
<div
className="mt-3"
>
<FormattedMessage
defaultMessage="Email notifications are sent for mentions and direct messages when you are offline or away for more than 5 minutes."
id="user.settings.notifications.emailInfo"
>
<span>
Email notifications are sent for mentions and direct messages when you are offline or away for more than 5 minutes.
</span>
</FormattedMessage>
</div>
</fieldset>
</div>
<div
className="setting-list-item"
>
<hr />
<SaveButton
btnClass=""
defaultMessage={
<Memo(MemoizedFormattedMessage)
defaultMessage="Save"
id="save_button.save"
/>
}
disabled={false}
extraClasses=""
onClick={[Function]}
saving={false}
savingMessage={
<Memo(MemoizedFormattedMessage)
defaultMessage="Saving"
id="save_button.saving"
/>
}
>
<button
className="btn btn-primary "
data-testid="saveSetting"
disabled={false}
id="saveSetting"
onClick={[Function]}
type="submit"
>
<Memo(LoadingWrapper)
loading={false}
text={
<Memo(MemoizedFormattedMessage)
defaultMessage="Saving"
id="save_button.saving"
/>
}
>
<span>
<FormattedMessage
defaultMessage="Save"
id="save_button.save"
>
<span>
Save
</span>
</FormattedMessage>
</span>
</Memo(LoadingWrapper)>
</button>
</SaveButton>
<button
className="btn btn-tertiary"
id="cancelSetting"
onClick={[Function]}
>
<FormattedMessage
defaultMessage="Cancel"
id="setting_item_max.cancel"
>
<span>
Cancel
</span>
</FormattedMessage>
</button>
</div>
</div>
</div>
</section>
</SettingItemMax>
</EmailNotificationSetting>
`;
exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot, active section != email and SendEmailNotifications !== true 1`] = `
<SettingItemMin
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Email notifications are not enabled"
id="user.settings.notifications.email.disabled"
/>
}
section="email"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Email Notifications"
id="user.settings.notifications.emailNotifications"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot, active section != email and SendEmailNotifications = true 1`] = `
<SettingItemMin
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Never"
id="user.settings.notifications.email.never"
/>
}
section="email"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Email Notifications"
id="user.settings.notifications.emailNotifications"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot, active section != email, SendEmailNotifications = true and enableEmail = true 1`] = `
<SettingItemMin
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Immediately"
id="user.settings.notifications.email.immediately"
/>
}
section="email"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Email Notifications"
id="user.settings.notifications.emailNotifications"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot, enabled email batching 1`] = `
<EmailNotificationSetting
actions={
Object {
"savePreferences": [MockFunction],
}
}
active={true}
areAllSectionsInactive={false}
currentUserId="current_user_id"
emailInterval={0}
enableEmail={false}
enableEmailBatching={true}
error=""
isCollapsedThreadsEnabled={false}
onCancel={[MockFunction]}
onChange={[MockFunction]}
onSubmit={[MockFunction]}
saving={false}
sendEmailNotifications={true}
setParentState={[MockFunction]}
threads="all"
updateSection={[MockFunction]}
>
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Send email notifications"
id="user.settings.notifications.email.send"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-email-interval={30}
data-enable-email="true"
id="emailNotificationImmediately"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Immediately"
id="user.settings.notifications.email.immediately"
/>
</label>
</div>
<fieldset>
<div
className="radio"
>
<label>
<input
checked={false}
data-email-interval={900}
data-enable-email="true"
id="emailNotificationMinutes"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Every {count, plural, one {minute} other {{count, number} minutes}}"
id="user.settings.notifications.email.everyXMinutes"
values={
Object {
"count": 15,
}
}
/>
</label>
</div>
<div
className="radio"
>
<label>
<input
checked={false}
data-email-interval={3600}
data-enable-email="true"
id="emailNotificationHour"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Every hour"
id="user.settings.notifications.email.everyHour"
/>
</label>
</div>
</fieldset>
<div
className="radio"
>
<label>
<input
checked={true}
data-email-interval={0}
data-enable-email="false"
id="emailNotificationNever"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Never"
id="user.settings.notifications.email.never"
/>
</label>
</div>
<div
className="mt-3"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Email notifications are sent for mentions and direct messages when you are offline or away for more than 5 minutes."
id="user.settings.notifications.emailInfo"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Notifications received over the time period selected are combined and sent in a single email."
id="user.settings.notifications.emailBatchingInfo"
/>
</div>
</fieldset>,
null,
]
}
saving={false}
section=""
serverError=""
submit={[Function]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Email Notifications"
id="user.settings.notifications.emailNotifications"
/>
}
updateSection={[Function]}
>
<section
className="section-max form-horizontal "
>
<h4
className="col-sm-12 section-title"
id="settingTitle"
>
<FormattedMessage
defaultMessage="Email Notifications"
id="user.settings.notifications.emailNotifications"
>
<span>
Email Notifications
</span>
</FormattedMessage>
</h4>
<div
className="col-sm-9 col-sm-offset-3"
>
<div
className="setting-list"
tabIndex={-1}
>
<div
className="setting-list-item"
>
<fieldset
key="userNotificationEmailOptions"
>
<legend
className="form-legend"
>
<FormattedMessage
defaultMessage="Send email notifications"
id="user.settings.notifications.email.send"
>
<span>
Send email notifications
</span>
</FormattedMessage>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-email-interval={30}
data-enable-email="true"
id="emailNotificationImmediately"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<FormattedMessage
defaultMessage="Immediately"
id="user.settings.notifications.email.immediately"
>
<span>
Immediately
</span>
</FormattedMessage>
</label>
</div>
<fieldset>
<div
className="radio"
>
<label>
<input
checked={false}
data-email-interval={900}
data-enable-email="true"
id="emailNotificationMinutes"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<FormattedMessage
defaultMessage="Every {count, plural, one {minute} other {{count, number} minutes}}"
id="user.settings.notifications.email.everyXMinutes"
values={
Object {
"count": 15,
}
}
>
<span>
Every 15 minutes
</span>
</FormattedMessage>
</label>
</div>
<div
className="radio"
>
<label>
<input
checked={false}
data-email-interval={3600}
data-enable-email="true"
id="emailNotificationHour"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<FormattedMessage
defaultMessage="Every hour"
id="user.settings.notifications.email.everyHour"
>
<span>
Every hour
</span>
</FormattedMessage>
</label>
</div>
</fieldset>
<div
className="radio"
>
<label>
<input
checked={true}
data-email-interval={0}
data-enable-email="false"
id="emailNotificationNever"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<FormattedMessage
defaultMessage="Never"
id="user.settings.notifications.email.never"
>
<span>
Never
</span>
</FormattedMessage>
</label>
</div>
<div
className="mt-3"
>
<FormattedMessage
defaultMessage="Email notifications are sent for mentions and direct messages when you are offline or away for more than 5 minutes."
id="user.settings.notifications.emailInfo"
>
<span>
Email notifications are sent for mentions and direct messages when you are offline or away for more than 5 minutes.
</span>
</FormattedMessage>
<FormattedMessage
defaultMessage="Notifications received over the time period selected are combined and sent in a single email."
id="user.settings.notifications.emailBatchingInfo"
>
<span>
Notifications received over the time period selected are combined and sent in a single email.
</span>
</FormattedMessage>
</div>
</fieldset>
</div>
<div
className="setting-list-item"
>
<hr />
<SaveButton
btnClass=""
defaultMessage={
<Memo(MemoizedFormattedMessage)
defaultMessage="Save"
id="save_button.save"
/>
}
disabled={false}
extraClasses=""
onClick={[Function]}
saving={false}
savingMessage={
<Memo(MemoizedFormattedMessage)
defaultMessage="Saving"
id="save_button.saving"
/>
}
>
<button
className="btn btn-primary "
data-testid="saveSetting"
disabled={false}
id="saveSetting"
onClick={[Function]}
type="submit"
>
<Memo(LoadingWrapper)
loading={false}
text={
<Memo(MemoizedFormattedMessage)
defaultMessage="Saving"
id="save_button.saving"
/>
}
>
<span>
<FormattedMessage
defaultMessage="Save"
id="save_button.save"
>
<span>
Save
</span>
</FormattedMessage>
</span>
</Memo(LoadingWrapper)>
</button>
</SaveButton>
<button
className="btn btn-tertiary"
id="cancelSetting"
onClick={[Function]}
>
<FormattedMessage
defaultMessage="Cancel"
id="setting_item_max.cancel"
>
<span>
Cancel
</span>
</FormattedMessage>
</button>
</div>
</div>
</div>
</section>
</SettingItemMax>
</EmailNotificationSetting>
`;
exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot, not send email notifications 1`] = `
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<div
className="pt-2"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Email notifications have not been enabled by your System Administrator."
id="user.settings.notifications.email.disabled_long"
/>
</div>,
]
}
saving={false}
section="email"
serverError=""
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Email Notifications"
id="user.settings.notifications.emailNotifications"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot, on serverError 1`] = `
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Send email notifications"
id="user.settings.notifications.email.send"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-email-interval={30}
data-enable-email="true"
id="emailNotificationImmediately"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Immediately"
id="user.settings.notifications.email.immediately"
/>
</label>
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-email-interval={0}
data-enable-email="false"
id="emailNotificationNever"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Never"
id="user.settings.notifications.email.never"
/>
</label>
</div>
<div
className="mt-3"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Email notifications are sent for mentions and direct messages when you are offline or away for more than 5 minutes."
id="user.settings.notifications.emailInfo"
/>
</div>
</fieldset>,
null,
]
}
saving={false}
section=""
serverError="serverError"
submit={[Function]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Email Notifications"
id="user.settings.notifications.emailNotifications"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot, when CRT on and email set to immediately 1`] = `
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Send email notifications"
id="user.settings.notifications.email.send"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={true}
data-email-interval={30}
data-enable-email="true"
id="emailNotificationImmediately"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Immediately"
id="user.settings.notifications.email.immediately"
/>
</label>
</div>
<div
className="radio"
>
<label>
<input
checked={false}
data-email-interval={0}
data-enable-email="false"
id="emailNotificationNever"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Never"
id="user.settings.notifications.email.never"
/>
</label>
</div>
<div
className="mt-3"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Email notifications are sent for mentions and direct messages when you are offline or away for more than 5 minutes."
id="user.settings.notifications.emailInfo"
/>
</div>
</fieldset>,
<React.Fragment>
<hr />
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Thread reply notifications"
id="user.settings.notifications.threads.desktop"
/>
</legend>
<div
className="checkbox"
>
<label>
<input
checked={true}
id="desktopThreadsNotificationAllActivity"
name="desktopThreadsNotificationLevel"
onChange={[Function]}
type="checkbox"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Notify me about threads I'm following"
id="user.settings.notifications.threads.allActivity"
/>
</label>
<br />
</div>
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="When enabled, any reply to a thread you're following will send an email notification."
id="user.settings.notifications.email_threads"
/>
</div>
</fieldset>
</React.Fragment>,
]
}
saving={false}
section=""
serverError=""
submit={[Function]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Email Notifications"
id="user.settings.notifications.emailNotifications"
/>
}
updateSection={[Function]}
/>
`;
exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot, when CRT on and email set to never 1`] = `
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<fieldset>
<legend
className="form-legend"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Send email notifications"
id="user.settings.notifications.email.send"
/>
</legend>
<div
className="radio"
>
<label>
<input
checked={false}
data-email-interval={30}
data-enable-email="true"
id="emailNotificationImmediately"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Immediately"
id="user.settings.notifications.email.immediately"
/>
</label>
</div>
<div
className="radio"
>
<label>
<input
checked={true}
data-email-interval={0}
data-enable-email="false"
id="emailNotificationNever"
name="emailNotifications"
onChange={[Function]}
type="radio"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Never"
id="user.settings.notifications.email.never"
/>
</label>
</div>
<div
className="mt-3"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Email notifications are sent for mentions and direct messages when you are offline or away for more than 5 minutes."
id="user.settings.notifications.emailInfo"
/>
</div>
</fieldset>,
null,
]
}
saving={false}
section=""
serverError=""
submit={[Function]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Email Notifications"
id="user.settings.notifications.emailNotifications"
/>
}
updateSection={[Function]}
/>
`;
|
3,552 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications/manage_auto_responder/manage_auto_responder.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import type {ComponentProps} from 'react';
import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import ManageAutoResponder from './manage_auto_responder';
describe('components/user_settings/notifications/ManageAutoResponder', () => {
const requiredProps: ComponentProps<typeof ManageAutoResponder> = {
autoResponderActive: false,
autoResponderMessage: 'Hello World!',
updateSection: jest.fn(),
setParentState: jest.fn(),
submit: jest.fn(),
saving: false,
error: '',
};
test('should match snapshot, default disabled', () => {
const wrapper = mountWithIntl(<ManageAutoResponder {...requiredProps}/>);
expect(wrapper).toMatchSnapshot();
expect(wrapper.find('#autoResponderActive').exists()).toBe(true);
expect(wrapper.find('#autoResponderMessage').exists()).toBe(false);
});
test('should match snapshot, enabled', () => {
const wrapper = mountWithIntl(
<ManageAutoResponder
{...requiredProps}
autoResponderActive={true}
/>,
);
expect(wrapper).toMatchSnapshot();
expect(wrapper.find('#autoResponderActive').exists()).toBe(true);
expect(wrapper.find('#autoResponderMessage').exists()).toBe(true);
});
test('should pass handleChange', () => {
const setParentState = jest.fn();
const wrapper = mountWithIntl(
<ManageAutoResponder
{...requiredProps}
autoResponderActive={true}
setParentState={setParentState}
/>,
);
expect(wrapper.find('#autoResponderActive').exists()).toBe(true);
expect(wrapper.find('#autoResponderMessageInput').exists()).toBe(true);
wrapper.find('#autoResponderMessageInput').simulate('change');
expect(setParentState).toBeCalled();
expect(setParentState).toBeCalledWith('autoResponderMessage', 'Hello World!');
wrapper.find('#autoResponderActive').simulate('change');
expect(setParentState).toBeCalled();
});
});
|
3,554 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications/manage_auto_responder | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/notifications/manage_auto_responder/__snapshots__/manage_auto_responder.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/user_settings/notifications/ManageAutoResponder should match snapshot, default disabled 1`] = `
<ManageAutoResponder
autoResponderActive={false}
autoResponderMessage="Hello World!"
error=""
saving={false}
setParentState={[MockFunction]}
submit={[MockFunction]}
updateSection={[MockFunction]}
>
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<div
className="checkbox"
id="autoResponderCheckbox"
>
<label>
<input
checked={false}
id="autoResponderActive"
onChange={[Function]}
type="checkbox"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Enabled"
id="user.settings.notifications.autoResponderEnabled"
/>
</label>
</div>,
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Set a custom message that will be automatically sent in response to Direct Messages. Mentions in Public and Private Channels will not trigger the automated reply. Enabling Automatic Replies sets your status to Out of Office and disables email and push notifications."
id="user.settings.notifications.autoResponderHint"
/>
</div>,
]
}
saving={false}
section=""
shiftEnter={true}
submit={[MockFunction]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Automatic Direct Message Replies"
id="user.settings.notifications.autoResponder"
/>
}
updateSection={[MockFunction]}
width="medium"
>
<section
className="section-max form-horizontal "
>
<h4
className="col-sm-12 section-title"
id="settingTitle"
>
<FormattedMessage
defaultMessage="Automatic Direct Message Replies"
id="user.settings.notifications.autoResponder"
>
<span>
Automatic Direct Message Replies
</span>
</FormattedMessage>
</h4>
<div
className="col-sm-10 col-sm-offset-2"
>
<div
className="setting-list"
tabIndex={-1}
>
<div
className="setting-list-item"
>
<div
className="checkbox"
id="autoResponderCheckbox"
key="autoResponderCheckbox"
>
<label>
<input
checked={false}
id="autoResponderActive"
onChange={[Function]}
type="checkbox"
/>
<FormattedMessage
defaultMessage="Enabled"
id="user.settings.notifications.autoResponderEnabled"
>
<span>
Enabled
</span>
</FormattedMessage>
</label>
</div>
<div
className="mt-5"
key="autoResponderHint"
>
<FormattedMessage
defaultMessage="Set a custom message that will be automatically sent in response to Direct Messages. Mentions in Public and Private Channels will not trigger the automated reply. Enabling Automatic Replies sets your status to Out of Office and disables email and push notifications."
id="user.settings.notifications.autoResponderHint"
>
<span>
Set a custom message that will be automatically sent in response to Direct Messages. Mentions in Public and Private Channels will not trigger the automated reply. Enabling Automatic Replies sets your status to Out of Office and disables email and push notifications.
</span>
</FormattedMessage>
</div>
</div>
<div
className="setting-list-item"
>
<hr />
<SaveButton
btnClass=""
defaultMessage={
<Memo(MemoizedFormattedMessage)
defaultMessage="Save"
id="save_button.save"
/>
}
disabled={false}
extraClasses=""
onClick={[Function]}
saving={false}
savingMessage={
<Memo(MemoizedFormattedMessage)
defaultMessage="Saving"
id="save_button.saving"
/>
}
>
<button
className="btn btn-primary "
data-testid="saveSetting"
disabled={false}
id="saveSetting"
onClick={[Function]}
type="submit"
>
<Memo(LoadingWrapper)
loading={false}
text={
<Memo(MemoizedFormattedMessage)
defaultMessage="Saving"
id="save_button.saving"
/>
}
>
<span>
<FormattedMessage
defaultMessage="Save"
id="save_button.save"
>
<span>
Save
</span>
</FormattedMessage>
</span>
</Memo(LoadingWrapper)>
</button>
</SaveButton>
<button
className="btn btn-tertiary"
id="cancelSetting"
onClick={[Function]}
>
<FormattedMessage
defaultMessage="Cancel"
id="setting_item_max.cancel"
>
<span>
Cancel
</span>
</FormattedMessage>
</button>
</div>
</div>
</div>
</section>
</SettingItemMax>
</ManageAutoResponder>
`;
exports[`components/user_settings/notifications/ManageAutoResponder should match snapshot, enabled 1`] = `
<ManageAutoResponder
autoResponderActive={true}
autoResponderMessage="Hello World!"
error=""
saving={false}
setParentState={[MockFunction]}
submit={[MockFunction]}
updateSection={[MockFunction]}
>
<SettingItemMax
containerStyle=""
infoPosition="bottom"
inputs={
Array [
<div
className="checkbox"
id="autoResponderCheckbox"
>
<label>
<input
checked={true}
id="autoResponderActive"
onChange={[Function]}
type="checkbox"
/>
<Memo(MemoizedFormattedMessage)
defaultMessage="Enabled"
id="user.settings.notifications.autoResponderEnabled"
/>
</label>
</div>,
<div
id="autoResponderMessage"
>
<div
className="pt-2"
>
<textarea
className="form-control"
id="autoResponderMessageInput"
maxLength={200}
onChange={[Function]}
placeholder="Message"
rows={5}
style={
Object {
"resize": "none",
}
}
value="Hello World!"
/>
</div>
</div>,
<div
className="mt-5"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Set a custom message that will be automatically sent in response to Direct Messages. Mentions in Public and Private Channels will not trigger the automated reply. Enabling Automatic Replies sets your status to Out of Office and disables email and push notifications."
id="user.settings.notifications.autoResponderHint"
/>
</div>,
]
}
saving={false}
section=""
shiftEnter={true}
submit={[MockFunction]}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Automatic Direct Message Replies"
id="user.settings.notifications.autoResponder"
/>
}
updateSection={[MockFunction]}
width="medium"
>
<section
className="section-max form-horizontal "
>
<h4
className="col-sm-12 section-title"
id="settingTitle"
>
<FormattedMessage
defaultMessage="Automatic Direct Message Replies"
id="user.settings.notifications.autoResponder"
>
<span>
Automatic Direct Message Replies
</span>
</FormattedMessage>
</h4>
<div
className="col-sm-10 col-sm-offset-2"
>
<div
className="setting-list"
tabIndex={-1}
>
<div
className="setting-list-item"
>
<div
className="checkbox"
id="autoResponderCheckbox"
key="autoResponderCheckbox"
>
<label>
<input
checked={true}
id="autoResponderActive"
onChange={[Function]}
type="checkbox"
/>
<FormattedMessage
defaultMessage="Enabled"
id="user.settings.notifications.autoResponderEnabled"
>
<span>
Enabled
</span>
</FormattedMessage>
</label>
</div>
<div
id="autoResponderMessage"
key="autoResponderMessage"
>
<div
className="pt-2"
>
<textarea
className="form-control"
id="autoResponderMessageInput"
maxLength={200}
onChange={[Function]}
placeholder="Message"
rows={5}
style={
Object {
"resize": "none",
}
}
value="Hello World!"
/>
</div>
</div>
<div
className="mt-5"
key="autoResponderHint"
>
<FormattedMessage
defaultMessage="Set a custom message that will be automatically sent in response to Direct Messages. Mentions in Public and Private Channels will not trigger the automated reply. Enabling Automatic Replies sets your status to Out of Office and disables email and push notifications."
id="user.settings.notifications.autoResponderHint"
>
<span>
Set a custom message that will be automatically sent in response to Direct Messages. Mentions in Public and Private Channels will not trigger the automated reply. Enabling Automatic Replies sets your status to Out of Office and disables email and push notifications.
</span>
</FormattedMessage>
</div>
</div>
<div
className="setting-list-item"
>
<hr />
<SaveButton
btnClass=""
defaultMessage={
<Memo(MemoizedFormattedMessage)
defaultMessage="Save"
id="save_button.save"
/>
}
disabled={false}
extraClasses=""
onClick={[Function]}
saving={false}
savingMessage={
<Memo(MemoizedFormattedMessage)
defaultMessage="Saving"
id="save_button.saving"
/>
}
>
<button
className="btn btn-primary "
data-testid="saveSetting"
disabled={false}
id="saveSetting"
onClick={[Function]}
type="submit"
>
<Memo(LoadingWrapper)
loading={false}
text={
<Memo(MemoizedFormattedMessage)
defaultMessage="Saving"
id="save_button.saving"
/>
}
>
<span>
<FormattedMessage
defaultMessage="Save"
id="save_button.save"
>
<span>
Save
</span>
</FormattedMessage>
</span>
</Memo(LoadingWrapper)>
</button>
</SaveButton>
<button
className="btn btn-tertiary"
id="cancelSetting"
onClick={[Function]}
>
<FormattedMessage
defaultMessage="Cancel"
id="setting_item_max.cancel"
>
<span>
Cancel
</span>
</FormattedMessage>
</button>
</div>
</div>
</div>
</section>
</SettingItemMax>
</ManageAutoResponder>
`;
|
3,556 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/security/user_settings_security.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import type {OAuthApp} from '@mattermost/types/integrations';
import type {UserProfile} from '@mattermost/types/users';
import type {MockIntl} from 'tests/helpers/intl-test-helper';
import type * as Utils from 'utils/utils';
import {SecurityTab} from './user_settings_security';
jest.mock('utils/utils', () => {
const original = jest.requireActual('utils/utils');
return {...original, isValidPassword: () => ({valid: true})};
});
describe('components/user_settings/display/UserSettingsDisplay', () => {
const user = {
id: 'user_id',
};
const requiredProps = {
user: user as UserProfile,
closeModal: jest.fn(),
collapseModal: jest.fn(),
setRequireConfirm: jest.fn(),
updateSection: jest.fn(),
authorizedApps: jest.fn(),
actions: {
getMe: jest.fn(),
updateUserPassword: jest.fn(() => Promise.resolve({error: true})),
getAuthorizedOAuthApps: jest.fn().mockResolvedValue({data: []}),
deauthorizeOAuthApp: jest.fn().mockResolvedValue({data: true}),
},
canUseAccessTokens: true,
enableOAuthServiceProvider: false,
enableSignUpWithEmail: true,
enableSignUpWithGitLab: false,
enableSignUpWithGoogle: true,
enableSignUpWithOpenId: false,
enableLdap: false,
enableSaml: true,
enableSignUpWithOffice365: false,
experimentalEnableAuthenticationTransfer: true,
passwordConfig: {} as ReturnType<typeof Utils.getPasswordConfig>,
militaryTime: false,
intl: {
formatMessage: jest.fn(({id, defaultMessage}) => defaultMessage || id),
} as MockIntl,
};
test('should match snapshot, enable google', () => {
const props = {...requiredProps, enableSaml: false};
const wrapper = shallow<SecurityTab>(<SecurityTab {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, enable gitlab', () => {
const props = {...requiredProps, enableSignUpWithGoogle: false, enableSaml: false, enableSignUpWithGitLab: true};
const wrapper = shallow<SecurityTab>(<SecurityTab {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, enable office365', () => {
const props = {...requiredProps, enableSignUpWithGoogle: false, enableSaml: false, enableSignUpWithOffice365: true};
const wrapper = shallow<SecurityTab>(<SecurityTab {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, enable openID', () => {
const props = {...requiredProps, enableSignUpWithGoogle: false, enableSaml: false, enableSignUpWithOpenId: true};
const wrapper = shallow<SecurityTab>(<SecurityTab {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('componentDidMount() should have called getAuthorizedOAuthApps', () => {
const props = {...requiredProps, enableOAuthServiceProvider: true};
shallow<SecurityTab>(<SecurityTab {...props}/>);
expect(requiredProps.actions.getAuthorizedOAuthApps).toHaveBeenCalled();
});
test('componentDidMount() should have updated state.authorizedApps', async () => {
const apps = [{name: 'app1'}];
const promise = Promise.resolve({data: apps});
const getAuthorizedOAuthApps = () => promise;
const props = {
...requiredProps,
actions: {...requiredProps.actions, getAuthorizedOAuthApps},
enableOAuthServiceProvider: true,
};
const wrapper = shallow<SecurityTab>(<SecurityTab {...props}/>);
await promise;
expect(wrapper.state().authorizedApps).toEqual(apps);
});
test('componentDidMount() should have updated state.serverError', async () => {
const error = {message: 'error'};
const promise = Promise.resolve({error});
const getAuthorizedOAuthApps = () => promise;
const props = {
...requiredProps,
actions: {...requiredProps.actions, getAuthorizedOAuthApps},
enableOAuthServiceProvider: true,
};
const wrapper = shallow<SecurityTab>(<SecurityTab {...props}/>);
await promise;
expect(wrapper.state('serverError')).toEqual(error.message);
});
test('submitPassword() should not have called updateUserPassword', async () => {
const wrapper = shallow<SecurityTab>(<SecurityTab {...requiredProps}/>);
await wrapper.instance().submitPassword();
expect(requiredProps.actions.updateUserPassword).toHaveBeenCalledTimes(0);
});
test('submitPassword() should have called updateUserPassword', async () => {
const updateUserPassword = jest.fn(() => Promise.resolve({data: true}));
const props = {
...requiredProps,
actions: {...requiredProps.actions, updateUserPassword},
};
const wrapper = shallow<SecurityTab>(<SecurityTab {...props}/>);
const password = 'psw';
const state = {
currentPassword: 'currentPassword',
newPassword: password,
confirmPassword: password,
};
wrapper.setState(state);
await wrapper.instance().submitPassword();
expect(updateUserPassword).toHaveBeenCalled();
expect(updateUserPassword).toHaveBeenCalledWith(
user.id,
state.currentPassword,
state.newPassword,
);
expect(requiredProps.updateSection).toHaveBeenCalled();
expect(requiredProps.updateSection).toHaveBeenCalledWith('');
});
test('deauthorizeApp() should have called deauthorizeOAuthApp', () => {
const appId = 'appId';
const event: any = {
currentTarget: {getAttribute: jest.fn().mockReturnValue(appId)},
preventDefault: jest.fn(),
};
const wrapper = shallow<SecurityTab>(<SecurityTab {...requiredProps}/>);
wrapper.setState({authorizedApps: []});
wrapper.instance().deauthorizeApp(event);
expect(requiredProps.actions.deauthorizeOAuthApp).toHaveBeenCalled();
expect(requiredProps.actions.deauthorizeOAuthApp).toHaveBeenCalledWith(
appId,
);
});
test('deauthorizeApp() should have updated state.authorizedApps', async () => {
const promise = Promise.resolve({data: true});
const props = {
...requiredProps,
actions: {...requiredProps.actions, deauthorizeOAuthApp: () => promise},
};
const wrapper = shallow<SecurityTab>(<SecurityTab {...props}/>);
const appId = 'appId';
const apps = [{id: appId}, {id: '2'}] as OAuthApp[];
const event: any = {
currentTarget: {getAttribute: jest.fn().mockReturnValue(appId)},
preventDefault: jest.fn(),
};
wrapper.setState({authorizedApps: apps});
wrapper.instance().deauthorizeApp(event);
await promise;
expect(wrapper.state().authorizedApps).toEqual(apps.slice(1));
});
test('deauthorizeApp() should have updated state.serverError', async () => {
const error = {message: 'error'};
const promise = Promise.resolve({error});
const props = {
...requiredProps,
actions: {...requiredProps.actions, deauthorizeOAuthApp: () => promise},
};
const wrapper = shallow<SecurityTab>(<SecurityTab {...props}/>);
const event: any = {
currentTarget: {getAttribute: jest.fn().mockReturnValue('appId')},
preventDefault: jest.fn(),
};
wrapper.instance().deauthorizeApp(event);
await promise;
expect(wrapper.state('serverError')).toEqual(error.message);
});
});
|
3,558 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/security | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/security/__snapshots__/user_settings_security.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, enable gitlab 1`] = `
<div>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<i
className="fa fa-angle-left"
onClick={[MockFunction]}
title="Collapse Icon"
/>
</div>
<MemoizedFormattedMessage
defaultMessage="Security Settings"
id="user.settings.security.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
>
<MemoizedFormattedMessage
defaultMessage="Security Settings"
id="user.settings.security.title"
/>
</h3>
<div
className="divider-dark first"
/>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="password"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Password"
id="user.settings.security.password"
/>
}
updateSection={[Function]}
/>
<div
className="divider-light"
/>
<Connect(MfaSection)
active={false}
areAllSectionsInactive={false}
updateSection={[Function]}
/>
<div
className="divider-light"
/>
<div
className="divider-light"
/>
<Connect(UserAccessTokenSection)
active={false}
areAllSectionsInactive={false}
setRequireConfirm={[MockFunction]}
updateSection={[Function]}
user={
Object {
"id": "user_id",
}
}
/>
<div
className="divider-light"
/>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Email and Password"
id="user.settings.security.emailPwd"
/>
}
max={null}
section="signin"
title="Sign-in Method"
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
<br />
<ToggleModalButton
className="security-links color--link"
dialogType={
Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": Object {
"$$typeof": Symbol(react.memo),
"compare": null,
"type": [Function],
},
"compare": null,
"type": [Function],
}
}
id="viewAccessHistory"
modalId="access_history"
>
<i
className="fa fa-clock-o"
title="Access History Icon"
/>
<MemoizedFormattedMessage
defaultMessage="View Access History"
id="user.settings.security.viewHistory"
/>
</ToggleModalButton>
<ToggleModalButton
className="security-links color--link mt-2"
dialogType={
Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
"type": [Function],
}
}
id="viewAndLogOutOfActiveSessions"
modalId="activity_log"
>
<i
className="fa fa-clock-o"
title="Active Sessions Icon"
/>
<MemoizedFormattedMessage
defaultMessage="View and Log Out of Active Sessions"
id="user.settings.security.logoutActiveSessions"
/>
</ToggleModalButton>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, enable google 1`] = `
<div>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<i
className="fa fa-angle-left"
onClick={[MockFunction]}
title="Collapse Icon"
/>
</div>
<MemoizedFormattedMessage
defaultMessage="Security Settings"
id="user.settings.security.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
>
<MemoizedFormattedMessage
defaultMessage="Security Settings"
id="user.settings.security.title"
/>
</h3>
<div
className="divider-dark first"
/>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="password"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Password"
id="user.settings.security.password"
/>
}
updateSection={[Function]}
/>
<div
className="divider-light"
/>
<Connect(MfaSection)
active={false}
areAllSectionsInactive={false}
updateSection={[Function]}
/>
<div
className="divider-light"
/>
<div
className="divider-light"
/>
<Connect(UserAccessTokenSection)
active={false}
areAllSectionsInactive={false}
setRequireConfirm={[MockFunction]}
updateSection={[Function]}
user={
Object {
"id": "user_id",
}
}
/>
<div
className="divider-light"
/>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Email and Password"
id="user.settings.security.emailPwd"
/>
}
max={null}
section="signin"
title="Sign-in Method"
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
<br />
<ToggleModalButton
className="security-links color--link"
dialogType={
Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": Object {
"$$typeof": Symbol(react.memo),
"compare": null,
"type": [Function],
},
"compare": null,
"type": [Function],
}
}
id="viewAccessHistory"
modalId="access_history"
>
<i
className="fa fa-clock-o"
title="Access History Icon"
/>
<MemoizedFormattedMessage
defaultMessage="View Access History"
id="user.settings.security.viewHistory"
/>
</ToggleModalButton>
<ToggleModalButton
className="security-links color--link mt-2"
dialogType={
Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
"type": [Function],
}
}
id="viewAndLogOutOfActiveSessions"
modalId="activity_log"
>
<i
className="fa fa-clock-o"
title="Active Sessions Icon"
/>
<MemoizedFormattedMessage
defaultMessage="View and Log Out of Active Sessions"
id="user.settings.security.logoutActiveSessions"
/>
</ToggleModalButton>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, enable office365 1`] = `
<div>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<i
className="fa fa-angle-left"
onClick={[MockFunction]}
title="Collapse Icon"
/>
</div>
<MemoizedFormattedMessage
defaultMessage="Security Settings"
id="user.settings.security.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
>
<MemoizedFormattedMessage
defaultMessage="Security Settings"
id="user.settings.security.title"
/>
</h3>
<div
className="divider-dark first"
/>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="password"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Password"
id="user.settings.security.password"
/>
}
updateSection={[Function]}
/>
<div
className="divider-light"
/>
<Connect(MfaSection)
active={false}
areAllSectionsInactive={false}
updateSection={[Function]}
/>
<div
className="divider-light"
/>
<div
className="divider-light"
/>
<Connect(UserAccessTokenSection)
active={false}
areAllSectionsInactive={false}
setRequireConfirm={[MockFunction]}
updateSection={[Function]}
user={
Object {
"id": "user_id",
}
}
/>
<div
className="divider-light"
/>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Email and Password"
id="user.settings.security.emailPwd"
/>
}
max={null}
section="signin"
title="Sign-in Method"
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
<br />
<ToggleModalButton
className="security-links color--link"
dialogType={
Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": Object {
"$$typeof": Symbol(react.memo),
"compare": null,
"type": [Function],
},
"compare": null,
"type": [Function],
}
}
id="viewAccessHistory"
modalId="access_history"
>
<i
className="fa fa-clock-o"
title="Access History Icon"
/>
<MemoizedFormattedMessage
defaultMessage="View Access History"
id="user.settings.security.viewHistory"
/>
</ToggleModalButton>
<ToggleModalButton
className="security-links color--link mt-2"
dialogType={
Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
"type": [Function],
}
}
id="viewAndLogOutOfActiveSessions"
modalId="activity_log"
>
<i
className="fa fa-clock-o"
title="Active Sessions Icon"
/>
<MemoizedFormattedMessage
defaultMessage="View and Log Out of Active Sessions"
id="user.settings.security.logoutActiveSessions"
/>
</ToggleModalButton>
</div>
</div>
`;
exports[`components/user_settings/display/UserSettingsDisplay should match snapshot, enable openID 1`] = `
<div>
<div
className="modal-header"
>
<button
aria-label="Close"
className="close"
data-dismiss="modal"
onClick={[MockFunction]}
type="button"
>
<span
aria-hidden="true"
>
×
</span>
</button>
<h4
className="modal-title"
>
<div
className="modal-back"
>
<i
className="fa fa-angle-left"
onClick={[MockFunction]}
title="Collapse Icon"
/>
</div>
<MemoizedFormattedMessage
defaultMessage="Security Settings"
id="user.settings.security.title"
/>
</h4>
</div>
<div
className="user-settings"
>
<h3
className="tab-header"
>
<MemoizedFormattedMessage
defaultMessage="Security Settings"
id="user.settings.security.title"
/>
</h3>
<div
className="divider-dark first"
/>
<SettingItem
active={false}
areAllSectionsInactive={false}
max={null}
section="password"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Password"
id="user.settings.security.password"
/>
}
updateSection={[Function]}
/>
<div
className="divider-light"
/>
<Connect(MfaSection)
active={false}
areAllSectionsInactive={false}
updateSection={[Function]}
/>
<div
className="divider-light"
/>
<div
className="divider-light"
/>
<Connect(UserAccessTokenSection)
active={false}
areAllSectionsInactive={false}
setRequireConfirm={[MockFunction]}
updateSection={[Function]}
user={
Object {
"id": "user_id",
}
}
/>
<div
className="divider-light"
/>
<SettingItem
active={false}
areAllSectionsInactive={false}
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Email and Password"
id="user.settings.security.emailPwd"
/>
}
max={null}
section="signin"
title="Sign-in Method"
updateSection={[Function]}
/>
<div
className="divider-dark"
/>
<br />
<ToggleModalButton
className="security-links color--link"
dialogType={
Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": Object {
"$$typeof": Symbol(react.memo),
"compare": null,
"type": [Function],
},
"compare": null,
"type": [Function],
}
}
id="viewAccessHistory"
modalId="access_history"
>
<i
className="fa fa-clock-o"
title="Access History Icon"
/>
<MemoizedFormattedMessage
defaultMessage="View Access History"
id="user.settings.security.viewHistory"
/>
</ToggleModalButton>
<ToggleModalButton
className="security-links color--link mt-2"
dialogType={
Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
"type": [Function],
}
}
id="viewAndLogOutOfActiveSessions"
modalId="activity_log"
>
<i
className="fa fa-clock-o"
title="Active Sessions Icon"
/>
<MemoizedFormattedMessage
defaultMessage="View and Log Out of Active Sessions"
id="user.settings.security.logoutActiveSessions"
/>
</ToggleModalButton>
</div>
</div>
`;
|
3,560 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/security | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/security/mfa_section/mfa_section.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
jest.mock('utils/browser_history');
import {shallow} from 'enzyme';
import React from 'react';
import MfaSection from 'components/user_settings/security/mfa_section/mfa_section';
import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {getHistory} from 'utils/browser_history';
describe('MfaSection', () => {
const baseProps = {
active: true,
areAllSectionsInactive: false,
mfaActive: false,
mfaAvailable: true,
mfaEnforced: false,
updateSection: jest.fn(),
actions: {
deactivateMfa: jest.fn(() => Promise.resolve({})),
},
};
describe('rendering', () => {
test('should render nothing when MFA is not available', () => {
const props = {
...baseProps,
mfaAvailable: false,
};
const wrapper = shallow(<MfaSection {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('when section is collapsed and MFA is not active', () => {
const props = {
...baseProps,
active: false,
mfaActive: false,
};
const wrapper = shallow(<MfaSection {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('when section is collapsed and MFA is active', () => {
const props = {
...baseProps,
active: false,
mfaActive: true,
};
const wrapper = shallow(<MfaSection {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('when section is expanded and MFA is not active', () => {
const props = {
...baseProps,
mfaActive: false,
};
const wrapper = shallow(<MfaSection {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('when section is expanded and MFA is active but not enforced', () => {
const props = {
...baseProps,
mfaActive: true,
};
const wrapper = shallow(<MfaSection {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('when section is expanded and MFA is active and enforced', () => {
const props = {
...baseProps,
mfaActive: true,
mfaEnforced: true,
};
const wrapper = shallow(<MfaSection {...props}/>);
expect(wrapper).toMatchSnapshot();
});
test('when section is expanded with a server error', () => {
const props = {
...baseProps,
serverError: 'An error occurred',
};
const wrapper = shallow(<MfaSection {...props}/>);
wrapper.setState({serverError: 'An error has occurred'});
expect(wrapper).toMatchSnapshot();
});
});
describe('setupMfa', () => {
it('should send to setup page', () => {
const wrapper = mountWithIntl(<MfaSection {...baseProps}/>);
const mockEvent = {
preventDefault: jest.fn(),
} as unknown as React.MouseEvent<HTMLElement>;
(wrapper.instance() as MfaSection).setupMfa(mockEvent);
expect(getHistory().push).toHaveBeenCalledWith('/mfa/setup');
});
});
describe('removeMfa', () => {
it('on success, should close section and clear state', async () => {
const wrapper = mountWithIntl(<MfaSection {...baseProps}/>);
const mockEvent = {
preventDefault: jest.fn(),
} as unknown as React.MouseEvent<HTMLElement>;
wrapper.setState({serverError: 'An error has occurred'});
await (wrapper.instance() as MfaSection).removeMfa(mockEvent);
expect(baseProps.updateSection).toHaveBeenCalledWith('');
expect(wrapper.state('serverError')).toEqual(null);
expect(getHistory().push).not.toHaveBeenCalled();
});
it('on success, should send to setup page if MFA enforcement is enabled', async () => {
const props = {
...baseProps,
mfaEnforced: true,
};
const wrapper = mountWithIntl(<MfaSection {...props}/>);
const mockEvent = {
preventDefault: jest.fn(),
} as unknown as React.MouseEvent<HTMLElement>;
await (wrapper.instance() as MfaSection).removeMfa(mockEvent);
expect(baseProps.updateSection).not.toHaveBeenCalled();
expect(getHistory().push).toHaveBeenCalledWith('/mfa/setup');
});
it('on error, should show error', async () => {
const error = {message: 'An error occurred'};
const wrapper = mountWithIntl(<MfaSection {...baseProps}/>);
const mockEvent = {
preventDefault: jest.fn(),
} as unknown as React.MouseEvent<HTMLElement>;
baseProps.actions.deactivateMfa.mockImplementation(() => Promise.resolve({error}));
await (wrapper.instance() as MfaSection).removeMfa(mockEvent);
expect(baseProps.updateSection).not.toHaveBeenCalled();
expect(wrapper.state('serverError')).toEqual(error.message);
});
});
});
|
3,562 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/security/mfa_section | petrpan-code/mattermost/mattermost/webapp/channels/src/components/user_settings/security/mfa_section/__snapshots__/mfa_section.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`MfaSection rendering should render nothing when MFA is not available 1`] = `""`;
exports[`MfaSection rendering when section is collapsed and MFA is active 1`] = `
<SettingItemMin
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Active"
id="user.settings.security.active"
/>
}
section="mfa"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Multi-factor Authentication"
id="user.settings.mfa.title"
/>
}
updateSection={[MockFunction]}
/>
`;
exports[`MfaSection rendering when section is collapsed and MFA is not active 1`] = `
<SettingItemMin
describe={
<Memo(MemoizedFormattedMessage)
defaultMessage="Inactive"
id="user.settings.security.inactive"
/>
}
section="mfa"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Multi-factor Authentication"
id="user.settings.mfa.title"
/>
}
updateSection={[MockFunction]}
/>
`;
exports[`MfaSection rendering when section is expanded and MFA is active and enforced 1`] = `
<SettingItemMax
containerStyle=""
extraInfo={
<Memo(MemoizedFormattedMessage)
defaultMessage="Multi-factor authentication is required on this server. Resetting is only recommended when you need to switch code generation to a new mobile device. You will be required to set it up again immediately."
id="user.settings.mfa.requiredHelp"
/>
}
infoPosition="bottom"
inputs={
<div
className="pt-2"
>
<a
className="btn btn-primary"
href="#"
onClick={[Function]}
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Reset MFA on Account"
id="user.settings.mfa.reset"
/>
</a>
<br />
</div>
}
saving={false}
section=""
serverError={null}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Multi-factor Authentication"
id="user.settings.mfa.title"
/>
}
updateSection={[MockFunction]}
width="medium"
/>
`;
exports[`MfaSection rendering when section is expanded and MFA is active but not enforced 1`] = `
<SettingItemMax
containerStyle=""
extraInfo={
<Memo(MemoizedFormattedMessage)
defaultMessage="Removing multi-factor authentication means you will no longer require a phone-based passcode to sign-in to your account."
id="user.settings.mfa.removeHelp"
/>
}
infoPosition="bottom"
inputs={
<div
className="pt-2"
>
<a
className="btn btn-primary"
href="#"
onClick={[Function]}
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Remove MFA from Account"
id="user.settings.mfa.remove"
/>
</a>
<br />
</div>
}
saving={false}
section=""
serverError={null}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Multi-factor Authentication"
id="user.settings.mfa.title"
/>
}
updateSection={[MockFunction]}
width="medium"
/>
`;
exports[`MfaSection rendering when section is expanded and MFA is not active 1`] = `
<SettingItemMax
containerStyle=""
extraInfo={
<Memo(MemoizedFormattedMessage)
defaultMessage="Adding multi-factor authentication will make your account more secure by requiring a code from your mobile phone each time you sign in."
id="user.settings.mfa.addHelp"
/>
}
infoPosition="bottom"
inputs={
<div
className="pt-2"
>
<a
className="btn btn-primary"
href="#"
onClick={[Function]}
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Add MFA to Account"
id="user.settings.mfa.add"
/>
</a>
<br />
</div>
}
saving={false}
section=""
serverError={null}
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Multi-factor Authentication"
id="user.settings.mfa.title"
/>
}
updateSection={[MockFunction]}
width="medium"
/>
`;
exports[`MfaSection rendering when section is expanded with a server error 1`] = `
<SettingItemMax
containerStyle=""
extraInfo={
<Memo(MemoizedFormattedMessage)
defaultMessage="Adding multi-factor authentication will make your account more secure by requiring a code from your mobile phone each time you sign in."
id="user.settings.mfa.addHelp"
/>
}
infoPosition="bottom"
inputs={
<div
className="pt-2"
>
<a
className="btn btn-primary"
href="#"
onClick={[Function]}
>
<Memo(MemoizedFormattedMessage)
defaultMessage="Add MFA to Account"
id="user.settings.mfa.add"
/>
</a>
<br />
</div>
}
saving={false}
section=""
serverError="An error has occurred"
title={
<Memo(MemoizedFormattedMessage)
defaultMessage="Multi-factor Authentication"
id="user.settings.mfa.title"
/>
}
updateSection={[MockFunction]}
width="medium"
/>
`;
|
3,573 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components | petrpan-code/mattermost/mattermost/webapp/channels/src/components/view_user_group_modal/view_user_group_modal.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import type {UserProfile} from '@mattermost/types/users';
import ViewUserGroupModal from './view_user_group_modal';
describe('component/view_user_group_modal', () => {
const users = [
{
id: 'user-1',
username: 'user1',
first_name: 'user',
last_name: 'one',
delete_at: 0,
} as UserProfile,
{
id: 'user-2',
username: 'user2',
first_name: 'user',
last_name: 'otwo',
delete_at: 0,
} as UserProfile,
];
const baseProps = {
onExited: jest.fn(),
searchTerm: '',
groupId: 'groupid123',
group: {
id: 'groupid123',
name: 'group',
display_name: 'Group Name',
description: 'Group description',
source: 'custom',
remote_id: null,
create_at: 1637349374137,
update_at: 1637349374137,
delete_at: 0,
has_syncables: false,
member_count: 6,
allow_reference: true,
scheme_admin: false,
},
users,
backButtonCallback: jest.fn(),
backButtonAction: jest.fn(),
currentUserId: 'user-1',
permissionToEditGroup: true,
permissionToJoinGroup: true,
permissionToLeaveGroup: true,
permissionToArchiveGroup: true,
isGroupMember: false,
actions: {
getGroup: jest.fn().mockImplementation(() => Promise.resolve()),
getUsersInGroup: jest.fn().mockImplementation(() => Promise.resolve()),
setModalSearchTerm: jest.fn(),
openModal: jest.fn(),
searchProfiles: jest.fn().mockImplementation(() => Promise.resolve()),
removeUsersFromGroup: jest.fn().mockImplementation(() => Promise.resolve()),
addUsersToGroup: jest.fn().mockImplementation(() => Promise.resolve()),
archiveGroup: jest.fn().mockImplementation(() => Promise.resolve()),
},
};
test('should match snapshot', () => {
const wrapper = shallow(
<ViewUserGroupModal
{...baseProps}
/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match snapshot, search user1', () => {
const wrapper = shallow(
<ViewUserGroupModal
{...baseProps}
searchTerm='user1'
/>,
);
const instance = wrapper.instance() as ViewUserGroupModal;
const e = {
target: {
value: '',
},
};
instance.handleSearch(e as React.ChangeEvent<HTMLInputElement>);
expect(baseProps.actions.setModalSearchTerm).toHaveBeenCalledTimes(1);
expect(baseProps.actions.setModalSearchTerm).toBeCalledWith('');
e.target.value = 'user1';
instance.handleSearch(e as React.ChangeEvent<HTMLInputElement>);
expect(wrapper.state('loading')).toEqual(true);
expect(baseProps.actions.setModalSearchTerm).toHaveBeenCalledTimes(2);
expect(baseProps.actions.setModalSearchTerm).toBeCalledWith(e.target.value);
});
});
|
3,575 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/view_user_group_modal | petrpan-code/mattermost/mattermost/webapp/channels/src/components/view_user_group_modal/__snapshots__/view_user_group_modal.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`component/view_user_group_modal should match snapshot 1`] = `
<Modal
animation={true}
aria-labelledby="viewUserGroupModalLabel"
autoFocus={true}
backdrop={true}
bsClass="modal"
dialogClassName="a11y__modal view-user-groups-modal"
dialogComponentClass={[Function]}
enforceFocus={true}
keyboard={true}
manager={
ModalManager {
"add": [Function],
"containers": Array [],
"data": Array [],
"handleContainerOverflow": true,
"hideSiblingNodes": true,
"isTopModal": [Function],
"modals": Array [],
"remove": [Function],
}
}
onExited={[MockFunction]}
onHide={[Function]}
renderBackdrop={[Function]}
restoreFocus={true}
role="dialog"
show={true}
>
<Connect(Component)
backButtonAction={[MockFunction]}
backButtonCallback={[MockFunction]}
decrementMemberCount={[Function]}
groupId="groupid123"
incrementMemberCount={[Function]}
onExited={[MockFunction]}
/>
<ModalBody
bsClass="modal-body"
componentClass="div"
>
<div
className="group-mention-name"
>
<span
className="group-name"
>
@group
</span>
</div>
<div
className="user-groups-search"
>
<ForwardRef
className="user-group-search-input"
data-testid="searchInput"
inputPrefix={
<i
className="icon icon-magnify"
/>
}
onChange={[Function]}
placeholder="Search group members"
type="text"
value=""
/>
</div>
<div
className="user-groups-modal__content group-member-list"
onScroll={[Function]}
>
<h2
className="group-member-count"
>
<MemoizedFormattedMessage
defaultMessage="{member_count} {member_count, plural, one {Member} other {Members}}"
id="view_user_group_modal.memberCount"
values={
Object {
"member_count": 6,
}
}
/>
</h2>
<Connect(Component)
decrementMemberCount={[Function]}
groupId="groupid123"
key="user-1"
user={
Object {
"delete_at": 0,
"first_name": "user",
"id": "user-1",
"last_name": "one",
"username": "user1",
}
}
/>
<Connect(Component)
decrementMemberCount={[Function]}
groupId="groupid123"
key="user-2"
user={
Object {
"delete_at": 0,
"first_name": "user",
"id": "user-2",
"last_name": "otwo",
"username": "user2",
}
}
/>
<LoadingScreen />
</div>
</ModalBody>
</Modal>
`;
|
3,583 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components | petrpan-code/mattermost/mattermost/webapp/channels/src/components/warn_metric_ack_modal/warn_metric_ack_modal.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import {Modal} from 'react-bootstrap';
import type {UserProfile} from '@mattermost/types/users';
import WarnMetricAckModal from 'components/warn_metric_ack_modal/warn_metric_ack_modal';
describe('components/WarnMetricAckModal', () => {
const serverError = 'some error';
const baseProps = {
stats: {
registered_users: 200,
},
user: {
id: 'someUserId',
first_name: 'Fake',
last_name: 'Person',
email: '[email protected]',
} as UserProfile,
show: false,
telemetryId: 'diag_0',
closeParentComponent: jest.fn(),
warnMetricStatus: {
id: 'metric1',
limit: 500,
acked: false,
store_status: 'status1',
},
actions: {
closeModal: jest.fn(),
getFilteredUsersStats: jest.fn(),
sendWarnMetricAck: jest.fn().mockResolvedValue({}),
},
};
test('should match snapshot, init', () => {
const wrapper = shallow<WarnMetricAckModal>(
<WarnMetricAckModal {...baseProps}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('error display', () => {
const wrapper = shallow<WarnMetricAckModal>(
<WarnMetricAckModal {...baseProps}/>,
);
wrapper.setState({serverError});
expect(wrapper).toMatchSnapshot();
});
test('should match state when onHide is called', () => {
const wrapper = shallow<WarnMetricAckModal>(
<WarnMetricAckModal {...baseProps}/>,
);
wrapper.setState({saving: true});
wrapper.instance().onHide();
expect(wrapper.state('saving')).toEqual(false);
});
test('should match state when onHideWithParent is called', () => {
const wrapper = shallow<WarnMetricAckModal>(
<WarnMetricAckModal {...baseProps}/>,
);
wrapper.setState({saving: true});
wrapper.instance().onHide();
expect(baseProps.closeParentComponent).toHaveBeenCalledTimes(1);
expect(wrapper.state('saving')).toEqual(false);
});
test('send ack on acknowledge button click', () => {
const props = {...baseProps};
const wrapper = shallow<WarnMetricAckModal>(
<WarnMetricAckModal {...props}/>,
);
wrapper.setState({saving: false});
wrapper.find('.save-button').simulate('click');
expect(props.actions.sendWarnMetricAck).toHaveBeenCalledTimes(1);
});
test('should have called props.onHide when Modal.onExited is called', () => {
const props = {...baseProps};
const wrapper = shallow(
<WarnMetricAckModal {...props}/>,
);
wrapper.find(Modal).props().onExited!(document.createElement('div'));
expect(baseProps.actions.closeModal).toHaveBeenCalledTimes(1);
});
});
|
3,585 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/warn_metric_ack_modal | petrpan-code/mattermost/mattermost/webapp/channels/src/components/warn_metric_ack_modal/__snapshots__/warn_metric_ack_modal.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/WarnMetricAckModal error display 1`] = `
<Modal
animation={true}
aria-labelledby="warnMetricAckHeaderModalLabel"
autoFocus={true}
backdrop={true}
bsClass="modal"
dialogClassName="a11y__modal"
dialogComponentClass={[Function]}
enforceFocus={true}
keyboard={false}
manager={
ModalManager {
"add": [Function],
"containers": Array [],
"data": Array [],
"handleContainerOverflow": true,
"hideSiblingNodes": true,
"isTopModal": [Function],
"modals": Array [],
"remove": [Function],
}
}
onExited={[Function]}
onHide={[Function]}
renderBackdrop={[Function]}
restoreFocus={true}
role="dialog"
show={false}
>
<ModalHeader
bsClass="modal-header"
closeButton={true}
closeLabel="Close"
>
<ModalTitle
bsClass="modal-title"
componentClass="h1"
id="warnMetricAckHeaderModalLabel"
/>
</ModalHeader>
<ModalBody
bsClass="modal-body"
componentClass="div"
>
<div>
<br />
<div
className="form-group has-error"
>
<br />
<label
className="control-label"
>
<MemoizedFormattedMessage
defaultMessage="Support could not be reached. Please {link}."
id="warn_metric_ack_modal.mailto.message"
values={
Object {
"link": <WarnMetricAckErrorLink
defaultMessage="email us"
forceAck={true}
messageId="warn_metric_ack_modal.mailto.link"
onClickHandler={[Function]}
url="mailto:[email protected][email protected]&subject=Mattermost%20Contact%20Us%20request&body=Mattermost%20Contact%20Us%20request.%0D%0AContact%20Fake%20Person%0D%0AEmail%20a%40test.com%0D%0ASite%20URL%20http%3A%2F%2Flocalhost%3A8065%0D%0ATelemetry%20Id%20diag_0%0D%0AIf%20you%20have%20any%20additional%20inquiries%2C%20please%20contact%20support%40mattermost.com"
/>,
}
}
/>
</label>
</div>
<br />
<div
className="help__format-text"
style={
Object {
"display": "flex",
"flexWrap": "wrap",
"opacity": "0.56",
}
}
>
<MemoizedFormattedMessage
defaultMessage="By clicking Acknowledge, you will be sharing your information with Mattermost Inc. {link}"
id="warn_metric_ack_modal.subtext"
values={
Object {
"link": <ErrorLink
defaultMessage="Learn more"
messageId="warn_metric_ack_modal.learn_more.link"
url="https://mattermost.com/pl/default-admin-advisory"
/>,
}
}
/>
</div>
</div>
</ModalBody>
<ModalFooter
bsClass="modal-footer"
componentClass="div"
>
<button
autoFocus={true}
className="btn btn-primary save-button"
data-dismiss="modal"
disabled={false}
onClick={[Function]}
>
<Memo(LoadingWrapper)
loading={false}
text="Sending email"
>
<MemoizedFormattedMessage
defaultMessage="Acknowledge"
id="warn_metric_ack_modal.contact_support"
/>
</Memo(LoadingWrapper)>
</button>
</ModalFooter>
</Modal>
`;
exports[`components/WarnMetricAckModal should match snapshot, init 1`] = `
<Modal
animation={true}
aria-labelledby="warnMetricAckHeaderModalLabel"
autoFocus={true}
backdrop={true}
bsClass="modal"
dialogClassName="a11y__modal"
dialogComponentClass={[Function]}
enforceFocus={true}
keyboard={false}
manager={
ModalManager {
"add": [Function],
"containers": Array [],
"data": Array [],
"handleContainerOverflow": true,
"hideSiblingNodes": true,
"isTopModal": [Function],
"modals": Array [],
"remove": [Function],
}
}
onExited={[Function]}
onHide={[Function]}
renderBackdrop={[Function]}
restoreFocus={true}
role="dialog"
show={false}
>
<ModalHeader
bsClass="modal-header"
closeButton={true}
closeLabel="Close"
>
<ModalTitle
bsClass="modal-title"
componentClass="h1"
id="warnMetricAckHeaderModalLabel"
/>
</ModalHeader>
<ModalBody
bsClass="modal-body"
componentClass="div"
>
<div>
<br />
<br />
<div
className="help__format-text"
style={
Object {
"display": "flex",
"flexWrap": "wrap",
"opacity": "0.56",
}
}
>
<MemoizedFormattedMessage
defaultMessage="By clicking Acknowledge, you will be sharing your information with Mattermost Inc. {link}"
id="warn_metric_ack_modal.subtext"
values={
Object {
"link": <ErrorLink
defaultMessage="Learn more"
messageId="warn_metric_ack_modal.learn_more.link"
url="https://mattermost.com/pl/default-admin-advisory"
/>,
}
}
/>
</div>
</div>
</ModalBody>
<ModalFooter
bsClass="modal-footer"
componentClass="div"
>
<button
autoFocus={true}
className="btn btn-primary save-button"
data-dismiss="modal"
disabled={false}
onClick={[Function]}
>
<Memo(LoadingWrapper)
loading={false}
text="Sending email"
>
<MemoizedFormattedMessage
defaultMessage="Acknowledge"
id="warn_metric_ack_modal.contact_support"
/>
</Memo(LoadingWrapper)>
</button>
</ModalFooter>
</Modal>
`;
|
3,588 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/admin_console/admin_panel.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import AdminPanel from './admin_panel';
describe('components/widgets/admin_console/AdminPanel', () => {
const defaultProps = {
className: 'test-class-name',
id: 'test-id',
titleId: 'test-title-id',
titleDefault: 'test-title-default',
subtitleId: 'test-subtitle-id',
subtitleDefault: 'test-subtitle-default',
subtitleValues: {foo: 'bar'},
};
test('should match snapshot', () => {
const wrapper = shallow(
<AdminPanel {...defaultProps}>{'Test'}</AdminPanel>,
);
expect(wrapper).toMatchInlineSnapshot(`
<div
className="AdminPanel clearfix test-class-name"
id="test-id"
>
<div
className="header"
>
<div>
<h3>
<MemoizedFormattedMessage
defaultMessage="test-title-default"
id="test-title-id"
/>
</h3>
<div
className="mt-2"
>
<MemoizedFormattedMessage
defaultMessage="test-subtitle-default"
id="test-subtitle-id"
values={
Object {
"foo": "bar",
}
}
/>
</div>
</div>
</div>
Test
</div>
`);
});
test('should match snapshot with button', () => {
const wrapper = shallow(
<AdminPanel
{...defaultProps}
button={<span>{'TestButton'}</span>}
>
{'Test'}
</AdminPanel>,
);
expect(wrapper).toMatchInlineSnapshot(`
<div
className="AdminPanel clearfix test-class-name"
id="test-id"
>
<div
className="header"
>
<div>
<h3>
<MemoizedFormattedMessage
defaultMessage="test-title-default"
id="test-title-id"
/>
</h3>
<div
className="mt-2"
>
<MemoizedFormattedMessage
defaultMessage="test-subtitle-default"
id="test-subtitle-id"
values={
Object {
"foo": "bar",
}
}
/>
</div>
</div>
<div
className="button"
>
<span>
TestButton
</span>
</div>
</div>
Test
</div>
`);
});
test('should match snapshot with onHeaderClick', () => {
const wrapper = shallow(
<AdminPanel
{...defaultProps}
onHeaderClick={jest.fn()}
>
{'Test'}
</AdminPanel>,
);
expect(wrapper).toMatchInlineSnapshot(`
<div
className="AdminPanel clearfix test-class-name"
id="test-id"
>
<div
className="header"
onClick={[MockFunction]}
>
<div>
<h3>
<MemoizedFormattedMessage
defaultMessage="test-title-default"
id="test-title-id"
/>
</h3>
<div
className="mt-2"
>
<MemoizedFormattedMessage
defaultMessage="test-subtitle-default"
id="test-subtitle-id"
values={
Object {
"foo": "bar",
}
}
/>
</div>
</div>
</div>
Test
</div>
`);
});
});
|
3,590 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/admin_console/admin_panel_togglable.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import AdminPanelTogglable from './admin_panel_togglable';
describe('components/widgets/admin_console/AdminPanelTogglable', () => {
const defaultProps = {
className: 'test-class-name',
id: 'test-id',
titleId: 'test-title-id',
titleDefault: 'test-title-default',
subtitleId: 'test-subtitle-id',
subtitleDefault: 'test-subtitle-default',
open: true,
onToggle: jest.fn(),
};
test('should match snapshot', () => {
const wrapper = shallow(<AdminPanelTogglable {...defaultProps}>{'Test'}</AdminPanelTogglable>);
expect(wrapper).toMatchInlineSnapshot(`
<AdminPanel
button={<AccordionToggleIcon />}
className="AdminPanelTogglable test-class-name"
id="test-id"
onHeaderClick={[MockFunction]}
subtitleDefault="test-subtitle-default"
subtitleId="test-subtitle-id"
titleDefault="test-title-default"
titleId="test-title-id"
>
Test
</AdminPanel>
`,
);
});
test('should match snapshot closed', () => {
const wrapper = shallow(
<AdminPanelTogglable
{...defaultProps}
open={false}
>
{'Test'}
</AdminPanelTogglable>);
expect(wrapper).toMatchInlineSnapshot(`
<AdminPanel
button={<AccordionToggleIcon />}
className="AdminPanelTogglable test-class-name closed"
id="test-id"
onHeaderClick={[MockFunction]}
subtitleDefault="test-subtitle-default"
subtitleId="test-subtitle-id"
titleDefault="test-title-default"
titleId="test-title-id"
>
Test
</AdminPanel>
`,
);
});
});
|
3,592 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/admin_console/admin_panel_with_button.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import AdminPanelWithButton from './admin_panel_with_button';
describe('components/widgets/admin_console/AdminPanelWithButton', () => {
const defaultProps = {
className: 'test-class-name',
id: 'test-id',
titleId: 'test-title-id',
titleDefault: 'test-title-default',
subtitleId: 'test-subtitle-id',
subtitleDefault: 'test-subtitle-default',
onButtonClick: jest.fn(),
buttonTextId: 'test-button-text-id',
buttonTextDefault: 'test-button-text-default',
disabled: false,
};
test('should match snapshot', () => {
const wrapper = shallow(
<AdminPanelWithButton {...defaultProps}>
{'Test'}
</AdminPanelWithButton>,
);
expect(wrapper).toMatchInlineSnapshot(`
<AdminPanel
button={
<a
className="btn btn-primary"
data-testid="test-button-text-default"
onClick={[MockFunction]}
>
<Memo(MemoizedFormattedMessage)
defaultMessage="test-button-text-default"
id="test-button-text-id"
/>
</a>
}
className="AdminPanelWithButton test-class-name"
id="test-id"
subtitleDefault="test-subtitle-default"
subtitleId="test-subtitle-id"
titleDefault="test-title-default"
titleId="test-title-id"
>
Test
</AdminPanel>
`);
});
test('should match snapshot when disabled', () => {
const wrapper = shallow(
<AdminPanelWithButton
{...defaultProps}
disabled={true}
>
{'Test'}
</AdminPanelWithButton>,
);
expect(wrapper).toMatchInlineSnapshot(`
<AdminPanel
button={
<a
className="btn btn-primary disabled"
data-testid="test-button-text-default"
onClick={[Function]}
>
<Memo(MemoizedFormattedMessage)
defaultMessage="test-button-text-default"
id="test-button-text-id"
/>
</a>
}
className="AdminPanelWithButton test-class-name"
id="test-id"
subtitleDefault="test-subtitle-default"
subtitleId="test-subtitle-id"
titleDefault="test-title-default"
titleId="test-title-id"
>
Test
</AdminPanel>
`);
});
});
|
3,594 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/admin_console/admin_panel_with_link.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import AdminPanelWithLink from './admin_panel_with_link';
describe('components/widgets/admin_console/AdminPanelWithLink', () => {
const defaultProps = {
className: 'test-class-name',
id: 'test-id',
titleId: 'test-title-id',
titleDefault: 'test-title-default',
subtitleId: 'test-subtitle-id',
subtitleDefault: 'test-subtitle-default',
url: '/path',
linkTextId: 'test-button-text-id',
linkTextDefault: 'test-button-text-default',
disabled: false,
};
test('should match snapshot', () => {
const wrapper = shallow(
<AdminPanelWithLink {...defaultProps}>{'Test'}</AdminPanelWithLink>,
);
expect(wrapper).toMatchInlineSnapshot(`
<AdminPanel
button={
<Link
className="btn btn-primary"
data-testid="test-id-link"
onClick={[Function]}
to="/path"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="test-button-text-default"
id="test-button-text-id"
/>
</Link>
}
className="AdminPanelWithLink test-class-name"
data-testid="test-id"
id="test-id"
subtitleDefault="test-subtitle-default"
subtitleId="test-subtitle-id"
titleDefault="test-title-default"
titleId="test-title-id"
>
Test
</AdminPanel>
`);
});
test('should match snapshot when disabled', () => {
const wrapper = shallow(
<AdminPanelWithLink
{...defaultProps}
disabled={true}
>
{'Test'}
</AdminPanelWithLink>,
);
expect(wrapper).toMatchInlineSnapshot(`
<AdminPanel
button={
<Link
className="btn btn-primary disabled"
data-testid="test-id-link"
onClick={[Function]}
to="/path"
>
<Memo(MemoizedFormattedMessage)
defaultMessage="test-button-text-default"
id="test-button-text-id"
/>
</Link>
}
className="AdminPanelWithLink test-class-name"
data-testid="test-id"
id="test-id"
subtitleDefault="test-subtitle-default"
subtitleId="test-subtitle-id"
titleDefault="test-title-default"
titleId="test-title-id"
>
Test
</AdminPanel>
`);
});
});
|
3,599 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/header/header.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import type {ComponentProps} from 'react';
import Header from './header';
describe('components/widgets/header', () => {
const levels: Array<ComponentProps<typeof Header>['level']> = [1, 2, 3, 4, 5, 6];
test('should match basic snapshot', () => {
const wrapper = shallow(
<Header
level={1}
heading={'Title'}
subtitle='Subheading'
right={(
<div>{'addons'}</div>
)}
/>,
);
expect(wrapper).toMatchSnapshot();
});
test.each(levels)(
'should render heading level %p',
(level) => {
const wrapper = shallow(
<Header
level={level}
heading={'Title'}
/>,
);
if (level === 0) {
expect(wrapper.find(`h${level}`).exists()).toBe(false);
expect(wrapper.find('div.left').containsMatchingElement(<>{'Title'}</>)).toBe(true);
} else {
expect(wrapper.find(`h${level}`).text()).toBe('Title');
}
},
);
test('should support subheadings', () => {
const wrapper = shallow(
<Header
heading={<h2 className='custom-heading'>{'Test title'}</h2>}
subtitle='Subheading'
/>,
);
expect(wrapper.find('div.left').containsMatchingElement(<p>{'Subheading'}</p>)).toBe(true);
});
test('should support custom heading', () => {
const wrapper = shallow(
<Header
heading={<h2 className='custom-heading'>{'Test title'}</h2>}
/>,
);
expect(wrapper.find('h2.custom-heading').text()).toBe('Test title');
});
});
|
3,602 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/header | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/header/__snapshots__/header.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/header should match basic snapshot 1`] = `
<header
className="Header"
>
<div
className="left"
>
<h1>
Title
</h1>
<p>
Subheading
</p>
</div>
<div
className="spacer"
/>
<div>
addons
</div>
</header>
`;
|
3,673 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/inputs/channels_input.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import type {Channel} from '@mattermost/types/channels';
import ChannelsInput from './channels_input';
describe('components/widgets/inputs/ChannelsInput', () => {
test('should match snapshot', () => {
const wrapper = shallow(
<ChannelsInput
placeholder='test'
ariaLabel='test'
onChange={jest.fn()}
channelsLoader={jest.fn()}
onInputChange={jest.fn()}
inputValue=''
value={[
{
id: 'test-channel-1',
type: 'O',
display_name: 'test channel 1',
} as Channel,
{
id: 'test-channel-2',
type: 'P',
display_name: 'test channel 2',
} as Channel,
]}
/>,
);
expect(wrapper).toMatchInlineSnapshot(`
<Async
aria-label="test"
cacheOptions={false}
className="ChannelsInput empty"
classNamePrefix="channels-input"
components={
Object {
"IndicatorsContainer": [Function],
"MultiValueRemove": [Function],
"NoOptionsMessage": [Function],
}
}
defaultMenuIsOpen={false}
defaultOptions={false}
filterOption={null}
formatOptionLabel={[Function]}
getOptionValue={[Function]}
inputValue=""
isClearable={false}
isMulti={true}
loadOptions={[Function]}
loadingMessage={[Function]}
onChange={[Function]}
onFocus={[Function]}
onInputChange={[Function]}
openMenuOnClick={false}
openMenuOnFocus={true}
placeholder="test"
tabSelectsValue={true}
value={
Array [
Object {
"display_name": "test channel 1",
"id": "test-channel-1",
"type": "O",
},
Object {
"display_name": "test channel 2",
"id": "test-channel-2",
"type": "P",
},
]
}
/>
`);
});
});
|
3,676 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/inputs/dropdown_input_hybrid.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import DropdownInputHybrid from './dropdown_input_hybrid';
describe('components/widgets/inputs/DropdownInputHybrid', () => {
test('should match snapshot', () => {
const wrapper = shallow(
<DropdownInputHybrid
onDropdownChange={jest.fn()}
onInputChange={jest.fn()}
value={{value: 'forever', label: 'Keep Forever'}}
inputValue={''}
width={90}
exceptionToInput={['forever']}
defaultValue={{value: 'forever', label: 'Keep Forever'}}
options={[
{value: 'days', label: 'Days'},
{value: 'months', label: 'Months'},
{value: 'years', label: 'Years'},
{value: 'forever', label: 'Keep Forever'},
]}
legend={'Channel Message Retention'}
placeholder={'Channel Message Retention'}
name={'channel_message_retention'}
/>,
);
expect(wrapper).toMatchSnapshot();
});
});
|
3,679 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/inputs/users_emails_input.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import type {UserProfile} from '@mattermost/types/users';
import UsersEmailsInput from './users_emails_input';
describe('components/widgets/inputs/UsersEmailsInput', () => {
test('should match snapshot', () => {
const wrapper = shallow(
<UsersEmailsInput
placeholder='test'
ariaLabel='test'
usersLoader={jest.fn()}
onChange={jest.fn()}
value={[
'[email protected]',
{
id: 'test-user-id',
username: 'test-username',
first_name: 'test',
last_name: 'user',
} as UserProfile,
]}
errorMessageId='errorMessageId'
errorMessageDefault='errorMessageDefault'
onInputChange={jest.fn()}
inputValue=''
emailInvitationsEnabled={false}
/>,
);
expect(wrapper).toMatchInlineSnapshot(`
<Fragment>
<Async
aria-label="test"
cacheOptions={false}
className="UsersEmailsInput empty"
classNamePrefix="users-emails-input"
components={
Object {
"IndicatorsContainer": [Function],
"Input": [Function],
"MultiValueRemove": [Function],
"NoOptionsMessage": [Function],
}
}
defaultMenuIsOpen={false}
defaultOptions={false}
filterOption={null}
formatOptionLabel={[Function]}
getOptionValue={[Function]}
inputValue=""
isClearable={false}
isMulti={true}
isValidNewOption={[Function]}
loadOptions={[Function]}
loadingMessage={[Function]}
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
onInputChange={[Function]}
openMenuOnClick={false}
openMenuOnFocus={true}
placeholder="test"
styles={
Object {
"input": [Function],
"placeholder": [Function],
}
}
tabSelectsValue={true}
value={
Array [
Object {
"label": "[email protected]",
"value": "[email protected]",
},
Object {
"first_name": "test",
"id": "test-user-id",
"last_name": "user",
"username": "test-username",
},
]
}
/>
</Fragment>
`);
});
});
|
3,681 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/inputs | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/inputs/__snapshots__/dropdown_input_hybrid.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/inputs/DropdownInputHybrid should match snapshot 1`] = `
<div
className="DropdownInput hybrid_container"
style={
Object {
"width": "100%",
}
}
>
<fieldset
className="Input_fieldset Input_fieldset___legend"
>
<legend
className="Input_legend Input_legend___focus"
>
Channel Message Retention
</legend>
<div
className="Input_wrapper input_hybrid_wrapper"
onBlur={[Function]}
onFocus={[Function]}
style={
Object {
"maxWidth": "0",
}
}
>
<input
className="Input form-control"
name="Input_channel_message_retention"
onChange={[MockFunction]}
placeholder="Channel Message Retention"
required={false}
type="text"
value=""
/>
</div>
<div
className="Input_wrapper dropdown_hybrid_wrapper showInput"
onBlur={[Function]}
onFocus={[Function]}
style={
Object {
"width": "100%",
}
}
>
<StateManager
className="Input Input__focus"
components={
Object {
"Control": [Function],
"IndicatorsContainer": [Function],
"Option": [Function],
}
}
defaultInputValue=""
defaultMenuIsOpen={false}
defaultValue={null}
hideSelectedOptions={true}
id="DropdownInput_channel_message_retention"
isSearchable={false}
menuPortalTarget={<body />}
onChange={[Function]}
options={
Array [
Object {
"label": "Days",
"value": "days",
},
Object {
"label": "Months",
"value": "months",
},
Object {
"label": "Years",
"value": "years",
},
Object {
"label": "Keep Forever",
"value": "forever",
},
]
}
placeholder="Channel Message Retention"
styles={
Object {
"control": [Function],
"indicatorSeparator": [Function],
"input": [Function],
"menuPortal": [Function],
}
}
value={
Object {
"label": "Keep Forever",
"value": "forever",
}
}
/>
</div>
</fieldset>
</div>
`;
|
3,685 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/inputs | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/inputs/input/input.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {mount, shallow} from 'enzyme';
import React from 'react';
import OverlayTrigger from 'components/overlay_trigger';
import Input from './input';
describe('components/widgets/inputs/Input', () => {
test('should match snapshot', () => {
const wrapper = shallow(
<Input/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should render with clearable enabled', () => {
const value = 'value';
const clearableTooltipText = 'tooltip text';
const onClear = jest.fn();
const wrapper = shallow(
<Input
value={value}
clearable={true}
clearableTooltipText={clearableTooltipText}
onClear={onClear}
/>,
);
const clear = wrapper.find('.Input__clear');
expect(clear.length).toEqual(1);
expect(wrapper.find('CloseCircleIcon').length).toEqual(1);
const tooltip = wrapper.find(OverlayTrigger);
expect(tooltip.length).toEqual(1);
const overlay = mount(tooltip.prop('overlay'));
expect(overlay.text()).toEqual(clearableTooltipText);
clear.first().simulate('mousedown');
expect(onClear).toHaveBeenCalledTimes(1);
});
});
|
3,687 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/inputs/input | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/inputs/input/__snapshots__/input.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/inputs/Input should match snapshot 1`] = `
<div
className="Input_container"
>
<fieldset
className="Input_fieldset"
>
<legend
className="Input_legend"
/>
<div
className="Input_wrapper"
>
<input
className="Input form-control medium"
id="input_"
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
/>
</div>
</fieldset>
</div>
`;
|
3,693 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/links/upgrade_link.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import {Provider} from 'react-redux';
import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import mockStore from 'tests/test_store';
import UpgradeLink from './upgrade_link';
let trackEventCall = 0;
jest.mock('actions/telemetry_actions.jsx', () => {
const original = jest.requireActual('actions/telemetry_actions.jsx');
return {
...original,
trackEvent: () => {
trackEventCall = 1;
},
};
});
describe('components/widgets/links/UpgradeLink', () => {
const mockDispatch = jest.fn();
jest.mock('react-redux', () => ({
useDispatch: () => mockDispatch,
}));
test('should match the snapshot on show', () => {
const store = mockStore({});
const wrapper = shallow(
<Provider store={store}><UpgradeLink/></Provider>,
);
expect(wrapper).toMatchSnapshot();
});
test('should trigger telemetry call when button clicked', (done) => {
const store = mockStore({});
const wrapper = mountWithIntl(
<Provider store={store}><UpgradeLink telemetryInfo='testing'/></Provider>,
);
expect(wrapper.find('button').exists()).toEqual(true);
wrapper.find('button').simulate('click');
setImmediate(() => {
expect(trackEventCall).toBe(1);
done();
});
expect(wrapper).toMatchSnapshot();
});
});
|
3,695 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/links | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/links/__snapshots__/upgrade_link.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/links/UpgradeLink should match the snapshot on show 1`] = `
<ContextProvider
value={
Object {
"store": Object {
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
},
"subscription": Subscription {
"handleChangeWrapper": [Function],
"listeners": Object {
"notify": [Function],
},
"onStateChange": [Function],
"parentSub": undefined,
"store": Object {
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
},
"unsubscribe": null,
},
}
}
>
<UpgradeLink />
</ContextProvider>
`;
exports[`components/widgets/links/UpgradeLink should trigger telemetry call when button clicked 1`] = `
<Provider
store={
Object {
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
}
}
>
<UpgradeLink
telemetryInfo="testing"
>
<button
className="upgradeLink"
onClick={[Function]}
>
<FormattedMessage
defaultMessage="Upgrade now"
id="upgradeLink.warn.upgrade_now"
>
<span>
Upgrade now
</span>
</FormattedMessage>
</button>
</UpgradeLink>
</Provider>
`;
|
3,696 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/loading/loading_spinner.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import LoadingSpinner from './loading_spinner';
describe('components/widgets/loadingLoadingSpinner', () => {
test('showing spinner with text', () => {
const wrapper = shallow(<LoadingSpinner text='test'/>);
expect(wrapper).toMatchSnapshot();
});
test('showing spinner without text', () => {
const wrapper = shallow(<LoadingSpinner/>);
expect(wrapper).toMatchSnapshot();
});
});
|
3,698 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/loading/loading_wrapper.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import LoadingWrapper from './loading_wrapper';
describe('components/widgets/loading/LoadingWrapper', () => {
const testCases = [
{
name: 'showing spinner with text',
loading: true,
text: 'test',
children: 'children',
},
{
name: 'showing spinner without text',
loading: true,
children: 'text',
},
{
name: 'showing content with children',
loading: false,
children: 'text',
},
{
name: 'showing content without children',
loading: false,
},
];
for (const testCase of testCases) {
test(testCase.name, () => {
const wrapper = mountWithIntl(
<LoadingWrapper
loading={testCase.loading}
text={testCase.text}
>
{testCase.children}
</LoadingWrapper>,
);
expect(wrapper).toMatchSnapshot();
});
}
});
|
3,700 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/loading | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/loading/__snapshots__/loading_spinner.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/loadingLoadingSpinner showing spinner with text 1`] = `
<span
className="LoadingSpinner with-text"
data-testid="loadingSpinner"
id="loadingSpinner"
>
<span
className="fa fa-spinner fa-fw fa-pulse spinner"
title="Loading Icon"
/>
test
</span>
`;
exports[`components/widgets/loadingLoadingSpinner showing spinner without text 1`] = `
<span
className="LoadingSpinner"
data-testid="loadingSpinner"
id="loadingSpinner"
>
<span
className="fa fa-spinner fa-fw fa-pulse spinner"
title="Loading Icon"
/>
</span>
`;
|
3,701 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/loading | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/loading/__snapshots__/loading_wrapper.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/loading/LoadingWrapper showing content with children 1`] = `
<Memo(LoadingWrapper)
loading={false}
>
text
</Memo(LoadingWrapper)>
`;
exports[`components/widgets/loading/LoadingWrapper showing content without children 1`] = `
<Memo(LoadingWrapper)
loading={false}
/>
`;
exports[`components/widgets/loading/LoadingWrapper showing spinner with text 1`] = `
<Memo(LoadingWrapper)
loading={true}
text="test"
>
<Memo(LoadingSpinner)
text="test"
>
<span
className="LoadingSpinner with-text"
data-testid="loadingSpinner"
id="loadingSpinner"
>
<span
className="fa fa-spinner fa-fw fa-pulse spinner"
title="Loading Icon"
/>
test
</span>
</Memo(LoadingSpinner)>
</Memo(LoadingWrapper)>
`;
exports[`components/widgets/loading/LoadingWrapper showing spinner without text 1`] = `
<Memo(LoadingWrapper)
loading={true}
>
<Memo(LoadingSpinner)
text={null}
>
<span
className="LoadingSpinner"
data-testid="loadingSpinner"
id="loadingSpinner"
>
<span
className="fa fa-spinner fa-fw fa-pulse spinner"
title="Loading Icon"
/>
</span>
</Memo(LoadingSpinner)>
</Memo(LoadingWrapper)>
`;
|
3,704 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import Menu from './menu';
jest.mock('./is_mobile_view_hack', () => ({
isMobile: jest.fn(() => false),
}));
(global as any).MutationObserver = class {
public disconnect() {}
public observe() {}
};
describe('components/Menu', () => {
test('should match snapshot', () => {
const wrapper = shallow(<Menu ariaLabel='test-label'>{'text'}</Menu>);
expect(wrapper).toMatchInlineSnapshot(`
<div
aria-label="test-label"
className="a11y__popup Menu"
role="menu"
>
<ul
className="Menu__content dropdown-menu"
onClick={[Function]}
style={Object {}}
>
text
</ul>
</div>
`);
});
test('should match snapshot with id', () => {
const wrapper = shallow(
<Menu
id='test-id'
ariaLabel='test-label'
>
{'text'}
</Menu>,
);
expect(wrapper).toMatchInlineSnapshot(`
<div
aria-label="test-label"
className="a11y__popup Menu"
id="test-id"
role="menu"
>
<ul
className="Menu__content dropdown-menu"
onClick={[Function]}
style={Object {}}
>
text
</ul>
</div>
`);
});
test('should match snapshot with openLeft and openUp', () => {
const wrapper = shallow(
<Menu
openLeft={true}
openUp={true}
ariaLabel='test-label'
>
{'text'}
</Menu>,
);
expect(wrapper).toMatchInlineSnapshot(`
<div
aria-label="test-label"
className="a11y__popup Menu"
role="menu"
>
<ul
className="Menu__content dropdown-menu openLeft openUp"
onClick={[Function]}
style={Object {}}
>
text
</ul>
</div>
`);
});
test('should hide the correct dividers', () => {
const pseudoMenu = document.createElement('div');
const listOfItems = [
'menu-divider',
'menu-divider',
'menu-divider',
'menu-divider',
'other',
'other',
'menu-divider',
'menu-divider',
'other',
'menu-divider',
'menu-divider',
'menu-divider',
'other',
'other',
'other',
'menu-divider',
'menu-divider',
'menu-divider',
'menu-divider',
];
for (const className of listOfItems) {
const element = document.createElement('div');
element.classList.add(className);
pseudoMenu.append(element);
}
const wrapper = shallow<Menu>(<Menu ariaLabel='test-label'>{'text'}</Menu>);
const instance = wrapper.instance();
Object.assign(instance.node, {current: pseudoMenu});
instance.hideUnneededDividers();
expect(instance.node.current).toMatchInlineSnapshot(`
<div>
<div
class="menu-divider"
style="display: none;"
/>
<div
class="menu-divider"
style="display: none;"
/>
<div
class="menu-divider"
style="display: none;"
/>
<div
class="menu-divider"
style="display: none;"
/>
<div
class="other"
/>
<div
class="other"
/>
<div
class="menu-divider"
style="display: block;"
/>
<div
class="menu-divider"
style="display: none;"
/>
<div
class="other"
/>
<div
class="menu-divider"
style="display: block;"
/>
<div
class="menu-divider"
style="display: none;"
/>
<div
class="menu-divider"
style="display: none;"
/>
<div
class="other"
/>
<div
class="other"
/>
<div
class="other"
/>
<div
class="menu-divider"
style="display: none;"
/>
<div
class="menu-divider"
style="display: none;"
/>
<div
class="menu-divider"
style="display: none;"
/>
<div
class="menu-divider"
style="display: none;"
/>
</div>
`);
});
test('should hide the correct dividers on mobile', () => {
const pseudoMenu = document.createElement('div');
const listOfItems = [
'mobile-menu-divider',
'mobile-menu-divider',
'mobile-menu-divider',
'mobile-menu-divider',
'other',
'other',
'mobile-menu-divider',
'mobile-menu-divider',
'other',
'mobile-menu-divider',
'mobile-menu-divider',
'mobile-menu-divider',
'other',
'other',
'other',
'mobile-menu-divider',
'mobile-menu-divider',
'mobile-menu-divider',
'mobile-menu-divider',
];
for (const className of listOfItems) {
const element = document.createElement('div');
element.classList.add(className);
pseudoMenu.append(element);
}
const wrapper = shallow<Menu>(<Menu ariaLabel='test-label'>{'text'}</Menu>);
const instance = wrapper.instance();
Object.assign(instance.node, {current: pseudoMenu});
instance.hideUnneededDividers();
expect(instance.node.current).toMatchInlineSnapshot(`
<div>
<div
class="mobile-menu-divider"
style="display: none;"
/>
<div
class="mobile-menu-divider"
style="display: none;"
/>
<div
class="mobile-menu-divider"
style="display: none;"
/>
<div
class="mobile-menu-divider"
style="display: none;"
/>
<div
class="other"
/>
<div
class="other"
/>
<div
class="mobile-menu-divider"
style="display: block;"
/>
<div
class="mobile-menu-divider"
style="display: none;"
/>
<div
class="other"
/>
<div
class="mobile-menu-divider"
style="display: block;"
/>
<div
class="mobile-menu-divider"
style="display: none;"
/>
<div
class="mobile-menu-divider"
style="display: none;"
/>
<div
class="other"
/>
<div
class="other"
/>
<div
class="other"
/>
<div
class="mobile-menu-divider"
style="display: none;"
/>
<div
class="mobile-menu-divider"
style="display: none;"
/>
<div
class="mobile-menu-divider"
style="display: none;"
/>
<div
class="mobile-menu-divider"
style="display: none;"
/>
</div>
`);
});
});
|
3,707 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_group.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import MenuGroup from './menu_group';
describe('components/MenuItem', () => {
test('should match snapshot with default divider', () => {
const wrapper = shallow(<MenuGroup>{'text'}</MenuGroup>);
expect(wrapper).toMatchInlineSnapshot(`
<Fragment>
<li
className="MenuGroup menu-divider"
onClick={[Function]}
/>
text
</Fragment>
`);
});
test('should match snapshot with custom divider', () => {
const wrapper = shallow(<MenuGroup divider='--'>{'text'}</MenuGroup>);
expect(wrapper).toMatchInlineSnapshot(`
<Fragment>
--
text
</Fragment>
`);
});
});
|
3,712 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_wrapper.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import MenuWrapper from './menu_wrapper';
describe('components/MenuWrapper', () => {
test('should match snapshot', () => {
const wrapper = shallow(
<MenuWrapper>
<p>{'title'}</p>
<p>{'menu'}</p>
</MenuWrapper>,
);
expect(wrapper).toMatchInlineSnapshot(`
<div
className="MenuWrapper "
onClick={[Function]}
>
<p>
title
</p>
<MenuWrapperAnimation
show={false}
>
<p>
menu
</p>
</MenuWrapperAnimation>
</div>
`);
});
test('should match snapshot with state false', () => {
const wrapper = shallow(
<MenuWrapper>
<p>{'title'}</p>
<p>{'menu'}</p>
</MenuWrapper>,
);
wrapper.setState({open: true});
expect(wrapper).toMatchInlineSnapshot(`
<div
className="MenuWrapper MenuWrapper--open"
onClick={[Function]}
>
<p>
title
</p>
<MenuWrapperAnimation
show={true}
>
<p>
menu
</p>
</MenuWrapperAnimation>
</div>
`);
});
test('should toggle the state on click', () => {
const wrapper = shallow(
<MenuWrapper>
<p>{'title'}</p>
<p>{'menu'}</p>
</MenuWrapper>,
);
expect(wrapper.state('open')).toBe(false);
wrapper.simulate('click', {preventDefault: jest.fn(), stopPropagation: jest.fn()});
expect(wrapper.state('open')).toBe(true);
wrapper.simulate('click', {preventDefault: jest.fn(), stopPropagation: jest.fn()});
expect(wrapper.state('open')).toBe(false);
});
test('should raise an exception on more or less than 2 children', () => {
expect(() => {
shallow(<MenuWrapper/>);
}).toThrow();
expect(() => {
shallow(
<MenuWrapper>
<p>{'title'}</p>
</MenuWrapper>,
);
}).toThrow();
expect(() => {
shallow(
<MenuWrapper>
<p>{'title1'}</p>
<p>{'title2'}</p>
<p>{'title3'}</p>
</MenuWrapper>,
);
}).toThrow();
});
test('should stop propogation and prevent default when toggled and prop is enabled', () => {
const wrapper = shallow<MenuWrapper>(
<MenuWrapper stopPropagationOnToggle={true}>
<p>{'title'}</p>
<p>{'menu'}</p>
</MenuWrapper>,
);
const event: any = {stopPropagation: jest.fn(), preventDefault: jest.fn()};
wrapper.instance().toggle(event);
expect(event.preventDefault).toHaveBeenCalled();
expect(event.stopPropagation).toHaveBeenCalled();
});
test('should call the onToggle callback when toggled', () => {
const onToggle = jest.fn();
const wrapper = shallow<MenuWrapper>(
<MenuWrapper onToggle={onToggle}>
<p>{'title'}</p>
<p>{'menu'}</p>
</MenuWrapper>,
);
const event: any = {stopPropagation: jest.fn(), preventDefault: jest.fn()};
wrapper.instance().toggle(event);
expect(event.preventDefault).not.toHaveBeenCalled();
expect(event.stopPropagation).not.toHaveBeenCalled();
expect(onToggle).toHaveBeenCalledWith(wrapper.instance().state.open);
});
test('should initialize state from props if prop is given', () => {
const wrapper = shallow<MenuWrapper>(
<MenuWrapper open={true}>
<p>{'title'}</p>
<p>{'menu'}</p>
</MenuWrapper>,
);
expect(wrapper.state('open')).toBe(true);
});
});
|
3,715 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_items/menu_cloud_trial.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {Provider} from 'react-redux';
import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import mockStore from 'tests/test_store';
import {CloudProducts} from 'utils/constants';
import {FileSizes} from 'utils/file_utils';
import {limitThresholds} from 'utils/limits';
import MenuCloudTrial from './menu_cloud_trial';
const usage = {
files: {
totalStorage: 0,
totalStorageLoaded: true,
},
messages: {
history: 0,
historyLoaded: true,
},
boards: {
cards: 0,
cardsLoaded: true,
},
integrations: {
enabled: 0,
enabledLoaded: true,
},
teams: {
active: 0,
cloudArchived: 0,
teamsLoaded: true,
},
};
const limits = {
limitsLoaded: true,
limits: {
integrations: {
enabled: 5,
},
messages: {
history: 10000,
},
files: {
total_storage: FileSizes.Gigabyte,
},
teams: {
active: 1,
teamsLoaded: true,
},
boards: {
cards: 500,
views: 5,
},
},
};
const users = {
currentUserId: 'uid',
profiles: {
uid: {},
},
};
describe('components/widgets/menu/menu_items/menu_cloud_trial', () => {
test('should render when on cloud license and during free trial period', () => {
const FOURTEEN_DAYS = 1209600000; // in milliseconds
const subscriptionCreateAt = Date.now();
const subscriptionEndAt = subscriptionCreateAt + FOURTEEN_DAYS;
const state = {
entities: {
general: {
license: {
IsLicensed: 'true',
Cloud: 'true',
},
},
cloud: {
subscription: {
is_free_trial: 'true',
trial_end_at: subscriptionEndAt,
},
limits,
},
usage,
users: {
currentUserId: 'uid',
profiles: {
uid: {},
},
},
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuCloudTrial id='menuCloudTrial'/></Provider>);
expect(wrapper.find('.MenuCloudTrial').exists()).toEqual(true);
});
test('should NOT render when NOT on cloud license and NOT during free trial period', () => {
const state = {
entities: {
users,
general: {
license: {
IsLicensed: 'false',
},
},
cloud: {
customer: null,
subscription: null,
products: null,
invoices: null,
limits,
},
usage,
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuCloudTrial id='menuCloudTrial'/></Provider>);
expect(wrapper.find('.MenuCloudTrial').exists()).toEqual(false);
});
test('should NOT render when NO license is available', () => {
const state = {
entities: {
users,
general: {},
cloud: {
customer: null,
subscription: null,
products: null,
invoices: null,
limits,
},
usage,
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuCloudTrial id='menuCloudTrial'/></Provider>);
expect(wrapper.find('.MenuCloudTrial').exists()).toEqual(false);
});
test('should NOT render when is cloud and not on a trial', () => {
const state = {
entities: {
users,
general: {
license: {
IsLicensed: 'true',
Cloud: 'true',
},
},
cloud: {
subscription: {
is_free_trial: 'false',
trial_end_at: 0,
},
limits,
},
usage,
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuCloudTrial id='menuCloudTrial'/></Provider>);
expect(wrapper.find('.open-learn-more-trial-modal').exists()).toEqual(false);
expect(wrapper.find('.MenuCloudTrial').exists()).toEqual(false);
});
test('should invite to start trial when the subscription is not paid and have not had trial before', () => {
const state = {
entities: {
general: {
license: {
IsLicensed: 'true',
Cloud: 'true',
},
},
cloud: {
subscription: {
is_free_trial: 'false',
trial_end_at: 0,
product_id: 'prod_starter',
},
products: {
prod_starter: {
id: 'prod_starter',
sku: CloudProducts.STARTER,
},
},
limits,
},
usage,
users: {
currentUserId: 'current_user_id',
profiles: {
current_user_id: {roles: 'system_admin'},
},
},
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuCloudTrial id='menuCloudTrial'/></Provider>);
expect(wrapper.find('.open-learn-more-trial-modal').exists()).toEqual(true);
});
test('should show the open trial benefits modal when is free trial', () => {
const state = {
entities: {
users,
general: {
license: {
IsLicensed: 'true',
Cloud: 'true',
},
},
cloud: {
subscription: {
product_id: 'prod_starter',
is_free_trial: 'true',
trial_end_at: 12345,
},
products: {
prod_starter: {
id: 'prod_starter',
sku: CloudProducts.STARTER,
},
},
limits,
},
usage,
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuCloudTrial id='menuCloudTrial'/></Provider>);
const openModalLink = wrapper.find('.open-trial-benefits-modal');
expect(openModalLink.exists()).toEqual(true);
expect(openModalLink.text()).toBe('Learn more');
});
test('should show the invitation to see plans when is not in Trial and has had previous Trial', () => {
const state = {
entities: {
general: {
license: {
IsLicensed: 'true',
Cloud: 'true',
},
},
cloud: {
subscription: {
is_free_trial: 'false',
trial_end_at: 232434,
product_id: 'prod_starter',
},
products: {
prod_starter: {
id: 'prod_starter',
sku: CloudProducts.STARTER,
},
},
limits,
},
usage,
users: {
currentUserId: 'current_user_id',
profiles: {
current_user_id: {roles: 'system_admin'},
},
},
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuCloudTrial id='menuCloudTrial'/></Provider>);
const openModalLink = wrapper.find('.open-see-plans-modal');
expect(openModalLink.exists()).toEqual(true);
expect(openModalLink.text()).toEqual('See plans');
});
test('should show the invitation to open the trial benefits modal when is End User and is in TRIAL', () => {
const state = {
entities: {
general: {
license: {
IsLicensed: 'true',
Cloud: 'true',
},
},
cloud: {
subscription: {
is_free_trial: 'true',
trial_end_at: 0,
product_id: 'prod_starter',
},
products: {
prod_starter: {
id: 'prod_starter',
sku: CloudProducts.STARTER,
},
},
limits,
},
usage,
users: {
currentUserId: 'current_user_id',
profiles: {
current_user_id: {roles: 'system_user'},
},
},
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuCloudTrial id='menuCloudTrial'/></Provider>);
const openModalLink = wrapper.find('.open-trial-benefits-modal');
expect(openModalLink.exists()).toEqual(true);
expect(openModalLink.text()).toEqual('Learn more');
});
test('should NOT show the menu cloud trial when is End User and is NOT in TRIAL', () => {
const state = {
entities: {
general: {
license: {
IsLicensed: 'true',
Cloud: 'true',
},
},
cloud: {
subscription: {
is_free_trial: 'false',
trial_end_at: 12345,
product_id: 'prod_starter',
},
products: {
prod_starter: {
id: 'prod_starter',
sku: CloudProducts.STARTER,
},
},
limits,
},
usage,
users: {
currentUserId: 'current_user_id',
profiles: {
current_user_id: {roles: 'system_user'},
},
},
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuCloudTrial id='menuCloudTrial'/></Provider>);
const openModalLink = wrapper.find('.open-trial-benefits-modal');
expect(openModalLink.exists()).toEqual(false);
});
test('should return null if some limit needs attention', () => {
const state = {
entities: {
users,
general: {
license: {
IsLicensed: 'true',
Cloud: 'true',
},
},
cloud: {
subscription: {
product_id: 'prod_starter',
is_free_trial: 'false',
trial_end_at: 232434,
},
products: {
prod_starter: {
id: 'prod_starter',
sku: CloudProducts.STARTER,
},
},
limits,
},
usage: {
...usage,
messages: {
...usage.messages,
history: Math.ceil((limitThresholds.warn / 100) * limits.limits.messages.history) + 1,
},
},
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuCloudTrial id='menuCloudTrial'/></Provider>);
expect(wrapper.find('.MenuCloudTrial').exists()).toEqual(false);
expect(wrapper.find('.open-see-plans-modal').exists()).toEqual(false);
expect(wrapper.find('.open-learn-more-trial-modal').exists()).toEqual(false);
expect(wrapper.find('.open-trial-benefits-modal').exists()).toEqual(false);
});
});
|
3,718 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_items/menu_item.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import menuItem from './menu_item';
describe('components/MenuItem', () => {
const TestComponent = menuItem(() => null);
const defaultProps = {
show: true,
id: 'test-id',
text: 'test-text',
otherProp: 'extra-prop',
};
test('should match snapshot not shown', () => {
const props = {...defaultProps, show: false};
const wrapper = shallow(<TestComponent {...props}/>);
expect(wrapper).toMatchInlineSnapshot('""');
});
test('should match snapshot shown with icon', () => {
const props = {...defaultProps, icon: 'test-icon'};
const wrapper = shallow(<TestComponent {...props}/>);
expect(wrapper).toMatchInlineSnapshot(`
<li
className="MenuItem MenuItem--with-icon"
id="test-id"
role="menuitem"
>
<Component
ariaLabel="test-text"
otherProp="extra-prop"
text={
<React.Fragment>
<span
className="icon"
>
test-icon
</span>
test-text
</React.Fragment>
}
/>
</li>
`);
});
test('should match snapshot shown without icon', () => {
const wrapper = shallow(<TestComponent {...defaultProps}/>);
expect(wrapper).toMatchInlineSnapshot(`
<li
className="MenuItem"
id="test-id"
role="menuitem"
>
<Component
ariaLabel="test-text"
otherProp="extra-prop"
text="test-text"
/>
</li>
`);
});
});
|
3,720 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_items/menu_item_action.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import {MenuItemActionImpl} from './menu_item_action';
describe('components/MenuItemAction', () => {
test('should match snapshot', () => {
const wrapper = shallow(
<MenuItemActionImpl
onClick={jest.fn()}
text='Whatever'
/>,
);
expect(wrapper).toMatchInlineSnapshot(`
<Fragment>
<button
className="style--none"
onClick={[MockFunction]}
>
<span
className="MenuItem__primary-text"
>
Whatever
</span>
</button>
</Fragment>
`);
});
test('should match snapshot with extra text', () => {
const wrapper = shallow(
<MenuItemActionImpl
onClick={jest.fn()}
text='Whatever'
extraText='Extra Text'
/>,
);
expect(wrapper).toMatchInlineSnapshot(`
<Fragment>
<button
className="style--none MenuItem__with-help"
onClick={[MockFunction]}
>
<span
className="MenuItem__primary-text"
>
Whatever
</span>
<span
className="MenuItem__help-text"
>
Extra Text
</span>
</button>
</Fragment>
`);
});
});
|
3,722 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_items/menu_item_cloud_limit.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {Provider} from 'react-redux';
import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import mockStore from 'tests/test_store';
import {FileSizes} from 'utils/file_utils';
import {limitThresholds} from 'utils/limits';
import MenuItemCloudLimit from './menu_item_cloud_limit';
const zeroUsage = {
files: {
totalStorage: 0,
totalStorageLoaded: true,
},
messages: {
history: 0,
historyLoaded: true,
},
boards: {
cards: 0,
cardsLoaded: true,
},
integrations: {
enabled: 0,
enabledLoaded: true,
},
teams: {
active: 0,
teamsLoaded: true,
},
};
const general = {
license: {
IsLicensed: 'true',
Cloud: 'true',
},
};
const subscription = {
is_free_trial: 'false',
};
const messageLimit = 10000;
const warnMessageUsage = Math.ceil((limitThresholds.warn / 100) * messageLimit) + 1;
const critialMessageUsage = Math.ceil((limitThresholds.danger / 100) * messageLimit) + 1;
const limits = {
limitsLoaded: true,
limits: {
integrations: {
enabled: 5,
},
messages: {
history: messageLimit,
},
files: {
total_storage: FileSizes.Gigabyte,
},
teams: {
active: 1,
teamsLoaded: true,
},
boards: {
cards: 500,
views: 5,
},
},
};
const usageWarnMessages = {
...zeroUsage,
messages: {
...zeroUsage.messages,
history: warnMessageUsage,
},
};
const usageCriticalMessages = {
...zeroUsage,
messages: {
...zeroUsage.messages,
history: critialMessageUsage,
},
};
const users = {
currentUserId: 'user_id',
profiles: {
user_id: {},
},
};
const id = 'menuItemCloudLimit';
describe('components/widgets/menu/menu_items/menu_item_cloud_limit', () => {
test('Does not render if not cloud', () => {
const state = {
entities: {
general: {
license: {
IsLicensed: 'true',
Cloud: 'false',
},
},
cloud: {
subscription: {
is_free_trial: 'false',
},
limits,
},
users,
usage: usageWarnMessages,
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuItemCloudLimit id={id}/></Provider>);
expect(wrapper.find('li').exists()).toEqual(false);
});
test('Does not render if free trial', () => {
const state = {
entities: {
general,
cloud: {
subscription: {
is_free_trial: 'true',
},
limits,
},
users,
usage: usageWarnMessages,
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuItemCloudLimit id={id}/></Provider>);
expect(wrapper.find('li').exists()).toEqual(false);
});
test('Does not render if no highest limit', () => {
const state = {
entities: {
general,
cloud: {
subscription,
limits,
},
users,
usage: zeroUsage,
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuItemCloudLimit id={id}/></Provider>);
expect(wrapper.find('li').exists()).toEqual(false);
});
test('renders when a limit needs attention', () => {
const state = {
entities: {
general,
cloud: {
subscription,
limits,
},
users,
usage: usageWarnMessages,
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuItemCloudLimit id={id}/></Provider>);
expect(wrapper.find('li').exists()).toEqual(true);
});
test('shows more attention grabbing UI and notify admin CTA if a limit is very close for non admin users', () => {
const state = {
entities: {
general,
cloud: {
subscription,
limits,
},
users,
usage: usageCriticalMessages,
teams: {
currentTeamId: 'current_team_id',
},
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuItemCloudLimit id={id}/></Provider>);
expect(wrapper.find('li').prop('className')).toContain('critical');
expect(wrapper.find('NotifyAdminCTA')).toHaveLength(1);
});
test('shows more attention grabbing UI if a limit is very close for admins', () => {
const state = {
entities: {
general,
cloud: {
subscription,
limits,
},
users: {
currentUserId: 'current_user_id',
profiles: {
current_user_id: {roles: 'system_admin'},
},
},
usage: usageCriticalMessages,
teams: {
currentTeamId: 'current_team_id',
},
},
};
const store = mockStore(state);
const wrapper = mountWithIntl(<Provider store={store}><MenuItemCloudLimit id={id}/></Provider>);
expect(wrapper.find('li').prop('className')).toContain('critical');
expect(wrapper.find('a')).toHaveLength(1);
expect(wrapper.find('a').text()).toEqual('View upgrade options.');
});
});
|
3,724 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_items/menu_item_external_link.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import {MenuItemExternalLinkImpl} from './menu_item_external_link';
describe('components/MenuItemExternalLink', () => {
test('should match snapshot', () => {
const wrapper = shallow(
<MenuItemExternalLinkImpl
url='http://test.com'
text='Whatever'
/>,
);
expect(wrapper).toMatchInlineSnapshot(`
<ExternalLink
href="http://test.com"
location="menu_item_external_link"
>
<span
className="MenuItem__primary-text"
>
Whatever
</span>
</ExternalLink>
`);
});
});
|
3,726 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_items/menu_item_link.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import {MenuItemLinkImpl} from './menu_item_link';
describe('components/MenuItemLink', () => {
test('should match snapshot', () => {
const wrapper = shallow(
<MenuItemLinkImpl
to='/wherever'
text='Whatever'
/>,
);
expect(wrapper).toMatchInlineSnapshot(`
<Fragment>
<Link
className=""
to="/wherever"
>
<span
className="MenuItem__primary-text"
>
Whatever
</span>
</Link>
</Fragment>
`);
});
});
|
3,728 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_items/menu_item_toggle_modal_redux.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import {MenuItemToggleModalReduxImpl} from './menu_item_toggle_modal_redux';
describe('components/MenuItemToggleModalRedux', () => {
test('should match snapshot', () => {
const wrapper = shallow(
<MenuItemToggleModalReduxImpl
modalId='test'
dialogType={jest.fn()}
dialogProps={{test: 'test'}}
text='Whatever'
/>,
);
expect(wrapper).toMatchInlineSnapshot(`
<Fragment>
<ToggleModalButton
className=""
dialogProps={
Object {
"test": "test",
}
}
dialogType={[MockFunction]}
modalId="test"
>
<span
className="MenuItem__primary-text"
>
Whatever
</span>
</ToggleModalButton>
</Fragment>
`);
});
test('should match snapshot with extra text', () => {
const wrapper = shallow(
<MenuItemToggleModalReduxImpl
modalId='test'
dialogType={jest.fn()}
dialogProps={{test: 'test'}}
text='Whatever'
extraText='Extra text'
/>,
);
expect(wrapper).toMatchSnapshot();
});
});
|
3,730 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_items/menu_start_trial.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import * as reactRedux from 'react-redux';
import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import mockStore from 'tests/test_store';
import MenuStartTrial from './menu_start_trial';
describe('components/widgets/menu/menu_items/menu_start_trial', () => {
const useDispatchMock = jest.spyOn(reactRedux, 'useDispatch');
beforeEach(() => {
useDispatchMock.mockClear();
});
test('should render when no trial license has ever been used and there is no license currently loaded', () => {
const state = {
entities: {
users: {
currentUserId: 'test_id',
},
general: {
config: {
EnableTutorial: true,
},
license: {
IsLicensed: 'false',
},
},
admin: {
prevTrialLicense: {
IsLicensed: 'false',
},
},
preferences: {
myPreferences: {
'tutorial_step-test_id': {
user_id: 'test_id',
category: 'tutorial_step',
name: 'test_id',
value: '6',
},
},
},
},
};
const store = mockStore(state);
const dummyDispatch = jest.fn();
useDispatchMock.mockReturnValue(dummyDispatch);
const wrapper = mountWithIntl(<reactRedux.Provider store={store}><MenuStartTrial id='startTrial'/></reactRedux.Provider>);
expect(wrapper.find('button').exists()).toEqual(true);
});
test('should render null when prevTrialLicense was used and there is no license currently loaded', () => {
const state = {
entities: {
users: {
currentUserId: 'test_id',
},
general: {
config: {
EnableTutorial: true,
},
license: {
IsLicensed: 'false',
IsTrial: 'false',
},
},
admin: {
prevTrialLicense: {
IsLicensed: 'true',
},
},
preferences: {
myPreferences: {
'tutorial_step-test_id': {
user_id: 'test_id',
category: 'tutorial_step',
name: 'test_id',
value: '6',
},
},
},
},
};
const store = mockStore(state);
const dummyDispatch = jest.fn();
useDispatchMock.mockReturnValue(dummyDispatch);
const wrapper = mountWithIntl(<reactRedux.Provider store={store}><MenuStartTrial id='startTrial'/></reactRedux.Provider>);
expect(wrapper.find('button').exists()).toEqual(false);
});
test('should render null when no trial license has ever been used but there is a license currently loaded', () => {
const state = {
entities: {
users: {
currentUserId: 'test_id',
},
general: {
config: {
EnableTutorial: true,
},
license: {
IsLicensed: 'true',
IsTrial: 'false',
},
},
admin: {
prevTrialLicense: {
IsLicensed: 'false',
},
},
preferences: {
myPreferences: {
'tutorial_step-test_id': {
user_id: 'test_id',
category: 'tutorial_step',
name: 'test_id',
value: '6',
},
},
},
},
};
const store = mockStore(state);
const dummyDispatch = jest.fn();
useDispatchMock.mockReturnValue(dummyDispatch);
const wrapper = mountWithIntl(<reactRedux.Provider store={store}><MenuStartTrial id='startTrial'/></reactRedux.Provider>);
expect(wrapper.find('button').exists()).toEqual(false);
});
test('should render menu option that open the start trial benefits modal when is current licensed but is trial', () => {
const state = {
entities: {
users: {
currentUserId: 'test_id',
},
general: {
config: {
EnableTutorial: true,
},
license: {
IsLicensed: 'true',
IsTrial: 'true',
},
},
admin: {
prevTrialLicense: {
IsLicensed: 'false',
},
},
preferences: {
myPreferences: {
'tutorial_step-test_id': {
user_id: 'test_id',
category: 'tutorial_step',
name: 'test_id',
value: '6',
},
},
},
},
};
const store = mockStore(state);
const dummyDispatch = jest.fn();
useDispatchMock.mockReturnValue(dummyDispatch);
const wrapper = mountWithIntl(<reactRedux.Provider store={store}><MenuStartTrial id='startTrial'/></reactRedux.Provider>);
expect(wrapper.find('button').exists()).toEqual(true);
expect(wrapper.find('button').text()).toEqual('Learn More');
});
test('should render menu option that open the start trial modal when has no license and no previous license', () => {
const state = {
entities: {
users: {
currentUserId: 'test_id',
},
general: {
config: {
EnableTutorial: true,
},
license: {
IsLicensed: 'false',
IsTrial: 'false',
},
},
admin: {
prevTrialLicense: {
IsLicensed: 'false',
},
},
preferences: {
myPreferences: {
'tutorial_step-test_id': {
user_id: 'test_id',
category: 'tutorial_step',
name: 'test_id',
value: '6',
},
},
},
},
};
const store = mockStore(state);
const dummyDispatch = jest.fn();
useDispatchMock.mockReturnValue(dummyDispatch);
const wrapper = mountWithIntl(<reactRedux.Provider store={store}><MenuStartTrial id='startTrial'/></reactRedux.Provider>);
expect(wrapper.find('button').exists()).toEqual(true);
expect(wrapper.find('div.start_trial_content').text()).toEqual('Try Enterprise for free now!');
expect(wrapper.find('button').text()).toEqual('Learn More');
});
});
|
3,734 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_items/submenu_item.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {mount} from 'enzyme';
import React from 'react';
import Constants from 'utils/constants';
import SubMenuItem from './submenu_item';
jest.mock('../is_mobile_view_hack', () => ({
isMobile: jest.fn(() => false),
}));
describe('components/widgets/menu/menu_items/submenu_item', () => {
test('empty subMenu should match snapshot', () => {
const wrapper = mount(
<SubMenuItem
key={'_pluginmenuitem'}
id={'1'}
text={'test'}
subMenu={[]}
action={jest.fn()}
root={true}
/>,
);
expect(wrapper).toMatchSnapshot();
});
test('present subMenu should match snapshot with submenu', () => {
const wrapper = mount(
<SubMenuItem
key={'_pluginmenuitem'}
id={'1'}
text={'test'}
subMenu={[
{
id: 'A',
text: 'Test A',
direction: 'left',
},
{
id: 'B',
text: 'Test B',
direction: 'left',
},
]}
action={jest.fn()}
root={true}
/>,
);
expect(wrapper).toMatchSnapshot();
});
test('test subMenu click triggers action', async () => {
const action1 = jest.fn().mockReturnValueOnce('default');
const action2 = jest.fn().mockReturnValueOnce('default');
const action3 = jest.fn().mockReturnValueOnce('default');
const wrapper = mount(
<SubMenuItem
key={'_pluginmenuitem'}
id={'Z'}
text={'test'}
subMenu={[
{
id: 'A',
text: 'Test A',
action: action2,
direction: 'left',
},
{
id: 'B',
text: 'Test B',
action: action3,
direction: 'left',
},
]}
action={action1}
root={true}
/>,
);
wrapper.setState({show: true});
wrapper.find('#Z').at(1).simulate('click');
await expect(action1).toHaveBeenCalledTimes(1);
wrapper.setState({show: true});
wrapper.find('#A').at(1).simulate('click');
await expect(action2).toHaveBeenCalledTimes(1);
wrapper.setState({show: true});
wrapper.find('#B').at(1).simulate('click');
await expect(action3).toHaveBeenCalledTimes(1);
});
test('should show/hide submenu based on keyboard commands', () => {
const wrapper = mount<SubMenuItem>(
<SubMenuItem
key={'_pluginmenuitem'}
id={'1'}
text={'test'}
subMenu={[]}
root={true}
direction={'right'}
/>,
);
wrapper.instance().show = jest.fn();
wrapper.instance().hide = jest.fn();
wrapper.instance().handleKeyDown({keyCode: Constants.KeyCodes.ENTER[1]} as any);
expect(wrapper.instance().show).toHaveBeenCalled();
wrapper.instance().handleKeyDown({keyCode: Constants.KeyCodes.LEFT[1]} as any);
expect(wrapper.instance().hide).toHaveBeenCalled();
wrapper.instance().handleKeyDown({keyCode: Constants.KeyCodes.RIGHT[1]} as any);
expect(wrapper.instance().show).toHaveBeenCalled();
});
});
|
3,736 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_items/useWords.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import type {LimitSummary} from 'components/common/hooks/useGetHighestThresholdCloudLimit';
import {renderWithContext, screen} from 'tests/react_testing_utils';
import {FileSizes} from 'utils/file_utils';
import {LimitTypes} from 'utils/limits';
import useWords from './useWords';
interface Props {
highestLimit: LimitSummary | false;
isAdminUser: boolean;
}
const emptyText = 'EMPTY TEXT';
function TestEl(props: Props) {
const words = useWords(props.highestLimit, props.isAdminUser, '');
if (!words) {
return <span>{emptyText}</span>;
}
return (
<ul>
<li>{words.title}</li>
<li>{words.description}</li>
<li>{words.status}</li>
</ul>
);
}
interface Test {
label: string;
expects: {
empty?: boolean;
title?: string | RegExp;
description?: string | RegExp;
status?: string | RegExp;
};
props: Props;
}
const asAdmin = (highestLimit: LimitSummary | false): Props => ({isAdminUser: true, highestLimit});
const asUser = (highestLimit: LimitSummary | false): Props => ({isAdminUser: false, highestLimit});
const mkLimit = (id: LimitSummary['id'], usage: LimitSummary['usage'], limit: LimitSummary['limit']): LimitSummary => ({id, usage, limit});
const oneGb = FileSizes.Gigabyte;
describe('useWords', () => {
const tests: Test[] = [
{
label: 'returns nothing if there is not a highest limit',
props: {
highestLimit: false,
isAdminUser: false,
},
expects: {
empty: true,
},
},
{
label: 'shows message history warn',
props: asAdmin(mkLimit(LimitTypes.messageHistory, 5000, 10000)),
expects: {
title: 'Total messages',
description: /closer.*10,000.*message limit/,
status: '5K',
},
},
{
label: 'shows message history critical',
props: asAdmin(mkLimit(LimitTypes.messageHistory, 8000, 10000)),
expects: {
title: 'Total messages',
description: /close to hitting.*10,000.*message/,
status: '8K',
},
},
{
label: 'shows message history reached',
props: asAdmin(mkLimit(LimitTypes.messageHistory, 10000, 10000)),
expects: {
title: 'Total messages',
description: /reached.*message history.*only.*last.*10K.*messages/,
status: '10K',
},
},
{
label: 'shows message history exceeded',
props: asAdmin(mkLimit(LimitTypes.messageHistory, 11000, 10000)),
expects: {
title: 'Total messages',
description: /over.*message history.*only.*last.*10K.*messages/,
status: '11K',
},
},
{
label: 'shows file storage warn',
props: asAdmin(mkLimit(LimitTypes.fileStorage, 0.5 * FileSizes.Gigabyte, oneGb)),
expects: {
title: 'File storage limit',
description: /closer.*1GB.*limit/,
status: '0.5GB',
},
},
{
label: 'shows file storage critical',
props: asAdmin(mkLimit(LimitTypes.fileStorage, 0.8 * FileSizes.Gigabyte, oneGb)),
expects: {
title: 'File storage limit',
description: /closer.*1GB.*limit/,
status: '0.8GB',
},
},
{
label: 'shows file storage reached',
props: asAdmin(mkLimit(LimitTypes.fileStorage, FileSizes.Gigabyte, oneGb)),
expects: {
title: 'File storage limit',
description: /reached.*1GB.*limit/,
status: '1GB',
},
},
{
label: 'shows file storage exceeded',
props: asAdmin(mkLimit(LimitTypes.fileStorage, 1.1 * FileSizes.Gigabyte, oneGb)),
expects: {
title: 'File storage limit',
description: /over.*1GB.*limit/,
status: '1.1GB',
},
},
{
label: 'admin prompted to upgrade',
props: asAdmin(mkLimit(LimitTypes.messageHistory, 6000, 10000)),
expects: {
description: 'View upgrade options.',
},
},
{
label: 'end user prompted to view plans',
props: asUser(mkLimit(LimitTypes.messageHistory, 6000, 10000)),
expects: {
description: 'View plans',
},
},
{
label: 'end user prompted to notify admin when over limit',
props: asUser(mkLimit(LimitTypes.messageHistory, 11000, 10000)),
expects: {
description: 'Notify admin',
},
},
];
const initialState = {
entities: {
general: {
license: {
Cloud: 'true',
},
},
},
};
tests.forEach((t: Test) => {
test(t.label, () => {
renderWithContext(
<TestEl {...t.props}/>,
initialState,
);
if (t.expects.empty) {
screen.getByText(emptyText);
}
if (t.expects.title) {
screen.getByText(t.expects.title);
}
if (t.expects.description) {
screen.getByText(t.expects.description);
}
if (t.expects.status) {
screen.getByText(t.expects.status);
}
});
});
});
|
3,738 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_items | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_items/__snapshots__/menu_item_toggle_modal_redux.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/MenuItemToggleModalRedux should match snapshot with extra text 1`] = `
<Fragment>
<ToggleModalButton
className="MenuItem__with-help"
dialogProps={
Object {
"test": "test",
}
}
dialogType={[MockFunction]}
modalId="test"
>
<span
className="MenuItem__primary-text"
>
Whatever
</span>
<span
className="MenuItem__help-text"
>
Extra text
</span>
</ToggleModalButton>
</Fragment>
`;
|
3,739 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_items | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_items/__snapshots__/submenu_item.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/menu/menu_items/submenu_item empty subMenu should match snapshot 1`] = `
<SubMenuItem
action={[MockFunction]}
direction="left"
id="1"
renderSelected={true}
root={true}
show={true}
subMenu={Array []}
subMenuClass="pl-4"
text="test"
>
<li
className="SubMenuItem MenuItem"
id="1_menuitem"
onClick={[Function]}
role="menuitem"
>
<div
className=""
id="1"
onClick={[Function]}
onKeyDown={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
tabIndex={0}
>
<div
className="flex"
>
test
<span
className="selected"
/>
<span
aria-label="submenu icon"
className="fa fa-angle-right SubMenu__icon-right-empty"
id="channelHeaderDropdownIconRight_1"
/>
</div>
<ul
className="a11y__popup Menu dropdown-menu SubMenu"
style={
Object {
"right": "100%",
"top": "unset",
"visibility": "hidden",
}
}
/>
</div>
</li>
</SubMenuItem>
`;
exports[`components/widgets/menu/menu_items/submenu_item present subMenu should match snapshot with submenu 1`] = `
<SubMenuItem
action={[MockFunction]}
direction="left"
id="1"
renderSelected={true}
root={true}
show={true}
subMenu={
Array [
Object {
"direction": "left",
"id": "A",
"text": "Test A",
},
Object {
"direction": "left",
"id": "B",
"text": "Test B",
},
]
}
subMenuClass="pl-4"
text="test"
>
<li
className="SubMenuItem MenuItem"
id="1_menuitem"
onClick={[Function]}
role="menuitem"
>
<div
className=""
id="1"
onClick={[Function]}
onKeyDown={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
tabIndex={0}
>
<div
className="flex"
>
test
<span
className="selected"
/>
<span
aria-label="submenu icon"
className="fa fa-angle-right SubMenu__icon-right"
id="channelHeaderDropdownIconRight_1"
/>
</div>
<ul
className="a11y__popup Menu dropdown-menu SubMenu"
style={
Object {
"right": "100%",
"top": "unset",
"visibility": "hidden",
}
}
>
<span
className="SubMenuItemContainer"
key="A"
tabIndex={0}
>
<SubMenuItem
direction="left"
id="A"
renderSelected={true}
root={false}
show={true}
subMenuClass="pl-4"
tabIndex={1}
text="Test A"
>
<li
className="SubMenuItem MenuItem"
id="A_menuitem"
onClick={[Function]}
role="menuitem"
>
<div
className=""
id="A"
onClick={[Function]}
onKeyDown={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
tabIndex={1}
>
<div
className="flex"
>
Test A
<span
className="selected"
/>
<span
aria-label="submenu icon"
className="fa fa-angle-right SubMenu__icon-right-empty"
id="channelHeaderDropdownIconRight_A"
/>
</div>
<ul
className="a11y__popup Menu dropdown-menu SubMenu"
style={
Object {
"right": "100%",
"top": "unset",
"visibility": "hidden",
}
}
/>
</div>
</li>
</SubMenuItem>
</span>
<span
className="SubMenuItemContainer"
key="B"
tabIndex={0}
>
<SubMenuItem
direction="left"
id="B"
renderSelected={true}
root={false}
show={true}
subMenuClass="pl-4"
tabIndex={1}
text="Test B"
>
<li
className="SubMenuItem MenuItem"
id="B_menuitem"
onClick={[Function]}
role="menuitem"
>
<div
className=""
id="B"
onClick={[Function]}
onKeyDown={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
tabIndex={1}
>
<div
className="flex"
>
Test B
<span
className="selected"
/>
<span
aria-label="submenu icon"
className="fa fa-angle-right SubMenu__icon-right-empty"
id="channelHeaderDropdownIconRight_B"
/>
</div>
<ul
className="a11y__popup Menu dropdown-menu SubMenu"
style={
Object {
"right": "100%",
"top": "unset",
"visibility": "hidden",
}
}
/>
</div>
</li>
</SubMenuItem>
</span>
</ul>
</div>
</li>
</SubMenuItem>
`;
|
3,741 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_modals | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_modals/submenu_modal/submenu_modal.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow, mount} from 'enzyme';
import React from 'react';
import {Modal} from 'react-bootstrap';
import SubMenuModal from './submenu_modal';
jest.mock('../../is_mobile_view_hack', () => ({
isMobile: jest.fn(() => false),
}));
(global as any).MutationObserver = class {
public disconnect() {}
public observe() {}
};
describe('components/submenu_modal', () => {
const action1 = jest.fn().mockReturnValueOnce('default');
const action2 = jest.fn().mockReturnValueOnce('default');
const action3 = jest.fn().mockReturnValueOnce('default');
const baseProps = {
elements: [
{
id: 'A',
text: 'Text A',
action: action1,
direction: 'left' as any,
},
{
id: 'B',
text: 'Text B',
action: action2,
direction: 'left' as any,
subMenu: [
{
id: 'C',
text: 'Text C',
action: action3,
direction: 'left' as any,
},
],
},
],
onExited: jest.fn(),
};
test('should match snapshot', () => {
const wrapper = shallow(
<SubMenuModal {...baseProps}/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match state when onHide is called', () => {
const wrapper = shallow<SubMenuModal>(
<SubMenuModal {...baseProps}/>,
);
wrapper.setState({show: true});
wrapper.instance().onHide();
expect(wrapper.state('show')).toEqual(false);
});
test('should have called click function when button is clicked', async () => {
const props = {
...baseProps,
};
const wrapper = mount(
<SubMenuModal {...props}/>,
);
wrapper.setState({show: true});
await wrapper.find('#A').at(1).simulate('click');
expect(action1).toHaveBeenCalledTimes(1);
expect(wrapper.state('show')).toEqual(false);
wrapper.setState({show: true});
await wrapper.find('#B').at(1).simulate('click');
expect(action2).toHaveBeenCalledTimes(1);
expect(wrapper.state('show')).toEqual(false);
wrapper.setState({show: true});
await wrapper.find('#C').at(1).simulate('click');
expect(action3).toHaveBeenCalledTimes(1);
expect(wrapper.state('show')).toEqual(false);
});
test('should have called props.onExited when Modal.onExited is called', () => {
const wrapper = shallow(
<SubMenuModal {...baseProps}/>,
);
wrapper.find(Modal).props().onExited!(document.createElement('div'));
expect(baseProps.onExited).toHaveBeenCalledTimes(1);
});
});
|
3,743 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_modals/submenu_modal | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/menu/menu_modals/submenu_modal/__snapshots__/submenu_modal.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/submenu_modal should match snapshot 1`] = `
<Modal
animation={true}
autoFocus={true}
backdrop={true}
bsClass="modal"
dialogClassName="SubMenuModal a11y__modal mobile-sub-menu"
dialogComponentClass={[Function]}
enforceFocus={false}
id="submenuModal"
keyboard={true}
manager={
ModalManager {
"add": [Function],
"containers": Array [],
"data": Array [],
"handleContainerOverflow": true,
"hideSiblingNodes": true,
"isTopModal": [Function],
"modals": Array [],
"remove": [Function],
}
}
onExited={[MockFunction]}
onHide={[Function]}
renderBackdrop={[Function]}
restoreFocus={true}
role="dialog"
show={true}
>
<ModalBody
bsClass="modal-body"
componentClass="div"
onClick={[Function]}
>
<MenuWrapper
animationComponent={[Function]}
className=""
>
<Menu
ariaLabel="mobile submenu"
openLeft={true}
>
<SubMenuItem
action={[MockFunction]}
direction="left"
id="A"
key="A"
renderSelected={true}
root={false}
show={true}
subMenuClass="pl-4"
text="Text A"
/>
<SubMenuItem
action={[MockFunction]}
direction="left"
id="B"
key="B"
renderSelected={true}
root={false}
show={true}
subMenu={
Array [
Object {
"action": [MockFunction],
"direction": "left",
"id": "C",
"text": "Text C",
},
]
}
subMenuClass="pl-4"
text="Text B"
/>
</Menu>
<div />
</MenuWrapper>
</ModalBody>
</Modal>
`;
|
3,745 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/modals/full_screen_modal.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {shallowWithIntl} from 'tests/helpers/intl-test-helper';
import FullScreenModal from './full_screen_modal';
describe('components/widgets/modals/FullScreenModal', () => {
test('showing content', () => {
const wrapper = shallowWithIntl(
<FullScreenModal
show={true}
onClose={jest.fn()}
ariaLabel='test'
>
{'test'}
</FullScreenModal>,
);
expect(wrapper).toMatchInlineSnapshot(`
<CSSTransition
appear={true}
classNames="FullScreenModal"
in={true}
mountOnEnter={true}
timeout={100}
unmountOnExit={true}
>
<div
aria-label="test"
aria-modal={true}
className="FullScreenModal"
role="dialog"
tabIndex={-1}
>
<button
aria-label="Close"
className="close-x"
onClick={[Function]}
>
<CloseIcon
id="closeIcon"
/>
</button>
test
</div>
<div
style={
Object {
"display": "none",
}
}
tabIndex={0}
/>
</CSSTransition>
`);
});
test('not showing content', () => {
const wrapper = shallowWithIntl(
<FullScreenModal
show={false}
onClose={jest.fn()}
ariaLabel='test'
>
{'test'}
</FullScreenModal>,
);
expect(wrapper).toMatchInlineSnapshot(`
<CSSTransition
appear={true}
classNames="FullScreenModal"
in={false}
mountOnEnter={true}
timeout={100}
unmountOnExit={true}
>
<div
aria-label="test"
aria-modal={true}
className="FullScreenModal"
role="dialog"
tabIndex={-1}
>
<button
aria-label="Close"
className="close-x"
onClick={[Function]}
>
<CloseIcon
id="closeIcon"
/>
</button>
test
</div>
<div
style={
Object {
"display": "none",
}
}
tabIndex={0}
/>
</CSSTransition>
`);
});
test('with back icon', () => {
const wrapper = shallowWithIntl(
<FullScreenModal
show={true}
onClose={jest.fn()}
onGoBack={jest.fn()}
ariaLabel='test'
>
{'test'}
</FullScreenModal>,
);
expect(wrapper).toMatchInlineSnapshot(`
<CSSTransition
appear={true}
classNames="FullScreenModal"
in={true}
mountOnEnter={true}
timeout={100}
unmountOnExit={true}
>
<div
aria-label="test"
aria-modal={true}
className="FullScreenModal"
role="dialog"
tabIndex={-1}
>
<button
aria-label="Back"
className="back"
onClick={[MockFunction]}
>
<BackIcon
id="backIcon"
/>
</button>
<button
aria-label="Close"
className="close-x"
onClick={[Function]}
>
<CloseIcon
id="closeIcon"
/>
</button>
test
</div>
<div
style={
Object {
"display": "none",
}
}
tabIndex={0}
/>
</CSSTransition>
`);
});
test('close on close icon click', () => {
const close = jest.fn();
const wrapper = shallowWithIntl(
<FullScreenModal
show={true}
onClose={close}
ariaLabel='test'
>
{'test'}
</FullScreenModal>,
);
expect(close).not.toBeCalled();
wrapper.find('button.close-x').simulate('click');
expect(close).toBeCalled();
});
test('go back on back icon click', () => {
const back = jest.fn();
const wrapper = shallowWithIntl(
<FullScreenModal
show={true}
onClose={jest.fn()}
onGoBack={back}
ariaLabel='test'
>
{'test'}
</FullScreenModal>,
);
expect(back).not.toBeCalled();
wrapper.find('button.back').simulate('click');
expect(back).toBeCalled();
});
test('close on esc keypress', () => {
const close = jest.fn();
shallowWithIntl(
<FullScreenModal
show={true}
onClose={close}
ariaLabel='test'
>
{'test'}
</FullScreenModal>,
);
expect(close).not.toBeCalled();
const event = new KeyboardEvent('keydown', {key: 'Escape'});
document.dispatchEvent(event);
expect(close).toBeCalled();
});
});
|
3,761 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/popover/popover.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import Popover from '.';
describe('components/widgets/popover', () => {
test('plain', () => {
const wrapper = shallow(
<Popover id='test'>
{'Some text'}
</Popover>,
);
expect(wrapper).toMatchSnapshot();
});
});
|
3,762 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/popover | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/popover/__snapshots__/popover.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/popover plain 1`] = `
<Popover
bsClass="popover"
bsSize="small"
bsStyle="info"
id="test"
placement="right"
>
Some text
</Popover>
`;
|
3,769 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/separator/separator.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import BasicSeparator from './basic-separator';
import NotificationSeparator from './notification-separator';
describe('components/widgets/separator', () => {
test('date separator with text', () => {
const wrapper = shallow(
<BasicSeparator>
{'Some text'}
</BasicSeparator>,
);
expect(wrapper).toMatchSnapshot();
});
test('notification message separator without text', () => {
const wrapper = shallow(<NotificationSeparator/>);
expect(wrapper).toMatchSnapshot();
});
test('notification message separator with text', () => {
const wrapper = shallow(<NotificationSeparator>{'Some text'}</NotificationSeparator>);
expect(wrapper).toMatchSnapshot();
});
});
|
3,770 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/separator | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/separator/__snapshots__/separator.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/separator date separator with text 1`] = `
<div
className="Separator BasicSeparator"
data-testid="basicSeparator"
>
<hr
className="separator__hr"
/>
<div
className="separator__text"
>
Some text
</div>
</div>
`;
exports[`components/widgets/separator notification message separator with text 1`] = `
<div
className="Separator NotificationSeparator"
data-testid="NotificationSeparator"
>
<hr
className="separator__hr"
/>
<div
className="separator__text"
>
Some text
</div>
</div>
`;
exports[`components/widgets/separator notification message separator without text 1`] = `
<div
className="Separator NotificationSeparator"
data-testid="NotificationSeparator"
>
<hr
className="separator__hr"
/>
</div>
`;
|
3,771 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/settings/bool_setting.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import BoolSetting from './bool_setting';
describe('components/widgets/settings/BoolSetting', () => {
test('render component with required props', () => {
const wrapper = shallow(
<BoolSetting
id='string.id'
label='some label'
value={true}
placeholder='Text aligned with checkbox'
/>,
);
expect(wrapper).toMatchInlineSnapshot(`
<Setting
inputClassName=""
inputId="string.id"
label="some label"
labelClassName=""
>
<div
className="checkbox"
>
<label>
<input
checked={true}
id="string.id"
onChange={[Function]}
type="checkbox"
/>
<span>
Text aligned with checkbox
</span>
</label>
</div>
</Setting>
`);
});
test('onChange', () => {
const onChange = jest.fn();
const wrapper = shallow(
<BoolSetting
id='string.id'
label='some label'
value={true}
placeholder='Text aligned with checkbox'
onChange={onChange}
/>,
);
wrapper.find('input').simulate('change', {target: {checked: true}});
expect(onChange).toHaveBeenCalledTimes(1);
expect(onChange).toHaveBeenCalledWith('string.id', true);
});
});
|
3,773 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/settings/radio_setting.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import RadioSetting from './radio_setting';
describe('components/widgets/settings/RadioSetting', () => {
test('render component with required props', () => {
const onChange = jest.fn();
const wrapper = shallow(
<RadioSetting
id='string.id'
label='some label'
options={[
{text: 'this is engineering', value: 'Engineering'},
{text: 'this is sales', value: 'Sales'},
{text: 'this is administration', value: 'Administration'},
]}
value={'Sales'}
onChange={onChange}
/>,
);
expect(wrapper).toMatchInlineSnapshot(`
<Setting
inputClassName=""
inputId="string.id"
label="some label"
labelClassName=""
>
<div
className="radio"
key="Engineering"
>
<label>
<input
checked={false}
name="string.id"
onChange={[Function]}
type="radio"
value="Engineering"
/>
this is engineering
</label>
</div>
<div
className="radio"
key="Sales"
>
<label>
<input
checked={true}
name="string.id"
onChange={[Function]}
type="radio"
value="Sales"
/>
this is sales
</label>
</div>
<div
className="radio"
key="Administration"
>
<label>
<input
checked={false}
name="string.id"
onChange={[Function]}
type="radio"
value="Administration"
/>
this is administration
</label>
</div>
</Setting>
`);
});
test('onChange', () => {
const onChange = jest.fn();
const wrapper = shallow(
<RadioSetting
id='string.id'
label='some label'
options={[
{text: 'this is engineering', value: 'Engineering'},
{text: 'this is sales', value: 'Sales'},
{text: 'this is administration', value: 'Administration'},
]}
value={'Sales'}
onChange={onChange}
/>,
);
wrapper.find('input').at(0).simulate('change', {target: {value: 'Administration'}});
expect(onChange).toHaveBeenCalledTimes(1);
expect(onChange).toHaveBeenCalledWith('string.id', 'Administration');
});
});
|
3,776 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/settings/text_setting.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import TextSetting from './text_setting';
describe('components/widgets/settings/TextSetting', () => {
test('render component with required props', () => {
const onChange = jest.fn();
const wrapper = shallow(
<TextSetting
id='string.id'
label='some label'
value='some value'
onChange={onChange}
/>,
);
expect(wrapper).toMatchSnapshot();
});
test('render with textarea type', () => {
const onChange = jest.fn();
const wrapper = shallow(
<TextSetting
id='string.id'
label='some label'
value='some value'
type='textarea'
onChange={onChange}
/>,
);
expect(wrapper).toMatchSnapshot();
});
test('onChange', () => {
const onChange = jest.fn();
const wrapper = shallow(
<TextSetting
id='string.id'
label='some label'
value='some value'
onChange={onChange}
/>,
);
wrapper.find('input').simulate('change', {target: {value: 'somenewvalue'}});
expect(onChange).toHaveBeenCalledTimes(1);
expect(onChange).toHaveBeenCalledWith('string.id', 'somenewvalue');
});
});
|
3,778 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/settings | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/settings/__snapshots__/text_setting.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/settings/TextSetting render component with required props 1`] = `
<Setting
inputClassName=""
inputId="string.id"
label="some label"
labelClassName=""
>
<input
className="form-control"
data-testid="string.idinput"
id="string.id"
maxLength={-1}
onChange={[Function]}
type="text"
value="some value"
/>
</Setting>
`;
exports[`components/widgets/settings/TextSetting render with textarea type 1`] = `
<Setting
inputClassName=""
inputId="string.id"
label="some label"
labelClassName=""
>
<textarea
className="form-control"
data-testid="string.idinput"
dir="auto"
id="string.id"
maxLength={-1}
onChange={[Function]}
rows={5}
value="some value"
/>
</Setting>
`;
|
3,781 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/tag/beta_tag.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import BetaTag from './beta_tag';
describe('components/widgets/tag/BetaTag', () => {
test('should match the snapshot', () => {
const wrapper = shallow(<BetaTag className={'test'}/>);
expect(wrapper).toMatchSnapshot();
});
});
|
3,783 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/tag/bot_tag.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import BotTag from './bot_tag';
describe('components/widgets/tag/BotTag', () => {
test('should match the snapshot', () => {
const wrapper = shallow(<BotTag className={'test'}/>);
expect(wrapper).toMatchSnapshot();
});
});
|
3,785 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/tag/guest_tag.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {renderWithContext, screen} from 'tests/react_testing_utils';
import GuestTag from './guest_tag';
describe('components/widgets/tag/GuestTag', () => {
test('should match the snapshot', () => {
renderWithContext(<GuestTag className={'test'}/>);
screen.getByText('GUEST');
});
test('should not render when hideTags is true', () => {
renderWithContext(<GuestTag className={'test'}/>, {entities: {general: {config: {HideGuestTags: 'true'}}}});
expect(() => screen.getByText('GUEST')).toThrow();
});
});
|
3,787 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/tag/tag.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import {AlertCircleOutlineIcon} from '@mattermost/compass-icons/components';
import Tag from './tag';
const classNameProp = 'Tag Tag--xs test';
describe('components/widgets/tag/Tag', () => {
test('should match the snapshot on show', () => {
const wrapper = shallow(
<Tag
className={'test'}
text={'Test text'}
/>,
);
expect(wrapper.props()).toEqual(expect.objectContaining({className: classNameProp}));
expect(wrapper.text()).toEqual('Test text');
expect(wrapper).toMatchSnapshot();
});
test('should match the snapshot with icon', () => {
const wrapper = shallow(
<Tag
className={'test'}
text={'Test text'}
icon={'alert-circle-outline'}
/>,
);
expect(wrapper.props()).toEqual(expect.objectContaining({className: classNameProp}));
expect(wrapper.find(AlertCircleOutlineIcon).exists()).toEqual(true);
expect(wrapper.text()).toContain('Test text');
expect(wrapper).toMatchSnapshot();
});
test('should match the snapshot with uppercase prop', () => {
const wrapper = shallow(
<Tag
className={'test'}
text={'Test text'}
uppercase={true}
/>,
);
expect(wrapper.props()).toEqual(expect.objectContaining({className: classNameProp, uppercase: true}));
expect(wrapper.text()).toEqual('Test text');
expect(wrapper).toMatchSnapshot();
});
test('should match the snapshot with size "sm"', () => {
const wrapper = shallow(
<Tag
className={'test'}
text={'Test text'}
size={'sm'}
/>,
);
expect(wrapper.props()).toEqual(expect.objectContaining({className: 'Tag Tag--sm test'}));
expect(wrapper.text()).toEqual('Test text');
expect(wrapper).toMatchSnapshot();
});
test('should match the snapshot with "success" variant', () => {
const wrapper = shallow(
<Tag
className={'test'}
text={'Test text'}
variant={'success'}
/>,
);
expect(wrapper.props()).toEqual(expect.objectContaining({className: 'Tag Tag--success Tag--xs test'}));
expect(wrapper.text()).toEqual('Test text');
expect(wrapper).toMatchSnapshot();
});
test('should transform into a button if onClick provided', () => {
const click = jest.fn();
const wrapper = shallow(
<Tag
className={'test'}
text={'Test text'}
onClick={click}
/>,
);
expect(wrapper.props()).toEqual(expect.objectContaining({className: classNameProp, onClick: click}));
expect(wrapper.text()).toEqual('Test text');
wrapper.simulate('click');
expect(click).toBeCalled();
expect(wrapper).toMatchSnapshot();
});
});
|
3,789 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/tag | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/tag/__snapshots__/beta_tag.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/tag/BetaTag should match the snapshot 1`] = `
<Memo(Tag)
className="BetaTag test"
size="xs"
text="BETA"
uppercase={true}
variant="info"
/>
`;
|
3,790 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/tag | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/tag/__snapshots__/bot_tag.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/tag/BotTag should match the snapshot 1`] = `
<Memo(Tag)
className="BotTag test"
size="xs"
text="BOT"
uppercase={true}
/>
`;
|
3,791 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/tag | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/tag/__snapshots__/tag.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/tag/Tag should match the snapshot on show 1`] = `
<TagWrapper
as="div"
className="Tag Tag--xs test"
uppercase={false}
>
<TagText>
Test text
</TagText>
</TagWrapper>
`;
exports[`components/widgets/tag/Tag should match the snapshot with "success" variant 1`] = `
<TagWrapper
as="div"
className="Tag Tag--success Tag--xs test"
uppercase={false}
>
<TagText>
Test text
</TagText>
</TagWrapper>
`;
exports[`components/widgets/tag/Tag should match the snapshot with icon 1`] = `
<TagWrapper
as="div"
className="Tag Tag--xs test"
uppercase={false}
>
<AlertCircleOutlineIcon
size={10}
/>
<TagText>
Test text
</TagText>
</TagWrapper>
`;
exports[`components/widgets/tag/Tag should match the snapshot with size "sm" 1`] = `
<TagWrapper
as="div"
className="Tag Tag--sm test"
uppercase={false}
>
<TagText>
Test text
</TagText>
</TagWrapper>
`;
exports[`components/widgets/tag/Tag should match the snapshot with uppercase prop 1`] = `
<TagWrapper
as="div"
className="Tag Tag--xs test"
uppercase={true}
>
<TagText>
Test text
</TagText>
</TagWrapper>
`;
exports[`components/widgets/tag/Tag should transform into a button if onClick provided 1`] = `
<TagWrapper
as="button"
className="Tag Tag--xs test"
onClick={
[MockFunction] {
"calls": Array [
Array [],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
}
}
uppercase={false}
>
<TagText>
Test text
</TagText>
</TagWrapper>
`;
|
3,793 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/team_icon/team_icon.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {shallowWithIntl} from 'tests/helpers/intl-test-helper';
import TeamIcon from './team_icon';
describe('components/widgets/team-icon', () => {
test('basic icon', () => {
const wrapper = shallowWithIntl(
<TeamIcon content='test'/>,
);
expect(wrapper).toMatchSnapshot();
});
test('image icon', () => {
const wrapper = shallowWithIntl(
<TeamIcon
url='http://example.com/image.png'
content='test'
/>,
);
expect(wrapper).toMatchSnapshot();
});
test('small icon', () => {
const wrapper = shallowWithIntl(
<TeamIcon
content='test'
size='sm'
/>,
);
expect(wrapper).toMatchSnapshot();
});
test('icon with hover', () => {
const wrapper = shallowWithIntl(
<TeamIcon
content='test'
withHover={true}
/>,
);
expect(wrapper).toMatchSnapshot();
});
});
|
3,795 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/team_icon | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/team_icon/__snapshots__/team_icon.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/team-icon basic icon 1`] = `
<div
className="TeamIcon TeamIcon__sm no-hover"
>
<div
className="TeamIcon__content no-hover"
>
<div
aria-label="test Team Initials"
className="TeamIcon__initials TeamIcon__initials__sm"
data-testid="teamIconInitial"
role="img"
>
te
</div>
</div>
</div>
`;
exports[`components/widgets/team-icon icon with hover 1`] = `
<div
className="TeamIcon TeamIcon__sm"
>
<div
className="TeamIcon__content "
>
<div
aria-label="test Team Initials"
className="TeamIcon__initials TeamIcon__initials__sm"
data-testid="teamIconInitial"
role="img"
>
te
</div>
</div>
</div>
`;
exports[`components/widgets/team-icon image icon 1`] = `
<div
className="TeamIcon TeamIcon__sm withImage no-hover"
>
<div
className="TeamIcon__content no-hover"
>
<div
aria-label="test Team Image"
className="TeamIcon__image TeamIcon__sm"
data-testid="teamIconImage"
role="img"
style={
Object {
"backgroundImage": "url('http://example.com/image.png')",
}
}
/>
</div>
</div>
`;
exports[`components/widgets/team-icon small icon 1`] = `
<div
className="TeamIcon TeamIcon__sm no-hover"
>
<div
className="TeamIcon__content no-hover"
>
<div
aria-label="test Team Initials"
className="TeamIcon__initials TeamIcon__initials__sm"
data-testid="teamIconInitial"
role="img"
>
te
</div>
</div>
</div>
`;
|
3,797 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/users | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/users/avatar/avatar.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import Avatar from './avatar';
describe('components/widgets/users/Avatar', () => {
test('should match the snapshot', () => {
const wrapper = shallow(
<Avatar
url='test-url'
username='test-username'
size='xl'
/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match the snapshot only with url', () => {
const wrapper = shallow(
<Avatar url='test-url'/>,
);
expect(wrapper).toMatchSnapshot();
});
test('should match the snapshot only plain text', () => {
const wrapper = shallow(
<Avatar text='SA'/>,
);
expect(wrapper).toMatchSnapshot();
});
});
|
3,800 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/users/avatar | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/users/avatar/__snapshots__/avatar.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/users/Avatar should match the snapshot 1`] = `
<img
alt="test-username profile image"
className="Avatar Avatar-xl"
loading="lazy"
onError={[Function]}
src="test-url"
tabIndex={0}
/>
`;
exports[`components/widgets/users/Avatar should match the snapshot only plain text 1`] = `
<div
className="Avatar Avatar-md Avatar-plain"
data-content="SA"
/>
`;
exports[`components/widgets/users/Avatar should match the snapshot only with url 1`] = `
<img
alt="user profile image"
className="Avatar Avatar-md"
loading="lazy"
onError={[Function]}
src="test-url"
tabIndex={0}
/>
`;
|
3,802 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/users | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/users/avatars/avatars.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {mount} from 'enzyme';
import React from 'react';
jest.mock('mattermost-redux/actions/users', () => {
return {
...jest.requireActual('mattermost-redux/actions/users'),
getMissingProfilesByIds: jest.fn((ids) => {
return {
type: 'MOCK_GET_MISSING_PROFILES_BY_IDS',
data: ids,
};
}),
};
});
import SimpleTooltip from 'components/widgets/simple_tooltip';
import {mockStore} from 'tests/test_store';
import Avatars from './avatars';
import Avatar from '../avatar';
describe('components/widgets/users/Avatars', () => {
const state = {
entities: {
general: {
config: {},
},
users: {
currentUserId: 'uid',
profiles: {
1: {
id: '1',
username: 'first.last1',
nickname: 'nickname1',
first_name: 'First1',
last_name: 'Last1',
last_picture_update: '1620680333191',
},
2: {
id: '2',
username: 'first.last2',
nickname: 'nickname2',
first_name: 'First2',
last_name: 'Last2',
last_picture_update: '1620680333191',
},
3: {
id: '3',
username: 'first.last3',
nickname: 'nickname3',
first_name: 'First3',
last_name: 'Last3',
last_picture_update: '1620680333191',
},
4: {
id: '4',
username: 'first.last4',
nickname: 'nickname4',
first_name: 'First4',
last_name: 'Last4',
last_picture_update: '1620680333191',
},
5: {
id: '5',
username: 'first.last5',
nickname: 'nickname5',
first_name: 'First5',
last_name: 'Last5',
last_picture_update: '1620680333191',
},
},
},
teams: {
currentTeamId: 'tid',
},
preferences: {
myPreferences: {},
},
},
};
test('should support userIds', () => {
const {mountOptions} = mockStore(state);
const wrapper = mount(
<Avatars
size='xl'
userIds={[
'1',
'2',
'3',
]}
/>,
mountOptions,
);
expect(wrapper).toMatchSnapshot();
expect(wrapper.find(Avatar).find({url: '/api/v4/users/1/image?_=1620680333191'}).exists()).toBe(true);
expect(wrapper.find(Avatar).find({url: '/api/v4/users/2/image?_=1620680333191'}).exists()).toBe(true);
expect(wrapper.find(Avatar).find({url: '/api/v4/users/3/image?_=1620680333191'}).exists()).toBe(true);
expect(wrapper.find(Avatar).length).toBe(3);
});
test('should properly count overflow', () => {
const {mountOptions} = mockStore(state);
const wrapper = mount(
<Avatars
size='xl'
userIds={[
'1',
'2',
'3',
'4',
'5',
]}
/>,
mountOptions,
);
expect(wrapper).toMatchSnapshot();
expect(wrapper.find(Avatar).find({url: '/api/v4/users/1/image?_=1620680333191'}).exists()).toBe(true);
expect(wrapper.find(Avatar).find({url: '/api/v4/users/2/image?_=1620680333191'}).exists()).toBe(true);
expect(wrapper.find(Avatar).find({url: '/api/v4/users/3/image?_=1620680333191'}).exists()).toBe(true);
expect(wrapper.find(Avatar).find({url: '/api/v4/users/4/image?_=1620680333191'}).exists()).toBe(false);
expect(wrapper.find(Avatar).find({url: '/api/v4/users/5/image?_=1620680333191'}).exists()).toBe(false);
expect(wrapper.find(Avatar).find({text: '+2'}).exists()).toBe(true);
});
test('should not duplicate displayed users in overflow tooltip', () => {
const {mountOptions} = mockStore(state);
const wrapper = mount(
<Avatars
size='xl'
userIds={[
'1',
'2',
'3',
'4',
'5',
]}
/>,
mountOptions,
);
expect(wrapper.find(SimpleTooltip).find({id: 'names-overflow'}).prop('content')).toBe('first.last4, first.last5');
});
test('should fetch missing users', () => {
const {store, mountOptions} = mockStore(state);
const wrapper = mount(
<Avatars
size='xl'
userIds={[
'1',
'6',
'7',
'2',
'8',
'9',
]}
/>,
mountOptions,
);
expect(wrapper).toMatchSnapshot();
expect(store.getActions()).toEqual([
{type: 'MOCK_GET_MISSING_PROFILES_BY_IDS', data: ['1', '6', '7', '2', '8', '9']},
]);
expect(wrapper.find(Avatar).find({url: '/api/v4/users/1/image?_=1620680333191'}).exists()).toBe(true);
expect(wrapper.find(Avatar).find({url: '/api/v4/users/6/image?_=0'}).exists()).toBe(true);
expect(wrapper.find(Avatar).find({url: '/api/v4/users/7/image?_=0'}).exists()).toBe(true);
expect(wrapper.find(SimpleTooltip).find({id: 'names-overflow'}).prop('content')).toBe('first.last2, Someone, Someone');
});
});
|
3,805 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/users/avatars | petrpan-code/mattermost/mattermost/webapp/channels/src/components/widgets/users/avatars/__snapshots__/avatars.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/widgets/users/Avatars should fetch missing users 1`] = `
<Memo(Avatars)
size="xl"
userIds={
Array [
"1",
"6",
"7",
"2",
"8",
"9",
]
}
>
<div
className="Avatars Avatars___xl"
onMouseLeave={[Function]}
>
<UserAvatar
disableProfileOverlay={false}
key="1"
overlayProps={
Object {
"animation": true,
"delayShow": undefined,
"onEntered": [Function],
}
}
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
userId="1"
>
<OverlayTrigger
defaultOverlayShown={false}
disabled={false}
overlay={
<Memo(Connect(injectIntl(ProfilePopover)))
className="user-profile-popover"
hide={[Function]}
src="/api/v4/users/1/image?_=0"
userId="1"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<OverlayTrigger
defaultOverlayShown={false}
overlay={
<OverlayWrapper
className="user-profile-popover"
hide={[Function]}
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
src="/api/v4/users/1/image?_=0"
userId="1"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<SimpleTooltip
animation={true}
content="first.last1"
id="name-1"
onClick={[Function]}
onEntered={[Function]}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<Tooltip
className="hidden-xs"
id="name-1"
placement="top"
>
first.last1
</Tooltip>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<OverlayWrapper
className="hidden-xs"
id="name-1"
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
placement="top"
>
first.last1
</OverlayWrapper>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<RoundButton
className="style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<button
className="RoundButton-dvlhqG gHOQXq style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<Memo(Avatar)
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
url="/api/v4/users/1/image?_=1620680333191"
>
<img
alt="user profile image"
className="Avatar Avatar-xl"
loading="lazy"
onError={[Function]}
src="/api/v4/users/1/image?_=1620680333191"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
/>
</Memo(Avatar)>
</button>
</RoundButton>
</OverlayTrigger>
</OverlayTrigger>
</SimpleTooltip>
</OverlayTrigger>
</OverlayTrigger>
</UserAvatar>
<UserAvatar
disableProfileOverlay={false}
key="6"
overlayProps={
Object {
"animation": true,
"delayShow": undefined,
"onEntered": [Function],
}
}
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
userId="6"
>
<OverlayTrigger
defaultOverlayShown={false}
disabled={false}
overlay={
<Memo(Connect(injectIntl(ProfilePopover)))
className="user-profile-popover"
hide={[Function]}
src="/api/v4/users/6/image?_=0"
userId="6"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<OverlayTrigger
defaultOverlayShown={false}
overlay={
<OverlayWrapper
className="user-profile-popover"
hide={[Function]}
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
src="/api/v4/users/6/image?_=0"
userId="6"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<SimpleTooltip
animation={true}
content="Someone"
id="name-6"
onClick={[Function]}
onEntered={[Function]}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<Tooltip
className="hidden-xs"
id="name-6"
placement="top"
>
Someone
</Tooltip>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<OverlayWrapper
className="hidden-xs"
id="name-6"
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
placement="top"
>
Someone
</OverlayWrapper>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<RoundButton
className="style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<button
className="RoundButton-dvlhqG gHOQXq style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<Memo(Avatar)
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
url="/api/v4/users/6/image?_=0"
>
<img
alt="user profile image"
className="Avatar Avatar-xl"
loading="lazy"
onError={[Function]}
src="/api/v4/users/6/image?_=0"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
/>
</Memo(Avatar)>
</button>
</RoundButton>
</OverlayTrigger>
</OverlayTrigger>
</SimpleTooltip>
</OverlayTrigger>
</OverlayTrigger>
</UserAvatar>
<UserAvatar
disableProfileOverlay={false}
key="7"
overlayProps={
Object {
"animation": true,
"delayShow": undefined,
"onEntered": [Function],
}
}
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
userId="7"
>
<OverlayTrigger
defaultOverlayShown={false}
disabled={false}
overlay={
<Memo(Connect(injectIntl(ProfilePopover)))
className="user-profile-popover"
hide={[Function]}
src="/api/v4/users/7/image?_=0"
userId="7"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<OverlayTrigger
defaultOverlayShown={false}
overlay={
<OverlayWrapper
className="user-profile-popover"
hide={[Function]}
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
src="/api/v4/users/7/image?_=0"
userId="7"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<SimpleTooltip
animation={true}
content="Someone"
id="name-7"
onClick={[Function]}
onEntered={[Function]}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<Tooltip
className="hidden-xs"
id="name-7"
placement="top"
>
Someone
</Tooltip>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<OverlayWrapper
className="hidden-xs"
id="name-7"
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
placement="top"
>
Someone
</OverlayWrapper>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<RoundButton
className="style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<button
className="RoundButton-dvlhqG gHOQXq style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<Memo(Avatar)
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
url="/api/v4/users/7/image?_=0"
>
<img
alt="user profile image"
className="Avatar Avatar-xl"
loading="lazy"
onError={[Function]}
src="/api/v4/users/7/image?_=0"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
/>
</Memo(Avatar)>
</button>
</RoundButton>
</OverlayTrigger>
</OverlayTrigger>
</SimpleTooltip>
</OverlayTrigger>
</OverlayTrigger>
</UserAvatar>
<SimpleTooltip
animation={true}
content="first.last2, Someone, Someone"
id="names-overflow"
onEntered={[Function]}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onEntered={[Function]}
overlay={
<Tooltip
className="hidden-xs"
id="names-overflow"
placement="top"
>
first.last2, Someone, Someone
</Tooltip>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onEntered={[Function]}
overlay={
<OverlayWrapper
className="hidden-xs"
id="names-overflow"
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
placement="top"
>
first.last2, Someone, Someone
</OverlayWrapper>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<Memo(Avatar)
onBlur={[Function]}
onClick={null}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={0}
text="+3"
>
<div
className="Avatar Avatar-xl Avatar-plain"
data-content="+3"
onBlur={[Function]}
onClick={null}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={0}
/>
</Memo(Avatar)>
</OverlayTrigger>
</OverlayTrigger>
</SimpleTooltip>
</div>
</Memo(Avatars)>
`;
exports[`components/widgets/users/Avatars should properly count overflow 1`] = `
<Memo(Avatars)
size="xl"
userIds={
Array [
"1",
"2",
"3",
"4",
"5",
]
}
>
<div
className="Avatars Avatars___xl"
onMouseLeave={[Function]}
>
<UserAvatar
disableProfileOverlay={false}
key="1"
overlayProps={
Object {
"animation": true,
"delayShow": undefined,
"onEntered": [Function],
}
}
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
userId="1"
>
<OverlayTrigger
defaultOverlayShown={false}
disabled={false}
overlay={
<Memo(Connect(injectIntl(ProfilePopover)))
className="user-profile-popover"
hide={[Function]}
src="/api/v4/users/1/image?_=0"
userId="1"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<OverlayTrigger
defaultOverlayShown={false}
overlay={
<OverlayWrapper
className="user-profile-popover"
hide={[Function]}
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
src="/api/v4/users/1/image?_=0"
userId="1"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<SimpleTooltip
animation={true}
content="first.last1"
id="name-1"
onClick={[Function]}
onEntered={[Function]}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<Tooltip
className="hidden-xs"
id="name-1"
placement="top"
>
first.last1
</Tooltip>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<OverlayWrapper
className="hidden-xs"
id="name-1"
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
placement="top"
>
first.last1
</OverlayWrapper>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<RoundButton
className="style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<button
className="RoundButton-dvlhqG gHOQXq style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<Memo(Avatar)
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
url="/api/v4/users/1/image?_=1620680333191"
>
<img
alt="user profile image"
className="Avatar Avatar-xl"
loading="lazy"
onError={[Function]}
src="/api/v4/users/1/image?_=1620680333191"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
/>
</Memo(Avatar)>
</button>
</RoundButton>
</OverlayTrigger>
</OverlayTrigger>
</SimpleTooltip>
</OverlayTrigger>
</OverlayTrigger>
</UserAvatar>
<UserAvatar
disableProfileOverlay={false}
key="2"
overlayProps={
Object {
"animation": true,
"delayShow": undefined,
"onEntered": [Function],
}
}
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
userId="2"
>
<OverlayTrigger
defaultOverlayShown={false}
disabled={false}
overlay={
<Memo(Connect(injectIntl(ProfilePopover)))
className="user-profile-popover"
hide={[Function]}
src="/api/v4/users/2/image?_=0"
userId="2"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<OverlayTrigger
defaultOverlayShown={false}
overlay={
<OverlayWrapper
className="user-profile-popover"
hide={[Function]}
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
src="/api/v4/users/2/image?_=0"
userId="2"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<SimpleTooltip
animation={true}
content="first.last2"
id="name-2"
onClick={[Function]}
onEntered={[Function]}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<Tooltip
className="hidden-xs"
id="name-2"
placement="top"
>
first.last2
</Tooltip>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<OverlayWrapper
className="hidden-xs"
id="name-2"
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
placement="top"
>
first.last2
</OverlayWrapper>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<RoundButton
className="style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<button
className="RoundButton-dvlhqG gHOQXq style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<Memo(Avatar)
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
url="/api/v4/users/2/image?_=1620680333191"
>
<img
alt="user profile image"
className="Avatar Avatar-xl"
loading="lazy"
onError={[Function]}
src="/api/v4/users/2/image?_=1620680333191"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
/>
</Memo(Avatar)>
</button>
</RoundButton>
</OverlayTrigger>
</OverlayTrigger>
</SimpleTooltip>
</OverlayTrigger>
</OverlayTrigger>
</UserAvatar>
<UserAvatar
disableProfileOverlay={false}
key="3"
overlayProps={
Object {
"animation": true,
"delayShow": undefined,
"onEntered": [Function],
}
}
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
userId="3"
>
<OverlayTrigger
defaultOverlayShown={false}
disabled={false}
overlay={
<Memo(Connect(injectIntl(ProfilePopover)))
className="user-profile-popover"
hide={[Function]}
src="/api/v4/users/3/image?_=0"
userId="3"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<OverlayTrigger
defaultOverlayShown={false}
overlay={
<OverlayWrapper
className="user-profile-popover"
hide={[Function]}
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
src="/api/v4/users/3/image?_=0"
userId="3"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<SimpleTooltip
animation={true}
content="first.last3"
id="name-3"
onClick={[Function]}
onEntered={[Function]}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<Tooltip
className="hidden-xs"
id="name-3"
placement="top"
>
first.last3
</Tooltip>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<OverlayWrapper
className="hidden-xs"
id="name-3"
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
placement="top"
>
first.last3
</OverlayWrapper>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<RoundButton
className="style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<button
className="RoundButton-dvlhqG gHOQXq style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<Memo(Avatar)
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
url="/api/v4/users/3/image?_=1620680333191"
>
<img
alt="user profile image"
className="Avatar Avatar-xl"
loading="lazy"
onError={[Function]}
src="/api/v4/users/3/image?_=1620680333191"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
/>
</Memo(Avatar)>
</button>
</RoundButton>
</OverlayTrigger>
</OverlayTrigger>
</SimpleTooltip>
</OverlayTrigger>
</OverlayTrigger>
</UserAvatar>
<SimpleTooltip
animation={true}
content="first.last4, first.last5"
id="names-overflow"
onEntered={[Function]}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onEntered={[Function]}
overlay={
<Tooltip
className="hidden-xs"
id="names-overflow"
placement="top"
>
first.last4, first.last5
</Tooltip>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onEntered={[Function]}
overlay={
<OverlayWrapper
className="hidden-xs"
id="names-overflow"
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
placement="top"
>
first.last4, first.last5
</OverlayWrapper>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<Memo(Avatar)
onBlur={[Function]}
onClick={null}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={0}
text="+2"
>
<div
className="Avatar Avatar-xl Avatar-plain"
data-content="+2"
onBlur={[Function]}
onClick={null}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={0}
/>
</Memo(Avatar)>
</OverlayTrigger>
</OverlayTrigger>
</SimpleTooltip>
</div>
</Memo(Avatars)>
`;
exports[`components/widgets/users/Avatars should support userIds 1`] = `
<Memo(Avatars)
size="xl"
userIds={
Array [
"1",
"2",
"3",
]
}
>
<div
className="Avatars Avatars___xl"
onMouseLeave={[Function]}
>
<UserAvatar
disableProfileOverlay={false}
key="1"
overlayProps={
Object {
"animation": true,
"delayShow": undefined,
"onEntered": [Function],
}
}
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
userId="1"
>
<OverlayTrigger
defaultOverlayShown={false}
disabled={false}
overlay={
<Memo(Connect(injectIntl(ProfilePopover)))
className="user-profile-popover"
hide={[Function]}
src="/api/v4/users/1/image?_=0"
userId="1"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<OverlayTrigger
defaultOverlayShown={false}
overlay={
<OverlayWrapper
className="user-profile-popover"
hide={[Function]}
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
src="/api/v4/users/1/image?_=0"
userId="1"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<SimpleTooltip
animation={true}
content="first.last1"
id="name-1"
onClick={[Function]}
onEntered={[Function]}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<Tooltip
className="hidden-xs"
id="name-1"
placement="top"
>
first.last1
</Tooltip>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<OverlayWrapper
className="hidden-xs"
id="name-1"
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
placement="top"
>
first.last1
</OverlayWrapper>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<RoundButton
className="style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<button
className="RoundButton-dvlhqG gHOQXq style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<Memo(Avatar)
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
url="/api/v4/users/1/image?_=1620680333191"
>
<img
alt="user profile image"
className="Avatar Avatar-xl"
loading="lazy"
onError={[Function]}
src="/api/v4/users/1/image?_=1620680333191"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
/>
</Memo(Avatar)>
</button>
</RoundButton>
</OverlayTrigger>
</OverlayTrigger>
</SimpleTooltip>
</OverlayTrigger>
</OverlayTrigger>
</UserAvatar>
<UserAvatar
disableProfileOverlay={false}
key="2"
overlayProps={
Object {
"animation": true,
"delayShow": undefined,
"onEntered": [Function],
}
}
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
userId="2"
>
<OverlayTrigger
defaultOverlayShown={false}
disabled={false}
overlay={
<Memo(Connect(injectIntl(ProfilePopover)))
className="user-profile-popover"
hide={[Function]}
src="/api/v4/users/2/image?_=0"
userId="2"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<OverlayTrigger
defaultOverlayShown={false}
overlay={
<OverlayWrapper
className="user-profile-popover"
hide={[Function]}
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
src="/api/v4/users/2/image?_=0"
userId="2"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<SimpleTooltip
animation={true}
content="first.last2"
id="name-2"
onClick={[Function]}
onEntered={[Function]}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<Tooltip
className="hidden-xs"
id="name-2"
placement="top"
>
first.last2
</Tooltip>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<OverlayWrapper
className="hidden-xs"
id="name-2"
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
placement="top"
>
first.last2
</OverlayWrapper>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<RoundButton
className="style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<button
className="RoundButton-dvlhqG gHOQXq style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<Memo(Avatar)
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
url="/api/v4/users/2/image?_=1620680333191"
>
<img
alt="user profile image"
className="Avatar Avatar-xl"
loading="lazy"
onError={[Function]}
src="/api/v4/users/2/image?_=1620680333191"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
/>
</Memo(Avatar)>
</button>
</RoundButton>
</OverlayTrigger>
</OverlayTrigger>
</SimpleTooltip>
</OverlayTrigger>
</OverlayTrigger>
</UserAvatar>
<UserAvatar
disableProfileOverlay={false}
key="3"
overlayProps={
Object {
"animation": true,
"delayShow": undefined,
"onEntered": [Function],
}
}
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
userId="3"
>
<OverlayTrigger
defaultOverlayShown={false}
disabled={false}
overlay={
<Memo(Connect(injectIntl(ProfilePopover)))
className="user-profile-popover"
hide={[Function]}
src="/api/v4/users/3/image?_=0"
userId="3"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<OverlayTrigger
defaultOverlayShown={false}
overlay={
<OverlayWrapper
className="user-profile-popover"
hide={[Function]}
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
src="/api/v4/users/3/image?_=0"
userId="3"
/>
}
placement="right"
rootClose={true}
trigger="click"
>
<SimpleTooltip
animation={true}
content="first.last3"
id="name-3"
onClick={[Function]}
onEntered={[Function]}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<Tooltip
className="hidden-xs"
id="name-3"
placement="top"
>
first.last3
</Tooltip>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<OverlayTrigger
animation={true}
defaultOverlayShown={false}
delayShow={500}
onClick={[Function]}
onEntered={[Function]}
overlay={
<OverlayWrapper
className="hidden-xs"
id="name-3"
intl={
Object {
"$t": [Function],
"defaultFormats": Object {},
"defaultLocale": "en",
"defaultRichTextElements": undefined,
"fallbackOnEmptyString": true,
"formatDate": [Function],
"formatDateTimeRange": [Function],
"formatDateToParts": [Function],
"formatDisplayName": [Function],
"formatList": [Function],
"formatListToParts": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatNumberToParts": [Function],
"formatPlural": [Function],
"formatRelativeTime": [Function],
"formatTime": [Function],
"formatTimeToParts": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getDisplayNames": [Function],
"getListFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralRules": [Function],
"getRelativeTimeFormat": [Function],
},
"locale": "en",
"messages": Object {},
"onError": [Function],
"onWarn": [Function],
"textComponent": "span",
"timeZone": "Etc/UTC",
"wrapRichTextChunksInFragment": undefined,
}
}
placement="top"
>
first.last3
</OverlayWrapper>
}
placement="top"
trigger={
Array [
"hover",
"focus",
]
}
>
<RoundButton
className="style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<button
className="RoundButton-dvlhqG gHOQXq style--none"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseOut={[Function]}
onMouseOver={[Function]}
>
<Memo(Avatar)
size="xl"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
url="/api/v4/users/3/image?_=1620680333191"
>
<img
alt="user profile image"
className="Avatar Avatar-xl"
loading="lazy"
onError={[Function]}
src="/api/v4/users/3/image?_=1620680333191"
style={
Object {
"background": "rgb(240, 240, 241)",
}
}
tabIndex={-1}
/>
</Memo(Avatar)>
</button>
</RoundButton>
</OverlayTrigger>
</OverlayTrigger>
</SimpleTooltip>
</OverlayTrigger>
</OverlayTrigger>
</UserAvatar>
</div>
</Memo(Avatars)>
`;
|
3,808 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components | petrpan-code/mattermost/mattermost/webapp/channels/src/components/youtube_video/youtube_video.test.tsx | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {mount, shallow} from 'enzyme';
import React from 'react';
import {Provider} from 'react-redux';
import type {DeepPartial} from 'redux';
import ExternalImage from 'components/external_image';
import mockStore from 'tests/test_store';
import type {GlobalState} from 'types/store';
import YoutubeVideo from './youtube_video';
jest.mock('actions/integration_actions');
describe('YoutubeVideo', () => {
const baseProps = {
postId: 'post_id_1',
googleDeveloperKey: 'googledevkey',
hasImageProxy: false,
link: 'https://www.youtube.com/watch?v=xqCoNej8Zxo',
show: true,
metadata: {
title: 'Youtube title',
images: [{
secure_url: 'linkForThumbnail',
url: 'linkForThumbnail',
}],
},
};
const initialState: DeepPartial<GlobalState> = {
entities: {
general: {
config: {},
license: {
Cloud: 'true',
},
},
users: {
currentUserId: 'currentUserId',
},
},
};
test('should match init snapshot', () => {
const store = mockStore(initialState);
const wrapper = mount(
<Provider store={store}>
<YoutubeVideo {...baseProps}/>
</Provider>,
);
expect(wrapper).toMatchSnapshot();
expect(wrapper.find(ExternalImage).prop('src')).toEqual('linkForThumbnail');
expect(wrapper.find('a').text()).toEqual('Youtube title');
});
test('should match snapshot for playing state', () => {
const wrapper = shallow(<YoutubeVideo {...baseProps}/>);
wrapper.setState({playing: true});
expect(wrapper).toMatchSnapshot();
});
test('should use url if secure_url is not present', () => {
const props = {
...baseProps,
metadata: {
title: 'Youtube title',
images: [{
url: 'linkUrl',
}],
},
};
const wrapper = shallow(<YoutubeVideo {...props}/>);
expect(wrapper.find(ExternalImage).prop('src')).toEqual('linkUrl');
});
});
|
3,810 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/components/youtube_video | petrpan-code/mattermost/mattermost/webapp/channels/src/components/youtube_video/__snapshots__/youtube_video.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`YoutubeVideo should match init snapshot 1`] = `
<Provider
store={
Object {
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
}
}
>
<YoutubeVideo
googleDeveloperKey="googledevkey"
hasImageProxy={false}
link="https://www.youtube.com/watch?v=xqCoNej8Zxo"
metadata={
Object {
"images": Array [
Object {
"secure_url": "linkForThumbnail",
"url": "linkForThumbnail",
},
],
"title": "Youtube title",
}
}
postId="post_id_1"
show={true}
>
<div
className="post__embed-container"
>
<div>
<h4>
<span
className="video-type"
>
YouTube -
</span>
<span
className="video-title"
>
<ExternalLink
href="https://www.youtube.com/watch?v=xqCoNej8Zxo"
location="youtube_video"
>
<a
href="https://www.youtube.com/watch?v=xqCoNej8Zxo"
location="youtube_video"
onClick={[Function]}
rel="noopener noreferrer"
target="_blank"
>
Youtube title
</a>
</ExternalLink>
</span>
</h4>
<div
className="video-div embed-responsive-item"
onClick={[Function]}
>
<div
className="embed-responsive video-div__placeholder"
>
<div
className="video-thumbnail__container"
>
<Connect(Component)
src="linkForThumbnail"
>
<Memo(ExternalImage)
dispatch={[Function]}
enableSVGs={false}
hasImageProxy={false}
src="linkForThumbnail"
>
<img
alt="youtube video thumbnail"
className="video-thumbnail"
src="linkForThumbnail"
/>
</Memo(ExternalImage)>
</Connect(Component)>
<div
className="block"
>
<span
className="play-button"
>
<span />
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</YoutubeVideo>
</Provider>
`;
exports[`YoutubeVideo should match snapshot for playing state 1`] = `
<div
className="post__embed-container"
>
<div>
<h4>
<span
className="video-type"
>
YouTube -
</span>
<span
className="video-title"
>
<ExternalLink
href="https://www.youtube.com/watch?v=xqCoNej8Zxo"
location="youtube_video"
>
Youtube title
</ExternalLink>
</span>
</h4>
<div
className="video-div embed-responsive-item"
onClick={[Function]}
>
<iframe
allowFullScreen={true}
frameBorder="0"
height="360px"
src="https://www.youtube.com/embed/xqCoNej8Zxo?autoplay=1&autohide=1&border=0&wmode=opaque&fs=1&enablejsapi=1"
width="480px"
/>
</div>
</div>
</div>
`;
|
3,932 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/packages/mattermost-redux/src | petrpan-code/mattermost/mattermost/webapp/channels/src/packages/mattermost-redux/src/actions/admin.test.ts | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import fs from 'fs';
import nock from 'nock';
import type {CreateDataRetentionCustomPolicy} from '@mattermost/types/data_retention';
import * as Actions from 'mattermost-redux/actions/admin';
import {Client4} from 'mattermost-redux/client';
import type {ActionResult} from 'mattermost-redux/types/actions';
import TestHelper from '../../test/test_helper';
import configureStore from '../../test/test_store';
import {RequestStatus, Stats} from '../constants';
const OK_RESPONSE = {status: 'OK'};
const NO_GROUPS_RESPONSE = {count: 0, groups: []};
const samlIdpURL = 'http://idpurl';
const samlIdpDescriptorURL = 'http://idpdescriptorurl';
const samlIdpPublicCertificateText = 'MIIC4jCCAcqgAwIBAgIQE9soWni/eL9ChsWeJCEKNDANBgkqhkiG9w0BAQsFADAtMSswKQYDVQQDEyJBREZTIFNpZ25pbmcgLSBhZGZzLnBhcm5hc2FkZXYuY29tMB4XDTE2MDcwMTE1MDgwN1oXDTE3MDcwMTE1MDgwN1owLTErMCkGA1UEAxMiQURGUyBTaWduaW5nIC0gYWRmcy5wYXJuYXNhZGV2LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANDxoju4k5q4H6sQ5v4/4wQSgrE9+ybLnz6+HPdmGd9gAS0qVafy8P1FbciEe+cBkpConYAMdGcBjmEdFOu5OAjsBgov1GMIHaPy4SwEyfn/FDmYSjCUSm7s5pxouAMP5mRJLdApQNwGeNxQNuFCUu3aM6X29ba/twwyQVaKIf1U1HVOY2UEs/X7qKU4ECwTy3Nxt1gaMISTPwxRU+d5dHbbI+2GKqzTriJd4alMHqnbBNWuuIDggOYT/zaRnGl9DAW/F6XgloWdO6SROnXH056fTZs7O5nJ9en9F82r7NOq5rBr/KI+R9eUlJHhfr/FtCYRrnPfTuubRFF2XtmrFwECAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAhZwCiYNFO2BuLH1UWmqG9lN7Ns/GjRDOuTt0hOUPHYFy2Es5iqmEakRrnecTz5KJxrO7SguaVK+VvTtssWszFnB2kRWIF98B2yjEjXjJHO1UhqjcKwbZScmmTukWf6lqlz+5uqyqPS/rxcNsBgNIwsJCl0z44Y5XHgpgGs+DXQx39RMyAvlmPWUY5dELVxAiEzKkOXAGDeJ5wIqiT61rmPkQuGjUBb/DZiFFBYmbp7npjVOb5XBrLErndIrHYiTZuIhpwCS+J3LHAOIL3eKD4iUcyB/lZjF6py1E2h+xVbpxHF9ENKQjsLkDjzIdhP269Gh8YUoOxkG63TXq8n6a3A==';
describe('Actions.Admin', () => {
let store = configureStore();
beforeAll(() => {
TestHelper.initBasic(Client4);
});
beforeEach(() => {
store = configureStore();
nock.cleanAll();
});
afterAll(() => {
TestHelper.tearDown();
});
it('getPlainLogs', async () => {
nock(Client4.getBaseRoute()).
get('/logs').
query(true).
reply(200, [
'[2017/04/04 14:56:19 EDT] [INFO] Starting Server...',
'[2017/04/04 14:56:19 EDT] [INFO] Server is listening on :8065',
'[2017/04/04 15:01:48 EDT] [INFO] Stopping Server...',
'[2017/04/04 15:01:48 EDT] [INFO] Closing SqlStore',
]);
await Actions.getPlainLogs()(store.dispatch, store.getState);
const state = store.getState();
const logs = state.entities.admin.plainLogs;
expect(logs).toBeTruthy();
expect(Object.keys(logs).length > 0).toBeTruthy();
});
it('getAudits', async () => {
nock(Client4.getBaseRoute()).
get('/audits').
query(true).
reply(200, [
{
id: 'z6ghakhm5brsub66cjhz9yb9za',
create_at: 1491331476323,
user_id: 'ua7yqgjiq3dabc46ianp3yfgty',
action: '/api/v4/teams/o5pjxhkq8br8fj6xnidt7hm3ja',
extra_info: '',
ip_address: '127.0.0.1',
session_id: 'u3yb6bqe6fg15bu4stzyto8rgh',
},
]);
await Actions.getAudits()(store.dispatch, store.getState);
const state = store.getState();
const audits = state.entities.admin.audits;
expect(audits).toBeTruthy();
expect(Object.keys(audits).length > 0).toBeTruthy();
});
it('getConfig', async () => {
nock(Client4.getBaseRoute()).
get('/config').
reply(200, {
TeamSettings: {
SiteName: 'Mattermost',
},
});
nock(Client4.getBaseRoute()).
get('/terms_of_service').
reply(200, {
create_at: 1537976679426,
id: '1234',
text: 'Terms of Service',
user_id: '1',
});
await Actions.getConfig()(store.dispatch, store.getState);
const state = store.getState();
const config = state.entities.admin.config;
expect(config).toBeTruthy();
expect(config.TeamSettings).toBeTruthy();
expect(config.TeamSettings.SiteName === 'Mattermost').toBeTruthy();
});
it('updateConfig', async () => {
nock(Client4.getBaseRoute()).
get('/config').
reply(200, {
TeamSettings: {
SiteName: 'Mattermost',
},
});
const {data} = await Actions.getConfig()(store.dispatch, store.getState) as ActionResult;
const updated = JSON.parse(JSON.stringify(data));
const oldSiteName = updated.TeamSettings.SiteName;
const testSiteName = 'MattermostReduxTest';
updated.TeamSettings.SiteName = testSiteName;
nock(Client4.getBaseRoute()).
put('/config').
reply(200, updated);
await Actions.updateConfig(updated)(store.dispatch, store.getState);
let state = store.getState();
let config = state.entities.admin.config;
expect(config).toBeTruthy();
expect(config.TeamSettings).toBeTruthy();
expect(config.TeamSettings.SiteName === testSiteName).toBeTruthy();
updated.TeamSettings.SiteName = oldSiteName;
nock(Client4.getBaseRoute()).
put('/config').
reply(200, updated);
await Actions.updateConfig(updated)(store.dispatch, store.getState);
state = store.getState();
config = state.entities.admin.config;
expect(config).toBeTruthy();
expect(config.TeamSettings).toBeTruthy();
expect(config.TeamSettings.SiteName === oldSiteName).toBeTruthy();
});
it('reloadConfig', async () => {
nock(Client4.getBaseRoute()).
post('/config/reload').
reply(200, OK_RESPONSE);
await Actions.reloadConfig()(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('getEnvironmentConfig', async () => {
nock(Client4.getBaseRoute()).
get('/config/environment').
reply(200, {
ServiceSettings: {
SiteURL: true,
},
TeamSettings: {
SiteName: true,
},
});
await store.dispatch(Actions.getEnvironmentConfig());
const state = store.getState();
const config = state.entities.admin.environmentConfig;
expect(config).toBeTruthy();
expect(config.ServiceSettings).toBeTruthy();
expect(config.ServiceSettings.SiteURL).toBeTruthy();
expect(config.TeamSettings).toBeTruthy();
expect(config.TeamSettings.SiteName).toBeTruthy();
});
it('testEmail', async () => {
nock(Client4.getBaseRoute()).
get('/config').
reply(200, {});
const {data: config} = await Actions.getConfig()(store.dispatch, store.getState) as ActionResult;
nock(Client4.getBaseRoute()).
post('/email/test').
reply(200, OK_RESPONSE);
await Actions.testEmail(config)(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('testSiteURL', async () => {
nock(Client4.getBaseRoute()).
post('/site_url/test').
reply(200, OK_RESPONSE);
await Actions.testSiteURL('http://lo.cal')(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('testS3Connection', async () => {
nock(Client4.getBaseRoute()).
get('/config').
reply(200, {});
const {data: config} = await Actions.getConfig()(store.dispatch, store.getState) as ActionResult;
nock(Client4.getBaseRoute()).
post('/file/s3_test').
reply(200, OK_RESPONSE);
await Actions.testS3Connection(config)(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('invalidateCaches', async () => {
nock(Client4.getBaseRoute()).
post('/caches/invalidate').
reply(200, OK_RESPONSE);
await Actions.invalidateCaches()(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('recycleDatabase', async () => {
nock(Client4.getBaseRoute()).
post('/database/recycle').
reply(200, OK_RESPONSE);
await Actions.recycleDatabase()(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('createComplianceReport', async () => {
const job = {
desc: 'testjob',
emails: '[email protected]',
keywords: 'testkeyword',
start_at: 1457654400000,
end_at: 1458000000000,
};
nock(Client4.getBaseRoute()).
post('/compliance/reports').
reply(201, {
id: 'six4h67ja7ntdkek6g13dp3wka',
create_at: 1491399241953,
user_id: 'ua7yqgjiq3dabc46ianp3yfgty',
status: 'running',
count: 0,
desc: 'testjob',
type: 'adhoc',
start_at: 1457654400000,
end_at: 1458000000000,
keywords: 'testkeyword',
emails: '[email protected]',
});
const {data: created} = await Actions.createComplianceReport(job)(store.dispatch, store.getState) as ActionResult;
const state = store.getState();
const request = state.requests.admin.createCompliance;
if (request.status === RequestStatus.FAILURE) {
throw new Error('createComplianceReport request failed');
}
const reports = state.entities.admin.complianceReports;
expect(reports).toBeTruthy();
expect(reports[created.id]).toBeTruthy();
});
it('getComplianceReport', async () => {
const job = {
desc: 'testjob',
emails: '[email protected]',
keywords: 'testkeyword',
start_at: 1457654400000,
end_at: 1458000000000,
};
nock(Client4.getBaseRoute()).
post('/compliance/reports').
reply(201, {
id: 'six4h67ja7ntdkek6g13dp3wka',
create_at: 1491399241953,
user_id: 'ua7yqgjiq3dabc46ianp3yfgty',
status: 'running',
count: 0,
desc: 'testjob',
type: 'adhoc',
start_at: 1457654400000,
end_at: 1458000000000,
keywords: 'testkeyword',
emails: '[email protected]',
});
const {data: report} = await Actions.createComplianceReport(job)(store.dispatch, store.getState) as ActionResult;
nock(Client4.getBaseRoute()).
get(`/compliance/reports/${report.id}`).
reply(200, report);
await Actions.getComplianceReport(report.id)(store.dispatch, store.getState);
const state = store.getState();
const reports = state.entities.admin.complianceReports;
expect(reports).toBeTruthy();
expect(reports[report.id]).toBeTruthy();
});
it('getComplianceReports', async () => {
const job = {
desc: 'testjob',
emails: '[email protected]',
keywords: 'testkeyword',
start_at: 1457654400000,
end_at: 1458000000000,
};
nock(Client4.getBaseRoute()).
post('/compliance/reports').
reply(201, {
id: 'six4h67ja7ntdkek6g13dp3wka',
create_at: 1491399241953,
user_id: 'ua7yqgjiq3dabc46ianp3yfgty',
status: 'running',
count: 0,
desc: 'testjob',
type: 'adhoc',
start_at: 1457654400000,
end_at: 1458000000000,
keywords: 'testkeyword',
emails: '[email protected]',
});
const {data: report} = await Actions.createComplianceReport(job)(store.dispatch, store.getState) as ActionResult;
nock(Client4.getBaseRoute()).
get('/compliance/reports').
query(true).
reply(200, [report]);
await Actions.getComplianceReports()(store.dispatch, store.getState);
const state = store.getState();
const reports = state.entities.admin.complianceReports;
expect(reports).toBeTruthy();
expect(reports[report.id]).toBeTruthy();
});
it('uploadBrandImage', async () => {
const testImageData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/brand/image').
reply(200, OK_RESPONSE);
await Actions.uploadBrandImage(testImageData as any)(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('deleteBrandImage', async () => {
nock(Client4.getBaseRoute()).
delete('/brand/image').
reply(200, OK_RESPONSE);
await Actions.deleteBrandImage()(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('getClusterStatus', async () => {
nock(Client4.getBaseRoute()).
get('/cluster/status').
reply(200, [
{
id: 'someid',
version: 'someversion',
},
]);
await Actions.getClusterStatus()(store.dispatch, store.getState);
const state = store.getState();
const clusterInfo = state.entities.admin.clusterInfo;
expect(clusterInfo).toBeTruthy();
expect(clusterInfo.length === 1).toBeTruthy();
expect(clusterInfo[0].id === 'someid').toBeTruthy();
});
it('testLdap', async () => {
nock(Client4.getBaseRoute()).
post('/ldap/test').
reply(200, OK_RESPONSE);
await Actions.testLdap()(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('syncLdap', async () => {
nock(Client4.getBaseRoute()).
post('/ldap/sync').
reply(200, OK_RESPONSE);
await Actions.syncLdap()(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('getSamlCertificateStatus', async () => {
nock(Client4.getBaseRoute()).
get('/saml/certificate/status').
reply(200, {
public_certificate_file: true,
private_key_file: true,
idp_certificate_file: true,
});
await Actions.getSamlCertificateStatus()(store.dispatch, store.getState);
const state = store.getState();
const certStatus = state.entities.admin.samlCertStatus;
expect(certStatus).toBeTruthy();
expect(certStatus.idp_certificate_file).toBeTruthy();
expect(certStatus.private_key_file).toBeTruthy();
expect(certStatus.public_certificate_file).toBeTruthy();
});
it('uploadPublicSamlCertificate', async () => {
const testFileData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/saml/certificate/public').
reply(200, OK_RESPONSE);
await Actions.uploadPublicSamlCertificate(testFileData as any)(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('uploadPrivateSamlCertificate', async () => {
const testFileData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/saml/certificate/private').
reply(200, OK_RESPONSE);
await Actions.uploadPrivateSamlCertificate(testFileData as any)(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('uploadIdpSamlCertificate', async () => {
const testFileData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/saml/certificate/idp').
reply(200, OK_RESPONSE);
await Actions.uploadIdpSamlCertificate(testFileData as any)(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('removePublicSamlCertificate', async () => {
nock(Client4.getBaseRoute()).
delete('/saml/certificate/public').
reply(200, OK_RESPONSE);
await Actions.removePublicSamlCertificate()(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('removePrivateSamlCertificate', async () => {
nock(Client4.getBaseRoute()).
delete('/saml/certificate/private').
reply(200, OK_RESPONSE);
await Actions.removePrivateSamlCertificate()(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('removeIdpSamlCertificate', async () => {
nock(Client4.getBaseRoute()).
delete('/saml/certificate/idp').
reply(200, OK_RESPONSE);
await Actions.removeIdpSamlCertificate()(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('uploadPublicLdapCertificate', async () => {
const testFileData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/ldap/certificate/public').
reply(200, OK_RESPONSE);
await Actions.uploadPublicLdapCertificate(testFileData as any)(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('uploadPrivateLdapCertificate', async () => {
const testFileData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/ldap/certificate/private').
reply(200, OK_RESPONSE);
await Actions.uploadPrivateLdapCertificate(testFileData as any)(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('removePublicLdapCertificate', async () => {
nock(Client4.getBaseRoute()).
delete('/ldap/certificate/public').
reply(200, OK_RESPONSE);
await Actions.removePublicLdapCertificate()(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('removePrivateLdapCertificate', async () => {
nock(Client4.getBaseRoute()).
delete('/ldap/certificate/private').
reply(200, OK_RESPONSE);
await Actions.removePrivateLdapCertificate()(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('testElasticsearch', async () => {
nock(Client4.getBaseRoute()).
post('/elasticsearch/test').
reply(200, OK_RESPONSE);
await Actions.testElasticsearch({})(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('purgeElasticsearchIndexes', async () => {
nock(Client4.getBaseRoute()).
post('/elasticsearch/purge_indexes').
reply(200, OK_RESPONSE);
await Actions.purgeElasticsearchIndexes()(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('uploadLicense', async () => {
const testFileData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/license').
reply(200, OK_RESPONSE);
await Actions.uploadLicense(testFileData as any)(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('removeLicense', async () => {
nock(Client4.getBaseRoute()).
delete('/license').
reply(200, OK_RESPONSE);
await Actions.removeLicense()(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('getStandardAnalytics', async () => {
nock(Client4.getBaseRoute()).
get('/analytics/old').
query(true).
times(2).
reply(200, [{name: 'channel_open_count', value: 495}, {name: 'channel_private_count', value: 19}, {name: 'post_count', value: 2763}, {name: 'unique_user_count', value: 316}, {name: 'team_count', value: 159}, {name: 'total_websocket_connections', value: 1}, {name: 'total_master_db_connections', value: 8}, {name: 'total_read_db_connections', value: 0}, {name: 'daily_active_users', value: 22}, {name: 'monthly_active_users', value: 114}, {name: 'registered_users', value: 500}]);
await Actions.getStandardAnalytics()(store.dispatch, store.getState);
await Actions.getStandardAnalytics(TestHelper.basicTeam!.id)(store.dispatch, store.getState);
const state = store.getState();
const analytics = state.entities.admin.analytics;
expect(analytics).toBeTruthy();
expect(analytics[Stats.TOTAL_PUBLIC_CHANNELS] > 0).toBeTruthy();
const teamAnalytics = state.entities.admin.teamAnalytics;
expect(teamAnalytics).toBeTruthy();
expect(teamAnalytics[TestHelper.basicTeam!.id]).toBeTruthy();
expect(teamAnalytics[TestHelper.basicTeam!.id][Stats.TOTAL_PUBLIC_CHANNELS] > 0).toBeTruthy();
});
it('getAdvancedAnalytics', async () => {
nock(Client4.getBaseRoute()).
get('/analytics/old').
query(true).
times(2).
reply(200, [{name: 'file_post_count', value: 24}, {name: 'hashtag_post_count', value: 876}, {name: 'incoming_webhook_count', value: 16}, {name: 'outgoing_webhook_count', value: 18}, {name: 'command_count', value: 14}, {name: 'session_count', value: 149}]);
await Actions.getAdvancedAnalytics()(store.dispatch, store.getState);
await Actions.getAdvancedAnalytics(TestHelper.basicTeam!.id)(store.dispatch, store.getState);
const state = store.getState();
const analytics = state.entities.admin.analytics;
expect(analytics).toBeTruthy();
expect(analytics[Stats.TOTAL_SESSIONS] > 0).toBeTruthy();
const teamAnalytics = state.entities.admin.teamAnalytics;
expect(teamAnalytics).toBeTruthy();
expect(teamAnalytics[TestHelper.basicTeam!.id]).toBeTruthy();
expect(teamAnalytics[TestHelper.basicTeam!.id][Stats.TOTAL_SESSIONS] > 0).toBeTruthy();
});
it('getPostsPerDayAnalytics', async () => {
nock(Client4.getBaseRoute()).
get('/analytics/old').
query(true).
times(2).
reply(200, [{name: '2017-06-18', value: 16}, {name: '2017-06-16', value: 209}, {name: '2017-06-12', value: 35}, {name: '2017-06-08', value: 227}, {name: '2017-06-07', value: 27}, {name: '2017-06-06', value: 136}, {name: '2017-06-05', value: 127}, {name: '2017-06-04', value: 39}, {name: '2017-06-02', value: 3}, {name: '2017-05-31', value: 52}, {name: '2017-05-30', value: 52}, {name: '2017-05-29', value: 9}, {name: '2017-05-26', value: 198}, {name: '2017-05-25', value: 144}, {name: '2017-05-24', value: 1130}, {name: '2017-05-23', value: 146}]);
await Actions.getPostsPerDayAnalytics()(store.dispatch, store.getState);
await Actions.getPostsPerDayAnalytics(TestHelper.basicTeam!.id)(store.dispatch, store.getState);
const state = store.getState();
const analytics = state.entities.admin.analytics;
expect(analytics).toBeTruthy();
expect(analytics[Stats.POST_PER_DAY]).toBeTruthy();
const teamAnalytics = state.entities.admin.teamAnalytics;
expect(teamAnalytics).toBeTruthy();
expect(teamAnalytics[TestHelper.basicTeam!.id]).toBeTruthy();
expect(teamAnalytics[TestHelper.basicTeam!.id][Stats.POST_PER_DAY]).toBeTruthy();
});
it('getUsersPerDayAnalytics', async () => {
nock(Client4.getBaseRoute()).
get('/analytics/old').
query(true).
times(2).
reply(200, [{name: '2017-06-18', value: 2}, {name: '2017-06-16', value: 47}, {name: '2017-06-12', value: 4}, {name: '2017-06-08', value: 55}, {name: '2017-06-07', value: 2}, {name: '2017-06-06', value: 1}, {name: '2017-06-05', value: 2}, {name: '2017-06-04', value: 13}, {name: '2017-06-02', value: 1}, {name: '2017-05-31', value: 3}, {name: '2017-05-30', value: 4}, {name: '2017-05-29', value: 3}, {name: '2017-05-26', value: 40}, {name: '2017-05-25', value: 26}, {name: '2017-05-24', value: 43}, {name: '2017-05-23', value: 3}]);
await Actions.getUsersPerDayAnalytics()(store.dispatch, store.getState);
await Actions.getUsersPerDayAnalytics(TestHelper.basicTeam!.id)(store.dispatch, store.getState);
const state = store.getState();
const analytics = state.entities.admin.analytics;
expect(analytics).toBeTruthy();
expect(analytics[Stats.USERS_WITH_POSTS_PER_DAY]).toBeTruthy();
const teamAnalytics = state.entities.admin.teamAnalytics;
expect(teamAnalytics).toBeTruthy();
expect(teamAnalytics[TestHelper.basicTeam!.id]).toBeTruthy();
expect(teamAnalytics[TestHelper.basicTeam!.id][Stats.USERS_WITH_POSTS_PER_DAY]).toBeTruthy();
});
it('uploadPlugin', async () => {
const testFileData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
const testPlugin = {id: 'testplugin', webapp: {bundle_path: '/static/somebundle.js'}};
nock(Client4.getBaseRoute()).
post('/plugins').
reply(200, testPlugin);
await Actions.uploadPlugin(testFileData as any, false)(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('overwriteInstallPlugin', async () => {
const downloadUrl = 'testplugin.tar.gz';
const testPlugin = {id: 'testplugin', webapp: {bundle_path: '/static/somebundle.js'}};
let urlMatch = `/plugins/install_from_url?plugin_download_url=${downloadUrl}&force=false`;
let scope = nock(Client4.getBaseRoute()).
post(urlMatch).
reply(200, testPlugin);
await Actions.installPluginFromUrl(downloadUrl, false)(store.dispatch, store.getState);
expect(scope.isDone()).toBe(true);
urlMatch = `/plugins/install_from_url?plugin_download_url=${downloadUrl}&force=true`;
scope = nock(Client4.getBaseRoute()).
post(urlMatch).
reply(200, testPlugin);
await Actions.installPluginFromUrl(downloadUrl, true)(store.dispatch, store.getState);
expect(scope.isDone()).toBe(true);
});
it('installPluginFromUrl', async () => {
const downloadUrl = 'testplugin.tar.gz';
const testPlugin = {id: 'testplugin', webapp: {bundle_path: '/static/somebundle.js'}};
const urlMatch = `/plugins/install_from_url?plugin_download_url=${downloadUrl}&force=false`;
nock(Client4.getBaseRoute()).
post(urlMatch).
reply(200, testPlugin);
await Actions.installPluginFromUrl(downloadUrl, false)(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('getPlugins', async () => {
const testPlugin = {id: 'testplugin', webapp: {bundle_path: '/static/somebundle.js'}};
const testPlugin2 = {id: 'testplugin2', webapp: {bundle_path: '/static/somebundle.js'}};
nock(Client4.getBaseRoute()).
get('/plugins').
reply(200, {active: [testPlugin], inactive: [testPlugin2]});
await Actions.getPlugins()(store.dispatch, store.getState);
const state = store.getState();
const plugins = state.entities.admin.plugins;
expect(plugins).toBeTruthy();
expect(plugins[testPlugin.id]).toBeTruthy();
expect(plugins[testPlugin.id].active).toBeTruthy();
expect(plugins[testPlugin2.id]).toBeTruthy();
expect(!plugins[testPlugin2.id].active).toBeTruthy();
});
it('getPluginStatuses', async () => {
const testPluginStatus = {
plugin_id: 'testplugin',
state: 1,
};
const testPluginStatus2 = {
plugin_id: 'testplugin2',
state: 0,
};
nock(Client4.getBaseRoute()).
get('/plugins/statuses').
reply(200, [testPluginStatus, testPluginStatus2]);
await Actions.getPluginStatuses()(store.dispatch, store.getState);
const state = store.getState();
const pluginStatuses = state.entities.admin.pluginStatuses;
expect(pluginStatuses).toBeTruthy();
expect(pluginStatuses[testPluginStatus.plugin_id]).toBeTruthy();
expect(pluginStatuses[testPluginStatus.plugin_id].active).toBeTruthy();
expect(pluginStatuses[testPluginStatus2.plugin_id]).toBeTruthy();
expect(!pluginStatuses[testPluginStatus2.plugin_id].active).toBeTruthy();
});
it('removePlugin', async () => {
const testPlugin = {id: 'testplugin3', webapp: {bundle_path: '/static/somebundle.js'}};
nock(Client4.getBaseRoute()).
get('/plugins').
reply(200, {active: [], inactive: [testPlugin]});
await Actions.getPlugins()(store.dispatch, store.getState);
let state = store.getState();
let plugins = state.entities.admin.plugins;
expect(plugins).toBeTruthy();
expect(plugins[testPlugin.id]).toBeTruthy();
nock(Client4.getBaseRoute()).
delete(`/plugins/${testPlugin.id}`).
reply(200, OK_RESPONSE);
await Actions.removePlugin(testPlugin.id)(store.dispatch, store.getState);
state = store.getState();
plugins = state.entities.admin.plugins;
expect(plugins).toBeTruthy();
expect(!plugins[testPlugin.id]).toBeTruthy();
});
it('enablePlugin', async () => {
const testPlugin = {id: TestHelper.generateId(), webapp: {bundle_path: '/static/somebundle.js'}};
nock(Client4.getBaseRoute()).
get('/plugins').
reply(200, {active: [], inactive: [testPlugin]});
await Actions.getPlugins()(store.dispatch, store.getState);
let state = store.getState();
let plugins = state.entities.admin.plugins;
expect(plugins).toBeTruthy();
expect(plugins[testPlugin.id]).toBeTruthy();
expect(!plugins[testPlugin.id].active).toBeTruthy();
nock(Client4.getBaseRoute()).
post(`/plugins/${testPlugin.id}/enable`).
reply(200, OK_RESPONSE);
await Actions.enablePlugin(testPlugin.id)(store.dispatch, store.getState);
state = store.getState();
plugins = state.entities.admin.plugins;
expect(plugins).toBeTruthy();
expect(plugins[testPlugin.id]).toBeTruthy();
expect(plugins[testPlugin.id].active).toBeTruthy();
});
it('disablePlugin', async () => {
const testPlugin = {id: TestHelper.generateId(), webapp: {bundle_path: '/static/somebundle.js'}};
nock(Client4.getBaseRoute()).
get('/plugins').
reply(200, {active: [testPlugin], inactive: []});
await Actions.getPlugins()(store.dispatch, store.getState);
let state = store.getState();
let plugins = state.entities.admin.plugins;
expect(plugins).toBeTruthy();
expect(plugins[testPlugin.id]).toBeTruthy();
expect(plugins[testPlugin.id].active).toBeTruthy();
nock(Client4.getBaseRoute()).
post(`/plugins/${testPlugin.id}/disable`).
reply(200, OK_RESPONSE);
await Actions.disablePlugin(testPlugin.id)(store.dispatch, store.getState);
state = store.getState();
plugins = state.entities.admin.plugins;
expect(plugins).toBeTruthy();
expect(plugins[testPlugin.id]).toBeTruthy();
expect(!plugins[testPlugin.id].active).toBeTruthy();
});
it('getLdapGroups', async () => {
const ldapGroups = {
count: 2,
groups: [
{primary_key: 'test1', name: 'test1', mattermost_group_id: null, has_syncables: false},
{primary_key: 'test2', name: 'test2', mattermost_group_id: 'mattermost-id', has_syncables: true},
],
};
nock(Client4.getBaseRoute()).
get('/ldap/groups?page=0&per_page=100').
reply(200, ldapGroups);
await Actions.getLdapGroups(0, 100, null as any)(store.dispatch, store.getState);
const state = store.getState();
const groups = state.entities.admin.ldapGroups;
expect(groups).toBeTruthy();
expect(groups[ldapGroups.groups[0].primary_key]).toBeTruthy();
expect(groups[ldapGroups.groups[1].primary_key]).toBeTruthy();
});
it('getLdapGroups is_linked', async () => {
let scope = nock(Client4.getBaseRoute()).
get('/ldap/groups?page=0&per_page=100&q=&is_linked=true').
reply(200, NO_GROUPS_RESPONSE);
await Actions.getLdapGroups(0, 100, {q: '', is_linked: true})(store.dispatch, store.getState);
expect(scope.isDone()).toBe(true);
scope = nock(Client4.getBaseRoute()).
get('/ldap/groups?page=0&per_page=100&q=&is_linked=false').
reply(200, NO_GROUPS_RESPONSE);
await Actions.getLdapGroups(0, 100, {q: '', is_linked: false})(store.dispatch, store.getState);
expect(scope.isDone()).toBe(true);
});
it('getLdapGroups is_configured', async () => {
let scope = nock(Client4.getBaseRoute()).
get('/ldap/groups?page=0&per_page=100&q=&is_configured=true').
reply(200, NO_GROUPS_RESPONSE);
await Actions.getLdapGroups(0, 100, {q: '', is_configured: true})(store.dispatch, store.getState);
expect(scope.isDone()).toBe(true);
scope = nock(Client4.getBaseRoute()).
get('/ldap/groups?page=0&per_page=100&q=&is_configured=false').
reply(200, NO_GROUPS_RESPONSE);
await Actions.getLdapGroups(0, 100, {q: '', is_configured: false})(store.dispatch, store.getState);
expect(scope.isDone()).toBe(true);
});
it('getLdapGroups with name query', async () => {
let scope = nock(Client4.getBaseRoute()).
get('/ldap/groups?page=0&per_page=100&q=est').
reply(200, NO_GROUPS_RESPONSE);
await Actions.getLdapGroups(0, 100, {q: 'est'})(store.dispatch, store.getState);
expect(scope.isDone()).toBe(true);
scope = nock(Client4.getBaseRoute()).
get('/ldap/groups?page=0&per_page=100&q=esta').
reply(200, NO_GROUPS_RESPONSE);
await Actions.getLdapGroups(0, 100, {q: 'esta'})(store.dispatch, store.getState);
expect(scope.isDone()).toBe(true);
});
it('linkLdapGroup', async () => {
const ldapGroups = {
count: 2,
groups: [
{primary_key: 'test1', name: 'test1', mattermost_group_id: null, has_syncables: false},
{primary_key: 'test2', name: 'test2', mattermost_group_id: 'mattermost-id', has_syncables: true},
],
};
nock(Client4.getBaseRoute()).
get('/ldap/groups?page=0&per_page=100').
reply(200, ldapGroups);
await Actions.getLdapGroups(0, 100, null as any)(store.dispatch, store.getState);
const key = 'test1';
nock(Client4.getBaseRoute()).
post(`/ldap/groups/${key}/link`).
reply(200, {display_name: 'test1', id: 'new-mattermost-id'});
await Actions.linkLdapGroup(key)(store.dispatch, store.getState);
const state = store.getState();
const groups = state.entities.admin.ldapGroups;
expect(groups[key]).toBeTruthy();
expect(groups[key].mattermost_group_id === 'new-mattermost-id').toBeTruthy();
expect(groups[key].has_syncables === false).toBeTruthy();
});
it('unlinkLdapGroup', async () => {
const ldapGroups = {
count: 2,
groups: [
{primary_key: 'test1', name: 'test1', mattermost_group_id: null, has_syncables: false},
{primary_key: 'test2', name: 'test2', mattermost_group_id: 'mattermost-id', has_syncables: true},
],
};
nock(Client4.getBaseRoute()).
get('/ldap/groups?page=0&per_page=100').
reply(200, ldapGroups);
await Actions.getLdapGroups(0, 100, null as any)(store.dispatch, store.getState);
const key = 'test2';
nock(Client4.getBaseRoute()).
delete(`/ldap/groups/${key}/link`).
reply(200, {ok: true});
await Actions.unlinkLdapGroup(key)(store.dispatch, store.getState);
const state = store.getState();
const groups = state.entities.admin.ldapGroups;
expect(groups[key]).toBeTruthy();
expect(groups[key].mattermost_group_id === undefined).toBeTruthy();
expect(groups[key].has_syncables === undefined).toBeTruthy();
});
it('getSamlMetadataFromIdp', async () => {
nock(Client4.getBaseRoute()).
post('/saml/metadatafromidp').
reply(200, {
idp_url: samlIdpURL,
idp_descriptor_url: samlIdpDescriptorURL,
idp_public_certificate: samlIdpPublicCertificateText,
});
await Actions.getSamlMetadataFromIdp('')(store.dispatch, store.getState);
const state = store.getState();
const metadataResponse = state.entities.admin.samlMetadataResponse;
expect(metadataResponse).toBeTruthy();
expect(metadataResponse.idp_url === samlIdpURL).toBeTruthy();
expect(metadataResponse.idp_descriptor_url === samlIdpDescriptorURL).toBeTruthy();
expect(metadataResponse.idp_public_certificate === samlIdpPublicCertificateText).toBeTruthy();
});
it('setSamlIdpCertificateFromMetadata', async () => {
nock(Client4.getBaseRoute()).
post('/saml/certificate/idp').
reply(200, OK_RESPONSE);
await Actions.setSamlIdpCertificateFromMetadata(samlIdpPublicCertificateText)(store.dispatch, store.getState);
expect(nock.isDone()).toBe(true);
});
it('sendWarnMetricAck', async () => {
const warnMetricAck = {
id: 'metric1',
};
nock(Client4.getBaseRoute()).
post('/warn_metrics/ack/metric1').
reply(200, OK_RESPONSE);
await Actions.sendWarnMetricAck(warnMetricAck.id, false)(store.dispatch);
expect(nock.isDone()).toBe(true);
});
it('getDataRetentionCustomPolicies', async () => {
const policies = {
policies: [
{
id: 'id1',
display_name: 'Test Policy',
post_duration: 100,
team_count: 2,
channel_count: 1,
},
{
id: 'id2',
display_name: 'Test Policy 2',
post_duration: 365,
team_count: 0,
channel_count: 9,
},
],
total_count: 2,
};
nock(Client4.getBaseRoute()).
get('/data_retention/policies?page=0&per_page=10').
reply(200, policies);
await Actions.getDataRetentionCustomPolicies()(store.dispatch, store.getState);
const state = store.getState();
const policesState = state.entities.admin.dataRetentionCustomPolicies;
expect(policesState).toBeTruthy();
expect(policesState.id1.id === 'id1').toBeTruthy();
expect(policesState.id1.display_name === 'Test Policy').toBeTruthy();
expect(policesState.id1.post_duration === 100).toBeTruthy();
expect(policesState.id1.team_count === 2).toBeTruthy();
expect(policesState.id1.channel_count === 1).toBeTruthy();
expect(policesState.id2.id === 'id2').toBeTruthy();
expect(policesState.id2.display_name === 'Test Policy 2').toBeTruthy();
expect(policesState.id2.post_duration === 365).toBeTruthy();
expect(policesState.id2.team_count === 0).toBeTruthy();
expect(policesState.id2.channel_count === 9).toBeTruthy();
});
it('getDataRetentionCustomPolicy', async () => {
const policy = {
id: 'id1',
display_name: 'Test Policy',
post_duration: 100,
team_count: 2,
channel_count: 1,
};
nock(Client4.getBaseRoute()).
get('/data_retention/policies/id1').
reply(200, policy);
await Actions.getDataRetentionCustomPolicy('id1')(store.dispatch, store.getState);
const state = store.getState();
const policesState = state.entities.admin.dataRetentionCustomPolicies;
expect(policesState).toBeTruthy();
expect(policesState.id1.id === 'id1').toBeTruthy();
expect(policesState.id1.display_name === 'Test Policy').toBeTruthy();
expect(policesState.id1.post_duration === 100).toBeTruthy();
expect(policesState.id1.team_count === 2).toBeTruthy();
expect(policesState.id1.channel_count === 1).toBeTruthy();
});
it('getDataRetentionCustomPolicyTeams', async () => {
const teams = [
{
...TestHelper.fakeTeam(),
policy_id: 'id1',
id: 'teamId1',
},
];
nock(Client4.getBaseRoute()).
get('/data_retention/policies/id1/teams?page=0&per_page=50').
reply(200, {
teams,
total_count: 1,
});
await Actions.getDataRetentionCustomPolicyTeams('id1')(store.dispatch, store.getState);
const state = store.getState();
const teamsState = state.entities.teams.teams;
expect(teamsState).toBeTruthy();
expect(teamsState.teamId1.policy_id === 'id1').toBeTruthy();
});
it('getDataRetentionCustomPolicyChannels', async () => {
const channels = [
{
...TestHelper.fakeChannel('teamId1'),
policy_id: 'id1',
id: 'channelId1',
},
];
nock(Client4.getBaseRoute()).
get('/data_retention/policies/id1/channels?page=0&per_page=50').
reply(200, {
channels,
total_count: 1,
});
await Actions.getDataRetentionCustomPolicyChannels('id1')(store.dispatch, store.getState);
const state = store.getState();
const teamsState = state.entities.channels.channels;
expect(teamsState).toBeTruthy();
expect(teamsState.channelId1.policy_id === 'id1').toBeTruthy();
});
it('searchDataRetentionCustomPolicyTeams', async () => {
nock(Client4.getBaseRoute()).
post('/data_retention/policies/id1/teams/search').
reply(200, [TestHelper.basicTeam]);
const response = await store.dispatch(Actions.searchDataRetentionCustomPolicyTeams('id1', 'test', {}));
expect(response.data.length === 1).toBeTruthy();
});
it('searchDataRetentionCustomPolicyChannels', async () => {
nock(Client4.getBaseRoute()).
post('/data_retention/policies/id1/channels/search').
reply(200, [TestHelper.basicChannel]);
const response = await store.dispatch(Actions.searchDataRetentionCustomPolicyChannels('id1', 'test', {}));
expect(response.data.length === 1).toBeTruthy();
});
it('createDataRetentionCustomPolicy', async () => {
const policy = {
display_name: 'Test',
post_duration: 100,
channel_ids: ['channel1'],
team_ids: ['team1', 'team2'],
};
nock(Client4.getBaseRoute()).
post('/data_retention/policies').
reply(200, {
id: 'id1',
display_name: 'Test',
post_duration: 100,
team_count: 2,
channel_count: 1,
});
await Actions.createDataRetentionCustomPolicy(policy)(store.dispatch, store.getState);
const state = store.getState();
const policesState = state.entities.admin.dataRetentionCustomPolicies;
expect(policesState).toBeTruthy();
expect(policesState.id1.id === 'id1').toBeTruthy();
expect(policesState.id1.display_name === 'Test').toBeTruthy();
expect(policesState.id1.post_duration === 100).toBeTruthy();
expect(policesState.id1.team_count === 2).toBeTruthy();
expect(policesState.id1.channel_count === 1).toBeTruthy();
});
it('updateDataRetentionCustomPolicy', async () => {
nock(Client4.getBaseRoute()).
patch('/data_retention/policies/id1').
reply(200, {
id: 'id1',
display_name: 'Test123',
post_duration: 365,
team_count: 2,
channel_count: 1,
});
await Actions.updateDataRetentionCustomPolicy('id1', {display_name: 'Test123', post_duration: 365} as CreateDataRetentionCustomPolicy)(store.dispatch, store.getState);
const updateState = store.getState();
const policyState = updateState.entities.admin.dataRetentionCustomPolicies;
expect(policyState).toBeTruthy();
expect(policyState.id1.id === 'id1').toBeTruthy();
expect(policyState.id1.display_name === 'Test123').toBeTruthy();
expect(policyState.id1.post_duration === 365).toBeTruthy();
expect(policyState.id1.team_count === 2).toBeTruthy();
expect(policyState.id1.channel_count === 1).toBeTruthy();
});
it('createDataRetentionCustomPolicy', async () => {
const policy = {
display_name: 'Test',
post_duration: 100,
channel_ids: ['channel1'],
team_ids: ['team1', 'team2'],
};
nock(Client4.getBaseRoute()).
post('/data_retention/policies').
reply(200, {
id: 'id1',
display_name: 'Test',
post_duration: 100,
team_count: 2,
channel_count: 1,
});
await Actions.createDataRetentionCustomPolicy(policy)(store.dispatch, store.getState);
const state = store.getState();
const policesState = state.entities.admin.dataRetentionCustomPolicies;
expect(policesState).toBeTruthy();
expect(policesState.id1.id === 'id1').toBeTruthy();
expect(policesState.id1.display_name === 'Test').toBeTruthy();
expect(policesState.id1.post_duration === 100).toBeTruthy();
expect(policesState.id1.team_count === 2).toBeTruthy();
expect(policesState.id1.channel_count === 1).toBeTruthy();
});
it('removeDataRetentionCustomPolicyTeams', async () => {
const teams = [
{
...TestHelper.fakeTeam(),
policy_id: 'id1',
id: 'teamId1',
},
{
...TestHelper.fakeTeam(),
policy_id: 'id1',
id: 'teamId2',
},
];
nock(Client4.getBaseRoute()).
get('/data_retention/policies/id1/teams?page=0&per_page=50').
reply(200, {
teams,
total_count: 2,
});
await Actions.getDataRetentionCustomPolicyTeams('id1')(store.dispatch, store.getState);
nock(Client4.getBaseRoute()).
delete('/data_retention/policies/id1/teams').
reply(200, OK_RESPONSE);
await Actions.removeDataRetentionCustomPolicyTeams('id1', ['teamId2'])(store.dispatch, store.getState);
const state = store.getState();
const teamsState = state.entities.teams.teams;
expect(teamsState).toBeTruthy();
expect(teamsState.teamId2.policy_id === null).toBeTruthy();
});
it('removeDataRetentionCustomPolicyChannels', async () => {
const channels = [
{
...TestHelper.fakeChannel('teamId1'),
policy_id: 'id1',
id: 'channelId1',
},
{
...TestHelper.fakeChannel('teamId1'),
policy_id: 'id1',
id: 'channelId2',
},
];
nock(Client4.getBaseRoute()).
get('/data_retention/policies/id1/channels?page=0&per_page=50').
reply(200, {
channels,
total_count: 1,
});
await Actions.getDataRetentionCustomPolicyChannels('id1')(store.dispatch, store.getState);
nock(Client4.getBaseRoute()).
delete('/data_retention/policies/id1/channels').
reply(200, OK_RESPONSE);
await Actions.removeDataRetentionCustomPolicyChannels('id1', ['channelId2'])(store.dispatch, store.getState);
const state = store.getState();
const channelsState = state.entities.channels.channels;
expect(channelsState).toBeTruthy();
expect(channelsState.channelId2.policy_id === null).toBeTruthy();
});
});
|
3,936 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/packages/mattermost-redux/src | petrpan-code/mattermost/mattermost/webapp/channels/src/packages/mattermost-redux/src/actions/bots.test.ts | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import nock from 'nock';
import * as BotActions from 'mattermost-redux/actions/bots';
import * as UserActions from 'mattermost-redux/actions/users';
import {Client4} from 'mattermost-redux/client';
import TestHelper from '../../test/test_helper';
import configureStore from '../../test/test_store';
describe('Actions.Bots', () => {
let store = configureStore();
beforeAll(() => {
TestHelper.initBasic(Client4);
});
beforeEach(() => {
store = configureStore();
});
afterAll(() => {
TestHelper.tearDown();
});
it('loadBots', async () => {
const bots = [TestHelper.fakeBot(), TestHelper.fakeBot()];
nock(Client4.getBaseRoute()).
get('/bots').
query(true).
reply(201, bots);
await store.dispatch(BotActions.loadBots());
const state = store.getState();
const botsResult = state.entities.bots.accounts;
expect(bots.length).toEqual(Object.values(botsResult).length);
});
it('loadBot', async () => {
const bot = TestHelper.fakeBot();
nock(Client4.getBaseRoute()).
get(`/bots/${bot.user_id}`).
query(true).
reply(201, bot);
await store.dispatch(BotActions.loadBot(bot.user_id));
const state = store.getState();
const botsResult = state.entities.bots.accounts[bot.user_id];
expect(bot.username).toEqual(botsResult.username);
});
it('createBot', async () => {
const bot = TestHelper.fakeBot();
nock(Client4.getBaseRoute()).
post('/bots').
reply(200, bot);
await store.dispatch(BotActions.createBot(bot));
const state = store.getState();
const botsResult = state.entities.bots.accounts[bot.user_id];
expect(bot.username).toEqual(botsResult.username);
});
it('patchBot', async () => {
const bot = TestHelper.fakeBot();
nock(Client4.getBaseRoute()).
post('/bots').
reply(200, bot);
await store.dispatch(BotActions.createBot(bot));
bot.username = 'mynewusername';
nock(Client4.getBaseRoute()).
put(`/bots/${bot.user_id}`).
reply(200, bot);
await store.dispatch(BotActions.patchBot(bot.user_id, bot as any));
const state = store.getState();
const botsResult = state.entities.bots.accounts[bot.user_id];
expect(bot.username).toEqual(botsResult.username);
});
it('disableBot', async () => {
const bot = TestHelper.fakeBot();
nock(Client4.getBaseRoute()).
post('/bots').
reply(200, bot);
await store.dispatch(BotActions.createBot(bot));
// Disable the bot by setting delete_at to a value > 0
bot.delete_at = 1507840900065;
nock(Client4.getBotRoute(bot.user_id)).
post('/disable').
reply(200, bot);
await store.dispatch(BotActions.disableBot(bot.user_id));
const state = store.getState();
const botsResult = state.entities.bots.accounts[bot.user_id];
expect(bot.delete_at).toEqual(botsResult.delete_at);
bot.delete_at = 0;
nock(Client4.getBotRoute(bot.user_id)).
post('/enable').
reply(200, bot);
await store.dispatch(BotActions.enableBot(bot.user_id));
const state2 = store.getState();
const botsResult2 = state2.entities.bots.accounts[bot.user_id];
expect(bot.delete_at).toEqual(botsResult2.delete_at);
});
it('assignBot', async () => {
const bot = TestHelper.fakeBot();
nock(Client4.getBaseRoute()).
post('/bots').
reply(200, bot);
await store.dispatch(BotActions.createBot(bot));
bot.owner_id = TestHelper.generateId();
nock(Client4.getBotRoute(bot.user_id)).
post('/assign/' + bot.owner_id).
reply(200, bot);
await store.dispatch(BotActions.assignBot(bot.user_id, bot.owner_id));
const state = store.getState();
const botsResult = state.entities.bots.accounts[bot.user_id];
expect(bot.owner_id).toEqual(botsResult.owner_id);
});
it('logout', async () => {
// Fill redux store with somthing
const bot = TestHelper.fakeBot();
nock(Client4.getBaseRoute()).
post('/bots').
reply(200, bot);
await store.dispatch(BotActions.createBot(bot));
// Should be cleared by logout
nock(Client4.getUsersRoute()).
post('/logout').
reply(200, {status: 'OK'});
await store.dispatch(UserActions.logout());
// Check is clear
const state = store.getState();
expect(0).toEqual(Object.keys(state.entities.bots.accounts).length);
});
});
|
3,940 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/packages/mattermost-redux/src | petrpan-code/mattermost/mattermost/webapp/channels/src/packages/mattermost-redux/src/actions/channels.test.ts | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import nock from 'nock';
import type {IncomingWebhook, OutgoingWebhook} from '@mattermost/types/integrations';
import {UserTypes} from 'mattermost-redux/action_types';
import * as Actions from 'mattermost-redux/actions/channels';
import {createIncomingHook, createOutgoingHook} from 'mattermost-redux/actions/integrations';
import {addUserToTeam} from 'mattermost-redux/actions/teams';
import {getProfilesByIds, loadMe} from 'mattermost-redux/actions/users';
import {Client4} from 'mattermost-redux/client';
import type {ActionResult} from 'mattermost-redux/types/actions';
import {getPreferenceKey} from 'mattermost-redux/utils/preference_utils';
import TestHelper from '../../test/test_helper';
import configureStore from '../../test/test_store';
import {General, RequestStatus, Preferences, Permissions} from '../constants';
import {CategoryTypes} from '../constants/channel_categories';
import {MarkUnread} from '../constants/channels';
const OK_RESPONSE = {status: 'OK'};
describe('Actions.Channels', () => {
let store = configureStore();
beforeAll(() => {
TestHelper.initBasic(Client4);
});
beforeEach(() => {
store = configureStore({
entities: {
general: {
config: {
CollapsedThreads: 'always_on',
},
},
},
});
});
afterAll(() => {
TestHelper.tearDown();
});
it('selectChannel', async () => {
const channelId = TestHelper.generateId();
await store.dispatch(Actions.selectChannel(channelId));
await TestHelper.wait(100);
const state = store.getState();
expect(state.entities.channels.currentChannelId).toEqual(channelId);
});
it('createChannel', async () => {
nock(Client4.getBaseRoute()).
post('/channels').
reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam!.id));
await store.dispatch(Actions.createChannel(TestHelper.fakeChannel(TestHelper.basicTeam!.id), TestHelper.basicUser!.id));
const createRequest = store.getState().requests.channels.createChannel;
if (createRequest.status === RequestStatus.FAILURE) {
throw new Error(JSON.stringify(createRequest.error));
}
const {channels, myMembers} = store.getState().entities.channels;
const channelsCount = Object.keys(channels).length;
const membersCount = Object.keys(myMembers).length;
expect(channels).toBeTruthy();
expect(myMembers).toBeTruthy();
expect(channels[Object.keys(myMembers)[0]]).toBeTruthy();
expect(myMembers[Object.keys(channels)[0]]).toBeTruthy();
expect(myMembers[Object.keys(channels)[0]].user_id).toEqual(TestHelper.basicUser!.id);
expect(channelsCount).toEqual(membersCount);
expect(channelsCount).toEqual(1);
expect(membersCount).toEqual(1);
});
it('createDirectChannel', async () => {
nock(Client4.getBaseRoute()).
post('/users').
query(true).
reply(201, TestHelper.fakeUserWithId());
const user = await TestHelper.basicClient4!.createUser(
TestHelper.fakeUser(),
'',
'',
TestHelper.basicTeam!.invite_id,
);
nock(Client4.getBaseRoute()).
post('/users/ids').
reply(200, [user]);
await store.dispatch(getProfilesByIds([user.id]));
nock(Client4.getBaseRoute()).
post('/channels/direct').
reply(201, {...TestHelper.fakeChannelWithId(''), type: 'D'});
const {data: created} = await store.dispatch(Actions.createDirectChannel(TestHelper.basicUser!.id, user.id));
const createRequest = store.getState().requests.channels.createChannel;
if (createRequest.status === RequestStatus.FAILURE) {
throw new Error(createRequest.error);
}
const state = store.getState();
const {channels, myMembers} = state.entities.channels;
const {profiles, profilesInChannel} = state.entities.users;
const preferences = state.entities.preferences.myPreferences;
const channelsCount = Object.keys(channels).length;
const membersCount = Object.keys(myMembers).length;
// channels is empty
expect(channels).toBeTruthy();
// members is empty
expect(myMembers).toBeTruthy();
// profiles does not have userId
expect(profiles[user.id]).toBeTruthy();
// preferences is empty
expect(Object.keys(preferences).length).toBeTruthy();
// channels should have the member
expect(channels[Object.keys(myMembers)[0]]).toBeTruthy();
// members should belong to channel
expect(myMembers[Object.keys(channels)[0]]).toBeTruthy();
expect(myMembers[Object.keys(channels)[0]].user_id).toEqual(TestHelper.basicUser!.id);
expect(channelsCount).toEqual(membersCount);
expect(channels[Object.keys(channels)[0]].type).toEqual('D');
expect(channelsCount).toEqual(1);
expect(membersCount).toEqual(1);
// profiles in channel is empty
expect(profilesInChannel).toBeTruthy();
// profiles in channel is empty for channel
expect(profilesInChannel[created.id]).toBeTruthy();
// 'incorrect number of profiles in channel'
expect(profilesInChannel[created.id].size).toEqual(2);
// creator is not in channel
expect(profilesInChannel[created.id].has(TestHelper.basicUser!.id)).toBeTruthy();
// user is not in channel
expect(profilesInChannel[created.id].has(user.id)).toBeTruthy();
});
it('createGroupChannel', async () => {
nock(Client4.getBaseRoute()).
post('/users').
query(true).
reply(201, TestHelper.fakeUserWithId());
const user = await TestHelper.basicClient4!.createUser(
TestHelper.fakeUser(),
'',
'',
TestHelper.basicTeam!.invite_id,
);
nock(Client4.getBaseRoute()).
post('/users').
query(true).
reply(201, TestHelper.fakeUserWithId());
const user2 = await TestHelper.basicClient4!.createUser(
TestHelper.fakeUser(),
'',
'',
TestHelper.basicTeam!.invite_id,
);
TestHelper.mockLogin();
store.dispatch({
type: UserTypes.LOGIN_SUCCESS,
});
await store.dispatch(loadMe());
nock(Client4.getBaseRoute()).
post('/users/ids').
reply(200, [user, user2]);
await store.dispatch(getProfilesByIds([user.id, user2.id]));
nock(Client4.getBaseRoute()).
post('/channels/group').
reply(201, {...TestHelper.fakeChannelWithId(''), type: 'G'});
const result = await store.dispatch(Actions.createGroupChannel([TestHelper.basicUser!.id, user.id, user2.id]));
const created = result.data;
// error was returned
expect(!result.error).toBeTruthy();
// channel was not returned
expect(created).toBeTruthy();
const createRequest = store.getState().requests.channels.createChannel;
if (createRequest.status === RequestStatus.FAILURE) {
throw new Error(createRequest.error);
}
const state = store.getState();
const {channels, myMembers} = state.entities.channels;
const preferences = state.entities.preferences.myPreferences;
const {profilesInChannel} = state.entities.users;
// channels is empty
expect(channels).toBeTruthy();
// channel does not exist
expect(channels[created.id]).toBeTruthy();
// members is empty
expect(myMembers).toBeTruthy();
// member does not exist
expect(myMembers[created.id]).toBeTruthy();
// preferences is empty
expect(Object.keys(preferences).length).toBeTruthy();
// profiles in channel is empty
expect(profilesInChannel).toBeTruthy();
// profiles in channel is empty for channel
expect(profilesInChannel[created.id]).toBeTruthy();
// incorrect number of profiles in channel
expect(profilesInChannel[created.id].size).toEqual(3);
// creator is not in channel
expect(profilesInChannel[created.id].has(TestHelper.basicUser!.id)).toBeTruthy();
// user is not in channel
expect(profilesInChannel[created.id].has(user.id)).toBeTruthy();
// user2 is not in channel
expect(profilesInChannel[created.id].has(user2.id)).toBeTruthy();
});
it('updateChannel', async () => {
const channel = {
...TestHelper.basicChannel!,
purpose: 'This is to test redux',
header: 'MM with Redux',
};
nock(Client4.getBaseRoute()).
put(`/channels/${channel.id}`).
reply(200, channel);
await store.dispatch(Actions.updateChannel(channel));
const updateRequest = store.getState().requests.channels.updateChannel;
if (updateRequest.status === RequestStatus.FAILURE) {
throw new Error(JSON.stringify(updateRequest.error));
}
const {channels} = store.getState().entities.channels;
const channelId = Object.keys(channels)[0];
expect(channelId).toBeTruthy();
expect(channels[channelId]).toBeTruthy();
expect(channels[channelId].header).toEqual('MM with Redux');
});
it('patchChannel', async () => {
const channel = {
header: 'MM with Redux2',
};
nock(Client4.getBaseRoute()).
put(`/channels/${TestHelper.basicChannel!.id}/patch`).
reply(200, {...TestHelper.basicChannel, ...channel});
await store.dispatch(Actions.patchChannel(TestHelper.basicChannel!.id, channel));
const updateRequest = store.getState().requests.channels.updateChannel;
if (updateRequest.status === RequestStatus.FAILURE) {
throw new Error(JSON.stringify(updateRequest.error));
}
const {channels} = store.getState().entities.channels;
const channelId = Object.keys(channels)[0];
expect(channelId).toBeTruthy();
expect(channels[channelId]).toBeTruthy();
expect(channels[channelId].header).toEqual('MM with Redux2');
});
it('updateChannelPrivacy', async () => {
const publicChannel = TestHelper.basicChannel!;
nock(Client4.getChannelRoute(publicChannel.id)).
put('/privacy').
reply(200, {...publicChannel, type: General.PRIVATE_CHANNEL});
expect(publicChannel.type).toEqual(General.OPEN_CHANNEL);
await store.dispatch(Actions.updateChannelPrivacy(publicChannel.id, General.PRIVATE_CHANNEL));
const updateRequest = store.getState().requests.channels.updateChannel;
if (updateRequest.status === RequestStatus.FAILURE) {
throw new Error(JSON.stringify(updateRequest.error));
}
const {channels} = store.getState().entities.channels;
const channelId = Object.keys(channels)[0];
expect(channelId).toBeTruthy();
expect(channels[channelId]).toBeTruthy();
expect(channels[channelId].type).toEqual(General.PRIVATE_CHANNEL);
});
it('getChannel', async () => {
nock(Client4.getBaseRoute()).
get(`/channels/${TestHelper.basicChannel!.id}`).
reply(200, TestHelper.basicChannel!);
await store.dispatch(Actions.getChannel(TestHelper.basicChannel!.id));
const {channels} = store.getState().entities.channels;
expect(channels[TestHelper.basicChannel!.id]).toBeTruthy();
});
it('getChannelByNameAndTeamName', async () => {
nock(Client4.getTeamsRoute()).
get(`/name/${TestHelper.basicTeam!.name}/channels/name/${TestHelper.basicChannel!.name}?include_deleted=false`).
reply(200, TestHelper.basicChannel!);
await store.dispatch(Actions.getChannelByNameAndTeamName(TestHelper.basicTeam!.name, TestHelper.basicChannel!.name));
const {channels} = store.getState().entities.channels;
expect(channels[TestHelper.basicChannel!.id]).toBeTruthy();
});
it('getChannelAndMyMember', async () => {
nock(Client4.getBaseRoute()).
get(`/channels/${TestHelper.basicChannel!.id}`).
reply(200, TestHelper.basicChannel!);
nock(Client4.getBaseRoute()).
get(`/channels/${TestHelper.basicChannel!.id}/members/me`).
reply(200, TestHelper.basicChannelMember!);
await store.dispatch(Actions.getChannelAndMyMember(TestHelper.basicChannel!.id));
const {channels, myMembers} = store.getState().entities.channels;
expect(channels[TestHelper.basicChannel!.id]).toBeTruthy();
expect(myMembers[TestHelper.basicChannel!.id]).toBeTruthy();
});
it('fetchChannelsAndMembers', async () => {
nock(Client4.getBaseRoute()).
post('/users').
query(true).
reply(201, TestHelper.fakeUserWithId());
const user = await TestHelper.basicClient4!.createUser(
TestHelper.fakeUser(),
'',
'',
TestHelper.basicTeam!.invite_id,
);
nock(Client4.getBaseRoute()).
post('/channels/direct').
reply(201, {...TestHelper.fakeChannelWithId(''), team_id: '', type: 'D'});
const {data: directChannel} = await store.dispatch(Actions.createDirectChannel(TestHelper.basicUser!.id, user.id));
nock(Client4.getBaseRoute()).
get(`/users/me/teams/${TestHelper.basicTeam!.id}/channels`).
query(true).
reply(200, [directChannel, TestHelper.basicChannel]);
nock(Client4.getBaseRoute()).
get(`/users/me/teams/${TestHelper.basicTeam!.id}/channels/members`).
reply(200, [{user_id: TestHelper.basicUser!.id, roles: 'channel_user', channel_id: directChannel.id}, TestHelper.basicChannelMember]);
await store.dispatch(Actions.fetchChannelsAndMembers(TestHelper.basicTeam!.id));
const {channels, channelsInTeam, myMembers} = store.getState().entities.channels;
expect(channels).toBeTruthy();
expect(myMembers).toBeTruthy();
expect(channels[Object.keys(myMembers)[0]]).toBeTruthy();
expect(myMembers[Object.keys(channels)[0]]).toBeTruthy();
expect(channelsInTeam[''].has(directChannel.id)).toBeTruthy();
expect(Object.keys(channels).length).toEqual(Object.keys(myMembers).length);
});
it('updateChannelNotifyProps', async () => {
const notifyProps = {
mark_unread: MarkUnread.MENTION as 'mention',
desktop: 'none' as const,
};
nock(Client4.getBaseRoute()).
get(`/users/me/teams/${TestHelper.basicTeam!.id}/channels`).
query(true).
reply(200, [TestHelper.basicChannel]);
nock(Client4.getBaseRoute()).
get(`/users/me/teams/${TestHelper.basicTeam!.id}/channels/members`).
reply(200, [TestHelper.basicChannelMember]);
await store.dispatch(Actions.fetchChannelsAndMembers(TestHelper.basicTeam!.id));
nock(Client4.getBaseRoute()).
put(`/channels/${TestHelper.basicChannel!.id}/members/${TestHelper.basicUser!.id}/notify_props`).
reply(200, OK_RESPONSE);
await store.dispatch(Actions.updateChannelNotifyProps(
TestHelper.basicUser!.id,
TestHelper.basicChannel!.id,
notifyProps));
const members = store.getState().entities.channels.myMembers;
const member = members[TestHelper.basicChannel!.id];
expect(member).toBeTruthy();
expect(member.notify_props.mark_unread).toEqual(MarkUnread.MENTION);
expect(member.notify_props.desktop).toEqual('none');
});
it('deleteChannel', async () => {
const secondClient = TestHelper.createClient4();
nock(Client4.getBaseRoute()).
post('/users').
query(true).
reply(201, TestHelper.fakeUserWithId());
const user = await TestHelper.basicClient4!.createUser(
TestHelper.fakeUser(),
'',
'',
TestHelper.basicTeam!.invite_id,
);
nock(Client4.getBaseRoute()).
post('/users/login').
reply(200, user);
await secondClient.login(user.email, 'password1');
nock(Client4.getBaseRoute()).
post('/channels').
reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam!.id));
const secondChannel = await secondClient.createChannel(
TestHelper.fakeChannel(TestHelper.basicTeam!.id));
nock(Client4.getBaseRoute()).
post(`/channels/${secondChannel.id}/members`).
reply(201, {user_id: TestHelper.basicUser!.id, roles: 'channel_user', channel_id: secondChannel.id});
await store.dispatch(Actions.joinChannel(
TestHelper.basicUser!.id,
TestHelper.basicTeam!.id,
secondChannel.id,
));
nock(Client4.getBaseRoute()).
get(`/users/me/teams/${TestHelper.basicTeam!.id}/channels`).
query(true).
reply(200, [secondChannel, TestHelper.basicChannel]);
nock(Client4.getBaseRoute()).
get(`/users/me/teams/${TestHelper.basicTeam!.id}/channels/members`).
reply(200, [{user_id: TestHelper.basicUser!.id, roles: 'channel_user', channel_id: secondChannel.id}, TestHelper.basicChannelMember]);
await store.dispatch(Actions.fetchChannelsAndMembers(TestHelper.basicTeam!.id));
nock(Client4.getBaseRoute()).
post('/hooks/incoming').
reply(201, {
id: TestHelper.generateId(),
create_at: 1507840900004,
update_at: 1507840900004,
delete_at: 0,
user_id: TestHelper.basicUser!.id,
channel_id: secondChannel.id,
team_id: TestHelper.basicTeam!.id,
display_name: 'TestIncomingHook',
description: 'Some description.',
});
const incomingHook = await store.dispatch(createIncomingHook({channel_id: secondChannel.id, display_name: 'test', description: 'test'} as IncomingWebhook));
nock(Client4.getBaseRoute()).
post('/hooks/outgoing').
reply(201, {
id: TestHelper.generateId(),
token: TestHelper.generateId(),
create_at: 1507841118796,
update_at: 1507841118796,
delete_at: 0,
creator_id: TestHelper.basicUser!.id,
channel_id: secondChannel.id,
team_id: TestHelper.basicTeam!.id,
trigger_words: ['testword'],
trigger_when: 0,
callback_urls: ['http://notarealurl'],
display_name: 'TestOutgoingHook',
description: '',
content_type: 'application/x-www-form-urlencoded',
});
const outgoingHook = await store.dispatch(createOutgoingHook({
channel_id: secondChannel.id,
team_id: TestHelper.basicTeam!.id,
display_name: 'TestOutgoingHook',
trigger_words: [TestHelper.generateId()],
callback_urls: ['http://notarealurl']} as OutgoingWebhook,
));
nock(Client4.getBaseRoute()).
delete(`/channels/${secondChannel.id}`).
reply(200, OK_RESPONSE);
await store.dispatch(Actions.deleteChannel(secondChannel.id));
const {incomingHooks, outgoingHooks} = store.getState().entities.integrations;
if (incomingHooks[incomingHook.id]) {
throw new Error('unexpected incomingHooks[incomingHook.id]');
}
if (outgoingHooks[outgoingHook.id]) {
throw new Error('unexpected outgoingHooks[outgoingHook.id]');
}
});
it('unarchiveChannel', async () => {
const secondClient = TestHelper.createClient4();
nock(Client4.getBaseRoute()).
post('/users').
query(true).
reply(201, TestHelper.fakeUserWithId());
const user = await TestHelper.basicClient4!.createUser(
TestHelper.fakeUser(),
'',
'',
TestHelper.basicTeam!.invite_id,
);
nock(Client4.getBaseRoute()).
post('/users/login').
reply(200, user);
await secondClient.login(user.email, 'password1');
nock(Client4.getBaseRoute()).
post('/channels').
reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam!.id));
const secondChannel = await secondClient.createChannel(
TestHelper.fakeChannel(TestHelper.basicTeam!.id));
nock(Client4.getBaseRoute()).
post(`/channels/${secondChannel.id}/members`).
reply(201, {user_id: TestHelper.basicUser!.id, roles: 'channel_user', channel_id: secondChannel.id});
await store.dispatch(Actions.joinChannel(
TestHelper.basicUser!.id,
TestHelper.basicTeam!.id,
secondChannel.id,
));
nock(Client4.getBaseRoute()).
get(`/users/me/teams/${TestHelper.basicTeam!.id}/channels`).
query(true).
reply(200, [secondChannel, TestHelper.basicChannel]);
nock(Client4.getBaseRoute()).
get(`/users/me/teams/${TestHelper.basicTeam!.id}/channels/members`).
reply(200, [{user_id: TestHelper.basicUser!.id, roles: 'channel_user', channel_id: secondChannel.id}, TestHelper.basicChannelMember]);
await store.dispatch(Actions.fetchChannelsAndMembers(TestHelper.basicTeam!.id));
nock(Client4.getBaseRoute()).
post('/hooks/incoming').
reply(201, {
id: TestHelper.generateId(),
create_at: 1507840900004,
update_at: 1507840900004,
delete_at: 1609090954545,
user_id: TestHelper.basicUser!.id,
channel_id: secondChannel.id,
team_id: TestHelper.basicTeam!.id,
display_name: 'TestIncomingHook',
description: 'Some description.',
});
const incomingHook = await store.dispatch(createIncomingHook({channel_id: secondChannel.id, display_name: 'test', description: 'test'} as IncomingWebhook));
nock(Client4.getBaseRoute()).
post('/hooks/outgoing').
reply(201, {
id: TestHelper.generateId(),
token: TestHelper.generateId(),
create_at: 1507841118796,
update_at: 1507841118796,
delete_at: 1609090954545,
creator_id: TestHelper.basicUser!.id,
channel_id: secondChannel.id,
team_id: TestHelper.basicTeam!.id,
trigger_words: ['testword'],
trigger_when: 0,
callback_urls: ['http://notarealurl'],
display_name: 'TestOutgoingHook',
description: '',
content_type: 'application/x-www-form-urlencoded',
});
const outgoingHook = await store.dispatch(createOutgoingHook({
channel_id: secondChannel.id,
team_id: TestHelper.basicTeam!.id,
display_name: 'TestOutgoingHook',
trigger_words: [TestHelper.generateId()],
callback_urls: ['http://notarealurl']} as OutgoingWebhook,
));
nock(Client4.getBaseRoute()).
delete(`/channels/${secondChannel.id}`).
reply(200, OK_RESPONSE);
await store.dispatch(Actions.unarchiveChannel(secondChannel.id));
const {incomingHooks, outgoingHooks} = store.getState().entities.integrations;
if (incomingHooks[incomingHook.id]) {
throw new Error('unexpected incomingHooks[incomingHook.id]');
}
if (outgoingHooks[outgoingHook.id]) {
throw new Error('unexpected outgoingHooks[outgoingHook.id]');
}
});
describe('markChannelAsRead', () => {
it('one read channel', async () => {
const channelId = TestHelper.generateId();
const teamId = TestHelper.generateId();
store = configureStore({
entities: {
channels: {
channels: {
[channelId]: {
id: channelId,
team_id: teamId,
},
},
messageCounts: {
[channelId]: {total: 10},
},
myMembers: {
[channelId]: {
channel_id: channelId,
mention_count: 0,
msg_count: 10,
last_viewed_at: 1000,
},
},
},
teams: {
myMembers: {
[teamId]: {
id: teamId,
mention_count: 0,
msg_count: 0,
},
},
},
},
});
await store.dispatch(Actions.markChannelAsRead(channelId));
const state = store.getState();
expect(state.entities.channels.myMembers[channelId].mention_count).toBe(0);
expect(state.entities.channels.myMembers[channelId].msg_count).toBe(state.entities.channels.messageCounts[channelId].total);
expect(state.entities.channels.myMembers[channelId].last_viewed_at).toBeGreaterThan(1000);
expect(state.entities.teams.myMembers[teamId].mention_count).toBe(0);
expect(state.entities.teams.myMembers[teamId].msg_count).toBe(0);
});
it('one unread channel', async () => {
const channelId = TestHelper.generateId();
const teamId = TestHelper.generateId();
store = configureStore({
entities: {
channels: {
channels: {
[channelId]: {
id: channelId,
team_id: teamId,
},
},
messageCounts: {
[channelId]: {total: 10},
},
myMembers: {
[channelId]: {
channel_id: channelId,
mention_count: 2,
msg_count: 5,
last_viewed_at: 1000,
},
},
},
teams: {
myMembers: {
[teamId]: {
id: teamId,
mention_count: 2,
msg_count: 5,
},
},
},
},
});
await store.dispatch(Actions.markChannelAsRead(channelId));
const state = store.getState();
expect(state.entities.channels.myMembers[channelId].mention_count).toBe(0);
expect(state.entities.channels.myMembers[channelId].msg_count).toBe(state.entities.channels.messageCounts[channelId].total);
expect(state.entities.channels.myMembers[channelId].last_viewed_at).toBeGreaterThan(1000);
expect(state.entities.teams.myMembers[teamId].mention_count).toBe(0);
expect(state.entities.teams.myMembers[teamId].msg_count).toBe(0);
});
it('one unread DM channel', async () => {
const channelId = TestHelper.generateId();
store = configureStore({
entities: {
channels: {
channels: {
[channelId]: {
id: channelId,
team_id: '',
},
},
messageCounts: {
[channelId]: {total: 10},
},
myMembers: {
[channelId]: {
channel_id: channelId,
mention_count: 2,
msg_count: 5,
last_viewed_at: 1000,
},
},
},
teams: {
myMembers: {
},
},
},
});
await store.dispatch(Actions.markChannelAsRead(channelId));
const state = store.getState();
expect(state.entities.channels.myMembers[channelId].mention_count).toBe(0);
expect(state.entities.channels.myMembers[channelId].msg_count).toBe(state.entities.channels.messageCounts[channelId].total);
expect(state.entities.channels.myMembers[channelId].last_viewed_at).toBeGreaterThan(1000);
});
it('two unread channels, same team, reading one', async () => {
const channelId1 = TestHelper.generateId();
const channelId2 = TestHelper.generateId();
const teamId = TestHelper.generateId();
store = configureStore({
entities: {
channels: {
channels: {
[channelId1]: {
id: channelId1,
team_id: teamId,
},
[channelId2]: {
id: channelId2,
team_id: teamId,
},
},
messageCounts: {
[channelId1]: {total: 10},
[channelId2]: {total: 12},
},
myMembers: {
[channelId1]: {
channel_id: channelId1,
mention_count: 2,
msg_count: 5,
last_viewed_at: 1000,
},
[channelId2]: {
channel_id: channelId2,
mention_count: 4,
msg_count: 9,
last_viewed_at: 2000,
},
},
},
teams: {
myMembers: {
[teamId]: {
id: teamId,
mention_count: 6,
msg_count: 8,
},
},
},
},
});
await store.dispatch(Actions.markChannelAsRead(channelId1));
const state = store.getState();
expect(state.entities.channels.myMembers[channelId1].mention_count).toBe(0);
expect(state.entities.channels.myMembers[channelId1].msg_count).toBe(state.entities.channels.messageCounts[channelId1].total);
expect(state.entities.channels.myMembers[channelId1].last_viewed_at).toBeGreaterThan(1000);
expect(state.entities.channels.myMembers[channelId2].mention_count).toBe(4);
expect(state.entities.channels.myMembers[channelId2].msg_count).toBe(9);
expect(state.entities.channels.myMembers[channelId2].last_viewed_at).toBe(2000);
expect(state.entities.teams.myMembers[teamId].mention_count).toBe(4);
expect(state.entities.teams.myMembers[teamId].msg_count).toBe(3);
});
it('two unread channels, different teams, reading one', async () => {
const channelId1 = TestHelper.generateId();
const channelId2 = TestHelper.generateId();
const teamId1 = TestHelper.generateId();
const teamId2 = TestHelper.generateId();
store = configureStore({
entities: {
channels: {
channels: {
[channelId1]: {
id: channelId1,
team_id: teamId1,
},
[channelId2]: {
id: channelId2,
team_id: teamId2,
},
},
messageCounts: {
[channelId1]: {total: 10},
[channelId2]: {total: 12},
},
myMembers: {
[channelId1]: {
channel_id: channelId1,
mention_count: 2,
msg_count: 5,
last_viewed_at: 1000,
},
[channelId2]: {
channel_id: channelId2,
mention_count: 4,
msg_count: 9,
last_viewed_at: 2000,
},
},
},
teams: {
myMembers: {
[teamId1]: {
id: teamId1,
mention_count: 2,
msg_count: 5,
},
[teamId2]: {
id: teamId2,
mention_count: 4,
msg_count: 3,
},
},
},
},
});
await store.dispatch(Actions.markChannelAsRead(channelId1));
const state = store.getState();
expect(state.entities.channels.myMembers[channelId1].mention_count).toBe(0);
expect(state.entities.channels.myMembers[channelId1].msg_count).toBe(state.entities.channels.messageCounts[channelId1].total);
expect(state.entities.channels.myMembers[channelId1].last_viewed_at).toBeGreaterThan(1000);
expect(state.entities.channels.myMembers[channelId2].mention_count).toBe(4);
expect(state.entities.channels.myMembers[channelId2].msg_count).toBe(9);
expect(state.entities.channels.myMembers[channelId2].last_viewed_at).toBe(2000);
expect(state.entities.teams.myMembers[teamId1].mention_count).toBe(0);
expect(state.entities.teams.myMembers[teamId1].msg_count).toBe(0);
expect(state.entities.teams.myMembers[teamId2].mention_count).toBe(4);
expect(state.entities.teams.myMembers[teamId2].msg_count).toBe(3);
});
});
it('getChannels', async () => {
const userClient = TestHelper.createClient4();
nock(Client4.getBaseRoute()).
post('/users').
query(true).
reply(201, TestHelper.fakeUserWithId());
const user = await TestHelper.basicClient4!.createUser(
TestHelper.fakeUser(),
'',
'',
TestHelper.basicTeam!.invite_id,
);
nock(Client4.getBaseRoute()).
post('/users/login').
reply(200, user);
await userClient.login(user.email, 'password1');
nock(Client4.getBaseRoute()).
post('/channels').
reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam!.id));
const userChannel = await userClient.createChannel(
TestHelper.fakeChannel(TestHelper.basicTeam!.id),
);
nock(Client4.getTeamsRoute()).
get(`/${TestHelper.basicTeam!.id}/channels`).
query(true).
reply(200, [TestHelper.basicChannel, userChannel]);
await store.dispatch(Actions.getChannels(TestHelper.basicTeam!.id, 0));
const moreRequest = store.getState().requests.channels.getChannels;
if (moreRequest.status === RequestStatus.FAILURE) {
throw new Error(JSON.stringify(moreRequest.error));
}
const {channels, channelsInTeam, myMembers} = store.getState().entities.channels;
const channel = channels[userChannel.id];
const team = channelsInTeam[userChannel.team_id];
expect(channel).toBeTruthy();
expect(team).toBeTruthy();
expect(team.has(userChannel.id)).toBeTruthy();
if (myMembers[channel.id]) {
throw new Error('unexpected myMembers[channel.id]');
}
});
it('getArchivedChannels', async () => {
const userClient = TestHelper.createClient4();
nock(Client4.getBaseRoute()).
post('/users').
query(true).
reply(201, TestHelper.fakeUserWithId());
const user = await TestHelper.basicClient4!.createUser(
TestHelper.fakeUser(),
'',
'',
TestHelper.basicTeam!.invite_id,
);
nock(Client4.getBaseRoute()).
post('/users/login').
reply(200, user);
await userClient.login(user.email, 'password1');
nock(Client4.getBaseRoute()).
post('/channels').
reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam!.id));
const userChannel = await userClient.createChannel(
TestHelper.fakeChannel(TestHelper.basicTeam!.id),
);
nock(Client4.getTeamsRoute()).
get(`/${TestHelper.basicTeam!.id}/channels/deleted`).
query(true).
reply(200, [TestHelper.basicChannel, userChannel]);
await store.dispatch(Actions.getArchivedChannels(TestHelper.basicTeam!.id, 0));
const moreRequest = store.getState().requests.channels.getChannels;
if (moreRequest.status === RequestStatus.FAILURE) {
throw new Error(JSON.stringify(moreRequest.error));
}
const {channels, channelsInTeam, myMembers} = store.getState().entities.channels;
const channel = channels[userChannel.id];
const team = channelsInTeam[userChannel.team_id];
expect(channel).toBeTruthy();
expect(team).toBeTruthy();
expect(team.has(userChannel.id)).toBeTruthy();
if (myMembers[channel.id]) {
throw new Error('unexpected myMembers[channel.id]');
}
});
it('getAllChannels', async () => {
const userClient = TestHelper.createClient4();
nock(Client4.getBaseRoute()).
post('/users').
query(true).
reply(201, TestHelper.fakeUserWithId());
const user = await TestHelper.basicClient4!.createUser(
TestHelper.fakeUser(),
'',
'',
TestHelper.basicTeam!.invite_id,
);
nock(Client4.getBaseRoute()).
post('/users/login').
reply(200, user);
await userClient.login(user.email, 'password1');
nock(Client4.getBaseRoute()).
post('/channels').
reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam!.id));
const userChannel = await userClient.createChannel(
TestHelper.fakeChannel(TestHelper.basicTeam!.id),
);
nock(Client4.getBaseRoute()).
get('/channels').
query(true).
reply(200, [TestHelper.basicChannel, userChannel]);
const {data} = await store.dispatch(Actions.getAllChannels(0));
const moreRequest = store.getState().requests.channels.getAllChannels;
if (moreRequest.status === RequestStatus.FAILURE) {
throw new Error(JSON.stringify(moreRequest.error));
}
expect(data.length === 2).toBeTruthy();
});
it('getAllChannelsWithCount', async () => {
const userClient = TestHelper.createClient4();
nock(Client4.getBaseRoute()).
post('/users').
query(true).
reply(201, TestHelper.fakeUserWithId());
const user = await TestHelper.basicClient4!.createUser(
TestHelper.fakeUser(),
'',
'',
TestHelper.basicTeam!.invite_id,
);
nock(Client4.getBaseRoute()).
post('/users/login').
reply(200, user);
await userClient.login(user.email, 'password1');
nock(Client4.getBaseRoute()).
post('/channels').
reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam!.id));
const userChannel = await userClient.createChannel(
TestHelper.fakeChannel(TestHelper.basicTeam!.id),
);
const mockTotalCount = 84;
const mockQuery = {
page: 0,
per_page: 50,
not_associated_to_group: '',
exclude_default_channels: false,
include_total_count: true,
include_deleted: false,
exclude_policy_constrained: false,
};
nock(Client4.getBaseRoute()).
get('/channels').
query(mockQuery).
reply(200, {channels: [TestHelper.basicChannel, userChannel], total_count: mockTotalCount});
expect(store.getState().entities.channels.totalCount === 0).toBeTruthy();
const {data} = await store.dispatch(Actions.getAllChannelsWithCount(0));
const moreRequest = store.getState().requests.channels.getAllChannels;
if (moreRequest.status === RequestStatus.FAILURE) {
throw new Error(JSON.stringify(moreRequest.error));
}
expect(data.channels.length === 2).toBeTruthy();
expect(data.total_count === mockTotalCount).toBeTruthy();
expect(store.getState().entities.channels.totalCount === mockTotalCount).toBeTruthy();
mockQuery.include_deleted = true;
nock(Client4.getBaseRoute()).
get('/channels').
query(mockQuery).
reply(200, {channels: [TestHelper.basicChannel, userChannel], total_count: mockTotalCount});
await store.dispatch(Actions.getAllChannelsWithCount(0, 50, '', false, true));
const request = store.getState().requests.channels.getAllChannels;
if (request.status === RequestStatus.FAILURE) {
throw new Error(JSON.stringify(request.error));
}
});
it('searchAllChannels', async () => {
const userClient = TestHelper.createClient4();
nock(Client4.getBaseRoute()).
post('/users').
query(true).
reply(201, TestHelper.fakeUserWithId());
const user = await TestHelper.basicClient4!.createUser(
TestHelper.fakeUser(),
'',
'',
TestHelper.basicTeam!.invite_id,
);
nock(Client4.getBaseRoute()).
post('/users/login').
reply(200, user);
await userClient.login(user.email, 'password1');
nock(Client4.getBaseRoute()).
post('/channels').
reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam!.id));
const userChannel = await userClient.createChannel(
TestHelper.fakeChannel(TestHelper.basicTeam!.id),
);
nock(Client4.getBaseRoute()).
post('/channels/search?include_deleted=false').
reply(200, [TestHelper.basicChannel, userChannel]);
await store.dispatch(Actions.searchAllChannels('test', {}));
const moreRequest = store.getState().requests.channels.getAllChannels;
if (moreRequest.status === RequestStatus.FAILURE) {
throw new Error(JSON.stringify(moreRequest.error));
}
nock(Client4.getBaseRoute()).
post('/channels/search?include_deleted=false').
reply(200, {channels: [TestHelper.basicChannel, userChannel], total_count: 2});
let response = await store.dispatch(Actions.searchAllChannels('test', {exclude_default_channels: false, page: 0, per_page: 100}));
const paginatedRequest = store.getState().requests.channels.getAllChannels;
if (paginatedRequest.status === RequestStatus.FAILURE) {
throw new Error(JSON.stringify(paginatedRequest.error));
}
expect(response.data.channels.length === 2).toBeTruthy();
nock(Client4.getBaseRoute()).
post('/channels/search?include_deleted=true').
reply(200, {channels: [TestHelper.basicChannel, userChannel], total_count: 2});
response = await store.dispatch(Actions.searchAllChannels('test', {exclude_default_channels: false, page: 0, per_page: 100, include_deleted: true}));
expect(response.data.channels.length === 2).toBeTruthy();
});
it('searchArchivedChannels', async () => {
const userClient = TestHelper.createClient4();
nock(Client4.getBaseRoute()).
post('/users').
query(true).
reply(201, TestHelper.fakeUserWithId());
const user = await TestHelper.basicClient4!.createUser(
TestHelper.fakeUser(),
'',
'',
TestHelper.basicTeam!.invite_id,
);
nock(Client4.getBaseRoute()).
post('/users/login').
reply(200, user);
await userClient.login(user.email, 'password1');
nock(Client4.getBaseRoute()).
post('/channels').
reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam!.id));
const userChannel = await userClient.createChannel(
TestHelper.fakeChannel(TestHelper.basicTeam!.id),
);
nock(Client4.getTeamsRoute()).
post(`/${TestHelper.basicTeam!.id}/channels/search_archived`).
reply(200, [TestHelper.basicChannel, userChannel]);
const {data} = await store.dispatch(Actions.searchChannels(TestHelper.basicTeam!.id, 'test', true));
const moreRequest = store.getState().requests.channels.getChannels;
if (moreRequest.status === RequestStatus.FAILURE) {
throw new Error(JSON.stringify(moreRequest.error));
}
expect(data.length === 2).toBeTruthy();
});
it('getChannelMembers', async () => {
nock(Client4.getBaseRoute()).
get(`/channels/${TestHelper.basicChannel!.id}/members`).
query(true).
reply(200, [TestHelper.basicChannelMember]);
await store.dispatch(Actions.getChannelMembers(TestHelper.basicChannel!.id));
const {membersInChannel} = store.getState().entities.channels;
expect(membersInChannel).toBeTruthy();
expect(membersInChannel[TestHelper.basicChannel!.id]).toBeTruthy();
expect(membersInChannel[TestHelper.basicChannel!.id][TestHelper.basicUser!.id]).toBeTruthy();
});
it('getChannelMember', async () => {
nock(Client4.getBaseRoute()).
get(`/channels/${TestHelper.basicChannel!.id}/members/${TestHelper.basicUser!.id}`).
reply(200, TestHelper.basicChannelMember!);
await store.dispatch(Actions.getChannelMember(TestHelper.basicChannel!.id, TestHelper.basicUser!.id));
const {membersInChannel} = store.getState().entities.channels;
expect(membersInChannel).toBeTruthy();
expect(membersInChannel[TestHelper.basicChannel!.id]).toBeTruthy();
expect(membersInChannel[TestHelper.basicChannel!.id][TestHelper.basicUser!.id]).toBeTruthy();
});
it('getMyChannelMember', async () => {
nock(Client4.getBaseRoute()).
get(`/channels/${TestHelper.basicChannel!.id}/members/me`).
reply(200, TestHelper.basicChannelMember!);
await store.dispatch(Actions.getMyChannelMember(TestHelper.basicChannel!.id));
const {myMembers} = store.getState().entities.channels;
expect(myMembers).toBeTruthy();
expect(myMembers[TestHelper.basicChannel!.id]).toBeTruthy();
});
it('getChannelMembersByIds', async () => {
nock(Client4.getBaseRoute()).
post(`/channels/${TestHelper.basicChannel!.id}/members/ids`).
reply(200, [TestHelper.basicChannelMember]);
await store.dispatch(Actions.getChannelMembersByIds(TestHelper.basicChannel!.id, [TestHelper.basicUser!.id]));
const {membersInChannel} = store.getState().entities.channels;
expect(membersInChannel).toBeTruthy();
expect(membersInChannel[TestHelper.basicChannel!.id]).toBeTruthy();
expect(membersInChannel[TestHelper.basicChannel!.id][TestHelper.basicUser!.id]).toBeTruthy();
});
it('getChannelStats', async () => {
nock(Client4.getBaseRoute()).
get(`/channels/${TestHelper.basicChannel!.id}/stats?exclude_files_count=true`).
reply(200, {channel_id: TestHelper.basicChannel!.id, member_count: 1});
await store.dispatch(Actions.getChannelStats(TestHelper.basicChannel!.id));
const {stats} = store.getState().entities.channels;
const stat = stats[TestHelper.basicChannel!.id];
expect(stat).toBeTruthy();
expect(stat.member_count >= 1).toBeTruthy();
});
it('addChannelMember', async () => {
const channelId = TestHelper.basicChannel!.id;
nock(Client4.getBaseRoute()).
post('/users').
query(true).
reply(201, TestHelper.fakeUserWithId());
const user = await TestHelper.basicClient4!.createUser(
TestHelper.fakeUser(),
'',
'',
TestHelper.basicTeam!.invite_id,
);
nock(Client4.getBaseRoute()).
post(`/channels/${TestHelper.basicChannel!.id}/members`).
reply(201, {channel_id: TestHelper.basicChannel!.id, roles: 'channel_user', user_id: TestHelper.basicUser!.id});
await store.dispatch(Actions.joinChannel(TestHelper.basicUser!.id, TestHelper.basicTeam!.id, channelId));
nock(Client4.getBaseRoute()).
get(`/channels/${TestHelper.basicChannel!.id}/stats?exclude_files_count=true`).
reply(200, {channel_id: TestHelper.basicChannel!.id, member_count: 1});
await store.dispatch(Actions.getChannelStats(channelId));
let state = store.getState();
let {stats} = state.entities.channels;
expect(stats).toBeTruthy();
// stats for channel
expect(stats[channelId]).toBeTruthy();
// member count for channel
expect(stats[channelId].member_count).toBeTruthy();
// incorrect member count for channel
expect(stats[channelId].member_count >= 1).toBeTruthy();
nock(Client4.getBaseRoute()).
post(`/channels/${TestHelper.basicChannel!.id}/members`).
reply(201, {channel_id: TestHelper.basicChannel!.id, roles: 'channel_user', user_id: user.id});
await store.dispatch(Actions.addChannelMember(channelId, user.id));
state = store.getState();
const {profilesInChannel, profilesNotInChannel} = state.entities.users;
const channel = profilesInChannel[channelId];
const notChannel = profilesNotInChannel[channelId];
expect(channel).toBeTruthy();
expect(notChannel).toBeTruthy();
expect(channel.has(user.id)).toBeTruthy();
// user should not present in profilesNotInChannel
expect(notChannel.has(user.id)).toEqual(false);
stats = state.entities.channels.stats;
expect(stats).toBeTruthy();
// stats for channel
expect(stats[channelId]).toBeTruthy();
// member count for channel
expect(stats[channelId].member_count).toBeTruthy();
// incorrect member count for channel
expect(stats[channelId].member_count >= 2).toBeTruthy();
});
it('removeChannelMember', async () => {
const channelId = TestHelper.basicChannel!.id;
nock(Client4.getBaseRoute()).
post('/users').
query(true).
reply(201, TestHelper.fakeUserWithId());
const user = await TestHelper.basicClient4!.createUser(
TestHelper.fakeUser(),
'',
'',
TestHelper.basicTeam!.invite_id,
);
nock(Client4.getBaseRoute()).
post(`/channels/${TestHelper.basicChannel!.id}/members`).
reply(201, {channel_id: TestHelper.basicChannel!.id, roles: 'channel_user', user_id: TestHelper.basicUser!.id});
await store.dispatch(Actions.joinChannel(TestHelper.basicUser!.id, TestHelper.basicTeam!.id, channelId));
nock(Client4.getBaseRoute()).
get(`/channels/${TestHelper.basicChannel!.id}/stats?exclude_files_count=true`).
reply(200, {channel_id: TestHelper.basicChannel!.id, member_count: 1});
await store.dispatch(Actions.getChannelStats(channelId));
nock(Client4.getBaseRoute()).
post(`/channels/${TestHelper.basicChannel!.id}/members`).
reply(201, {channel_id: TestHelper.basicChannel!.id, roles: 'channel_user', user_id: user.id});
await store.dispatch(Actions.addChannelMember(channelId, user.id));
let state = store.getState();
let {stats} = state.entities.channels;
expect(stats).toBeTruthy();
// stats for channel
expect(stats[channelId]).toBeTruthy();
// member count for channel
expect(stats[channelId].member_count).toBeTruthy();
// incorrect member count for channel
expect(stats[channelId].member_count >= 2).toBeTruthy();
nock(Client4.getBaseRoute()).
delete(`/channels/${TestHelper.basicChannel!.id}/members/${user.id}`).
reply(200, OK_RESPONSE);
await store.dispatch(Actions.removeChannelMember(channelId, user.id));
state = store.getState();
const {profilesInChannel, profilesNotInChannel} = state.entities.users;
const channel = profilesInChannel[channelId];
const notChannel = profilesNotInChannel[channelId];
expect(channel).toBeTruthy();
expect(notChannel).toBeTruthy();
expect(notChannel.has(user.id)).toBeTruthy();
// user should not present in profilesInChannel
expect(channel.has(user.id)).toEqual(false);
stats = state.entities.channels.stats;
expect(stats).toBeTruthy();
// stats for channel
expect(stats[channelId]).toBeTruthy();
// member count for channel
expect(stats[channelId].member_count).toBeTruthy();
// incorrect member count for channel
expect(stats[channelId].member_count >= 1).toBeTruthy();
});
it('updateChannelMemberRoles', async () => {
nock(Client4.getBaseRoute()).
post('/users').
reply(201, TestHelper.fakeUserWithId());
const user = await TestHelper.basicClient4!.createUser(TestHelper.fakeUser(), '', '');
nock(Client4.getTeamsRoute()).
post(`/${TestHelper.basicChannel!.id}/members`).
reply(201, {team_id: TestHelper.basicTeam!.id, roles: 'channel_user', user_id: user.id});
await store.dispatch(addUserToTeam(TestHelper.basicTeam!.id, user.id));
nock(Client4.getBaseRoute()).
post(`/channels/${TestHelper.basicChannel!.id}/members`).
reply(201, {channel_id: TestHelper.basicChannel!.id, roles: 'channel_user', user_id: user.id});
await store.dispatch(Actions.addChannelMember(TestHelper.basicChannel!.id, user.id));
const roles = General.CHANNEL_USER_ROLE + ' ' + General.CHANNEL_ADMIN_ROLE;
nock(Client4.getBaseRoute()).
put(`/channels/${TestHelper.basicChannel!.id}/members/${user.id}/roles`).
reply(200, {roles});
await store.dispatch(Actions.updateChannelMemberRoles(TestHelper.basicChannel!.id, user.id, roles));
const members = store.getState().entities.channels.membersInChannel;
expect(members[TestHelper.basicChannel!.id]).toBeTruthy();
expect(members[TestHelper.basicChannel!.id][user.id]).toBeTruthy();
expect(members[TestHelper.basicChannel!.id][user.id].roles === roles).toBeTruthy();
});
it('updateChannelHeader', async () => {
nock(Client4.getBaseRoute()).
get(`/channels/${TestHelper.basicChannel!.id}`).
reply(200, TestHelper.basicChannel!);
await store.dispatch(Actions.getChannel(TestHelper.basicChannel!.id));
const header = 'this is an updated test header';
await store.dispatch(Actions.updateChannelHeader(TestHelper.basicChannel!.id, header));
const {channels} = store.getState().entities.channels;
const channel = channels[TestHelper.basicChannel!.id];
expect(channel).toBeTruthy();
expect(channel.header).toEqual(header);
});
it('updateChannelPurpose', async () => {
nock(Client4.getBaseRoute()).
get(`/channels/${TestHelper.basicChannel!.id}`).
reply(200, TestHelper.basicChannel!);
await store.dispatch(Actions.getChannel(TestHelper.basicChannel!.id));
const purpose = 'this is an updated test purpose';
await store.dispatch(Actions.updateChannelPurpose(TestHelper.basicChannel!.id, purpose));
const {channels} = store.getState().entities.channels;
const channel = channels[TestHelper.basicChannel!.id];
expect(channel).toBeTruthy();
expect(channel.purpose).toEqual(purpose);
});
describe('leaveChannel', () => {
const team = TestHelper.fakeTeam();
const user = TestHelper.fakeUserWithId();
test('should delete the channel member when leaving a public channel', async () => {
const channel = {id: 'channel', team_id: team.id, type: General.OPEN_CHANNEL};
store = configureStore({
entities: {
channels: {
channels: {
channel,
},
myMembers: {
[channel.id]: {channel_id: channel.id, user_id: user.id},
},
},
users: {
currentUserId: user.id,
},
},
});
nock(Client4.getBaseRoute()).
delete(`/channels/${channel.id}/members/${user.id}`).
reply(200, OK_RESPONSE);
await store.dispatch(Actions.leaveChannel(channel.id));
const state = store.getState();
expect(state.entities.channels.channels[channel.id]).not.toBeDefined();
expect(state.entities.channels.myMembers[channel.id]).not.toBeDefined();
});
test('should delete the channel member and channel when leaving a private channel', async () => {
const channel = {id: 'channel', team_id: team.id, type: General.PRIVATE_CHANNEL};
store = configureStore({
entities: {
channels: {
channels: {
channel,
},
myMembers: {
[channel.id]: {channel_id: channel.id, user_id: user.id},
},
},
users: {
currentUserId: user.id,
},
},
});
nock(Client4.getBaseRoute()).
delete(`/channels/${channel.id}/members/${user.id}`).
reply(200, OK_RESPONSE);
await store.dispatch(Actions.leaveChannel(channel.id));
const state = store.getState();
expect(state.entities.channels.channels[channel.id]).not.toBeDefined();
expect(state.entities.channels.myMembers[channel.id]).not.toBeDefined();
});
test('should remove a channel from the sidebar when leaving it', async () => {
const channel = {id: 'channel', team_id: team.id, type: General.OPEN_CHANNEL};
const category = {id: 'category', team_id: team.id, type: CategoryTypes.CUSTOM, channel_ids: [channel.id]};
store = configureStore({
entities: {
channelCategories: {
byId: {
category,
},
orderByTeam: {
[team.id]: [category.id],
},
},
channels: {
channels: {
channel,
},
myMembers: {
[channel.id]: {channel_id: channel.id, user_id: user.id},
},
},
users: {
currentUserId: user.id,
},
},
});
nock(Client4.getBaseRoute()).
delete(`/channels/${channel.id}/members/${user.id}`).
reply(200, OK_RESPONSE);
await store.dispatch(Actions.leaveChannel(channel.id));
const state = store.getState();
expect(state.entities.channels.channels[channel.id]).not.toBeDefined();
expect(state.entities.channels.myMembers[channel.id]).not.toBeDefined();
expect(state.entities.channelCategories.byId[category.id].channel_ids).toEqual([]);
});
test('should restore a channel when failing to leave it (non-custom category)', async () => {
const channel = {id: 'channel', team_id: team.id, type: General.OPEN_CHANNEL};
const category = {id: 'category', team_id: team.id, type: CategoryTypes.CHANNELS, channel_ids: [channel.id]};
store = await configureStore({
entities: {
channelCategories: {
byId: {
category,
},
orderByTeam: {
[team.id]: [category.id],
},
},
channels: {
channels: {
channel,
},
myMembers: {
[channel.id]: {channel_id: channel.id, user_id: user.id},
},
},
users: {
currentUserId: user.id,
},
},
});
nock(Client4.getBaseRoute()).
delete(`/channels/${channel.id}/members/${user.id}`).
reply(500, {});
await store.dispatch(Actions.leaveChannel(channel.id));
// Allow async Client4 API calls to the dispatched action to run first.
await new Promise((resolve) => setTimeout(resolve, 500));
const state = store.getState();
expect(state.entities.channels.channels[channel.id]).toBeDefined();
expect(state.entities.channels.myMembers[channel.id]).toBeDefined();
expect(state.entities.channelCategories.byId[category.id].channel_ids).toEqual([channel.id]);
});
});
test('joinChannel', async () => {
const channel = TestHelper.basicChannel!;
const team = TestHelper.basicTeam!;
const user = TestHelper.basicUser!;
const channelsCategory = {id: 'channelsCategory', team_id: team.id, type: CategoryTypes.CHANNELS, channel_ids: []};
store = configureStore({
entities: {
channelCategories: {
byId: {
channelsCategory,
},
orderByTeam: {
[team.id]: ['channelsCategory'],
},
},
users: {
currentUserId: user.id,
},
},
});
nock(Client4.getBaseRoute()).
get(`/channels/${channel.id}`).
reply(200, channel);
nock(Client4.getBaseRoute()).
post(`/channels/${channel.id}/members`).
reply(201, {channel_id: channel.id, roles: 'channel_user', user_id: user.id});
nock(Client4.getBaseRoute()).
put(`/users/${user.id}/teams/${team.id}/channels/categories`).
reply(200, [{...channelsCategory, channel_ids: []}]);
await store.dispatch(Actions.joinChannel(user.id, team.id, channel.id));
// Allow async Client4 API calls to the dispatched action to run first.
await new Promise((resolve) => setTimeout(resolve, 500));
const state = store.getState();
expect(state.entities.channels.channels[channel.id]).toBeDefined();
expect(state.entities.channels.myMembers[channel.id]).toBeDefined();
expect(state.entities.channelCategories.byId[channelsCategory.id].channel_ids).toEqual([channel.id]);
});
test('joinChannelByName', async () => {
const channel = TestHelper.basicChannel!;
const team = TestHelper.basicTeam!;
const user = TestHelper.basicUser!;
const channelsCategory = {id: 'channelsCategory', team_id: team.id, type: CategoryTypes.CHANNELS, channel_ids: []};
store = configureStore({
entities: {
channelCategories: {
byId: {
channelsCategory,
},
orderByTeam: {
[team.id]: ['channelsCategory'],
},
},
users: {
currentUserId: user.id,
},
},
});
nock(Client4.getTeamsRoute()).
get(`/${TestHelper.basicTeam!.id}/channels/name/${channel.name}?include_deleted=true`).
reply(200, channel);
nock(Client4.getBaseRoute()).
post(`/channels/${channel.id}/members`).
reply(201, {channel_id: channel.id, roles: 'channel_user', user_id: TestHelper.basicUser!.id});
nock(Client4.getBaseRoute()).
put(`/users/${user.id}/teams/${team.id}/channels/categories`).
reply(200, [{...channelsCategory, channel_ids: []}]);
await store.dispatch(Actions.joinChannel(user.id, team.id, '', channel.name));
const state = store.getState();
expect(state.entities.channels.channels[channel.id]).toBeDefined();
expect(state.entities.channels.myMembers[channel.id]).toBeDefined();
expect(state.entities.channelCategories.byId[channelsCategory.id].channel_ids).toEqual([channel.id]);
});
test('favoriteChannel', async () => {
const channel = TestHelper.basicChannel!;
const team = TestHelper.basicTeam!;
const currentUserId = TestHelper.generateId();
const favoritesCategory = {id: 'favoritesCategory', team_id: team.id, type: CategoryTypes.FAVORITES, channel_ids: []};
const channelsCategory = {id: 'channelsCategory', team_id: team.id, type: CategoryTypes.CHANNELS, channel_ids: [channel.id]};
store = configureStore({
entities: {
channels: {
channels: {
[channel.id]: channel,
},
},
channelCategories: {
byId: {
favoritesCategory,
channelsCategory,
},
orderByTeam: {
[team.id]: ['favoritesCategory', 'channelsCategory'],
},
},
users: {
currentUserId,
},
},
});
nock(Client4.getBaseRoute()).
put(`/users/${currentUserId}/teams/${team.id}/channels/categories`).
reply(200, [
{...favoritesCategory, channel_ids: [channel.id]},
{...channelsCategory, channel_ids: []},
]);
await store.dispatch(Actions.favoriteChannel(channel.id));
// Allow async Client4 API calls to the dispatched action to run first.
await new Promise((resolve) => setTimeout(resolve, 500));
const state = store.getState();
// Should favorite the channel in channel categories
expect(state.entities.channelCategories.byId.favoritesCategory.channel_ids).toEqual([channel.id]);
expect(state.entities.channelCategories.byId.channelsCategory.channel_ids).toEqual([]);
});
it('unfavoriteChannel', async () => {
const channel = TestHelper.basicChannel!;
const team = TestHelper.basicTeam!;
const currentUserId = TestHelper.generateId();
const favoritesCategory = {id: 'favoritesCategory', team_id: team.id, type: CategoryTypes.FAVORITES, channel_ids: [channel.id]};
const channelsCategory = {id: 'channelsCategory', team_id: team.id, type: CategoryTypes.CHANNELS, channel_ids: []};
store = configureStore({
entities: {
channels: {
channels: {
[channel.id]: channel,
},
},
channelCategories: {
byId: {
favoritesCategory,
channelsCategory,
},
orderByTeam: {
[team.id]: ['favoritesCategory', 'channelsCategory'],
},
},
users: {
currentUserId,
},
},
});
nock(Client4.getBaseRoute()).
put(`/users/${currentUserId}/teams/${team.id}/channels/categories`).
reply(200, [
{...favoritesCategory, channel_ids: []},
{...channelsCategory, channel_ids: [channel.id]},
]);
await store.dispatch(Actions.unfavoriteChannel(channel.id));
const state = store.getState();
// Should unfavorite the channel in channel categories
expect(state.entities.channelCategories.byId.favoritesCategory.channel_ids).toEqual([]);
expect(state.entities.channelCategories.byId.channelsCategory.channel_ids).toEqual([channel.id]);
});
it('autocompleteChannels', async () => {
const prefix = TestHelper.basicChannel!.name.slice(0, 5);
nock(Client4.getTeamRoute(TestHelper.basicChannel!.team_id)).
get('/channels/autocomplete').
query({name: prefix}).
reply(200, [TestHelper.basicChannel]);
const result = await store.dispatch(Actions.autocompleteChannels(
TestHelper.basicChannel!.team_id,
prefix,
));
expect(result).toEqual({data: [TestHelper.basicChannel]});
});
it('autocompleteChannelsForSearch', async () => {
const prefix = TestHelper.basicChannel!.name.slice(0, 5);
nock(Client4.getTeamRoute(TestHelper.basicChannel!.team_id)).
get('/channels/search_autocomplete').
query({name: prefix}).
reply(200, [TestHelper.basicChannel]);
const result = await store.dispatch(Actions.autocompleteChannelsForSearch(
TestHelper.basicChannel!.team_id,
prefix,
));
expect(result).toEqual({data: [TestHelper.basicChannel]});
});
it('updateChannelScheme', async () => {
TestHelper.mockLogin();
store.dispatch({
type: UserTypes.LOGIN_SUCCESS,
});
await store.dispatch(loadMe());
nock(Client4.getBaseRoute()).
post('/channels').
reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam!.id));
await store.dispatch(Actions.createChannel(TestHelper.fakeChannel(TestHelper.basicTeam!.id), TestHelper.basicUser!.id));
const createRequest = store.getState().requests.channels.createChannel;
if (createRequest.status === RequestStatus.FAILURE) {
throw new Error(JSON.stringify(createRequest.error));
}
const {channels} = store.getState().entities.channels;
const schemeId = 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
const {id} = channels[Object.keys(channels)[0]];
nock(Client4.getBaseRoute()).
put('/channels/' + id + '/scheme').
reply(200, OK_RESPONSE);
await store.dispatch(Actions.updateChannelScheme(id, schemeId));
const updated = store.getState().entities.channels.channels[id];
expect(updated).toBeTruthy();
expect(updated.scheme_id).toEqual(schemeId);
});
it('updateChannelMemberSchemeRoles', async () => {
TestHelper.mockLogin();
store.dispatch({
type: UserTypes.LOGIN_SUCCESS,
});
await store.dispatch(loadMe());
nock(Client4.getBaseRoute()).
post('/channels').
reply(201, TestHelper.fakeChannelWithId(TestHelper.basicTeam!.id));
const userId = 'asdf';
await store.dispatch(Actions.createChannel(TestHelper.fakeChannel(TestHelper.basicTeam!.id), userId));
const {channels} = store.getState().entities.channels;
const channelId = channels[Object.keys(channels)[0]].id;
nock(Client4.getBaseRoute()).
put(`/channels/${channelId}/members/${userId}/schemeRoles`).
reply(200, OK_RESPONSE);
await store.dispatch(Actions.updateChannelMemberSchemeRoles(channelId, userId, true, true));
const update1 = store.getState().entities.channels.membersInChannel[channelId][userId];
expect(update1).toBeTruthy();
expect(update1.scheme_admin).toEqual(true);
expect(update1.scheme_user).toEqual(true);
nock(Client4.getBaseRoute()).
put(`/channels/${channelId}/members/${userId}/schemeRoles`).
reply(200, OK_RESPONSE);
await store.dispatch(Actions.updateChannelMemberSchemeRoles(channelId, userId, false, false));
const update2 = store.getState().entities.channels.membersInChannel[channelId][userId];
expect(update2).toBeTruthy();
expect(update2.scheme_admin).toEqual(false);
expect(update2.scheme_user).toEqual(false);
});
it('markGroupChannelOpen', async () => {
const channelId = TestHelper.generateId();
const now = new Date().getTime();
const currentUserId = TestHelper.generateId();
store = await configureStore({
entities: {
users: {
currentUserId,
},
},
});
nock(Client4.getBaseRoute()).
put(`/users/${currentUserId}/preferences`).
reply(200, OK_RESPONSE);
await Actions.markGroupChannelOpen(channelId)(store.dispatch, store.getState);
const state = store.getState();
let prefKey = getPreferenceKey(Preferences.CATEGORY_GROUP_CHANNEL_SHOW, channelId);
let preference = state.entities.preferences.myPreferences[prefKey];
expect(preference).toBeTruthy();
expect(preference.value === 'true').toBeTruthy();
prefKey = getPreferenceKey(Preferences.CATEGORY_CHANNEL_OPEN_TIME, channelId);
preference = state.entities.preferences.myPreferences[prefKey];
expect(preference).toBeTruthy();
expect(parseInt(preference.value, 10) >= now).toBeTruthy();
});
it('getChannelTimezones', async () => {
const {dispatch, getState} = store;
const channelId = TestHelper.basicChannel!.id;
const response = {
useAutomaticTimezone: 'true',
manualTimezone: '',
automaticTimezone: 'xoxoxo/blablabla',
};
nock(Client4.getBaseRoute()).
get(`/channels/${TestHelper.basicChannel!.id}/timezones`).
query(true).
reply(200, response);
const {data} = await Actions.getChannelTimezones(channelId)(dispatch, getState) as ActionResult;
expect(response).toEqual(data);
});
it('membersMinusGroupMembers', async () => {
const channelID = 'cid10000000000000000000000';
const groupIDs = ['gid10000000000000000000000', 'gid20000000000000000000000'];
const page = 7;
const perPage = 63;
nock(Client4.getBaseRoute()).get(
`/channels/${channelID}/members_minus_group_members?group_ids=${groupIDs.join(',')}&page=${page}&per_page=${perPage}`).
reply(200, {users: [], total_count: 0});
const {error} = await Actions.membersMinusGroupMembers(channelID, groupIDs, page, perPage)(store.dispatch, store.getState) as ActionResult;
expect(error).toEqual(undefined);
});
it('getChannelModerations', async () => {
const channelID = 'cid10000000000000000000000';
nock(Client4.getBaseRoute()).get(
`/channels/${channelID}/moderations`).
reply(200, [{
name: Permissions.CHANNEL_MODERATED_PERMISSIONS.CREATE_POST,
roles: {
members: true,
guests: false,
},
}]);
const {error} = await store.dispatch(Actions.getChannelModerations(channelID));
const moderations = store.getState().entities.channels.channelModerations[channelID];
expect(error).toEqual(undefined);
expect(moderations[0].name).toEqual(Permissions.CHANNEL_MODERATED_PERMISSIONS.CREATE_POST);
expect(moderations[0].roles.members).toEqual(true);
expect(moderations[0].roles.guests).toEqual(false);
});
it('patchChannelModerations', async () => {
const channelID = 'cid10000000000000000000000';
nock(Client4.getBaseRoute()).put(
`/channels/${channelID}/moderations/patch`).
reply(200, [{
name: Permissions.CHANNEL_MODERATED_PERMISSIONS.CREATE_REACTIONS,
roles: {
members: true,
guests: false,
},
}]);
const {error} = await store.dispatch(Actions.patchChannelModerations(channelID, []));
const moderations = store.getState().entities.channels.channelModerations[channelID];
expect(error).toEqual(undefined);
expect(moderations[0].name).toEqual(Permissions.CHANNEL_MODERATED_PERMISSIONS.CREATE_REACTIONS);
expect(moderations[0].roles.members).toEqual(true);
expect(moderations[0].roles.guests).toEqual(false);
});
it('getChannelMemberCountsByGroup', async () => {
const channelID = 'cid10000000000000000000000';
nock(Client4.getBaseRoute()).get(
`/channels/${channelID}/member_counts_by_group?include_timezones=true`).
reply(200, [
{
group_id: 'group-1',
channel_member_count: 1,
channel_member_timezones_count: 1,
},
{
group_id: 'group-2',
channel_member_count: 999,
channel_member_timezones_count: 131,
},
]);
await store.dispatch(Actions.getChannelMemberCountsByGroup(channelID));
const channelMemberCounts = store.getState().entities.channels.channelMemberCountsByGroup[channelID];
expect(channelMemberCounts['group-1'].group_id).toEqual('group-1');
expect(channelMemberCounts['group-1'].channel_member_count).toEqual(1);
expect(channelMemberCounts['group-1'].channel_member_timezones_count).toEqual(1);
expect(channelMemberCounts['group-2'].group_id).toEqual('group-2');
expect(channelMemberCounts['group-2'].channel_member_count).toEqual(999);
expect(channelMemberCounts['group-2'].channel_member_timezones_count).toEqual(131);
});
});
|
3,943 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/packages/mattermost-redux/src | petrpan-code/mattermost/mattermost/webapp/channels/src/packages/mattermost-redux/src/actions/emojis.test.ts | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import fs from 'fs';
import nock from 'nock';
import * as Actions from 'mattermost-redux/actions/emojis';
import {Client4} from 'mattermost-redux/client';
import type {ActionResult} from 'mattermost-redux/types/actions';
import TestHelper from '../../test/test_helper';
import configureStore from '../../test/test_store';
const OK_RESPONSE = {status: 'OK'};
describe('Actions.Emojis', () => {
let store = configureStore();
beforeAll(() => {
TestHelper.initBasic(Client4);
});
beforeEach(() => {
store = configureStore();
});
afterAll(() => {
TestHelper.tearDown();
});
it('createCustomEmoji', async () => {
const testImageData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/emoji').
reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser!.id, name: TestHelper.generateId()});
const {data: created} = await Actions.createCustomEmoji(
{
name: TestHelper.generateId(),
creator_id: TestHelper.basicUser!.id,
},
testImageData,
)(store.dispatch, store.getState) as ActionResult;
const state = store.getState();
const emojis = state.entities.emojis.customEmoji;
expect(emojis).toBeTruthy();
expect(emojis[created.id]).toBeTruthy();
});
it('getCustomEmojis', async () => {
const testImageData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/emoji').
reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser!.id, name: TestHelper.generateId()});
const {data: created} = await Actions.createCustomEmoji(
{
name: TestHelper.generateId(),
creator_id: TestHelper.basicUser!.id,
},
testImageData,
)(store.dispatch, store.getState) as ActionResult;
nock(Client4.getBaseRoute()).
get('/emoji').
query(true).
reply(200, [created]);
await Actions.getCustomEmojis()(store.dispatch, store.getState);
const state = store.getState();
const emojis = state.entities.emojis.customEmoji;
expect(emojis).toBeTruthy();
expect(emojis[created.id]).toBeTruthy();
});
it('deleteCustomEmoji', async () => {
const testImageData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/emoji').
reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser!.id, name: TestHelper.generateId()});
const {data: created} = await Actions.createCustomEmoji(
{
name: TestHelper.generateId(),
creator_id: TestHelper.basicUser!.id,
},
testImageData,
)(store.dispatch, store.getState) as ActionResult;
nock(Client4.getBaseRoute()).
delete(`/emoji/${created.id}`).
reply(200, OK_RESPONSE);
await Actions.deleteCustomEmoji(created.id)(store.dispatch, store.getState);
const state = store.getState();
const emojis = state.entities.emojis.customEmoji;
expect(!emojis[created.id]).toBeTruthy();
});
it('loadProfilesForCustomEmojis', async () => {
const fakeUser = TestHelper.fakeUser();
fakeUser.id = TestHelper.generateId();
const junkUserId = TestHelper.generateId();
const testEmojis = [TestHelper.getCustomEmojiMock({
name: TestHelper.generateId(),
creator_id: TestHelper.basicUser!.id,
}),
TestHelper.getCustomEmojiMock({
name: TestHelper.generateId(),
creator_id: TestHelper.basicUser!.id,
}),
TestHelper.getCustomEmojiMock({
name: TestHelper.generateId(),
creator_id: fakeUser.id,
}),
TestHelper.getCustomEmojiMock({
name: TestHelper.generateId(),
creator_id: junkUserId,
})];
nock(Client4.getUsersRoute()).
post('/ids').
reply(200, [TestHelper.basicUser, fakeUser]);
await store.dispatch(Actions.loadProfilesForCustomEmojis(testEmojis));
const state = store.getState();
const profiles = state.entities.users.profiles;
expect(profiles[TestHelper.basicUser!.id]).toBeTruthy();
expect(profiles[fakeUser.id]).toBeTruthy();
expect(!profiles[junkUserId]).toBeTruthy();
});
it('searchCustomEmojis', async () => {
const testImageData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/emoji').
reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser!.id, name: TestHelper.generateId()});
const {data: created} = await Actions.createCustomEmoji(
{
name: TestHelper.generateId(),
creator_id: TestHelper.basicUser!.id,
},
testImageData,
)(store.dispatch, store.getState) as ActionResult;
nock(Client4.getBaseRoute()).
post('/emoji/search').
reply(200, [created]);
await Actions.searchCustomEmojis(created.name, {prefix_only: true})(store.dispatch, store.getState);
const state = store.getState();
const emojis = state.entities.emojis.customEmoji;
expect(emojis).toBeTruthy();
expect(emojis[created.id]).toBeTruthy();
});
it('autocompleteCustomEmojis', async () => {
const testImageData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/emoji').
reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser!.id, name: TestHelper.generateId()});
const {data: created} = await Actions.createCustomEmoji(
{
name: TestHelper.generateId(),
creator_id: TestHelper.basicUser!.id,
},
testImageData,
)(store.dispatch, store.getState) as ActionResult;
nock(Client4.getBaseRoute()).
get('/emoji/autocomplete').
query(true).
reply(200, [created]);
await Actions.autocompleteCustomEmojis(created.name)(store.dispatch, store.getState);
const state = store.getState();
const emojis = state.entities.emojis.customEmoji;
expect(emojis).toBeTruthy();
expect(emojis[created.id]).toBeTruthy();
});
it('getCustomEmoji', async () => {
const testImageData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/emoji').
reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser!.id, name: TestHelper.generateId()});
const {data: created} = await Actions.createCustomEmoji(
{
name: TestHelper.generateId(),
creator_id: TestHelper.basicUser!.id,
},
testImageData,
)(store.dispatch, store.getState) as ActionResult;
nock(Client4.getBaseRoute()).
get(`/emoji/${created.id}`).
reply(200, created);
await Actions.getCustomEmoji(created.id)(store.dispatch, store.getState);
const state = store.getState();
const emojis = state.entities.emojis.customEmoji;
expect(emojis).toBeTruthy();
expect(emojis[created.id]).toBeTruthy();
});
it('getCustomEmojiByName', async () => {
const testImageData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/emoji').
reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser!.id, name: TestHelper.generateId()});
const {data: created} = await Actions.createCustomEmoji(
{
name: TestHelper.generateId(),
creator_id: TestHelper.basicUser!.id,
},
testImageData,
)(store.dispatch, store.getState) as ActionResult;
nock(Client4.getBaseRoute()).
get(`/emoji/name/${created.name}`).
reply(200, created);
await Actions.getCustomEmojiByName(created.name)(store.dispatch, store.getState);
let state = store.getState();
const emojis = state.entities.emojis.customEmoji;
expect(emojis).toBeTruthy();
expect(emojis[created.id]).toBeTruthy();
const missingName = TestHelper.generateId();
nock(Client4.getBaseRoute()).
get(`/emoji/name/${missingName}`).
reply(404, {message: 'Not found', status_code: 404});
await Actions.getCustomEmojiByName(missingName)(store.dispatch, store.getState);
state = store.getState();
expect(state.entities.emojis.nonExistentEmoji.has(missingName)).toBeTruthy();
});
describe('getCustomEmojisByName', () => {
test('should be able to request a single emoji', async () => {
const emoji1 = TestHelper.getCustomEmojiMock({name: 'emoji1', id: 'emojiId1'});
nock(Client4.getBaseRoute()).
post('/emoji/names', ['emoji1']).
reply(200, [emoji1]);
await store.dispatch(Actions.getCustomEmojisByName(['emoji1']));
const state = store.getState();
expect(state.entities.emojis.customEmoji[emoji1.id]).toEqual(emoji1);
});
test('should be able to request multiple emojis', async () => {
const emoji1 = TestHelper.getCustomEmojiMock({name: 'emoji1', id: 'emojiId1'});
const emoji2 = TestHelper.getCustomEmojiMock({name: 'emoji2', id: 'emojiId2'});
nock(Client4.getBaseRoute()).
post('/emoji/names', ['emoji1', 'emoji2']).
reply(200, [emoji1, emoji2]);
await store.dispatch(Actions.getCustomEmojisByName(['emoji1', 'emoji2']));
const state = store.getState();
expect(state.entities.emojis.customEmoji[emoji1.id]).toEqual(emoji1);
expect(state.entities.emojis.customEmoji[emoji2.id]).toEqual(emoji2);
});
test('should correctly track non-existent emojis', async () => {
const emoji1 = TestHelper.getCustomEmojiMock({name: 'emoji1', id: 'emojiId1'});
nock(Client4.getBaseRoute()).
post('/emoji/names', ['emoji1', 'emoji2']).
reply(200, [emoji1]);
await store.dispatch(Actions.getCustomEmojisByName(['emoji1', 'emoji2']));
const state = store.getState();
expect(state.entities.emojis.customEmoji[emoji1.id]).toEqual(emoji1);
expect(state.entities.emojis.nonExistentEmoji).toEqual(new Set(['emoji2']));
});
test('should be able to request over 200 emojis', async () => {
const emojis = [];
for (let i = 0; i < 500; i++) {
emojis.push(TestHelper.getCustomEmojiMock({name: 'emoji' + i, id: 'emojiId' + i}));
}
const names = emojis.map((emoji) => emoji.name);
nock(Client4.getBaseRoute()).
post('/emoji/names', names.slice(0, 200)).
reply(200, emojis.slice(0, 200));
nock(Client4.getBaseRoute()).
post('/emoji/names', names.slice(200, 400)).
reply(200, emojis.slice(200, 400));
nock(Client4.getBaseRoute()).
post('/emoji/names', names.slice(400, 500)).
reply(200, emojis.slice(400, 500));
await store.dispatch(Actions.getCustomEmojisByName(names));
const state = store.getState();
expect(Object.keys(state.entities.emojis.customEmoji)).toHaveLength(emojis.length);
for (const emoji of emojis) {
expect(state.entities.emojis.customEmoji[emoji.id]).toEqual(emoji);
}
});
});
it('getCustomEmojisInText', async () => {
const testImageData = fs.createReadStream('src/packages/mattermost-redux/test/assets/images/test.png');
nock(Client4.getBaseRoute()).
post('/emoji').
reply(201, {id: TestHelper.generateId(), create_at: 1507918415696, update_at: 1507918415696, delete_at: 0, creator_id: TestHelper.basicUser!.id, name: TestHelper.generateId()});
const {data: created} = await Actions.createCustomEmoji(
{
name: TestHelper.generateId(),
creator_id: TestHelper.basicUser!.id,
},
testImageData,
)(store.dispatch, store.getState) as ActionResult;
const missingName = TestHelper.generateId();
nock(Client4.getBaseRoute()).
post('/emoji/names', [created.name, missingName]).
reply(200, [created]);
await Actions.getCustomEmojisInText(`some text :${created.name}: :${missingName}:`)(store.dispatch, store.getState);
const state = store.getState();
expect(state.entities.emojis.customEmoji[created.id]).toBeTruthy();
expect(state.entities.emojis.nonExistentEmoji.has(missingName)).toBeTruthy();
});
});
|
3,945 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/packages/mattermost-redux/src | petrpan-code/mattermost/mattermost/webapp/channels/src/packages/mattermost-redux/src/actions/errors.test.ts | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import nock from 'nock';
import {logError} from 'mattermost-redux/actions/errors';
import {Client4} from 'mattermost-redux/client';
import TestHelper from '../../test/test_helper';
import configureStore from '../../test/test_store';
describe('Actions.Errors', () => {
let store = configureStore();
beforeAll(() => {
TestHelper.initBasic(Client4);
Client4.setEnableLogging(true);
});
beforeEach(() => {
store = configureStore();
});
afterAll(() => {
TestHelper.tearDown();
Client4.setEnableLogging(false);
});
it('logError should hit /logs endpoint, unless server error', async () => {
let count = 0;
nock(Client4.getBaseRoute()).
post('/logs').
reply(200, () => {
count++;
return '{}';
}).
post('/logs').
reply(200, () => {
count++;
return '{}';
}).
post('/logs').
reply(200, () => {
count++;
return '{}';
});
await store.dispatch(logError({message: 'error'}));
await store.dispatch(logError({message: 'error', server_error_id: 'error_id'}));
await store.dispatch(logError({message: 'error'}));
if (count > 2) {
throw new Error(`should not hit /logs endpoint, called ${count} times`);
}
await store.dispatch(logError({message: 'error', server_error_id: 'api.context.session_expired.app_error'}));
if (count > 2) {
throw new Error('should not add session expired errors to the reducer');
}
});
});
|
3,947 | 0 | petrpan-code/mattermost/mattermost/webapp/channels/src/packages/mattermost-redux/src | petrpan-code/mattermost/mattermost/webapp/channels/src/packages/mattermost-redux/src/actions/files.test.ts | // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import fs from 'fs';
import nock from 'nock';
import {FileTypes} from 'mattermost-redux/action_types';
import * as Actions from 'mattermost-redux/actions/files';
import {Client4} from 'mattermost-redux/client';
import TestHelper from '../../test/test_helper';
import configureStore from '../../test/test_store';
describe('Actions.Files', () => {
let store = configureStore();
beforeAll(() => {
TestHelper.initBasic(Client4);
});
beforeEach(() => {
store = configureStore();
});
afterAll(() => {
TestHelper.tearDown();
});
it('getFilesForPost', async () => {
const {basicClient4, basicChannel} = TestHelper;
const testFileName = 'test.png';
const testImageData = fs.createReadStream(`src/packages/mattermost-redux/test/assets/images/${testFileName}`);
const clientId = TestHelper.generateId();
const imageFormData = new FormData();
imageFormData.append('files', testImageData as any);
imageFormData.append('channel_id', basicChannel!.id);
imageFormData.append('client_ids', clientId);
nock(Client4.getBaseRoute()).
post('/files').
reply(201, {file_infos: [{id: TestHelper.generateId(), user_id: TestHelper.basicUser!.id, create_at: 1507921547541, update_at: 1507921547541, delete_at: 0, name: 'test.png', extension: 'png', size: 258428, mime_type: 'image/png', width: 600, height: 600, has_preview_image: true}], client_ids: [TestHelper.generateId()]});
const fileUploadResp = await basicClient4!.
uploadFile(imageFormData);
const fileId = fileUploadResp.file_infos[0].id;
const fakePostForFile = TestHelper.fakePost(basicChannel!.id);
fakePostForFile.file_ids = [fileId];
nock(Client4.getBaseRoute()).
post('/posts').
reply(201, {...TestHelper.fakePostWithId('undefined'), ...fakePostForFile});
const postForFile = await basicClient4!.createPost(fakePostForFile);
nock(Client4.getBaseRoute()).
get(`/posts/${postForFile.id}/files/info`).
reply(200, [{id: fileId, user_id: TestHelper.basicUser!.id, create_at: 1507921547541, update_at: 1507921547541, delete_at: 0, name: 'test.png', extension: 'png', size: 258428, mime_type: 'image/png', width: 600, height: 600, has_preview_image: true}]);
await Actions.getFilesForPost(postForFile.id)(store.dispatch, store.getState);
const {files: allFiles, fileIdsByPostId} = store.getState().entities.files;
expect(allFiles).toBeTruthy();
expect(allFiles[fileId]).toBeTruthy();
expect(allFiles[fileId].id).toEqual(fileId);
expect(allFiles[fileId].name).toEqual(testFileName);
expect(fileIdsByPostId).toBeTruthy();
expect(fileIdsByPostId[postForFile.id]).toBeTruthy();
expect(fileIdsByPostId[postForFile.id][0]).toEqual(fileId);
});
it('getFilePublicLink', async () => {
const fileId = 't1izsr9uspgi3ynggqu6xxjn9y';
nock(Client4.getBaseRoute()).
get(`/files/${fileId}/link`).
query(true).
reply(200, {
link: 'https://mattermost.com/files/ndans23ry2rtjd1z73g6i5f3fc/public?h=rE1-b2N1VVVMsAQssjwlfNawbVOwUy1TRDuTeGC_tys',
});
await Actions.getFilePublicLink(fileId)(store.dispatch, store.getState);
const state = store.getState();
const filePublicLink = state.entities.files.filePublicLink.link;
expect('https://mattermost.com/files/ndans23ry2rtjd1z73g6i5f3fc/public?h=rE1-b2N1VVVMsAQssjwlfNawbVOwUy1TRDuTeGC_tys').toEqual(filePublicLink);
expect(filePublicLink).toBeTruthy();
expect(filePublicLink.length > 0).toBeTruthy();
});
it('receivedFiles', async () => {
const files = {
filename: {data: 'data'},
};
const result = Actions.receivedFiles(files as any);
expect(result).toEqual({
type: FileTypes.RECEIVED_FILES_FOR_SEARCH,
data: files,
});
});
});
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.