-
-
-
}
- focused={true}
section="name_format"
title={
-
-
-
-
-
@@ -658,7 +656,6 @@ export default class UserSettingsDisplay extends React.Component {
}
width='medium'
describe={locale}
- focused={this.props.prevActiveSection === this.prevSections.languages}
section={'languages'}
updateSection={this.updateSection}
/>
@@ -681,7 +678,6 @@ export default class UserSettingsDisplay extends React.Component {
setRequireConfirm={this.props.setRequireConfirm}
setEnforceFocus={this.props.setEnforceFocus}
allowCustomThemes={this.props.allowCustomThemes}
- focused={this.props.prevActiveSection === this.prevSections.theme}
/>
diff --git a/components/user_settings/display/user_settings_display.test.jsx b/components/user_settings/display/user_settings_display.test.jsx
index 0dc547adcc66..37e2355aadfe 100644
--- a/components/user_settings/display/user_settings_display.test.jsx
+++ b/components/user_settings/display/user_settings_display.test.jsx
@@ -2,7 +2,9 @@
// See LICENSE.txt for license information.
import React from 'react';
+import PropTypes from 'prop-types';
import {shallow} from 'enzyme';
+import configureStore from 'redux-mock-store';
import {mountWithIntl} from 'tests/helpers/intl-test-helper.jsx';
import UserSettingsDisplay from 'components/user_settings/display/user_settings_display.jsx';
@@ -48,6 +50,14 @@ describe('components/user_settings/display/UserSettingsDisplay', () => {
savePreferences: jest.fn(),
},
};
+ const mockStore = configureStore();
+ const state = {
+ views: {
+ settings: {},
+ },
+ };
+
+ const store = mockStore(state);
test('should match snapshot, no active section', () => {
const wrapper = shallow(
);
@@ -140,7 +150,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => {
const updateSection = jest.fn();
const props = {...requiredProps, updateSection};
- const wrapper = mountWithIntl(
);
+ const wrapper = mountWithIntl(
+
,
+ {
+ context: {store},
+ childContextTypes: {store: PropTypes.object},
+ },
+ );
await wrapper.instance().handleSubmit();
expect(updateSection).toHaveBeenCalledWith('');
@@ -149,7 +165,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => {
test('should have called updateSection', () => {
const updateSection = jest.fn();
const props = {...requiredProps, updateSection};
- const wrapper = mountWithIntl(
);
+ const wrapper = mountWithIntl(
+
,
+ {
+ context: {store},
+ childContextTypes: {store: PropTypes.object},
+ },
+ );
wrapper.instance().updateSection('');
expect(updateSection).toHaveBeenCalledWith('');
@@ -161,7 +183,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => {
test('should have called closeModal', () => {
const closeModal = jest.fn();
const props = {...requiredProps, closeModal};
- const wrapper = mountWithIntl(
);
+ const wrapper = mountWithIntl(
+
,
+ {
+ context: {store},
+ childContextTypes: {store: PropTypes.object},
+ },
+ );
wrapper.find('#closeButton').simulate('click');
expect(closeModal).toHaveBeenCalled();
@@ -170,14 +198,26 @@ describe('components/user_settings/display/UserSettingsDisplay', () => {
test('should have called collapseModal', () => {
const collapseModal = jest.fn();
const props = {...requiredProps, collapseModal};
- const wrapper = mountWithIntl(
);
+ const wrapper = mountWithIntl(
+
,
+ {
+ context: {store},
+ childContextTypes: {store: PropTypes.object},
+ },
+ );
wrapper.find('.fa-angle-left').simulate('click');
expect(collapseModal).toHaveBeenCalled();
});
test('should update militaryTime state', () => {
- const wrapper = mountWithIntl(
);
+ const wrapper = mountWithIntl(
+
,
+ {
+ context: {store},
+ childContextTypes: {store: PropTypes.object},
+ },
+ );
wrapper.instance().handleClockRadio('false');
expect(wrapper.state('militaryTime')).toBe('false');
@@ -187,7 +227,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => {
});
test('should update teammateNameDisplay state', () => {
- const wrapper = mountWithIntl(
);
+ const wrapper = mountWithIntl(
+
,
+ {
+ context: {store},
+ childContextTypes: {store: PropTypes.object},
+ },
+ );
wrapper.instance().handleTeammateNameDisplayRadio('username');
expect(wrapper.state('teammateNameDisplay')).toBe('username');
@@ -200,7 +246,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => {
});
test('should update channelDisplayMode state', () => {
- const wrapper = mountWithIntl(
);
+ const wrapper = mountWithIntl(
+
,
+ {
+ context: {store},
+ childContextTypes: {store: PropTypes.object},
+ },
+ );
wrapper.instance().handleChannelDisplayModeRadio('full');
expect(wrapper.state('channelDisplayMode')).toBe('full');
@@ -210,7 +262,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => {
});
test('should update messageDisplay state', () => {
- const wrapper = mountWithIntl(
);
+ const wrapper = mountWithIntl(
+
,
+ {
+ context: {store},
+ childContextTypes: {store: PropTypes.object},
+ },
+ );
wrapper.instance().handlemessageDisplayRadio('clean');
expect(wrapper.state('messageDisplay')).toBe('clean');
@@ -220,7 +278,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => {
});
test('should update collapseDisplay state', () => {
- const wrapper = mountWithIntl(
);
+ const wrapper = mountWithIntl(
+
,
+ {
+ context: {store},
+ childContextTypes: {store: PropTypes.object},
+ },
+ );
wrapper.instance().handleCollapseRadio('false');
expect(wrapper.state('collapseDisplay')).toBe('false');
@@ -230,7 +294,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => {
});
test('should update linkPreviewDisplay state', () => {
- const wrapper = mountWithIntl(
);
+ const wrapper = mountWithIntl(
+
,
+ {
+ context: {store},
+ childContextTypes: {store: PropTypes.object},
+ },
+ );
wrapper.instance().handleLinkPreviewRadio('false');
expect(wrapper.state('linkPreviewDisplay')).toBe('false');
@@ -240,7 +310,13 @@ describe('components/user_settings/display/UserSettingsDisplay', () => {
});
test('should update display state', () => {
- const wrapper = mountWithIntl(
);
+ const wrapper = mountWithIntl(
+
,
+ {
+ context: {store},
+ childContextTypes: {store: PropTypes.object},
+ },
+ );
wrapper.instance().handleOnChange({display: 'linkPreviewDisplay'});
expect(wrapper.state('display')).toBe('linkPreviewDisplay');
diff --git a/components/user_settings/display/user_settings_theme/__snapshots__/user_settings_theme.test.jsx.snap b/components/user_settings/display/user_settings_theme/__snapshots__/user_settings_theme.test.jsx.snap
index 178189f28130..1bc0a77d89c0 100644
--- a/components/user_settings/display/user_settings_theme/__snapshots__/user_settings_theme.test.jsx.snap
+++ b/components/user_settings/display/user_settings_theme/__snapshots__/user_settings_theme.test.jsx.snap
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/user_settings/display/user_settings_theme/user_settings_theme.jsx should match snapshot 1`] = `
-
}
describe={describe}
- focused={this.props.prevActiveSection === prevSections.email}
section={'email'}
updateSection={this.updateSection}
/>
@@ -890,7 +879,6 @@ class UserSettingsGeneralTab extends React.Component {
@@ -992,7 +980,6 @@ class UserSettingsGeneralTab extends React.Component {
@@ -1075,7 +1062,6 @@ class UserSettingsGeneralTab extends React.Component {
@@ -1178,7 +1164,6 @@ class UserSettingsGeneralTab extends React.Component {
@@ -1236,7 +1221,6 @@ class UserSettingsGeneralTab extends React.Component {
diff --git a/components/user_settings/general/user_settings_general.test.js b/components/user_settings/general/user_settings_general.test.js
index c7562c58824b..5ef800f7deb9 100644
--- a/components/user_settings/general/user_settings_general.test.js
+++ b/components/user_settings/general/user_settings_general.test.js
@@ -2,6 +2,8 @@
// See LICENSE.txt for license information.
import React from 'react';
+import {Provider} from 'react-redux';
+import configureStore from 'redux-mock-store';
import {shallowWithIntl, mountWithIntl} from 'tests/helpers/intl-test-helper.jsx';
@@ -18,7 +20,6 @@ describe('components/user_settings/general/UserSettingsGeneral', () => {
updateSection: jest.fn(),
updateTab: jest.fn(),
activeSection: '',
- prevActiveSection: '',
closeModal: jest.fn(),
collapseModal: jest.fn(),
actions: {
@@ -33,6 +34,15 @@ describe('components/user_settings/general/UserSettingsGeneral', () => {
maxFileSize: 1024,
};
+ const mockStore = configureStore();
+ const state = {
+ views: {
+ settings: {},
+ },
+ };
+
+ const store = mockStore(state);
+
test('submitUser() should have called updateMe', () => {
const updateMe = jest.fn().mockResolvedValue({data: true});
const props = {...requiredProps, actions: {...requiredProps.actions, updateMe}};
@@ -97,21 +107,33 @@ describe('components/user_settings/general/UserSettingsGeneral', () => {
props.ldapPositionAttributeSet = false;
props.samlPositionAttributeSet = false;
- let wrapper = mountWithIntl(
);
+ let wrapper = mountWithIntl(
+
+
+
+ );
expect(wrapper.find('#position').length).toBe(1);
expect(wrapper.find('#position').is('input')).toBeTruthy();
props.ldapPositionAttributeSet = true;
props.samlPositionAttributeSet = false;
- wrapper = mountWithIntl(
);
+ wrapper = mountWithIntl(
+
+
+
+ );
expect(wrapper.find('#position').length).toBe(0);
props.user.auth_service = 'saml';
props.ldapPositionAttributeSet = false;
props.samlPositionAttributeSet = true;
- wrapper = mountWithIntl(
);
+ wrapper = mountWithIntl(
+
+
+
+ );
expect(wrapper.find('#position').length).toBe(0);
});
});
diff --git a/components/user_settings/modal/user_settings_modal.jsx b/components/user_settings/modal/user_settings_modal.jsx
index 3dc9702df928..db1b0f042984 100644
--- a/components/user_settings/modal/user_settings_modal.jsx
+++ b/components/user_settings/modal/user_settings_modal.jsx
@@ -76,7 +76,6 @@ class UserSettingsModal extends React.Component {
this.state = {
active_tab: 'general',
active_section: '',
- prev_active_section: 'dummySectionName', // dummy value that should never match any section name
showConfirmModal: false,
enforceFocus: true,
show: true,
@@ -145,7 +144,6 @@ class UserSettingsModal extends React.Component {
this.setState({
active_tab: 'general',
active_section: '',
- prev_active_section: 'dummySectionName',
});
this.props.onHide();
}
@@ -157,7 +155,6 @@ class UserSettingsModal extends React.Component {
this.setState({
active_tab: '',
active_section: '',
- prev_active_section: '',
});
}
@@ -226,7 +223,6 @@ class UserSettingsModal extends React.Component {
this.setState({
active_tab: tab,
active_section: '',
- prev_active_section: 'dummySectionName',
});
}
}
@@ -236,7 +232,6 @@ class UserSettingsModal extends React.Component {
this.showConfirmModal(() => this.updateSection(section, true));
} else {
this.setState({
- prev_active_section: section ? '' : this.state.active_section,
active_section: section,
});
}
@@ -296,7 +291,6 @@ class UserSettingsModal extends React.Component {
doLoad={loadUserSettings}
activeTab={this.state.active_tab}
activeSection={this.state.active_section}
- prevActiveSection={this.state.prev_active_section}
updateSection={this.updateSection}
updateTab={this.updateTab}
closeModal={this.closeModal}
diff --git a/components/user_settings/notifications/__snapshots__/desktop_notification_settings.test.jsx.snap b/components/user_settings/notifications/__snapshots__/desktop_notification_settings.test.jsx.snap
index 40e6e30e4e72..471c28e4aff3 100644
--- a/components/user_settings/notifications/__snapshots__/desktop_notification_settings.test.jsx.snap
+++ b/components/user_settings/notifications/__snapshots__/desktop_notification_settings.test.jsx.snap
@@ -267,7 +267,7 @@ exports[`components/user_settings/notifications/DesktopNotificationSettings shou
`;
exports[`components/user_settings/notifications/DesktopNotificationSettings should match snapshot, on buildMinimizedSetting 1`] = `
-
{
diff --git a/components/user_settings/notifications/email_notification_setting/__snapshots__/email_notification_setting.test.jsx.snap b/components/user_settings/notifications/email_notification_setting/__snapshots__/email_notification_setting.test.jsx.snap
index df7863a0572c..b1c1617a6656 100644
--- a/components/user_settings/notifications/email_notification_setting/__snapshots__/email_notification_setting.test.jsx.snap
+++ b/components/user_settings/notifications/email_notification_setting/__snapshots__/email_notification_setting.test.jsx.snap
@@ -284,7 +284,7 @@ exports[`components/user_settings/notifications/EmailNotificationSetting should
`;
exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot, active section != email and SendEmailNotifications !== true 1`] = `
-
}
- focused={false}
section="email"
title="Email notifications"
updateSection={[Function]}
@@ -300,7 +299,7 @@ exports[`components/user_settings/notifications/EmailNotificationSetting should
`;
exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot, active section != email and SendEmailNotifications = true 1`] = `
-
}
- focused={false}
section="email"
title="Email notifications"
updateSection={[Function]}
@@ -316,7 +314,7 @@ exports[`components/user_settings/notifications/EmailNotificationSetting should
`;
exports[`components/user_settings/notifications/EmailNotificationSetting should match snapshot, active section != email, SendEmailNotifications = true and enableEmail = true 1`] = `
-
}
- focused={false}
section="email"
title="Email notifications"
updateSection={[Function]}
diff --git a/components/user_settings/notifications/email_notification_setting/email_notification_setting.jsx b/components/user_settings/notifications/email_notification_setting/email_notification_setting.jsx
index a647ffd61d80..880896416388 100644
--- a/components/user_settings/notifications/email_notification_setting/email_notification_setting.jsx
+++ b/components/user_settings/notifications/email_notification_setting/email_notification_setting.jsx
@@ -10,7 +10,7 @@ import {getEmailInterval} from 'mattermost-redux/utils/notify_props';
import {Preferences} from 'utils/constants.jsx';
import {localizeMessage} from 'utils/utils.jsx';
import SettingItemMax from 'components/setting_item_max.jsx';
-import SettingItemMin from 'components/setting_item_min.jsx';
+import SettingItemMin from 'components/setting_item_min';
const SECONDS_PER_MINUTE = 60;
diff --git a/components/user_settings/notifications/user_settings_notifications.jsx b/components/user_settings/notifications/user_settings_notifications.jsx
index f9bb90f700e9..d5e333a712fb 100644
--- a/components/user_settings/notifications/user_settings_notifications.jsx
+++ b/components/user_settings/notifications/user_settings_notifications.jsx
@@ -8,7 +8,7 @@ import {FormattedMessage} from 'react-intl';
import Constants, {NotificationLevels} from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';
import SettingItemMax from 'components/setting_item_max.jsx';
-import SettingItemMin from 'components/setting_item_min.jsx';
+import SettingItemMin from 'components/setting_item_min';
import DesktopNotificationSettings from './desktop_notification_settings.jsx';
import EmailNotificationSetting from './email_notification_setting';
@@ -107,20 +107,11 @@ function getNotificationsStateFromProps(props) {
};
}
-const prevSections = {
- desktop: 'dummySectionName', // dummy value that should never match any section name
- email: 'desktop',
- push: 'email',
- keys: 'push',
- comments: 'keys',
-};
-
export default class NotificationsTab extends React.Component {
static propTypes = {
user: PropTypes.object,
updateSection: PropTypes.func,
activeSection: PropTypes.string,
- prevActiveSection: PropTypes.string,
closeModal: PropTypes.func.isRequired,
collapseModal: PropTypes.func.isRequired,
siteName: PropTypes.string,
@@ -134,7 +125,6 @@ export default class NotificationsTab extends React.Component {
static defaultProps = {
user: null,
activeSection: '',
- prevActiveSection: '',
activeTab: '',
}
@@ -515,7 +505,6 @@ export default class NotificationsTab extends React.Component {
@@ -698,7 +687,6 @@ export default class NotificationsTab extends React.Component {
@@ -822,7 +810,6 @@ export default class NotificationsTab extends React.Component {
@@ -938,7 +925,6 @@ export default class NotificationsTab extends React.Component {
cancel={this.handleCancel}
error={this.state.serverError}
active={this.props.activeSection === 'desktop'}
- focused={this.props.prevActiveSection === prevSections.desktop}
/>
diff --git a/components/user_settings/notifications/user_settings_notifications.test.js b/components/user_settings/notifications/user_settings_notifications.test.js
index 6374384d2158..d6dba9f1f01b 100644
--- a/components/user_settings/notifications/user_settings_notifications.test.js
+++ b/components/user_settings/notifications/user_settings_notifications.test.js
@@ -17,7 +17,6 @@ describe('components/user_settings/display/UserSettingsDisplay', () => {
activeSection: '',
closeModal: jest.fn(),
collapseModal: jest.fn(),
- prevActiveSection: '',
actions: {
updateMe: jest.fn(() => Promise.resolve({})),
},
diff --git a/components/user_settings/security/mfa_section/__snapshots__/mfa_section.test.jsx.snap b/components/user_settings/security/mfa_section/__snapshots__/mfa_section.test.jsx.snap
index aa9c187ae303..1472a5c074c3 100644
--- a/components/user_settings/security/mfa_section/__snapshots__/mfa_section.test.jsx.snap
+++ b/components/user_settings/security/mfa_section/__snapshots__/mfa_section.test.jsx.snap
@@ -3,7 +3,7 @@
exports[`MfaSection rendering should render nothing when MFA is not available 1`] = `""`;
exports[`MfaSection rendering when section is collapsed and MFA is active 1`] = `
-
}
- focused={false}
section="mfa"
title={
}
- focused={false}
section="mfa"
title={
- ,
]
}
- focused={true}
section="groupChannels"
title={
-
}
- focused={false}
section="channelSwitcher"
title={
);
}
@@ -587,7 +584,6 @@ export default class UserSettingsSidebar extends React.Component {
describe={this.renderOrganizationLabel()}
section={'groupChannels'}
updateSection={this.updateSection}
- focused={this.props.prevActiveSection === this.getPreviousSection('groupChannels')}
/>
);
}
@@ -690,7 +686,6 @@ export default class UserSettingsSidebar extends React.Component {
describe={this.renderChannelSwitcherLabel(this.props.channelSwitcherOption)}
section={'channelSwitcher'}
updateSection={this.updateSection}
- focused={this.props.prevActiveSection === this.getPreviousSection('channelSwitcher')}
/>
);
};
diff --git a/components/user_settings/sidebar/user_settings_sidebar.test.jsx b/components/user_settings/sidebar/user_settings_sidebar.test.jsx
index f01968b1e844..0c6f43c3ea1a 100644
--- a/components/user_settings/sidebar/user_settings_sidebar.test.jsx
+++ b/components/user_settings/sidebar/user_settings_sidebar.test.jsx
@@ -2,6 +2,8 @@
// See LICENSE.txt for license information.
import React from 'react';
+import PropTypes from 'prop-types';
+import configureStore from 'redux-mock-store';
import {mountWithIntl, shallowWithIntl} from 'tests/helpers/intl-test-helper.jsx';
@@ -30,8 +32,15 @@ describe('components/user_settings/sidebar/UserSettingsSidebar', () => {
actions: {
savePreferences: () => true,
},
- prevActiveSection: 'dummySectionName',
};
+ const mockStore = configureStore();
+ const state = {
+ views: {
+ settings: {},
+ },
+ };
+
+ const store = mockStore(state);
test('should match snapshot', () => {
const wrapper = shallowWithIntl();
@@ -64,7 +73,13 @@ describe('components/user_settings/sidebar/UserSettingsSidebar', () => {
test('should pass handleChange for channel grouping', () => {
const props = {...defaultProps, activeSection: 'groupChannels'};
- const wrapper = mountWithIntl();
+ const wrapper = mountWithIntl(
+ ,
+ {
+ context: {store},
+ childContextTypes: {store: PropTypes.object},
+ },
+ );
wrapper.find('#noneOption').simulate('change');
expect(wrapper.state('settings')).toEqual({
@@ -135,7 +150,13 @@ describe('components/user_settings/sidebar/UserSettingsSidebar', () => {
...defaultProps.sidebarPreference,
grouping: 'none',
}};
- const wrapper = mountWithIntl();
+ const wrapper = mountWithIntl(
+ ,
+ {
+ context: {store},
+ childContextTypes: {store: PropTypes.object},
+ },
+ );
wrapper.find('#recentSectionEnabled').simulate('change');
expect(wrapper.state('settings')).toEqual({
diff --git a/components/user_settings/user_settings.jsx b/components/user_settings/user_settings.jsx
index 118eb1b347e0..308f3f44a384 100644
--- a/components/user_settings/user_settings.jsx
+++ b/components/user_settings/user_settings.jsx
@@ -16,7 +16,6 @@ export default class UserSettings extends React.PureComponent {
user: PropTypes.object.isRequired,
activeTab: PropTypes.string,
activeSection: PropTypes.string,
- prevActiveSection: PropTypes.string,
updateSection: PropTypes.func,
updateTab: PropTypes.func,
closeModal: PropTypes.func.isRequired,
@@ -32,7 +31,6 @@ export default class UserSettings extends React.PureComponent {