@@ -297,9 +297,17 @@ export async function enableKeyBackup(app: ElementAppPage): Promise<string> {
297297 *
298298 * Assumes the dialog is already open for some reason (see also {@link enableKeyBackup}).
299299 *
300+ * @param page - The playwright `Page` fixture.
301+ * @param opts - Options object
302+ * @param opts.accountPassword - The user's account password. If we are also resetting cross-signing, then we will need
303+ * to upload the public cross-signing keys, which will cause the app to prompt for the password.
304+ *
300305 * @returns the new recovery key.
301306 */
302- export async function completeCreateSecretStorageDialog ( page : Page ) : Promise < string > {
307+ export async function completeCreateSecretStorageDialog (
308+ page : Page ,
309+ opts ?: { accountPassword ?: string } ,
310+ ) : Promise < string > {
303311 const currentDialogLocator = page . locator ( ".mx_Dialog" ) ;
304312
305313 await expect ( currentDialogLocator . getByRole ( "heading" , { name : "Set up Secure Backup" } ) ) . toBeVisible ( ) ;
@@ -311,8 +319,14 @@ export async function completeCreateSecretStorageDialog(page: Page): Promise<str
311319 const recoveryKey = await page . evaluate ( ( ) => navigator . clipboard . readText ( ) ) ;
312320 await currentDialogLocator . getByRole ( "button" , { name : "Continue" , exact : true } ) . click ( ) ;
313321
314- // If the device is unverified, there should be a "Setting up keys" step; however, it
315- // can be quite quick, and playwright can miss it, so we can't test for it.
322+ // If the device is unverified, there should be a "Setting up keys" step.
323+ // If this is not the first time we are setting up cross-signing, the app will prompt for our password; otherwise
324+ // the step is quite quick, and playwright can miss it, so we can't test for it.
325+ if ( Object . hasOwn ( opts , "accountPassword" ) ) {
326+ await expect ( currentDialogLocator . getByRole ( "heading" , { name : "Setting up keys" } ) ) . toBeVisible ( ) ;
327+ await page . getByPlaceholder ( "Password" ) . fill ( opts ! . accountPassword ) ;
328+ await currentDialogLocator . getByRole ( "button" , { name : "Continue" } ) . click ( ) ;
329+ }
316330
317331 // Either way, we end up at a success dialog:
318332 await expect ( currentDialogLocator . getByRole ( "heading" , { name : "Secure Backup successful" } ) ) . toBeVisible ( ) ;
0 commit comments