@@ -71,9 +71,11 @@ describe("EventTile", () => {
71
71
function getComponent (
72
72
overrides : Partial < EventTileProps > = { } ,
73
73
renderingType : TimelineRenderingType = TimelineRenderingType . Room ,
74
+ roomContext : Partial < IRoomState > = { } ,
74
75
) {
75
76
const context = getRoomContext ( room , {
76
77
timelineRenderingType : renderingType ,
78
+ ...roomContext ,
77
79
} ) ;
78
80
return render ( < WrappedEventTile roomContext = { context } eventTilePropertyOverrides = { overrides } /> ) ;
79
81
}
@@ -437,8 +439,6 @@ describe("EventTile", () => {
437
439
} ) ;
438
440
439
441
it ( "should update the warning when the event is replaced with an unencrypted one" , async ( ) => {
440
- jest . spyOn ( client , "isRoomEncrypted" ) . mockReturnValue ( true ) ;
441
-
442
442
// we start out with an event from the trusted device
443
443
mxEvent = await mkEncryptedMatrixEvent ( {
444
444
plainContent : { msgtype : "m.text" , body : "msg1" } ,
@@ -452,7 +452,7 @@ describe("EventTile", () => {
452
452
shieldReason : null ,
453
453
} as EventEncryptionInfo ) ;
454
454
455
- const roomContext = getRoomContext ( room , { } ) ;
455
+ const roomContext = getRoomContext ( room , { isRoomEncrypted : true } ) ;
456
456
const { container, rerender } = render ( < WrappedEventTile roomContext = { roomContext } /> ) ;
457
457
await flushPromises ( ) ;
458
458
@@ -581,4 +581,28 @@ describe("EventTile", () => {
581
581
} ) ;
582
582
} ) ;
583
583
} ) ;
584
+
585
+ it ( "should display the not encrypted status for an unencrypted event when the room becomes encrypted" , async ( ) => {
586
+ jest . spyOn ( client . getCrypto ( ) ! , "getEncryptionInfoForEvent" ) . mockResolvedValue ( {
587
+ shieldColour : EventShieldColour . NONE ,
588
+ shieldReason : null ,
589
+ } ) ;
590
+
591
+ const { rerender } = getComponent ( ) ;
592
+ await flushPromises ( ) ;
593
+ // The room and the event are unencrypted, the tile should not show the not encrypted status
594
+ expect ( screen . queryByText ( "Not encrypted" ) ) . toBeNull ( ) ;
595
+
596
+ // The room is now encrypted
597
+ rerender (
598
+ < WrappedEventTile
599
+ roomContext = { getRoomContext ( room , {
600
+ isRoomEncrypted : true ,
601
+ } ) }
602
+ /> ,
603
+ ) ;
604
+
605
+ // The event tile should now show the not encrypted status
606
+ await waitFor ( ( ) => expect ( screen . getByText ( "Not encrypted" ) ) . toBeInTheDocument ( ) ) ;
607
+ } ) ;
584
608
} ) ;
0 commit comments