@@ -22,7 +22,7 @@ import {
22
22
RoomStateEvent ,
23
23
SearchResult ,
24
24
} from "matrix-js-sdk/src/matrix" ;
25
- import { CryptoApi , UserVerificationStatus } from "matrix-js-sdk/src/crypto-api" ;
25
+ import { CryptoApi , UserVerificationStatus , CryptoEvent } from "matrix-js-sdk/src/crypto-api" ;
26
26
import { KnownMembership } from "matrix-js-sdk/src/types" ;
27
27
import {
28
28
fireEvent ,
@@ -307,6 +307,32 @@ describe("RoomView", () => {
307
307
expect ( roomViewInstance . state . liveTimeline ) . not . toEqual ( oldTimeline ) ;
308
308
} ) ;
309
309
310
+ it ( "should update when the e2e status when the user verification changed" , async ( ) => {
311
+ room . currentState . setStateEvents ( [
312
+ mkRoomMemberJoinEvent ( cli . getSafeUserId ( ) , room . roomId ) ,
313
+ mkRoomMemberJoinEvent ( "[email protected] " , room . roomId ) ,
314
+ ] ) ;
315
+ room . getMyMembership = jest . fn ( ) . mockReturnValue ( KnownMembership . Join ) ;
316
+ // Not all the calls to cli.isRoomEncrypted are migrated, so we need to mock both.
317
+ mocked ( cli . isRoomEncrypted ) . mockReturnValue ( true ) ;
318
+ jest . spyOn ( cli , "getCrypto" ) . mockReturnValue ( crypto ) ;
319
+ jest . spyOn ( cli . getCrypto ( ) ! , "isEncryptionEnabledInRoom" ) . mockResolvedValue ( true ) ;
320
+ jest . spyOn ( cli . getCrypto ( ) ! , "getUserVerificationStatus" ) . mockResolvedValue (
321
+ new UserVerificationStatus ( false , false , false ) ,
322
+ ) ;
323
+ jest . spyOn ( cli . getCrypto ( ) ! , "getUserDeviceInfo" ) . mockResolvedValue (
324
+ new Map ( [ [ "[email protected] " , new Map < string , any > ( ) ] ] ) ,
325
+ ) ;
326
+
327
+ const { container } = await renderRoomView ( ) ;
328
+ await waitFor ( ( ) => expect ( container . querySelector ( ".mx_E2EIcon_normal" ) ) . toBeInTheDocument ( ) ) ;
329
+
330
+ const verificationStatus = new UserVerificationStatus ( true , true , false ) ;
331
+ jest . spyOn ( cli . getCrypto ( ) ! , "getUserVerificationStatus" ) . mockResolvedValue ( verificationStatus ) ;
332
+ cli . emit ( CryptoEvent . UserTrustStatusChanged , cli . getSafeUserId ( ) , verificationStatus ) ;
333
+ await waitFor ( ( ) => expect ( container . querySelector ( ".mx_E2EIcon_verified" ) ) . toBeInTheDocument ( ) ) ;
334
+ } ) ;
335
+
310
336
describe ( "with virtual rooms" , ( ) => {
311
337
it ( "checks for a virtual room on initial load" , async ( ) => {
312
338
const { container } = await renderRoomView ( ) ;
0 commit comments