@@ -409,6 +409,85 @@ void main() {
409409 verifyNoMoreInteractions (client);
410410 });
411411
412+ test ('addMembers with hideHistoryBefore' , () async {
413+ const channelId = 'test-channel-id' ;
414+ const channelType = 'test-channel-type' ;
415+ const memberIds = ['test-member-id-1' , 'test-member-id-2' ];
416+ final channelModel = ChannelModel (id: channelId, type: channelType);
417+ final message = Message (id: 'test-message-id' , text: 'members-added' );
418+ final hideHistoryBefore = DateTime .parse ('2024-01-01T00:00:00Z' );
419+
420+ final path = _getChannelUrl (channelId, channelType);
421+
422+ when (() => client.post (
423+ path,
424+ data: {
425+ 'add_members' : memberIds,
426+ 'message' : message,
427+ 'hide_history_before' : hideHistoryBefore.toUtc ().toIso8601String (),
428+ },
429+ )).thenAnswer ((_) async => successResponse (path, data: {
430+ 'channel' : channelModel.toJson (),
431+ 'message' : message.toJson (),
432+ }));
433+
434+ final res = await channelApi.addMembers (
435+ channelId,
436+ channelType,
437+ memberIds,
438+ message: message,
439+ hideHistoryBefore: hideHistoryBefore,
440+ );
441+
442+ expect (res, isNotNull);
443+ expect (res.channel.cid, channelModel.cid);
444+ expect (res.message? .id, message.id);
445+
446+ verify (() => client.post (path, data: any (named: 'data' ))).called (1 );
447+ verifyNoMoreInteractions (client);
448+ });
449+
450+ test ('addMembers with hideHistoryBefore takes precedence over hideHistory' ,
451+ () async {
452+ const channelId = 'test-channel-id' ;
453+ const channelType = 'test-channel-type' ;
454+ const memberIds = ['test-member-id-1' , 'test-member-id-2' ];
455+ final channelModel = ChannelModel (id: channelId, type: channelType);
456+ final message = Message (id: 'test-message-id' , text: 'members-added' );
457+ const hideHistory = true ;
458+ final hideHistoryBefore = DateTime .parse ('2024-01-01T00:00:00Z' );
459+
460+ final path = _getChannelUrl (channelId, channelType);
461+
462+ when (() => client.post (
463+ path,
464+ data: {
465+ 'add_members' : memberIds,
466+ 'message' : message,
467+ 'hide_history_before' : hideHistoryBefore.toUtc ().toIso8601String (),
468+ },
469+ )).thenAnswer ((_) async => successResponse (path, data: {
470+ 'channel' : channelModel.toJson (),
471+ 'message' : message.toJson (),
472+ }));
473+
474+ final res = await channelApi.addMembers (
475+ channelId,
476+ channelType,
477+ memberIds,
478+ message: message,
479+ hideHistory: hideHistory,
480+ hideHistoryBefore: hideHistoryBefore,
481+ );
482+
483+ expect (res, isNotNull);
484+ expect (res.channel.cid, channelModel.cid);
485+ expect (res.message? .id, message.id);
486+
487+ verify (() => client.post (path, data: any (named: 'data' ))).called (1 );
488+ verifyNoMoreInteractions (client);
489+ });
490+
412491 test ('removeMembers' , () async {
413492 const channelId = 'test-channel-id' ;
414493 const channelType = 'test-channel-type' ;
0 commit comments