@@ -77,6 +77,16 @@ def test_reactions(client, room, room2, user, user2, mod, admin, global_mod, glo
77
77
r = sogs_put (client , "/room/test-room/reaction/4/🦒🦍🐍🐊🦢🦁🦎" , {}, user )
78
78
assert r .json == {'added' : True , "seqno" : new_seqno + 1 }
79
79
80
+ # user2 is the fourth reactor (of 5) and so should get ourself last in the truncated reactor
81
+ # list:
82
+ for u in (user , mod , global_mod , user2 , admin ):
83
+ r = sogs_put (client , "/room/test-room/reaction/4/🂤" , {}, u )
84
+
85
+ # user2 is fifth (of 5) and so should not be in the truncated reactor list (but should still get
86
+ # "you"):
87
+ for u in (user , mod , global_mod , global_admin , user2 ):
88
+ r = sogs_put (client , "/room/test-room/reaction/4/🂵" , {}, u )
89
+
80
90
exp_reactions = {
81
91
'abcdefghijkl' : {'index' : 4 , 'count' : 1 , 'reactors' : [user .session_id ]},
82
92
'f' : {'index' : 2 , 'count' : 1 , 'reactors' : [user .session_id ]},
@@ -90,6 +100,18 @@ def test_reactions(client, room, room2, user, user2, mod, admin, global_mod, glo
90
100
},
91
101
'🖕' : {'index' : 0 , 'count' : 2 , 'reactors' : [user .session_id , user2 .session_id ], 'you' : True },
92
102
'🦒🦍🐍🐊🦢🦁🦎' : {'index' : 6 , 'count' : 1 , 'reactors' : [user .session_id ]},
103
+ '🂤' : {
104
+ 'index' : 7 ,
105
+ 'count' : 5 ,
106
+ 'reactors' : [u .session_id for u in (user , mod , global_mod , user2 )],
107
+ 'you' : True ,
108
+ },
109
+ '🂵' : {
110
+ 'index' : 8 ,
111
+ 'count' : 5 ,
112
+ 'reactors' : [u .session_id for u in (user , mod , global_mod , global_admin )],
113
+ 'you' : True ,
114
+ },
93
115
}
94
116
95
117
r = sogs_get (client , f"/room/test-room/messages/since/{ seqno } ?t=r" , user2 ).json
@@ -101,7 +123,7 @@ def test_reactions(client, room, room2, user, user2, mod, admin, global_mod, glo
101
123
'id' : 4 ,
102
124
'data' : 'ZWRpdGVkIGZha2UgZGF0YSA0' ,
103
125
'signature' : 'ZmFrZSBzaWcgNGI' + 'A' * 71 + '==' ,
104
- 'seqno' : seqno + 7 ,
126
+ 'seqno' : seqno + 17 ,
105
127
'session_id' : mod .session_id ,
106
128
'reactions' : exp_reactions ,
107
129
}
@@ -110,9 +132,9 @@ def test_reactions(client, room, room2, user, user2, mod, admin, global_mod, glo
110
132
# If we fetch just after the edit, we should only get the reactions:
111
133
112
134
r = sogs_get (client , f"/room/test-room/messages/since/{ seqno + 1 } ?t=r" , user2 )
113
- assert r .json == [{'id' : 4 , 'seqno' : seqno + 7 , 'reactions' : exp_reactions }]
135
+ assert r .json == [{'id' : 4 , 'seqno' : seqno + 17 , 'reactions' : exp_reactions }]
114
136
115
- seqno += 7
137
+ seqno += 17
116
138
117
139
# Fetch the *full* list of reactors
118
140
r = sogs_get (client , "/room/test-room/reactors/4/🍍" , user ).json
@@ -136,6 +158,11 @@ def test_reactions(client, room, room2, user, user2, mod, admin, global_mod, glo
136
158
del exp_reactions ['🍍' ]['reactors' ][0 ]
137
159
exp_reactions ['🍍' ]['count' ] -= 1
138
160
161
+ # We're reducing the reactor limit below, so chop off the last reactor from these in the
162
+ # expected result:
163
+ for card in '🂤🂵' :
164
+ del exp_reactions [card ]['reactors' ][- 1 ]
165
+
139
166
# Also tests that the `reactors` query param is working right
140
167
r = sogs_get (client , f"/room/test-room/messages/since/{ seqno } ?t=r&reactors=3" , user2 )
141
168
assert r .json == [{'id' : 4 , 'seqno' : seqno + 1 , 'reactions' : exp_reactions }]
@@ -158,7 +185,8 @@ def test_reactions(client, room, room2, user, user2, mod, admin, global_mod, glo
158
185
assert exp_reactions ["🍍" ]["count" ] == 5
159
186
assert r .json == {"removed" : 5 , "seqno" : seqno + 5 }
160
187
del exp_reactions ["🍍" ]
161
- exp_reactions ["🦒🦍🐍🐊🦢🦁🦎" ]["index" ] -= 1
188
+ for reaction in ("🦒🦍🐍🐊🦢🦁🦎" , '🂤' , '🂵' ):
189
+ exp_reactions [reaction ]["index" ] -= 1
162
190
163
191
r = sogs_get (client , f"/room/test-room/messages/since/{ seqno } ?t=r&reactors=0" , user2 )
164
192
assert r .json == [{'id' : 4 , 'seqno' : seqno + 5 , 'reactions' : exp_reactions }]
0 commit comments