Skip to content

Commit

Permalink
Merge branch 'fix/ksuite-bridge-types' into 'master'
Browse files Browse the repository at this point in the history
move ksuite bridge to redux package for tests

See merge request kchat/webapp!960
  • Loading branch information
antonbuks committed Nov 5, 2024
2 parents d0ed14e + 57eb410 commit 1eca2eb
Show file tree
Hide file tree
Showing 32 changed files with 174 additions and 834 deletions.
11 changes: 5 additions & 6 deletions webapp/channels/src/actions/new_post.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion webapp/channels/src/actions/notification_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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';

Expand Down
7 changes: 7 additions & 0 deletions webapp/channels/src/actions/notification_actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ describe('notification_actions', () => {
groups: {},
myGroups: [],
},

// Infomaniak specific mock
ksuiteBridge: {
bridge: {
isConnected: false,
},
},
},
views: {
browser: {
Expand Down
3 changes: 2 additions & 1 deletion webapp/channels/src/actions/views/root.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion webapp/channels/src/components/root/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions webapp/channels/src/components/root/root.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}),
}));

Expand Down Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion webapp/channels/src/components/root/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down
Loading

0 comments on commit 1eca2eb

Please sign in to comment.