diff --git a/webapp/channels/src/actions/websocket_actions.jsx b/webapp/channels/src/actions/websocket_actions.jsx index 9e5caa492a..bbd33bdc1c 100644 --- a/webapp/channels/src/actions/websocket_actions.jsx +++ b/webapp/channels/src/actions/websocket_actions.jsx @@ -1503,6 +1503,10 @@ function handleSidebarCategoryCreated(msg) { return (doDispatch, doGetState) => { const state = doGetState(); + if (!msg.broadcast.team_id) { + return; + } + if (msg.broadcast.team_id !== getCurrentTeamId(state)) { // The new category will be loaded when we switch teams. return; @@ -1518,6 +1522,10 @@ function handleSidebarCategoryUpdated(msg) { return (doDispatch, doGetState) => { const state = doGetState(); + if (!msg.broadcast.team_id) { + return; + } + if (msg.broadcast.team_id !== getCurrentTeamId(state)) { // The updated categories will be loaded when we switch teams. return; @@ -1533,6 +1541,10 @@ function handleSidebarCategoryDeleted(msg) { return (doDispatch, doGetState) => { const state = doGetState(); + if (!msg.broadcast.team_id) { + return; + } + if (msg.broadcast.team_id !== getCurrentTeamId(state)) { // The category will be removed when we switch teams. return; diff --git a/webapp/channels/src/components/root/root.test.tsx b/webapp/channels/src/components/root/root.test.tsx index 27f6ed19dd..75705ad226 100644 --- a/webapp/channels/src/components/root/root.test.tsx +++ b/webapp/channels/src/components/root/root.test.tsx @@ -15,6 +15,7 @@ import * as GlobalActions from 'actions/global_actions'; import testConfigureStore from 'packages/mattermost-redux/test/test_store'; import {renderWithContext, waitFor} from 'tests/react_testing_utils'; import {StoragePrefixes} from 'utils/constants'; +import * as Utils from 'utils/utils'; import {handleLoginLogoutSignal, redirectToOnboardingOrDefaultTeam} from './actions'; import type {Props} from './root'; @@ -49,14 +50,9 @@ jest.mock('components/team_sidebar', () => () =>
); jest.mock('components/mobile_view_watcher', () => () => ); jest.mock('./performance_reporter_controller', () => () => ); -jest.mock('utils/utils', () => { - const original = jest.requireActual('utils/utils'); - - return { - ...original, - applyTheme: jest.fn(), - }; -}); +jest.mock('utils/utils', () => ({ + applyTheme: jest.fn(), +})); jest.mock('actions/global_actions', () => ({ redirectUserToDefaultTeam: jest.fn(), @@ -74,7 +70,7 @@ describe('components/Root', () => { const store = testConfigureStore(); const baseProps: Props = { - theme: {} as Theme, + theme: {sidebarBg: 'color'} as Theme, isConfigLoaded: true, telemetryEnabled: true, noAccounts: false, @@ -372,6 +368,51 @@ describe('components/Root', () => { }); }); }); + + describe('applyTheme', () => { + test('should apply theme initially and on change', async () => { + const props = { + ...baseProps, + }; + + const {rerender} = renderWithContext(