@@ -37,6 +37,7 @@ import { WidgetMessagingStore } from "../../src/stores/widgets/WidgetMessagingSt
37
37
import DMRoomMap from "../../src/utils/DMRoomMap" ;
38
38
import ToastStore from "../../src/stores/ToastStore" ;
39
39
import { getIncomingCallToastKey , IncomingCallToast } from "../../src/toasts/IncomingCallToast" ;
40
+ import { AudioID } from "../../src/LegacyCallHandler" ;
40
41
41
42
describe ( "IncomingCallEvent" , ( ) => {
42
43
useMockedCalls ( ) ;
@@ -59,6 +60,10 @@ describe("IncomingCallEvent", () => {
59
60
stubClient ( ) ;
60
61
client = mocked ( MatrixClientPeg . safeGet ( ) ) ;
61
62
63
+ const audio = document . createElement ( "audio" ) ;
64
+ audio . id = AudioID . Ring ;
65
+ document . body . appendChild ( audio ) ;
66
+
62
67
room = new Room ( "!1:example.org" , client , "@alice:example.org" ) ;
63
68
64
69
alice = mkRoomMember ( room . roomId , "@alice:example.org" ) ;
@@ -96,7 +101,12 @@ describe("IncomingCallEvent", () => {
96
101
jest . restoreAllMocks ( ) ;
97
102
} ) ;
98
103
104
+ const notifyContent = {
105
+ call_id : "" ,
106
+ } ;
99
107
const renderToast = ( ) => {
108
+ call . event . getContent = ( ) => notifyContent as any ;
109
+
100
110
render ( < IncomingCallToast notifyEvent = { call . event } /> ) ;
101
111
} ;
102
112
@@ -141,7 +151,9 @@ describe("IncomingCallEvent", () => {
141
151
} ) ,
142
152
) ;
143
153
await waitFor ( ( ) =>
144
- expect ( toastStore . dismissToast ) . toHaveBeenCalledWith ( getIncomingCallToastKey ( call . event . getStateKey ( ) ! ) ) ,
154
+ expect ( toastStore . dismissToast ) . toHaveBeenCalledWith (
155
+ getIncomingCallToastKey ( notifyContent . call_id , room . roomId ) ,
156
+ ) ,
145
157
) ;
146
158
147
159
defaultDispatcher . unregister ( dispatcherRef ) ;
@@ -155,7 +167,9 @@ describe("IncomingCallEvent", () => {
155
167
156
168
fireEvent . click ( screen . getByRole ( "button" , { name : "Close" } ) ) ;
157
169
await waitFor ( ( ) =>
158
- expect ( toastStore . dismissToast ) . toHaveBeenCalledWith ( getIncomingCallToastKey ( call . event . getStateKey ( ) ! ) ) ,
170
+ expect ( toastStore . dismissToast ) . toHaveBeenCalledWith (
171
+ getIncomingCallToastKey ( notifyContent . call_id , room . roomId ) ,
172
+ ) ,
159
173
) ;
160
174
161
175
defaultDispatcher . unregister ( dispatcherRef ) ;
@@ -171,7 +185,9 @@ describe("IncomingCallEvent", () => {
171
185
} ) ;
172
186
173
187
await waitFor ( ( ) =>
174
- expect ( toastStore . dismissToast ) . toHaveBeenCalledWith ( getIncomingCallToastKey ( call . event . getStateKey ( ) ! ) ) ,
188
+ expect ( toastStore . dismissToast ) . toHaveBeenCalledWith (
189
+ getIncomingCallToastKey ( notifyContent . call_id , room . roomId ) ,
190
+ ) ,
175
191
) ;
176
192
} ) ;
177
193
@@ -182,7 +198,9 @@ describe("IncomingCallEvent", () => {
182
198
event . emit ( MatrixEventEvent . BeforeRedaction , event , { } as unknown as MatrixEvent ) ;
183
199
184
200
await waitFor ( ( ) =>
185
- expect ( toastStore . dismissToast ) . toHaveBeenCalledWith ( getIncomingCallToastKey ( call . event . getStateKey ( ) ! ) ) ,
201
+ expect ( toastStore . dismissToast ) . toHaveBeenCalledWith (
202
+ getIncomingCallToastKey ( notifyContent . call_id , room . roomId ) ,
203
+ ) ,
186
204
) ;
187
205
} ) ;
188
206
} ) ;
0 commit comments