@@ -240,24 +240,26 @@ test.describe("User verification", () => {
240
240
test . use ( {
241
241
displayName : "Alice" ,
242
242
botCreateOpts : { displayName : "Bob" , autoAcceptInvites : true , userIdPrefix : "bob_" } ,
243
+ room : async ( { page, app, bot : bob , user : aliceCredentials } , use ) => {
244
+ await app . client . bootstrapCrossSigning ( aliceCredentials ) ;
245
+
246
+ // the other user creates a DM
247
+ const dmRoomId = await createDMRoom ( bob , aliceCredentials . userId ) ;
248
+
249
+ // accept the DM
250
+ await app . viewRoomByName ( "Bob" ) ;
251
+ await page . getByRole ( "button" , { name : "Start chatting" } ) . click ( ) ;
252
+ await use ( { roomId : dmRoomId } ) ;
253
+ } ,
243
254
} ) ;
244
255
245
256
test ( "can receive a verification request when there is no existing DM" , async ( {
246
257
page,
247
- app,
248
258
bot : bob ,
249
259
user : aliceCredentials ,
250
260
toasts,
261
+ room : { roomId : dmRoomId } ,
251
262
} ) => {
252
- await app . client . bootstrapCrossSigning ( aliceCredentials ) ;
253
-
254
- // the other user creates a DM
255
- const dmRoomId = await createDMRoom ( bob , aliceCredentials . userId ) ;
256
-
257
- // accept the DM
258
- await app . viewRoomByName ( "Bob" ) ;
259
- await page . getByRole ( "button" , { name : "Start chatting" } ) . click ( ) ;
260
-
261
263
// once Alice has joined, Bob starts the verification
262
264
const bobVerificationRequest = await bob . evaluateHandle (
263
265
async ( client , { dmRoomId, aliceCredentials } ) => {
@@ -294,6 +296,51 @@ test.describe("User verification", () => {
294
296
await expect ( page . getByText ( "You've successfully verified Bob!" ) ) . toBeVisible ( ) ;
295
297
await page . getByRole ( "button" , { name : "Got it" } ) . click ( ) ;
296
298
} ) ;
299
+
300
+ test ( "can abort emoji verification when emoji mismatch" , async ( {
301
+ page,
302
+ bot : bob ,
303
+ user : aliceCredentials ,
304
+ toasts,
305
+ room : { roomId : dmRoomId } ,
306
+ cryptoBackend,
307
+ } ) => {
308
+ test . skip ( cryptoBackend === "legacy" , "Not implemented for legacy crypto" ) ;
309
+
310
+ // once Alice has joined, Bob starts the verification
311
+ const bobVerificationRequest = await bob . evaluateHandle (
312
+ async ( client , { dmRoomId, aliceCredentials } ) => {
313
+ const room = client . getRoom ( dmRoomId ) ;
314
+ while ( room . getMember ( aliceCredentials . userId ) ?. membership !== "join" ) {
315
+ await new Promise ( ( resolve ) => {
316
+ room . once ( window . matrixcs . RoomStateEvent . Members , resolve ) ;
317
+ } ) ;
318
+ }
319
+
320
+ return client . getCrypto ( ) . requestVerificationDM ( aliceCredentials . userId , dmRoomId ) ;
321
+ } ,
322
+ { dmRoomId, aliceCredentials } ,
323
+ ) ;
324
+
325
+ // Accept verification via toast
326
+ const toast = await toasts . getToast ( "Verification requested" ) ;
327
+ await toast . getByRole ( "button" , { name : "Verify Session" } ) . click ( ) ;
328
+
329
+ // request verification by emoji
330
+ await page . locator ( "#mx_RightPanel" ) . getByRole ( "button" , { name : "Verify by emoji" } ) . click ( ) ;
331
+
332
+ /* on the bot side, wait for the verifier to exist ... */
333
+ const botVerifier = await awaitVerifier ( bobVerificationRequest ) ;
334
+ // ... confirm ...
335
+ botVerifier . evaluate ( ( verifier ) => verifier . verify ( ) ) . catch ( ( ) => { } ) ;
336
+ // ... and abort the verification
337
+ await page . getByRole ( "button" , { name : "They don't match" } ) . click ( ) ;
338
+
339
+ const dialog = page . locator ( ".mx_Dialog" ) ;
340
+ await expect ( dialog . getByText ( "Your messages are not secure" ) ) . toBeVisible ( ) ;
341
+ await dialog . getByRole ( "button" , { name : "OK" } ) . click ( ) ;
342
+ await expect ( dialog ) . not . toBeVisible ( ) ;
343
+ } ) ;
297
344
} ) ;
298
345
299
346
/** Extract the qrcode out of an on-screen html element */
0 commit comments