Skip to content

Commit

Permalink
MM-12810 Webapp redirecting to select_team page when base url is hit (m…
Browse files Browse the repository at this point in the history
…attermost#1945)

* MM-12810 Webapp redirecting to select_team page when base url is hit

* Remove user store dependency
  • Loading branch information
sudheerDev committed Oct 26, 2018
1 parent 5391c9f commit 96752fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 1 addition & 4 deletions components/root/root.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {trackLoadTime} from 'actions/diagnostics_actions.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import BrowserStore from 'stores/browser_store.jsx';
import ErrorStore from 'stores/error_store.jsx';
import UserStore from 'stores/user_store.jsx';
import {loadRecentlyUsedCustomEmojis} from 'actions/emoji_actions.jsx';
import * as I18n from 'i18n/i18n.jsx';
import {initializePlugins} from 'plugins';
Expand Down Expand Up @@ -189,7 +188,6 @@ export default class Root extends React.Component {
const afterIntl = () => {
initializePlugins();

this.redirectIfNecessary(this.props);
this.setState({configLoaded: true});
};
if (global.Intl) {
Expand Down Expand Up @@ -221,8 +219,6 @@ export default class Root extends React.Component {
this.props.history.push('/signup_user_complete');
} else if (props.showTermsOfService) {
this.props.history.push('/terms_of_service');
} else if (UserStore.getCurrentUser()) {
GlobalActions.redirectUserToDefaultTeam();
}
}
}
Expand All @@ -233,6 +229,7 @@ export default class Root extends React.Component {

componentDidMount() {
this.props.actions.loadMeAndConfig().then(() => {
GlobalActions.redirectUserToDefaultTeam();
this.onConfigLoaded();
});

Expand Down
8 changes: 7 additions & 1 deletion tests/components/root/root.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React from 'react';
import {shallow} from 'enzyme';

import Root from 'components/root/root';
import * as GlobalActions from 'actions/global_actions.jsx';

jest.mock('fastclick', () => ({
attach: () => {}, // eslint-disable-line no-empty-function
Expand All @@ -14,6 +15,10 @@ jest.mock('actions/diagnostics_actions', () => ({
trackLoadTime: () => {}, // eslint-disable-line no-empty-function
}));

jest.mock('actions/global_actions', () => ({
redirectUserToDefaultTeam: jest.fn(),
}));

describe('components/Root', () => {
const baseProps = {
diagnosticsEnabled: true,
Expand All @@ -25,7 +30,7 @@ describe('components/Root', () => {
},
};

test('should load user, config, and license on mount', (done) => {
test('should load user, config, and license on mount and redirect to defaultTeam on success', (done) => {
const props = {
...baseProps,
actions: {
Expand All @@ -38,6 +43,7 @@ describe('components/Root', () => {
class MockedRoot extends Root {
onConfigLoaded = jest.fn(() => {
expect(this.onConfigLoaded).toHaveBeenCalledTimes(1);
expect(GlobalActions.redirectUserToDefaultTeam).toHaveBeenCalledTimes(1);
done();
});
}
Expand Down

0 comments on commit 96752fe

Please sign in to comment.