@@ -91,6 +91,17 @@ const bobJoin = function(this: CryptoTestContext) {
91
91
cy . contains ( ".mx_TextualEvent" , "Bob joined the room" ) . should ( "exist" ) ;
92
92
} ;
93
93
94
+ /** configure the given MatrixClient to auto-accept any invites */
95
+ function autoJoin ( client : MatrixClient ) {
96
+ cy . window ( { log : false } ) . then ( async win => {
97
+ client . on ( win . matrixcs . RoomMemberEvent . Membership , ( event , member ) => {
98
+ if ( member . membership === "invite" && member . userId === client . getUserId ( ) ) {
99
+ client . joinRoom ( member . roomId ) ;
100
+ }
101
+ } ) ;
102
+ } ) ;
103
+ }
104
+
94
105
const handleVerificationRequest = ( request : VerificationRequest ) : Chainable < EmojiMapping [ ] > => {
95
106
return cy . wrap ( new Promise < EmojiMapping [ ] > ( ( resolve ) => {
96
107
const onShowSas = ( event : ISasEvent ) => {
@@ -174,4 +185,22 @@ describe("Cryptography", function() {
174
185
testMessages . call ( this ) ;
175
186
verify . call ( this ) ;
176
187
} ) ;
188
+
189
+ it ( "should allow verification when there is no existing DM" , function ( this : CryptoTestContext ) {
190
+ cy . bootstrapCrossSigning ( ) ;
191
+ autoJoin ( this . bob ) ;
192
+
193
+ /* we need to have a room with the other user present, so we can open the verification panel */
194
+ let roomId : string ;
195
+ cy . createRoom ( { name : "TestRoom" , invite : [ this . bob . getUserId ( ) ] } ) . then ( _room1Id => {
196
+ roomId = _room1Id ;
197
+ cy . log ( `Created test room ${ roomId } ` ) ;
198
+ cy . visit ( `/#/room/${ roomId } ` ) ;
199
+ // wait for Bob to join the room, otherwise our attempt to open his user details may race
200
+ // with his join.
201
+ cy . contains ( ".mx_TextualEvent" , "Bob joined the room" ) . should ( "exist" ) ;
202
+ } ) ;
203
+
204
+ verify . call ( this ) ;
205
+ } ) ;
177
206
} ) ;
0 commit comments