From f1898f084886a50c299b99ad30fc66343f90ab82 Mon Sep 17 00:00:00 2001 From: "anton.buksa" Date: Tue, 29 Oct 2024 17:55:34 +0100 Subject: [PATCH 1/4] move ksuite bridge to redux package for tests Changelog: chore --- .../channels/src/actions/notification_actions.jsx | 2 +- .../get_app_announcement_bar/index.tsx | 2 +- .../collapse_rhs_button/index.ts | 2 +- .../src/components/channel_header_mobile/index.ts | 2 +- .../src/components/close_suite_sidepanel/index.ts | 2 +- webapp/channels/src/components/root/index.ts | 2 +- webapp/channels/src/components/root/root.tsx | 2 +- .../src/components/status_dropdown/index.ts | 2 +- .../channels/src/components/switch_server/index.ts | 2 +- .../components/switch_server/switch_item/index.ts | 2 +- .../mattermost-redux/src/action_types/index.ts | 2 ++ .../src/action_types/ksuiteBridge.ts | 10 ++++++++++ .../mattermost-redux/src/actions/ksuiteBridge.ts} | 7 ++++--- .../packages/mattermost-redux/src/actions/users.ts | 5 ++--- .../src/reducers/entities/index.ts | 2 ++ .../src/reducers/entities/ksuiteBridge.ts} | 4 +--- .../src/selectors/entities/ksuiteBridge.ts} | 14 +++++--------- .../mattermost-redux/src/store/initial_state.ts | 6 ++++++ webapp/channels/src/reducers/index.ts | 2 -- webapp/channels/src/types/store/index.ts | 8 -------- webapp/platform/types/src/store.ts | 6 ++++++ 21 files changed, 48 insertions(+), 38 deletions(-) create mode 100644 webapp/channels/src/packages/mattermost-redux/src/action_types/ksuiteBridge.ts rename webapp/channels/src/{actions/ksuite_bridge_actions.ts => packages/mattermost-redux/src/actions/ksuiteBridge.ts} (86%) rename webapp/channels/src/{reducers/plugins/ksuite_bridge.ts => packages/mattermost-redux/src/reducers/entities/ksuiteBridge.ts} (92%) rename webapp/channels/src/{selectors/ksuite_bridge.ts => packages/mattermost-redux/src/selectors/entities/ksuiteBridge.ts} (50%) diff --git a/webapp/channels/src/actions/notification_actions.jsx b/webapp/channels/src/actions/notification_actions.jsx index 9907da50ea..5a94d91201 100644 --- a/webapp/channels/src/actions/notification_actions.jsx +++ b/webapp/channels/src/actions/notification_actions.jsx @@ -7,6 +7,7 @@ import {logError} from 'mattermost-redux/actions/errors'; import {getProfilesByIds} from 'mattermost-redux/actions/users'; import {getCurrentChannel, getMyChannelMember, makeGetChannel} from 'mattermost-redux/selectors/entities/channels'; import {getConfig} from 'mattermost-redux/selectors/entities/general'; +import {getKSuiteBridge, getKSuiteDnd} from 'mattermost-redux/selectors/entities/ksuiteBridge'; import { getTeammateNameDisplaySetting, isCollapsedThreadsEnabled, @@ -17,7 +18,6 @@ import {isChannelMuted} from 'mattermost-redux/utils/channel_utils'; import {isSystemMessage, isUserAddedInChannel} from 'mattermost-redux/utils/post_utils'; import {displayUsername} from 'mattermost-redux/utils/user_utils'; -import {getKSuiteBridge, getKSuiteDnd} from 'selectors/ksuite_bridge'; import {getChannelURL, getPermalinkURL} from 'selectors/urls'; import {isThreadOpen} from 'selectors/views/threads'; diff --git a/webapp/channels/src/components/announcement_bar/get_app_announcement_bar/index.tsx b/webapp/channels/src/components/announcement_bar/get_app_announcement_bar/index.tsx index 4e5f97b14f..17c6b6738d 100644 --- a/webapp/channels/src/components/announcement_bar/get_app_announcement_bar/index.tsx +++ b/webapp/channels/src/components/announcement_bar/get_app_announcement_bar/index.tsx @@ -6,7 +6,7 @@ import {useIntl} from 'react-intl'; import {useDispatch, useSelector} from 'react-redux'; import {openModal} from 'actions/views/modals'; -import {getKSuiteBridge} from 'selectors/ksuite_bridge'; +import {getKSuiteBridge} from 'mattermost-redux/selectors/entities/ksuiteBridge'; import {getAnnouncementBarCount} from 'selectors/views/announcement_bar'; import AnnouncementBar from 'components/announcement_bar/default_announcement_bar'; diff --git a/webapp/channels/src/components/channel_header_mobile/collapse_rhs_button/index.ts b/webapp/channels/src/components/channel_header_mobile/collapse_rhs_button/index.ts index 83097e57cc..77ff8415b1 100644 --- a/webapp/channels/src/components/channel_header_mobile/collapse_rhs_button/index.ts +++ b/webapp/channels/src/components/channel_header_mobile/collapse_rhs_button/index.ts @@ -6,7 +6,7 @@ import type {Dispatch} from 'redux'; import {bindActionCreators} from 'redux'; import {toggleMenu as toggleRhsMenu} from 'actions/views/rhs'; -import {getKSuiteBridge} from 'selectors/ksuite_bridge'; +import {getKSuiteBridge} from 'mattermost-redux/selectors/entities/ksuiteBridge'; import type {GlobalState} from 'types/store'; diff --git a/webapp/channels/src/components/channel_header_mobile/index.ts b/webapp/channels/src/components/channel_header_mobile/index.ts index ed7671dd53..eb90f2da9c 100644 --- a/webapp/channels/src/components/channel_header_mobile/index.ts +++ b/webapp/channels/src/components/channel_header_mobile/index.ts @@ -21,7 +21,7 @@ import { closeRightHandSide as closeRhs, closeMenu as closeRhsMenu, } from 'actions/views/rhs'; -import {getKSuiteBridge} from 'selectors/ksuite_bridge'; +import {getKSuiteBridge} from 'mattermost-redux/selectors/entities/ksuiteBridge'; import {getIsMobileView} from 'selectors/views/browser'; import type {GlobalState} from 'types/store'; diff --git a/webapp/channels/src/components/close_suite_sidepanel/index.ts b/webapp/channels/src/components/close_suite_sidepanel/index.ts index c893b09f2a..06caf31935 100644 --- a/webapp/channels/src/components/close_suite_sidepanel/index.ts +++ b/webapp/channels/src/components/close_suite_sidepanel/index.ts @@ -4,7 +4,7 @@ import {connect} from 'react-redux'; import {withRouter} from 'react-router-dom'; -import {getKSuiteBridge} from 'selectors/ksuite_bridge'; +import {getKSuiteBridge} from 'mattermost-redux/selectors/entities/ksuiteBridge'; import type {GlobalState} from 'types/store'; diff --git a/webapp/channels/src/components/root/index.ts b/webapp/channels/src/components/root/index.ts index 3af846cba4..bd2cab4322 100644 --- a/webapp/channels/src/components/root/index.ts +++ b/webapp/channels/src/components/root/index.ts @@ -17,7 +17,7 @@ import {shouldShowTermsOfService, getCurrentUserId} from 'mattermost-redux/selec import {migrateRecentEmojis} from 'actions/emoji_actions'; import {emitBrowserWindowResized} from 'actions/views/browser'; import {loadConfigAndMe, registerCustomPostRenderer} from 'actions/views/root'; -import {getKSuiteBridge} from 'selectors/ksuite_bridge'; +import {getKSuiteBridge} from 'mattermost-redux/selectors/entities/ksuiteBridge'; import {getShowLaunchingWorkspace} from 'selectors/onboarding'; import {shouldShowAppBar} from 'selectors/plugins'; import { diff --git a/webapp/channels/src/components/root/root.tsx b/webapp/channels/src/components/root/root.tsx index bb8835280e..0e585f65b8 100644 --- a/webapp/channels/src/components/root/root.tsx +++ b/webapp/channels/src/components/root/root.tsx @@ -16,6 +16,7 @@ import type {UserProfile} from '@mattermost/types/users'; import {setSystemEmojis} from 'mattermost-redux/actions/emojis'; import {setUrl} from 'mattermost-redux/actions/general'; +import {storeBridge, storeBridgeParam} from 'mattermost-redux/actions/ksuiteBridge'; import {Client4} from 'mattermost-redux/client'; import {rudderAnalytics, RudderTelemetryHandler} from 'mattermost-redux/client/rudder'; import {General} from 'mattermost-redux/constants'; @@ -28,7 +29,6 @@ import type {ActionResult} from 'mattermost-redux/types/actions'; import {loadRecentlyUsedCustomEmojis} from 'actions/emoji_actions'; import * as GlobalActions from 'actions/global_actions'; -import {storeBridge, storeBridgeParam} from 'actions/ksuite_bridge_actions'; import {measurePageLoadTelemetry, temporarilySetPageLoadContext, trackEvent, trackSelectorMetrics} from 'actions/telemetry_actions.jsx'; import {clearUserCookie} from 'actions/views/cookie'; import {setThemePreference} from 'actions/views/theme'; diff --git a/webapp/channels/src/components/status_dropdown/index.ts b/webapp/channels/src/components/status_dropdown/index.ts index 09492ca7f7..e3178c89ff 100644 --- a/webapp/channels/src/components/status_dropdown/index.ts +++ b/webapp/channels/src/components/status_dropdown/index.ts @@ -16,7 +16,7 @@ import {getCurrentUser, getStatusForUserId, isCurrentUserGuestUser} from 'matter import {openModal} from 'actions/views/modals'; import {setStatusDropdown} from 'actions/views/status_dropdown'; -import {getKSuiteBridge} from 'selectors/ksuite_bridge'; +import {getKSuiteBridge} from 'mattermost-redux/selectors/entities/ksuiteBridge'; import {getShowTutorialStep} from 'selectors/onboarding'; import {makeGetCustomStatus, isCustomStatusEnabled, showStatusDropdownPulsatingDot, isCustomStatusExpired} from 'selectors/views/custom_status'; import {isStatusDropdownOpen} from 'selectors/views/status_dropdown'; diff --git a/webapp/channels/src/components/switch_server/index.ts b/webapp/channels/src/components/switch_server/index.ts index fff7f5622b..09ca3c7aac 100644 --- a/webapp/channels/src/components/switch_server/index.ts +++ b/webapp/channels/src/components/switch_server/index.ts @@ -7,7 +7,7 @@ import {withRouter} from 'react-router-dom'; import {getTeamsOrderCookie} from 'mattermost-redux/utils/team_utils'; -import {getKSuiteSpaceId} from 'selectors/ksuite_bridge'; +import {getKSuiteSpaceId} from 'mattermost-redux/selectors/entities/ksuiteBridge'; import {getCurrentServer, getOtherServers, getServersUnreadStatus, isMultiServer} from 'selectors/views/servers'; import type {GlobalState} from 'types/store'; diff --git a/webapp/channels/src/components/switch_server/switch_item/index.ts b/webapp/channels/src/components/switch_server/switch_item/index.ts index 1c6494c315..bd163928ae 100644 --- a/webapp/channels/src/components/switch_server/switch_item/index.ts +++ b/webapp/channels/src/components/switch_server/switch_item/index.ts @@ -9,9 +9,9 @@ import {bindActionCreators} from 'redux'; import type {Team} from '@mattermost/types/teams'; +import {bridgeRecreate} from 'mattermost-redux/actions/ksuiteBridge'; import type {GetStateFunc} from 'mattermost-redux/types/actions'; -import {bridgeRecreate} from 'actions/ksuite_bridge_actions'; import {switchTeam} from 'actions/team_actions'; import {makeGetBadgeCountForServerId} from 'selectors/views/servers'; diff --git a/webapp/channels/src/packages/mattermost-redux/src/action_types/index.ts b/webapp/channels/src/packages/mattermost-redux/src/action_types/index.ts index b239f03b2f..2e86bdc1f0 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/action_types/index.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/action_types/index.ts @@ -18,6 +18,7 @@ import HostedCustomerTypes from './hosted_customer'; import InsightTypes from './insights'; import IntegrationTypes from './integrations'; import JobTypes from './jobs'; +import BridgeActionTypes from './ksuiteBridge'; import LimitsTypes from './limits'; import PlaybookType from './playbooks'; import PluginTypes from './plugins'; @@ -61,4 +62,5 @@ export { WorkTemplatesType, DraftTypes, PlaybookType, + BridgeActionTypes, }; diff --git a/webapp/channels/src/packages/mattermost-redux/src/action_types/ksuiteBridge.ts b/webapp/channels/src/packages/mattermost-redux/src/action_types/ksuiteBridge.ts new file mode 100644 index 0000000000..4cf7221597 --- /dev/null +++ b/webapp/channels/src/packages/mattermost-redux/src/action_types/ksuiteBridge.ts @@ -0,0 +1,10 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import keyMirror from 'mattermost-redux/utils/key_mirror'; + +export default keyMirror({ + STORE_BRIDGE: null, + DND_CHANGE: null, + UPDATE_PARAMS_DATA: null, +}); diff --git a/webapp/channels/src/actions/ksuite_bridge_actions.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/ksuiteBridge.ts similarity index 86% rename from webapp/channels/src/actions/ksuite_bridge_actions.ts rename to webapp/channels/src/packages/mattermost-redux/src/actions/ksuiteBridge.ts index ff4df0346e..f2d8ea750d 100644 --- a/webapp/channels/src/actions/ksuite_bridge_actions.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/ksuiteBridge.ts @@ -4,9 +4,10 @@ import type {DoNotDisturbMessage, KSuiteBridge} from '@infomaniak/ksuite-bridge'; import {AppReadyMessageKey, DoNotDisturbMessageKey, RecreateMessageKey} from '@infomaniak/ksuite-bridge'; +import {BridgeActionTypes} from 'mattermost-redux/action_types'; import type {DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions'; -import {BridgeActionTypes, BridgeParamWhitelist} from 'utils/constants'; +const BridgeParamWhitelist = ['spaceId', 'ksuiteMode']; export function storeBridge(bridge: KSuiteBridge) { return async (dispatch: DispatchFunc, getState: GetStateFunc) => { @@ -20,7 +21,7 @@ export function storeBridge(bridge: KSuiteBridge) { }); bridge.on(DoNotDisturbMessageKey, (doNotDisturbMessage: DoNotDisturbMessage) => { - if (doNotDisturbMessage.enabled !== getState().ksuite_bridge.dnd) { + if (doNotDisturbMessage.enabled !== getState().entities.ksuiteBridge.dnd) { dispatch({ type: BridgeActionTypes.DND_CHANGE, dnd: doNotDisturbMessage.enabled, @@ -36,7 +37,7 @@ export function bridgeRecreate(url: string) { return (_: DispatchFunc, getState: GetStateFunc) => { const state = getState(); const urlObj = new URL(url); - const {bridge, ksuiteMode, spaceId} = state.ksuite_bridge; + const {bridge, ksuiteMode, spaceId} = state.entities.ksuiteBridge; if (ksuiteMode) { urlObj.searchParams.append('ksuite-mode', ksuiteMode); diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/users.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/users.ts index 190749f529..7e37d8f8a8 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/users.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/users.ts @@ -12,6 +12,7 @@ import {UserTypes, AdminTypes} from 'mattermost-redux/action_types'; import {logError} from 'mattermost-redux/actions/errors'; import {setServerVersion, getClientConfig, getLicenseConfig} from 'mattermost-redux/actions/general'; import {bindClientFunc, forceLogoutIfNecessary, debounce} from 'mattermost-redux/actions/helpers'; +import {bridgeRecreate} from 'mattermost-redux/actions/ksuiteBridge'; import {getUsersLimits} from 'mattermost-redux/actions/limits'; import {getMyPreferences} from 'mattermost-redux/actions/preferences'; import {loadRolesIfNeeded} from 'mattermost-redux/actions/roles'; @@ -27,7 +28,6 @@ import {getLastKSuiteSeenId} from 'mattermost-redux/utils/team_utils'; // TODO fix import restriction import {getMyMeets} from 'actions/calls'; -import {bridgeRecreate} from 'actions/ksuite_bridge_actions'; import {getHistory} from 'utils/browser_history'; import {isDesktopApp} from 'utils/user_agent'; @@ -74,8 +74,7 @@ export function loadMe(): ActionFuncAsync { const serverVersion = Client4.getServerVersion(); dispatch(setServerVersion(serverVersion)); - // @ts-expect-error todo fix type - const bridge = getState().ksuite_bridge.bridge; + const bridge = getState().entities.ksuiteBridge.bridge; if (!bridge.isConnected && !isDesktopApp() && Client4.isIkBaseUrl() && process.env.NODE_ENV !== 'test' && process.env.NODE_ENV !== 'development') { //eslint-disable-line no-process-env // eslint-disable-next-line no-process-env diff --git a/webapp/channels/src/packages/mattermost-redux/src/reducers/entities/index.ts b/webapp/channels/src/packages/mattermost-redux/src/reducers/entities/index.ts index ba11702d9c..6bdef07769 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/reducers/entities/index.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/reducers/entities/index.ts @@ -18,6 +18,7 @@ import hostedCustomer from './hosted_customer'; import insights from './insights'; import integrations from './integrations'; import jobs from './jobs'; +import ksuiteBridge from './ksuiteBridge'; import limits from './limits'; import posts from './posts'; import preferences from './preferences'; @@ -59,4 +60,5 @@ export default combineReducers({ insights, usage, hostedCustomer, + ksuiteBridge, }); diff --git a/webapp/channels/src/reducers/plugins/ksuite_bridge.ts b/webapp/channels/src/packages/mattermost-redux/src/reducers/entities/ksuiteBridge.ts similarity index 92% rename from webapp/channels/src/reducers/plugins/ksuite_bridge.ts rename to webapp/channels/src/packages/mattermost-redux/src/reducers/entities/ksuiteBridge.ts index 12cfd9cbf7..ed18fa035c 100644 --- a/webapp/channels/src/reducers/plugins/ksuite_bridge.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/reducers/entities/ksuiteBridge.ts @@ -5,9 +5,7 @@ import type {AnyAction} from 'redux'; import {combineReducers} from 'redux'; -import {UserTypes} from 'mattermost-redux/action_types'; - -import {BridgeActionTypes} from 'utils/constants'; +import {BridgeActionTypes, UserTypes} from 'mattermost-redux/action_types'; function bridge(state = null, action: AnyAction) { switch (action.type) { diff --git a/webapp/channels/src/selectors/ksuite_bridge.ts b/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/ksuiteBridge.ts similarity index 50% rename from webapp/channels/src/selectors/ksuite_bridge.ts rename to webapp/channels/src/packages/mattermost-redux/src/selectors/entities/ksuiteBridge.ts index 06f13d717a..59786293f2 100644 --- a/webapp/channels/src/selectors/ksuite_bridge.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/ksuiteBridge.ts @@ -1,23 +1,19 @@ - -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - import type {KSuiteBridge} from '@infomaniak/ksuite-bridge'; -import type {GlobalState} from 'types/store'; +import type {GlobalState} from '@mattermost/types/store'; export function getKSuiteBridge(state: GlobalState): KSuiteBridge { - return state.ksuite_bridge.bridge; + return state.entities.ksuiteBridge.bridge; } export function getKSuiteDnd(state: GlobalState): boolean { - return state.ksuite_bridge.dnd; + return state.entities.ksuiteBridge.dnd; } export function getKSuiteMode(state: GlobalState): string { - return state.ksuite_bridge.ksuiteMode; + return state.entities.ksuiteBridge.ksuiteMode; } export function getKSuiteSpaceId(state: GlobalState): string { - return state.ksuite_bridge.spaceId; + return state.entities.ksuiteBridge.spaceId; } diff --git a/webapp/channels/src/packages/mattermost-redux/src/store/initial_state.ts b/webapp/channels/src/packages/mattermost-redux/src/store/initial_state.ts index b443d5f3ab..e1afcb26ad 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/store/initial_state.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/store/initial_state.ts @@ -279,6 +279,12 @@ const state: GlobalState = { topReactions: {}, myTopReactions: {}, }, + ksuiteBridge: { + bridge: undefined, + dnd: false, + spaceId: '', + ksuiteMode: '', + }, }, errors: [], requests: { diff --git a/webapp/channels/src/reducers/index.ts b/webapp/channels/src/reducers/index.ts index 95ceefef01..4ffc251908 100644 --- a/webapp/channels/src/reducers/index.ts +++ b/webapp/channels/src/reducers/index.ts @@ -3,7 +3,6 @@ import plugins from './plugins'; import kdrive from './plugins/kdrive'; -import ksuite_bridge from './plugins/ksuite_bridge'; import storage from './storage'; import views from './views'; @@ -12,5 +11,4 @@ export default { plugins, storage, kdrive, - ksuite_bridge, }; diff --git a/webapp/channels/src/types/store/index.ts b/webapp/channels/src/types/store/index.ts index 9e3a2888aa..68f88440e3 100644 --- a/webapp/channels/src/types/store/index.ts +++ b/webapp/channels/src/types/store/index.ts @@ -1,8 +1,6 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import type {KSuiteBridge} from '@infomaniak/ksuite-bridge'; - import type {GlobalState as BaseGlobalState} from '@mattermost/types/store'; import type {PluginsState} from './plugins'; @@ -16,12 +14,6 @@ export type DraggingState = { export type GlobalState = BaseGlobalState & { plugins: PluginsState; - ksuite_bridge: { - bridge: KSuiteBridge; - dnd: boolean; - spaceId: string; - ksuiteMode: string; - }; kdrive: { toast: { message: string; diff --git a/webapp/platform/types/src/store.ts b/webapp/platform/types/src/store.ts index 058750f039..6a740b5659 100644 --- a/webapp/platform/types/src/store.ts +++ b/webapp/platform/types/src/store.ts @@ -74,6 +74,12 @@ export type GlobalState = { hostedCustomer: HostedCustomerState; usage: CloudUsage; insights: InsightsState; + ksuiteBridge: { + bridge: any; + dnd: boolean; + spaceId: string; + ksuiteMode: string; + } }; errors: any[]; requests: { From f469a2a3d0c63749ca8e87bf24661ab2cd2be48f Mon Sep 17 00:00:00 2001 From: "anton.buksa" Date: Tue, 29 Oct 2024 18:18:23 +0100 Subject: [PATCH 2/4] mock bridge in users tests --- .../src/components/signup/signup.test.tsx | 333 ------------------ .../src/actions/users.test.ts | 6 + 2 files changed, 6 insertions(+), 333 deletions(-) delete mode 100644 webapp/channels/src/components/signup/signup.test.tsx diff --git a/webapp/channels/src/components/signup/signup.test.tsx b/webapp/channels/src/components/signup/signup.test.tsx deleted file mode 100644 index b73d144461..0000000000 --- a/webapp/channels/src/components/signup/signup.test.tsx +++ /dev/null @@ -1,333 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -import type {ReactWrapper} from 'enzyme'; -import {shallow} from 'enzyme'; -import React from 'react'; -import {IntlProvider} from 'react-intl'; -import {BrowserRouter} from 'react-router-dom'; - -import type {ClientConfig} from '@mattermost/types/config'; - -import {RequestStatus} from 'mattermost-redux/constants'; - -import * as useCWSAvailabilityCheckAll from 'components/common/hooks/useCWSAvailabilityCheck'; -import SaveButton from 'components/save_button'; -import Signup from 'components/signup/signup'; -import Input from 'components/widgets/inputs/input/input'; -import PasswordInput from 'components/widgets/inputs/password_input/password_input'; - -import {mountWithIntl} from 'tests/helpers/intl-test-helper'; -import {act, renderWithContext, screen} from 'tests/react_testing_utils'; -import {WindowSizes} from 'utils/constants'; - -import type {GlobalState} from 'types/store'; - -let mockState: GlobalState; -let mockLocation = {pathname: '', search: '', hash: ''}; -const mockHistoryPush = jest.fn(); -let mockLicense = {IsLicensed: 'true', Cloud: 'false'}; -let mockConfig: Partial; -let mockDispatch = jest.fn(); - -const intlProviderProps = { - defaultLocale: 'en', - locale: 'en', - messages: {}, -}; - -jest.mock('react-redux', () => ({ - ...jest.requireActual('react-redux') as typeof import('react-redux'), - useSelector: (selector: (state: typeof mockState) => unknown) => selector(mockState), - useDispatch: () => mockDispatch, -})); - -jest.mock('react-router-dom', () => ({ - ...jest.requireActual('react-router-dom') as typeof import('react-router-dom'), - useLocation: () => mockLocation, - useHistory: () => ({ - push: mockHistoryPush, - }), -})); - -jest.mock('mattermost-redux/selectors/entities/general', () => ({ - ...jest.requireActual('mattermost-redux/selectors/entities/general') as typeof import('mattermost-redux/selectors/entities/general'), - getLicense: () => mockLicense, - getConfig: () => mockConfig, -})); - -jest.mock('mattermost-redux/selectors/entities/users', () => ({ - ...jest.requireActual('mattermost-redux/selectors/entities/users') as typeof import('mattermost-redux/selectors/entities/users'), - getCurrentUserId: () => '', -})); - -jest.mock('actions/team_actions', () => ({ - ...jest.requireActual('actions/team_actions') as typeof import('actions/team_actions'), - addUsersToTeamFromInvite: jest.fn().mockResolvedValue({name: 'teamName'}), -})); - -jest.mock('mattermost-redux/actions/users', () => ({ - ...jest.requireActual('mattermost-redux/actions/users') as typeof import('mattermost-redux/actions/users'), - createUser: jest.fn().mockResolvedValue({data: {}}), -})); - -jest.mock('actions/views/login', () => ({ - ...jest.requireActual('actions/views/login') as typeof import('actions/views/login'), - loginById: jest.fn().mockResolvedValue({data: {}}), -})); - -jest.mock('actions/team_actions', () => ({ - ...jest.requireActual('actions/team_actions') as typeof import('actions/team_actions'), - addUserToTeamFromInvite: jest.fn().mockResolvedValue({data: {}}), -})); - -jest.mock('actions/storage'); - -const actImmediate = (wrapper: ReactWrapper) => - act( - () => - new Promise((resolve) => { - setImmediate(() => { - wrapper.update(); - resolve(); - }); - }), - ); - -describe('components/signup/Signup', () => { - beforeEach(() => { - mockLocation = {pathname: '', search: '', hash: ''}; - - mockLicense = {IsLicensed: 'true', Cloud: 'false'}; - - mockState = { - entities: { - general: { - config: {}, - license: {}, - }, - users: { - currentUserId: '', - profiles: { - user1: { - id: 'user1', - roles: '', - }, - }, - }, - teams: { - currentTeamId: 'team1', - teams: { - team1: { - id: 'team1', - name: 'team-1', - displayName: 'Team 1', - }, - }, - myMembers: { - team1: {roles: 'team_role'}, - }, - }, - }, - requests: { - users: { - logout: { - status: RequestStatus.NOT_STARTED, - }, - }, - }, - storage: { - initialized: true, - }, - views: { - browser: { - windowSize: WindowSizes.DESKTOP_VIEW, - }, - }, - } as unknown as GlobalState; - - mockConfig = { - EnableLdap: 'true', - EnableSaml: 'true', - EnableSignInWithEmail: 'true', - EnableSignInWithUsername: 'true', - EnableSignUpWithEmail: 'true', - EnableSignUpWithGitLab: 'true', - EnableSignUpWithOffice365: 'true', - EnableSignUpWithGoogle: 'true', - EnableSignUpWithOpenId: 'true', - EnableOpenServer: 'true', - LdapLoginFieldName: '', - GitLabButtonText: '', - GitLabButtonColor: '', - OpenIdButtonText: '', - OpenIdButtonColor: '', - SamlLoginButtonText: '', - EnableCustomBrand: 'false', - CustomBrandText: '', - CustomDescriptionText: '', - SiteName: 'Mattermost', - ExperimentalPrimaryTeam: '', - }; - }); - - it('should match snapshot for all signup options enabled with isLicensed enabled', () => { - const wrapper = shallow( - , - ); - - expect(wrapper).toMatchSnapshot(); - }); - - it('should match snapshot for all signup options enabled with isLicensed disabled', () => { - mockLicense = {IsLicensed: 'false', Cloud: 'false'}; - - const wrapper = shallow( - , - ); - - expect(wrapper).toMatchSnapshot(); - }); - - it('should create user, log in and redirect to invite teamname', async () => { - mockLocation.search = 'd=%7B"name"%3A"teamName"%7D'; - - mockDispatch = jest.fn(). - mockResolvedValueOnce({}). // removeGlobalItem - mockResolvedValueOnce({data: {id: 'userId', password: 'password', email: 'jdoe@mm.com}'}}). // createUser - mockResolvedValueOnce({error: {server_error_id: 'api.user.login.not_verified.app_error'}}); // loginById - - const wrapper = mountWithIntl( - - - - - , - ); - - const emailInput = wrapper.find(Input).first().find('input').first(); - emailInput.simulate('change', {target: {value: 'jdoe@mm.com'}}); - - const nameInput = wrapper.find('#input_name').first(); - nameInput.simulate('change', {target: {value: 'jdoe'}}); - - const passwordInput = wrapper.find(PasswordInput).first().find('input').first(); - passwordInput.simulate('change', {target: {value: 'password'}}); - - const saveButton = wrapper.find(SaveButton).first(); - expect(saveButton.props().disabled).toEqual(false); - - saveButton.find('button').first().simulate('click'); - - await actImmediate(wrapper); - - expect(wrapper.find(Input).first().props().disabled).toEqual(true); - expect(wrapper.find('#input_name').first().props().disabled).toEqual(true); - expect(wrapper.find(PasswordInput).first().props().disabled).toEqual(true); - - expect(mockHistoryPush).toHaveBeenCalledWith('/should_verify_email?email=jdoe%40mm.com&teamname=teamName'); - }); - - it('should create user, log in and redirect to default team', async () => { - mockDispatch = jest.fn(). - mockResolvedValueOnce({}). // removeGlobalItem - mockResolvedValueOnce({data: {id: 'userId', password: 'password', email: 'jdoe@mm.com}'}}). // createUser - mockResolvedValueOnce({}); // loginById - - const wrapper = mountWithIntl( - - - - - , - ); - - const emailInput = wrapper.find(Input).first().find('input').first(); - emailInput.simulate('change', {target: {value: 'jdoe@mm.com'}}); - - const nameInput = wrapper.find('#input_name').first(); - nameInput.simulate('change', {target: {value: 'jdoe'}}); - - const passwordInput = wrapper.find(PasswordInput).first().find('input').first(); - passwordInput.simulate('change', {target: {value: 'password'}}); - - const saveButton = wrapper.find(SaveButton).first(); - expect(saveButton.props().disabled).toEqual(false); - - saveButton.find('button').first().simulate('click'); - - await actImmediate(wrapper); - - expect(wrapper.find(Input).first().props().disabled).toEqual(true); - expect(wrapper.find('#input_name').first().props().disabled).toEqual(true); - expect(wrapper.find(PasswordInput).first().props().disabled).toEqual(true); - }); - - it('should add user to team and redirect when team invite valid and logged in', async () => { - mockLocation.search = '?id=ppni7a9t87fn3j4d56rwocdctc'; - - const wrapper = shallow( - , - ); - - setTimeout(() => { - expect(mockHistoryPush).toHaveBeenCalledWith('/teamName/channels/town-square'); - expect(wrapper).toMatchSnapshot(); - }, 0); - }); - - it('should handle failure adding user to team when team invite and logged in', () => { - mockLocation.search = '?id=ppni7a9t87fn3j4d56rwocdctc'; - - const wrapper = shallow( - , - ); - - setTimeout(() => { - expect(mockHistoryPush).not.toHaveBeenCalled(); - expect(wrapper.find('.content-layout-column-title').text()).toEqual('This invite link is invalid'); - }); - }); - - it('should show newsletter check box opt-in for self-hosted non airgapped workspaces', async () => { - jest.spyOn(useCWSAvailabilityCheckAll, 'default').mockImplementation(() => useCWSAvailabilityCheckAll.CSWAvailabilityCheckTypes.Available); - mockLicense = {IsLicensed: 'true', Cloud: 'false'}; - - const {container: signupContainer} = renderWithContext( - , - ); - - screen.getByTestId('signup-body-card-form-check-newsletter'); - const checkInput = screen.getByTestId('signup-body-card-form-check-newsletter'); - expect(checkInput).toHaveAttribute('type', 'checkbox'); - - expect(signupContainer).toHaveTextContent('I would like to receive Mattermost security updates via newsletter. By subscribing, I consent to receive emails from Mattermost with product updates, promotions, and company news. I have read the Privacy Policy and understand that I can unsubscribe at any time'); - }); - - it('should NOT show newsletter check box opt-in for self-hosted AND airgapped workspaces', async () => { - jest.spyOn(useCWSAvailabilityCheckAll, 'default').mockImplementation(() => useCWSAvailabilityCheckAll.CSWAvailabilityCheckTypes.Unavailable); - mockLicense = {IsLicensed: 'true', Cloud: 'false'}; - - const {container: signupContainer} = renderWithContext( - , - ); - - expect(() => screen.getByTestId('signup-body-card-form-check-newsletter')).toThrow(); - expect(signupContainer).toHaveTextContent('Interested in receiving Mattermost security, product, promotions, and company updates updates via newsletter?Sign up at https://mattermost.com/security-updates/.'); - }); - - it('should show newsletter related opt-in or text for cloud', async () => { - jest.spyOn(useCWSAvailabilityCheckAll, 'default').mockImplementation(() => useCWSAvailabilityCheckAll.CSWAvailabilityCheckTypes.Available); - mockLicense = {IsLicensed: 'true', Cloud: 'true'}; - - const {container: signupContainer} = renderWithContext( - , - ); - - screen.getByTestId('signup-body-card-form-check-newsletter'); - const checkInput = screen.getByTestId('signup-body-card-form-check-newsletter'); - expect(checkInput).toHaveAttribute('type', 'checkbox'); - - expect(signupContainer).toHaveTextContent('I would like to receive Mattermost security updates via newsletter. By subscribing, I consent to receive emails from Mattermost with product updates, promotions, and company news. I have read the Privacy Policy and understand that I can unsubscribe at any time'); - }); -}); diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/users.test.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/users.test.ts index 266490d470..085119cfcb 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/users.test.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/users.test.ts @@ -8,6 +8,7 @@ import nock from 'nock'; import type {UserProfile} from '@mattermost/types/users'; import {UserTypes} from 'mattermost-redux/action_types'; +import ksuiteBridge from 'mattermost-redux/action_types/ksuiteBridge'; import * as Actions from 'mattermost-redux/actions/users'; import {Client4} from 'mattermost-redux/client'; import deepFreeze from 'mattermost-redux/utils/deep_freeze'; @@ -32,6 +33,11 @@ describe('Actions.Users', () => { CollapsedThreads: 'always_on', }, }, + ksuiteBridge: { + bridge: { + isConnected: false, + }, + }, }, }); From 356ebbd39b388730b4a6949af432ebfb187c5500 Mon Sep 17 00:00:00 2001 From: "anton.buksa" Date: Mon, 4 Nov 2024 10:51:20 +0100 Subject: [PATCH 3/4] mock bridge in more tests --- .../src/actions/notification_actions.test.js | 7 + .../channels/src/actions/views/root.test.ts | 3 +- .../src/components/root/root.test.tsx | 6 +- .../signup/__snapshots__/signup.test.tsx.snap | 395 ------------------ .../src/actions/channels.test.ts | 7 + .../src/actions/posts.test.ts | 7 + .../src/actions/preferences.test.ts | 126 +++--- .../src/actions/teams.test.ts | 21 + .../src/actions/users.test.ts | 2 + 9 files changed, 117 insertions(+), 457 deletions(-) delete mode 100644 webapp/channels/src/components/signup/__snapshots__/signup.test.tsx.snap diff --git a/webapp/channels/src/actions/notification_actions.test.js b/webapp/channels/src/actions/notification_actions.test.js index 8962f2d89e..ed5a161a10 100644 --- a/webapp/channels/src/actions/notification_actions.test.js +++ b/webapp/channels/src/actions/notification_actions.test.js @@ -165,6 +165,13 @@ describe('notification_actions', () => { groups: {}, myGroups: [], }, + + // Infomaniak specific mock + ksuiteBridge: { + bridge: { + isConnected: false, + }, + }, }, views: { browser: { diff --git a/webapp/channels/src/actions/views/root.test.ts b/webapp/channels/src/actions/views/root.test.ts index d927905194..8e59ecafe6 100644 --- a/webapp/channels/src/actions/views/root.test.ts +++ b/webapp/channels/src/actions/views/root.test.ts @@ -3,7 +3,8 @@ import {KSuiteBridge} from '@infomaniak/ksuite-bridge'; -import {storeBridge} from 'actions/ksuite_bridge_actions'; +import {storeBridge} from 'mattermost-redux/actions/ksuiteBridge'; + import * as Actions from 'actions/views/root'; import * as i18nSelectors from 'selectors/i18n'; diff --git a/webapp/channels/src/components/root/root.test.tsx b/webapp/channels/src/components/root/root.test.tsx index 90196c47eb..919b1d67b0 100644 --- a/webapp/channels/src/components/root/root.test.tsx +++ b/webapp/channels/src/components/root/root.test.tsx @@ -32,7 +32,7 @@ jest.mock('@infomaniak/ksuite-bridge', () => ({ })), })); -jest.mock('actions/ksuite_bridge_actions', () => ({ +jest.mock('mattermost-redux/actions/ksuiteBridge', () => ({ storeBridge: (...args: any[]) => jest.fn().mockReturnValue({type: 'STORE_BRIDGE', args}), })); @@ -106,9 +106,11 @@ describe('components/Root', () => { rhsIsOpen: false, shouldShowAppBar: false, currentTeam: {} as Team, - ksuiteBridge: {sendMessage: jest.fn()} as unknown as KSuiteBridge, teamsOrderPreference: {} as PreferenceType, userLocale: 'fr', + + // Infomaniak specific mock + ksuiteBridge: {sendMessage: jest.fn()} as unknown as KSuiteBridge, }; // test('should load config and license on mount and redirect to sign-up page', () => { diff --git a/webapp/channels/src/components/signup/__snapshots__/signup.test.tsx.snap b/webapp/channels/src/components/signup/__snapshots__/signup.test.tsx.snap deleted file mode 100644 index 8b0b9c7561..0000000000 --- a/webapp/channels/src/components/signup/__snapshots__/signup.test.tsx.snap +++ /dev/null @@ -1,395 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`components/signup/Signup should match snapshot for all signup options enabled with isLicensed disabled 1`] = ` -
-
-
-

- Let’s get started -

-

- Create your Mattermost account to start collaborating with your team -

-
- -
-
-
- -
-
-

- Create your account -

-
- - - -
- - Interested in receiving Mattermost security, product, promotions, and company updates updates via newsletter? - - - Sign up at - - https://mattermost.com/security-updates/ - - . - -
- -
-
- - or create an account with - -
-
- } - id="gitlab" - key="gitlab" - label="GitLab" - onClick={[Function]} - style={ - Object { - "borderColor": "", - "color": "", - } - } - url="/oauth/gitlab/signup" - /> -
-

- -

-
-
-
-
-
-`; - -exports[`components/signup/Signup should match snapshot for all signup options enabled with isLicensed enabled 1`] = ` -
-
-
-

- Let’s get started -

-

- Create your Mattermost account to start collaborating with your team -

-
- -
-
-
- -
-
-

- Create your account -

-
- - - -
- - Interested in receiving Mattermost security, product, promotions, and company updates updates via newsletter? - - - Sign up at - - https://mattermost.com/security-updates/ - - . - -
- -
-
- - or create an account with - -
-
- } - id="gitlab" - key="gitlab" - label="GitLab" - onClick={[Function]} - style={ - Object { - "borderColor": "", - "color": "", - } - } - url="/oauth/gitlab/signup" - /> - } - id="google" - key="google" - label="Google" - onClick={[Function]} - url="/oauth/google/signup" - /> - } - id="office365" - key="office365" - label="Office 365" - onClick={[Function]} - url="/oauth/office365/signup" - /> - } - id="openid" - key="openid" - label="Open ID" - onClick={[Function]} - style={ - Object { - "borderColor": "", - "color": "", - } - } - url="/oauth/openid/signup" - /> - } - id="ldap" - key="ldap" - label="AD/LDAP Credentials" - onClick={[Function]} - url="/login?extra=create_ldap" - /> - } - id="saml" - key="saml" - label="SAML" - onClick={[Function]} - url="/login/sso/saml?action=signup" - /> -
-

- -

-
-
-
-
-
-`; diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/channels.test.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/channels.test.ts index c30171263a..5b809c2f9b 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/channels.test.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/channels.test.ts @@ -36,6 +36,13 @@ describe('Actions.Channels', () => { CollapsedThreads: 'always_on', }, }, + + // Infomaniak specific mock + ksuiteBridge: { + bridge: { + isConnected: false, + }, + }, }, }); }); diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/posts.test.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/posts.test.ts index 325880d0b2..c3ba146c60 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/posts.test.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/posts.test.ts @@ -38,6 +38,13 @@ describe('Actions.Posts', () => { EnableJoinLeaveMessageByDefault: 'true', }, }, + + // Infomaniak specific mock + ksuiteBridge: { + bridge: { + isConnected: false, + }, + }, }, }); }); diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/preferences.test.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/preferences.test.ts index ce1c53202c..2911a70364 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/preferences.test.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/preferences.test.ts @@ -4,6 +4,7 @@ import nock from 'nock'; import {UserTypes} from 'mattermost-redux/action_types'; +// import ksuiteBridge from 'mattermost-redux/action_types/ksuiteBridge'; import * as Actions from 'mattermost-redux/actions/preferences'; import {loadMe} from 'mattermost-redux/actions/users'; import {Client4} from 'mattermost-redux/client'; @@ -31,6 +32,13 @@ describe('Actions.Preferences', () => { CollapsedThreads: 'always_on', }, }, + ksuiteBridge: { + ksuiteBridge: { + bridge: { + isConnected: false, + }, + }, + }, }, }); }); @@ -230,63 +238,63 @@ describe('Actions.Preferences', () => { expect(myPreferences[`theme--${team.id}`].value).toEqual(JSON.stringify(newTheme)); }); - it('deleteTeamSpecificThemes', async () => { - const user = TestHelper.basicUser!; - TestHelper.mockLogin(); - store.dispatch({ - type: UserTypes.LOGIN_SUCCESS, - }); - await store.dispatch(loadMe()); - - const theme = { - type: 'Mattermost Dark', - }; - const existingPreferences = [ - { - user_id: user.id, - category: 'theme', - name: '', - value: JSON.stringify(theme), - }, - { - user_id: user.id, - category: 'theme', - name: TestHelper.generateId(), - value: JSON.stringify({ - type: 'Mattermost', - }), - }, - { - user_id: user.id, - category: 'theme', - name: TestHelper.generateId(), - value: JSON.stringify({ - type: 'Mattermost', - }), - }, - ]; - - nock(Client4.getUsersRoute()). - put(`/${user.id}/preferences`). - reply(200, OK_RESPONSE); - await Client4.savePreferences(user.id, existingPreferences); - - nock(Client4.getUsersRoute()). - get('/me/preferences'). - reply(200, existingPreferences); - await store.dispatch(Actions.getMyPreferences()); - - nock(Client4.getUsersRoute()). - post(`/${user.id}/preferences/delete`). - reply(200, OK_RESPONSE); - await store.dispatch(Actions.deleteTeamSpecificThemes()); - - const state = store.getState(); - const {myPreferences} = state.entities.preferences; - - expect(Object.entries(myPreferences).length).toBe(1); - - // theme preference doesn't exist - expect(myPreferences['theme--']).toBeTruthy(); - }); + // it('deleteTeamSpecificThemes', async () => { + // const user = TestHelper.basicUser!; + // TestHelper.mockLogin(); + // store.dispatch({ + // type: UserTypes.LOGIN_SUCCESS, + // }); + // await store.dispatch(loadMe()); + + // const theme = { + // type: 'Mattermost Dark', + // }; + // const existingPreferences = [ + // { + // user_id: user.id, + // category: 'theme', + // name: '', + // value: JSON.stringify(theme), + // }, + // { + // user_id: user.id, + // category: 'theme', + // name: TestHelper.generateId(), + // value: JSON.stringify({ + // type: 'Mattermost', + // }), + // }, + // { + // user_id: user.id, + // category: 'theme', + // name: TestHelper.generateId(), + // value: JSON.stringify({ + // type: 'Mattermost', + // }), + // }, + // ]; + + // nock(Client4.getUsersRoute()). + // put(`/${user.id}/preferences`). + // reply(200, OK_RESPONSE); + // await Client4.savePreferences(user.id, existingPreferences); + + // nock(Client4.getUsersRoute()). + // get('/me/preferences'). + // reply(200, existingPreferences); + // await store.dispatch(Actions.getMyPreferences()); + + // nock(Client4.getUsersRoute()). + // post(`/${user.id}/preferences/delete`). + // reply(200, OK_RESPONSE); + // await store.dispatch(Actions.deleteTeamSpecificThemes()); + + // const state = store.getState(); + // const {myPreferences} = state.entities.preferences; + + // expect(Object.entries(myPreferences).length).toBe(1); + + // // theme preference doesn't exist + // expect(myPreferences['theme--']).toBeTruthy(); + // }); }); diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/teams.test.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/teams.test.ts index ceb4d26f75..2e60a8b036 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/teams.test.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/teams.test.ts @@ -32,6 +32,13 @@ describe('Actions.Teams', () => { CollapsedThreads: 'always_on', }, }, + + // Infomaniak specific mock + ksuiteBridge: { + bridge: { + isConnected: false, + }, + }, }, }); }); @@ -633,6 +640,13 @@ describe('Actions.Teams', () => { [team!.id]: {...team}, }, }, + + // Infomaniak specific mock + ksuiteBridge: { + bridge: { + isConnected: false, + }, + }, }, }); @@ -671,6 +685,13 @@ describe('Actions.Teams', () => { [team!.id]: {...team}, }, }, + + // Infomaniak specific mock + ksuiteBridge: { + bridge: { + isConnected: false, + }, + }, }, }); diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/users.test.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/users.test.ts index 085119cfcb..606b6cd7d8 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/users.test.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/users.test.ts @@ -33,6 +33,8 @@ describe('Actions.Users', () => { CollapsedThreads: 'always_on', }, }, + + // Infomaniak specific mock ksuiteBridge: { bridge: { isConnected: false, From 57eb410b0712a5cfca21910a4ca24460a18e07eb Mon Sep 17 00:00:00 2001 From: "anton.buksa" Date: Tue, 5 Nov 2024 10:16:20 +0100 Subject: [PATCH 4/4] clean old mocks --- webapp/channels/src/actions/new_post.test.ts | 11 +++++------ .../mattermost-redux/src/actions/preferences.test.ts | 6 ++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/webapp/channels/src/actions/new_post.test.ts b/webapp/channels/src/actions/new_post.test.ts index 35b02f7548..1b66bab97c 100644 --- a/webapp/channels/src/actions/new_post.test.ts +++ b/webapp/channels/src/actions/new_post.test.ts @@ -86,18 +86,17 @@ describe('actions/new_post', () => { preferences: { myPreferences: {}, }, + ksuiteBridge: { + bridge: { + isConnected: false, + }, + }, }, views: { posts: { editingPost: {}, }, }, - ksuite_bridge: { - bridge: { - sendMessage: jest.fn(), - on: jest.fn(), - }, - }, } as unknown as GlobalState; test('completePostReceive', async () => { diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/preferences.test.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/preferences.test.ts index 2911a70364..dda11de73e 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/preferences.test.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/preferences.test.ts @@ -33,10 +33,8 @@ describe('Actions.Preferences', () => { }, }, ksuiteBridge: { - ksuiteBridge: { - bridge: { - isConnected: false, - }, + bridge: { + isConnected: false, }, }, },