This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,13 @@ export async function checkDeviceIsConnectedKeyBackup(
113
113
expectedBackupVersion : string ,
114
114
checkBackupKeyInCache : boolean ,
115
115
) : Promise < void > {
116
+ // Sanity check the given backup version: if it's null, something went wrong earlier in the test.
117
+ if ( ! expectedBackupVersion ) {
118
+ throw new Error (
119
+ `Invalid backup version passed to \`checkDeviceIsConnectedKeyBackup\`: ${ expectedBackupVersion } ` ,
120
+ ) ;
121
+ }
122
+
116
123
await page . getByRole ( "button" , { name : "User menu" } ) . click ( ) ;
117
124
await page . locator ( ".mx_UserMenu_contextMenu" ) . getByRole ( "menuitem" , { name : "Security & Privacy" } ) . click ( ) ;
118
125
await expect ( page . locator ( ".mx_Dialog" ) . getByRole ( "button" , { name : "Restore from Backup" } ) ) . toBeVisible ( ) ;
Original file line number Diff line number Diff line change @@ -50,11 +50,17 @@ test.describe("Device verification", () => {
50
50
bootstrapSecretStorage : true ,
51
51
} ) ;
52
52
aliceBotClient . setCredentials ( credentials ) ;
53
- const mxClientHandle = await aliceBotClient . prepareClient ( ) ;
54
53
55
- expectedBackupVersion = await mxClientHandle . evaluate ( async ( mxClient ) => {
56
- return await mxClient . getCrypto ( ) ! . getActiveSessionBackupVersion ( ) ;
57
- } ) ;
54
+ // Backup is prepared in the background. Poll until it is ready.
55
+ const botClientHandle = await aliceBotClient . prepareClient ( ) ;
56
+ await expect
57
+ . poll ( async ( ) => {
58
+ expectedBackupVersion = await botClientHandle . evaluate ( ( cli ) =>
59
+ cli . getCrypto ( ) ! . getActiveSessionBackupVersion ( ) ,
60
+ ) ;
61
+ return expectedBackupVersion ;
62
+ } )
63
+ . not . toBe ( null ) ;
58
64
} ) ;
59
65
60
66
// Click the "Verify with another device" button, and have the bot client auto-accept it.
You can’t perform that action at this time.
0 commit comments