Skip to content

Commit 0fdc97b

Browse files
committed
Fix MessageSearch / GroupChannelProvider migration test
1 parent d01ee5e commit 0fdc97b

File tree

6 files changed

+20
-18
lines changed

6 files changed

+20
-18
lines changed

src/modules/CreateChannel/context/__tests__/CreateChannel.migration.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const mockState = {
3434
},
3535
isOnline: true,
3636
},
37-
};const mockActions = { connect: jest.fn(), disconnect: jest.fn() };
37+
}; const mockActions = { connect: jest.fn(), disconnect: jest.fn() };
3838

3939
jest.mock('../../../../lib/Sendbird/context/hooks/useSendbird', () => ({
4040
__esModule: true,

src/modules/GroupChannel/context/GroupChannelProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ const GroupChannelManager :React.FC<React.PropsWithChildren<GroupChannelProvider
311311
return children;
312312
};
313313

314-
const GroupChannelProvider: React.FC<React.PropsWithChildren<GroupChannelProviderProps>> = (props) => {
314+
const GroupChannelProvider: React.FC<GroupChannelProviderProps> = (props) => {
315315
return (
316316
<InternalGroupChannelProvider>
317317
<GroupChannelManager {...props}>

src/modules/GroupChannel/context/__tests__/GroupChannel.migration.spec.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React from 'react';
1+
import React, { act } from 'react';
22
import { render, screen } from '@testing-library/react';
3-
import type { GroupChannelProviderProps } from '../types'
3+
import type { GroupChannelProviderProps } from '../types';
44
import { GroupChannelProvider, useGroupChannelContext } from '../GroupChannelProvider';
55
import { ThreadReplySelectType } from '../const';
66
import { match } from 'ts-pattern';
@@ -57,8 +57,7 @@ const mockProps: GroupChannelProviderProps = {
5757
scrollBehavior: 'smooth',
5858
forceLeftToRightMessageLayout: false,
5959

60-
startingPoint: 0,
61-
60+
startingPoint: undefined,
6261
// Message Focusing
6362
animatedMessageId: null,
6463
onMessageAnimated: jest.fn(),
@@ -93,23 +92,23 @@ const mockProps: GroupChannelProviderProps = {
9392
describe('GroupChannel Migration Compatibility Tests', () => {
9493
// 1. Provider Props Interface test
9594
describe('GroupChannelProvider Props Compatibility', () => {
96-
it('should accept all legacy props without type errors', () => {
97-
const { rerender } = render(
95+
it('should accept all legacy props without type errors', async () => {
96+
const { rerender } = await act(async () => render(
9897
<GroupChannelProvider {...mockProps}>
9998
{mockProps.children}
10099
</GroupChannelProvider>,
101-
);
100+
));
102101

103102
// Props change scenario test
104-
rerender(
103+
await act(async () => rerender(
105104
<GroupChannelProvider
106105
{...mockProps}
107106
isReactionEnabled={false}
108107
onBackClick={() => {}}
109108
>
110109
{mockProps.children}
111110
</GroupChannelProvider>,
112-
);
111+
));
113112
});
114113
});
115114

src/modules/GroupChannel/context/types.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ReplyType } from '../../../types';
1616
import { useMessageActions } from './hooks/useMessageActions';
1717
import { useGroupChannelMessages } from '@sendbird/uikit-tools';
1818
import { ThreadReplySelectType } from './const';
19+
import { PropsWithChildren } from 'react';
1920

2021
// Message data source types
2122
type MessageDataSource = ReturnType<typeof useGroupChannelMessages>;
@@ -66,8 +67,13 @@ interface InternalGroupChannelState extends MessageDataSource {
6667
scrollPubSub: PubSubTypes<ScrollTopics, ScrollTopicUnion>;
6768
}
6869

69-
export interface GroupChannelProviderProps extends
70-
Pick<UserProfileProviderProps, 'renderUserProfile' | 'disableUserProfile'> {
70+
export interface GroupChannelProviderProps extends PropsWithChildren<
71+
Pick<UserProfileProviderProps,
72+
'renderUserProfile' |
73+
'disableUserProfile' |
74+
'onUserProfileMessage'|
75+
'onStartDirectMessage'
76+
>> {
7177
// Required
7278
channelUrl: string;
7379

src/modules/MessageSearch/context/__tests__/MessageSearch.migration.spec.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,11 @@ describe('MessageSearch Migration Compatibility Tests', () => {
5959
'children',
6060
'requestString',
6161
'retryCount',
62-
'setRetryCount',
6362
'selectedMessageId',
6463
'setSelectedMessageId',
65-
'messageSearchDispatcher',
6664
'scrollRef',
6765
'allMessages',
6866
'loading',
69-
'isInvalid',
7067
'currentChannel',
7168
'currentMessageSearchQuery',
7269
'hasMoreResult',

src/modules/MessageSearch/context/hooks/useMessageSearch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { MessageSearchQuery } from '@sendbird/chat/message';
44

55
import { useSyncExternalStore } from 'use-sync-external-store/shim';
66
import { ClientSentMessages } from '../../../../types';
7-
import { MessageSearchContext } from '../MessageSearchProvider';
7+
import { MessageSearchContext, type MessageSearchState } from '../MessageSearchProvider';
88

99
const useMessageSearch = () => {
1010
const store = useContext(MessageSearchContext);
1111
if (!store) throw new Error('useMessageSearch must be used within a MessageSearchProvider');
1212

13-
const state = useSyncExternalStore(store.subscribe, store.getState);
13+
const state: MessageSearchState = useSyncExternalStore(store.subscribe, store.getState);
1414
const actions = useMemo(() => ({
1515
setCurrentChannel: (channel: GroupChannel) => store.setState(state => ({
1616
...state,

0 commit comments

Comments
 (0)