@@ -20,6 +20,8 @@ import "@testing-library/jest-dom";
20
20
21
21
import MatrixClientContext from "../../../../src/contexts/MatrixClientContext" ;
22
22
import { DecryptionFailureBar } from "../../../../src/components/views/rooms/DecryptionFailureBar" ;
23
+ import defaultDispatcher from "../../../../src/dispatcher/dispatcher" ;
24
+ import { Action } from "../../../../src/dispatcher/actions" ;
23
25
24
26
type MockDevice = { deviceId : string } ;
25
27
@@ -71,6 +73,7 @@ function getBar(wrapper: RenderResult) {
71
73
describe ( "<DecryptionFailureBar />" , ( ) => {
72
74
beforeEach ( ( ) => {
73
75
jest . useFakeTimers ( ) ;
76
+ jest . spyOn ( defaultDispatcher , "dispatch" ) . mockRestore ( ) ;
74
77
} ) ;
75
78
76
79
afterEach ( ( ) => {
@@ -285,6 +288,41 @@ describe("<DecryptionFailureBar />", () => {
285
288
286
289
bar . unmount ( ) ;
287
290
} ) ;
291
+ it ( "Displays button to review device list if we are verified" , async ( ) => {
292
+ // stub so we dont have to deal with launching modals
293
+ jest . spyOn ( defaultDispatcher , "dispatch" ) . mockImplementation ( ( ) => { } ) ;
294
+ ourDevice = verifiedDevice1 ;
295
+ allDevices = [ verifiedDevice1 , verifiedDevice2 ] ;
296
+
297
+ const bar = render (
298
+ // @ts -ignore
299
+ < MatrixClientContext . Provider value = { mockClient } >
300
+ < DecryptionFailureBar
301
+ failures = { [
302
+ // @ts -ignore
303
+ mockEvent1 ,
304
+ // @ts -ignore
305
+ mockEvent2 ,
306
+ // @ts -ignore
307
+ mockEvent3 ,
308
+ ] }
309
+ />
310
+ ,
311
+ </ MatrixClientContext . Provider > ,
312
+ ) ;
313
+
314
+ await waitFor ( ( ) => expect ( mockClient . isSecretStored ) . toHaveBeenCalled ( ) ) ;
315
+
316
+ act ( ( ) => {
317
+ jest . advanceTimersByTime ( 5000 ) ;
318
+ } ) ;
319
+
320
+ fireEvent . click ( screen . getByText ( "View your device list" ) ) ;
321
+
322
+ expect ( defaultDispatcher . dispatch ) . toHaveBeenCalledWith ( { action : Action . ViewUserDeviceSettings } ) ;
323
+
324
+ bar . unmount ( ) ;
325
+ } ) ;
288
326
289
327
it ( "Does not display a button to send key requests if we are unverified" , async ( ) => {
290
328
ourDevice = unverifiedDevice1 ;
0 commit comments