@@ -435,6 +435,51 @@ func TestPresenceSyncDifferentRooms(t *testing.T) {
435435 })
436436}
437437
438+ func TestRoomSummary (t * testing.T ) {
439+ runtime .SkipIf (t , runtime .Synapse ) // Currently more of a Dendrite test, so skip on Synapse
440+ deployment := Deploy (t , b .BlueprintOneToOneRoom )
441+ defer deployment .Destroy (t )
442+ alice := deployment .Client (t , "hs1" , "@alice:hs1" )
443+ bob := deployment .Client (t , "hs1" , "@bob:hs1" )
444+
445+ _ , aliceSince := alice .MustSync (t , client.SyncReq {TimeoutMillis : "0" })
446+ roomID := alice .CreateRoom (t , map [string ]interface {}{
447+ "preset" : "public_chat" ,
448+ "invite" : []string {bob .UserID },
449+ })
450+ aliceSince = alice .MustSyncUntil (t , client.SyncReq {Since : aliceSince },
451+ client .SyncJoinedTo (alice .UserID , roomID ),
452+ func (clientUserID string , syncResp gjson.Result ) error {
453+ summary := syncResp .Get ("rooms.join." + client .GjsonEscape (roomID ) + ".summary" )
454+ invitedUsers := summary .Get (client .GjsonEscape ("m.invited_member_count" )).Int ()
455+ joinedUsers := summary .Get (client .GjsonEscape ("m.joined_member_count" )).Int ()
456+ // We expect there to be one joined and one invited user
457+ if invitedUsers != 1 || joinedUsers != 1 {
458+ return fmt .Errorf ("expected one invited and one joined user, got %d and %d: %v" , invitedUsers , joinedUsers , summary .Raw )
459+ }
460+ return nil
461+ },
462+ )
463+
464+ joinedCheck := func (clientUserID string , syncResp gjson.Result ) error {
465+ summary := syncResp .Get ("rooms.join." + client .GjsonEscape (roomID ) + ".summary" )
466+ invitedUsers := summary .Get (client .GjsonEscape ("m.invited_member_count" )).Int ()
467+ joinedUsers := summary .Get (client .GjsonEscape ("m.joined_member_count" )).Int ()
468+ // We expect there to be two joined and no invited user
469+ if invitedUsers != 0 || joinedUsers != 2 {
470+ return fmt .Errorf ("expected no invited and two joined user, got %d and %d: %v" , invitedUsers , joinedUsers , summary .Raw )
471+ }
472+ return nil
473+ }
474+
475+ sinceToken := bob .MustSyncUntil (t , client.SyncReq {}, client .SyncInvitedTo (bob .UserID , roomID ))
476+ bob .JoinRoom (t , roomID , []string {})
477+ // Verify Bob sees the correct room summary
478+ bob .MustSyncUntil (t , client.SyncReq {Since : sinceToken }, client .SyncJoinedTo (bob .UserID , roomID ), joinedCheck )
479+ // .. and Alice as well.
480+ alice .MustSyncUntil (t , client.SyncReq {Since : aliceSince }, client .SyncJoinedTo (bob .UserID , roomID ), joinedCheck )
481+ }
482+
438483func sendMessages (t * testing.T , client * client.CSAPI , roomID string , prefix string , count int ) {
439484 t .Helper ()
440485 for i := 0 ; i < count ; i ++ {
0 commit comments