@@ -60,6 +60,11 @@ test.describe("User verification", () => {
6060 // Accept
6161 await toast . getByRole ( "button" , { name : "Verify User" } ) . click ( ) ;
6262
63+ // Wait for the QR code to be rendered. If we don't do this, then the QR code can be rendered just as
64+ // Playwright tries to click the "Verify by emoji" button, which seems to make it miss the button.
65+ // (richvdh: I thought Playwright was supposed to be resilient to such things, but empirically not.)
66+ await expect ( page . getByAltText ( "QR Code" ) ) . toBeVisible ( ) ;
67+
6368 // request verification by emoji
6469 await page . locator ( "#mx_RightPanel" ) . getByRole ( "button" , { name : "Verify by emoji" } ) . click ( ) ;
6570
@@ -101,20 +106,29 @@ test.describe("User verification", () => {
101106 const toast = await toasts . getToast ( "Verification requested" ) ;
102107 await toast . getByRole ( "button" , { name : "Verify User" } ) . click ( ) ;
103108
109+ // Wait for the QR code to be rendered. If we don't do this, then the QR code can be rendered just as
110+ // Playwright tries to click the "Verify by emoji" button, which seems to make it miss the button.
111+ // (richvdh: I thought Playwright was supposed to be resilient to such things, but empirically not.)
112+ await expect ( page . getByAltText ( "QR Code" ) ) . toBeVisible ( ) ;
113+
104114 // request verification by emoji
105115 await page . locator ( "#mx_RightPanel" ) . getByRole ( "button" , { name : "Verify by emoji" } ) . click ( ) ;
106116
107117 /* on the bot side, wait for the verifier to exist ... */
108118 const botVerifier = await awaitVerifier ( bobVerificationRequest ) ;
109- // ... confirm ...
110- botVerifier . evaluate ( ( verifier ) => verifier . verify ( ) ) . catch ( ( ) => { } ) ;
119+ // ... and confirm. We expect the verification to fail; we catch the error on the DOM side
120+ // to stop playwright marking the evaluate as failing in the UI.
121+ const botVerification = botVerifier . evaluate ( ( verifier ) => verifier . verify ( ) . catch ( ( ) => { } ) ) ;
122+
111123 // ... and abort the verification
112124 await page . getByRole ( "button" , { name : "They don't match" } ) . click ( ) ;
113125
114126 const dialog = page . locator ( ".mx_Dialog" ) ;
115127 await expect ( dialog . getByText ( "Your messages are not secure" ) ) . toBeVisible ( ) ;
116128 await dialog . getByRole ( "button" , { name : "OK" } ) . click ( ) ;
117129 await expect ( dialog ) . not . toBeVisible ( ) ;
130+
131+ await botVerification ;
118132 } ) ;
119133} ) ;
120134
0 commit comments