@@ -184,5 +184,59 @@ describe("RoomListStoreV3", () => {
184
184
) ;
185
185
expect ( fn ) . toHaveBeenCalled ( ) ;
186
186
} ) ;
187
+
188
+ describe ( "Update from read receipt" , ( ) => {
189
+ function getReadReceiptEvent ( userId : string ) {
190
+ const content = {
191
+ some_id : {
192
+ "m.read" : {
193
+ [ userId ] : {
194
+ ts : 5000 ,
195
+ } ,
196
+ } ,
197
+ } ,
198
+ } ;
199
+ const event = mkEvent ( {
200
+ event : true ,
201
+ content,
202
+ user : "@foo:matrix.org" ,
203
+ type : EventType . Receipt ,
204
+ } ) ;
205
+ return event ;
206
+ }
207
+
208
+ it ( "Room is re-inserted on read receipt from our user" , async ( ) => {
209
+ const { store, rooms, client, dispatcher } = await getRoomListStore ( ) ;
210
+ const event = getReadReceiptEvent ( client . getSafeUserId ( ) ) ;
211
+ const fn = jest . fn ( ) ;
212
+ store . on ( LISTS_UPDATE_EVENT , fn ) ;
213
+ dispatcher . dispatch (
214
+ {
215
+ action : "MatrixActions.Room.receipt" ,
216
+ room : rooms [ 10 ] ,
217
+ event,
218
+ } ,
219
+ true ,
220
+ ) ;
221
+ expect ( fn ) . toHaveBeenCalled ( ) ;
222
+ } ) ;
223
+
224
+ it ( "Read receipt from other users do not cause room to be re-inserted" , async ( ) => {
225
+ const { store, rooms, dispatcher } = await getRoomListStore ( ) ;
226
+ const event = getReadReceiptEvent ( "@foobar:matrix.org" ) ;
227
+ const fn = jest . fn ( ) ;
228
+ store . on ( LISTS_UPDATE_EVENT , fn ) ;
229
+ dispatcher . dispatch (
230
+ {
231
+ action : "MatrixActions.Room.receipt" ,
232
+ room : rooms [ 10 ] ,
233
+ event,
234
+ } ,
235
+ true ,
236
+ ) ;
237
+ expect ( fn ) . not . toHaveBeenCalled ( ) ;
238
+ } ) ;
239
+ } ) ;
240
+
187
241
} ) ;
188
242
} ) ;
0 commit comments