@@ -20,6 +20,8 @@ import "@testing-library/jest-dom";
2020
2121import MatrixClientContext from "../../../../src/contexts/MatrixClientContext" ;
2222import { DecryptionFailureBar } from "../../../../src/components/views/rooms/DecryptionFailureBar" ;
23+ import defaultDispatcher from "../../../../src/dispatcher/dispatcher" ;
24+ import { Action } from "../../../../src/dispatcher/actions" ;
2325
2426type MockDevice = { deviceId : string } ;
2527
@@ -71,6 +73,7 @@ function getBar(wrapper: RenderResult) {
7173describe ( "<DecryptionFailureBar />" , ( ) => {
7274 beforeEach ( ( ) => {
7375 jest . useFakeTimers ( ) ;
76+ jest . spyOn ( defaultDispatcher , "dispatch" ) . mockRestore ( ) ;
7477 } ) ;
7578
7679 afterEach ( ( ) => {
@@ -285,6 +288,41 @@ describe("<DecryptionFailureBar />", () => {
285288
286289 bar . unmount ( ) ;
287290 } ) ;
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+ } ) ;
288326
289327 it ( "Does not display a button to send key requests if we are unverified" , async ( ) => {
290328 ourDevice = unverifiedDevice1 ;
0 commit comments