@@ -22,6 +22,7 @@ import {
22
22
} from "./utils" ;
23
23
import { type Bot } from "../../pages/bot" ;
24
24
import { Toasts } from "../../pages/toasts.ts" ;
25
+ import type { ElementAppPage } from "../../pages/ElementAppPage.ts" ;
25
26
26
27
test . describe ( "Device verification" , { tag : "@no-webkit" } , ( ) => {
27
28
let aliceBotClient : Bot ;
@@ -163,46 +164,52 @@ test.describe("Device verification", { tag: "@no-webkit" }, () => {
163
164
164
165
test ( "Verify device with Security Phrase during login" , async ( { page, app, credentials, homeserver } ) => {
165
166
await logIntoElement ( page , credentials ) ;
167
+ await enterRecoveryKeyAndCheckVerified ( page , app , "new passphrase" ) ;
168
+ } ) ;
166
169
167
- // Select the security phrase
168
- await page . locator ( ".mx_AuthPage" ) . getByRole ( "button" , { name : "Verify with Recovery Key or Phrase" } ) . click ( ) ;
170
+ test ( "Verify device with Recovery Key during login" , async ( { page , app , credentials , homeserver } ) => {
171
+ const recoveryKey = ( await aliceBotClient . getRecoveryKey ( ) ) . encodedPrivateKey ;
169
172
170
- // Fill the passphrase
171
- const dialog = page . locator ( ".mx_Dialog" ) ;
172
- await dialog . locator ( "textarea" ) . fill ( "new passphrase" ) ;
173
- await dialog . getByRole ( "button" , { name : "Continue" , disabled : false } ) . click ( ) ;
173
+ await logIntoElement ( page , credentials ) ;
174
+ await enterRecoveryKeyAndCheckVerified ( page , app , recoveryKey ) ;
175
+ } ) ;
174
176
175
- await page . locator ( ".mx_AuthPage" ) . getByRole ( "button" , { name : "Done" } ) . click ( ) ;
177
+ test ( "Verify device with Recovery Key from settings" , async ( { page, app, credentials } ) => {
178
+ const recoveryKey = ( await aliceBotClient . getRecoveryKey ( ) ) . encodedPrivateKey ;
176
179
177
- // Check that our device is now cross-signed
178
- await checkDeviceIsCrossSigned ( app ) ;
180
+ await logIntoElement ( page , credentials ) ;
179
181
180
- // Check that the current device is connected to key backup
181
- // The backup decryption key should be in cache also, as we got it directly from the 4S
182
- await checkDeviceIsConnectedKeyBackup ( app , expectedBackupVersion , true ) ;
183
- } ) ;
182
+ /* Dismiss "Verify this device" */
183
+ const authPage = page . locator ( ".mx_AuthPage" ) ;
184
+ await authPage . getByRole ( "button" , { name : "Skip verification for now" } ) . click ( ) ;
185
+ await authPage . getByRole ( "button" , { name : "I'll verify later" } ) . click ( ) ;
186
+ await page . waitForSelector ( ".mx_MatrixChat" ) ;
184
187
185
- test ( "Verify device with Recovery Key during login" , async ( { page, app, credentials, homeserver } ) => {
186
- await logIntoElement ( page , credentials ) ;
188
+ const settings = await app . settings . openUserSettings ( "Encryption" ) ;
189
+ await settings . getByRole ( "button" , { name : "Verify this device" } ) . click ( ) ;
190
+ await enterRecoveryKeyAndCheckVerified ( page , app , recoveryKey ) ;
191
+ } ) ;
187
192
188
- // Select the security phrase
189
- await page . locator ( ".mx_AuthPage" ) . getByRole ( "button" , { name : "Verify with Recovery Key or Phrase" } ) . click ( ) ;
193
+ /** Helper for the three tests above which verify by recovery key */
194
+ async function enterRecoveryKeyAndCheckVerified ( page : Page , app : ElementAppPage , recoveryKey : string ) {
195
+ await page . getByRole ( "button" , { name : "Verify with Recovery Key or Phrase" } ) . click ( ) ;
190
196
191
- // Fill the recovery key
197
+ // Enter the recovery key
192
198
const dialog = page . locator ( ".mx_Dialog" ) ;
193
- const aliceRecoveryKey = await aliceBotClient . getRecoveryKey ( ) ;
194
- await dialog . locator ( "textarea" ) . fill ( aliceRecoveryKey . encodedPrivateKey ) ;
199
+ // We use `pressSequentially` here to make sure that the FocusLock isn't causing us any problems
200
+ // (cf https://github.com/element-hq/element-web/issues/30089)
201
+ await dialog . locator ( "textarea" ) . pressSequentially ( recoveryKey ) ;
195
202
await dialog . getByRole ( "button" , { name : "Continue" , disabled : false } ) . click ( ) ;
196
203
197
- await page . locator ( ".mx_AuthPage" ) . getByRole ( "button" , { name : "Done" } ) . click ( ) ;
204
+ await page . getByRole ( "button" , { name : "Done" } ) . click ( ) ;
198
205
199
206
// Check that our device is now cross-signed
200
207
await checkDeviceIsCrossSigned ( app ) ;
201
208
202
209
// Check that the current device is connected to key backup
203
210
// The backup decryption key should be in cache also, as we got it directly from the 4S
204
211
await checkDeviceIsConnectedKeyBackup ( app , expectedBackupVersion , true ) ;
205
- } ) ;
212
+ }
206
213
207
214
test ( "Handle incoming verification request with SAS" , async ( { page, credentials, homeserver, toasts } ) => {
208
215
await logIntoElement ( page , credentials ) ;
0 commit comments