@@ -798,4 +798,53 @@ describe("RoomListStoreV3", () => {
798
798
expect ( store . getSortedRooms ( ) [ 34 ] ) . toEqual ( unmutedRoom ) ;
799
799
} ) ;
800
800
} ) ;
801
+
802
+ describe ( "Low priority rooms" , ( ) => {
803
+ async function getRoomListStoreWithRooms ( ) {
804
+ const client = stubClient ( ) ;
805
+ const rooms = getMockedRooms ( client ) ;
806
+
807
+ // Let's say that rooms 34, 84, 64, 14, 57 are low priority
808
+ const lowPriorityIndices = [ 34 , 84 , 64 , 14 , 57 ] ;
809
+ const lowPriorityRooms = lowPriorityIndices . map ( ( i ) => rooms [ i ] ) ;
810
+ for ( const room of lowPriorityRooms ) {
811
+ room . tags [ DefaultTagID . LowPriority ] = { } ;
812
+ }
813
+
814
+ // Let's say that rooms 65, 78, 82, 5, 36 are muted
815
+ const mutedIndices = [ 14 , 57 , 65 , 78 , 82 , 5 , 36 ] ;
816
+ const mutedRooms = mutedIndices . map ( ( i ) => rooms [ i ] ) ;
817
+ jest . spyOn ( RoomNotificationStateStore . instance , "getRoomState" ) . mockImplementation ( ( room ) => {
818
+ const state = {
819
+ muted : mutedRooms . includes ( room ) ,
820
+ } as unknown as RoomNotificationState ;
821
+ return state ;
822
+ } ) ;
823
+
824
+ client . getVisibleRooms = jest . fn ( ) . mockReturnValue ( rooms ) ;
825
+ jest . spyOn ( AsyncStoreWithClient . prototype , "matrixClient" , "get" ) . mockReturnValue ( client ) ;
826
+ const store = new RoomListStoreV3Class ( dispatcher ) ;
827
+ await store . start ( ) ;
828
+
829
+ // We expect the following order: Low Priority -> Low Priority & Muted -> Muted
830
+ const expectedRoomIds = [ 84 , 64 , 34 , 57 , 14 , 82 , 78 , 65 , 36 , 5 ] . map ( ( i ) => rooms [ i ] . roomId ) ;
831
+
832
+ return {
833
+ client,
834
+ rooms,
835
+ expectedRoomIds,
836
+ store,
837
+ dispatcher,
838
+ } ;
839
+ }
840
+
841
+ it ( "Low priority rooms are pushed to the bottom of the list just before muted rooms" , async ( ) => {
842
+ const { store, expectedRoomIds } = await getRoomListStoreWithRooms ( ) ;
843
+ const result = store
844
+ . getSortedRooms ( )
845
+ . slice ( 90 )
846
+ . map ( ( r ) => r . roomId ) ;
847
+ expect ( result ) . toEqual ( expectedRoomIds ) ;
848
+ } ) ;
849
+ } ) ;
801
850
} ) ;
0 commit comments