@@ -68,6 +68,7 @@ import AutoDiscoveryUtils from "../../../../src/utils/AutoDiscoveryUtils";
68
68
import { type ValidatedServerConfig } from "../../../../src/utils/ValidatedServerConfig" ;
69
69
import Modal from "../../../../src/Modal.tsx" ;
70
70
import { SetupEncryptionStore } from "../../../../src/stores/SetupEncryptionStore.ts" ;
71
+ import RoomListStore from "../../../../src/stores/room-list/RoomListStore.ts" ;
71
72
72
73
jest . mock ( "matrix-js-sdk/src/oidc/authorize" , ( ) => ( {
73
74
completeAuthorizationCodeGrant : jest . fn ( ) ,
@@ -154,6 +155,7 @@ describe("<MatrixChat />", () => {
154
155
whoami : jest . fn ( ) ,
155
156
logout : jest . fn ( ) ,
156
157
getDeviceId : jest . fn ( ) ,
158
+ forget : ( ) => Promise . resolve ( ) ,
157
159
} ) ;
158
160
let mockClient : Mocked < MatrixClient > ;
159
161
const serverConfig = {
@@ -675,6 +677,34 @@ describe("<MatrixChat />", () => {
675
677
jest . restoreAllMocks ( ) ;
676
678
} ) ;
677
679
680
+ describe ( "forget_room" , ( ) => {
681
+ it ( "should dispatch after_forget_room action on successful forget" , async ( ) => {
682
+ await clearAllModals ( ) ;
683
+ await getComponentAndWaitForReady ( ) ;
684
+
685
+ // Mock out the old room list store
686
+ jest . spyOn ( RoomListStore . instance , "manualRoomUpdate" ) . mockImplementation ( async ( ) => { } ) ;
687
+
688
+ // Register a mock function to the dispatcher
689
+ const fn = jest . fn ( ) ;
690
+ defaultDispatcher . register ( fn ) ;
691
+
692
+ // Forge the room
693
+ defaultDispatcher . dispatch ( {
694
+ action : "forget_room" ,
695
+ room_id : roomId ,
696
+ } ) ;
697
+
698
+ // On success, we expect the following action to have been dispatched.
699
+ await waitFor ( ( ) => {
700
+ expect ( fn ) . toHaveBeenCalledWith ( {
701
+ action : Action . AfterForgetRoom ,
702
+ room : room ,
703
+ } ) ;
704
+ } ) ;
705
+ } ) ;
706
+ } ) ;
707
+
678
708
describe ( "leave_room" , ( ) => {
679
709
beforeEach ( async ( ) => {
680
710
await clearAllModals ( ) ;
0 commit comments