@@ -20,6 +20,7 @@ const mockUsePushNotificationContext = jest.fn();
2020const mockSubscribeToLiveRoom = jest . fn ( ) ;
2121const mockUnsubscribeFromLiveRoom = jest . fn ( ) ;
2222const mockEnablePush = jest . fn ( ) ;
23+ const mockUseViewSize = jest . fn < boolean , [ unknown ] > ( ( ) => true ) ;
2324const mockUseQueries = useQueries as jest . Mock ;
2425
2526jest . mock ( '@tanstack/react-query' , ( ) => {
@@ -73,6 +74,14 @@ jest.mock('../../hooks/useToastNotification', () => ({
7374 useToastNotification : ( ) => ( { displayToast : mockDisplayToast } ) ,
7475} ) ) ;
7576
77+ jest . mock ( '../../hooks' , ( ) => {
78+ const actual = jest . requireActual ( '../../hooks' ) ;
79+ return {
80+ ...actual ,
81+ useViewSize : ( size : unknown ) => mockUseViewSize ( size ) ,
82+ } ;
83+ } ) ;
84+
7685jest . mock ( '../../graphql/users' , ( ) => ( {
7786 getUserShortInfo : jest . fn ( ) ,
7887} ) ) ;
@@ -257,6 +266,7 @@ const createParticipant = (
257266describe ( 'LiveRoom' , ( ) => {
258267 beforeEach ( ( ) => {
259268 jest . clearAllMocks ( ) ;
269+ mockUseViewSize . mockReturnValue ( true ) ;
260270 mockUseLiveRoomParticipantStreams . mockReturnValue ( new Map ( ) ) ;
261271 mockSubscribeToLiveRoom . mockResolvedValue ( { } ) ;
262272 mockUnsubscribeFromLiveRoom . mockResolvedValue ( { } ) ;
@@ -946,6 +956,49 @@ describe('LiveRoom', () => {
946956 expect ( screen . getAllByTestId ( 'live-room-tile' ) ) . toHaveLength ( 12 ) ;
947957 } ) ;
948958
959+ it ( 'limits stage pagination to four visible speakers on mobile' , ( ) => {
960+ mockUseViewSize . mockReturnValue ( false ) ;
961+ const activeSpeakerParticipantIds = Array . from (
962+ { length : 12 } ,
963+ ( _ , index ) => `speaker-${ index + 1 } ` ,
964+ ) ;
965+ const participants = activeSpeakerParticipantIds . reduce <
966+ NonNullable < LiveRoomContextValue [ 'roomState' ] > [ 'participants' ]
967+ > (
968+ ( acc , participantId ) => ( {
969+ ...acc ,
970+ [ participantId ] : createParticipant ( participantId ) ,
971+ } ) ,
972+ {
973+ host : createParticipant ( 'host' , 'host' ) ,
974+ } ,
975+ ) ;
976+
977+ mockUseLiveRoomConnection . mockReturnValue (
978+ createContextValue ( {
979+ roomState : {
980+ ...createContextValue ( ) . roomState ! ,
981+ participants,
982+ stage : {
983+ speakerQueueParticipantIds : [ ] ,
984+ activeSpeakerParticipantIds,
985+ raisedHandParticipantIds : [ ] ,
986+ } ,
987+ } ,
988+ } ) ,
989+ ) ;
990+
991+ renderLiveRoom ( ) ;
992+
993+ expect ( screen . getByText ( 'Page 1 / 4' ) ) . toBeInTheDocument ( ) ;
994+ expect ( screen . getAllByTestId ( 'live-room-tile' ) ) . toHaveLength ( 4 ) ;
995+
996+ fireEvent . click ( screen . getByRole ( 'button' , { name : 'Next' } ) ) ;
997+
998+ expect ( screen . getByText ( 'Page 2 / 4' ) ) . toBeInTheDocument ( ) ;
999+ expect ( screen . getAllByTestId ( 'live-room-tile' ) ) . toHaveLength ( 4 ) ;
1000+ } ) ;
1001+
9491002 it ( 'logs a room query error only once for the same failure' , ( ) => {
9501003 let contextValue = createContextValue ( { selectedMicId : 'mic-1' } ) ;
9511004
0 commit comments