@@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.
88
99import { test , expect } from "../../element-web-test" ;
1010import { isDendrite } from "../../plugins/homeserver/dendrite" ;
11- import { completeCreateSecretStorageDialog , createBot , logIntoElement } from "./utils.ts" ;
11+ import { createBot , logIntoElement } from "./utils.ts" ;
1212import { type Client } from "../../pages/client.ts" ;
1313import { type ElementAppPage } from "../../pages/ElementAppPage.ts" ;
1414
@@ -28,21 +28,27 @@ test.describe("Dehydration", () => {
2828 test . skip ( isDendrite , "does not yet support dehydration v2" ) ;
2929
3030 test ( "Verify device and reset creates dehydrated device" , async ( { page, user, credentials, app } , workerInfo ) => {
31- // Verify the device by resetting the key (which will create SSSS, and dehydrated device)
31+ // Verify the device by resetting the identity key, and then set up recovery (which will create SSSS, and dehydrated device)
3232
3333 const securityTab = await app . settings . openUserSettings ( "Security & Privacy" ) ;
3434 await expect ( securityTab . getByText ( "Offline device enabled" ) ) . not . toBeVisible ( ) ;
3535
3636 await app . closeDialog ( ) ;
3737
38- // Verify the device by resetting the key
38+ // Reset the identity key
3939 const settings = await app . settings . openUserSettings ( "Encryption" ) ;
4040 await settings . getByRole ( "button" , { name : "Verify this device" } ) . click ( ) ;
4141 await page . getByRole ( "button" , { name : "Proceed with reset" } ) . click ( ) ;
4242 await page . getByRole ( "button" , { name : "Continue" } ) . click ( ) ;
43- await page . getByRole ( "button" , { name : "Copy" } ) . click ( ) ;
43+
44+ // Set up recovery
45+ await page . getByRole ( "button" , { name : "Set up recovery" } ) . click ( ) ;
46+ await page . getByRole ( "button" , { name : "Continue" } ) . click ( ) ;
47+ const recoveryKey = await page . getByTestId ( "recoveryKey" ) . innerText ( ) ;
4448 await page . getByRole ( "button" , { name : "Continue" } ) . click ( ) ;
45- await page . getByRole ( "button" , { name : "Done" } ) . click ( ) ;
49+ await page . getByRole ( "textbox" ) . fill ( recoveryKey ) ;
50+ await page . getByRole ( "button" , { name : "Finish set up" } ) . click ( ) ;
51+ await page . getByRole ( "button" , { name : "Close" } ) . click ( ) ;
4652
4753 await expectDehydratedDeviceEnabled ( app ) ;
4854
@@ -80,7 +86,7 @@ test.describe("Dehydration", () => {
8086 await expectDehydratedDeviceEnabled ( app ) ;
8187 } ) ;
8288
83- test ( "Reset recovery key during login re-creates dehydrated device" , async ( {
89+ test ( "Reset identity during login and set up recovery re-creates dehydrated device" , async ( {
8490 page,
8591 homeserver,
8692 app,
@@ -99,16 +105,26 @@ test.describe("Dehydration", () => {
99105 // Log in our client
100106 await logIntoElement ( page , credentials ) ;
101107
102- // Oh no, we forgot our recovery key
108+ // Oh no, we forgot our recovery key - reset our identity
103109 await page . locator ( ".mx_AuthPage" ) . getByRole ( "button" , { name : "Reset all" } ) . click ( ) ;
104- await page . locator ( ".mx_AuthPage" ) . getByRole ( "button" , { name : "Proceed with reset" } ) . click ( ) ;
110+ await expect (
111+ page . getByRole ( "heading" , { name : "Are you sure you want to reset your identity?" } ) ,
112+ ) . toBeVisible ( ) ;
113+ await page . getByRole ( "button" , { name : "Continue" , exact : true } ) . click ( ) ;
114+ await page . getByPlaceholder ( "Password" ) . fill ( credentials . password ) ;
115+ await page . getByRole ( "button" , { name : "Continue" } ) . click ( ) ;
105116
106- await completeCreateSecretStorageDialog ( page , { accountPassword : credentials . password } ) ;
117+ // And set up recovery
118+ const settings = await app . settings . openUserSettings ( "Encryption" ) ;
119+ await settings . getByRole ( "button" , { name : "Set up recovery" } ) . click ( ) ;
120+ await settings . getByRole ( "button" , { name : "Continue" } ) . click ( ) ;
121+ const recoveryKey = await settings . getByTestId ( "recoveryKey" ) . innerText ( ) ;
122+ await settings . getByRole ( "button" , { name : "Continue" } ) . click ( ) ;
123+ await settings . getByRole ( "textbox" ) . fill ( recoveryKey ) ;
124+ await settings . getByRole ( "button" , { name : "Finish set up" } ) . click ( ) ;
107125
108126 // There should be a brand new dehydrated device
109- const dehydratedDeviceIds = await getDehydratedDeviceIds ( app . client ) ;
110- expect ( dehydratedDeviceIds . length ) . toBe ( 1 ) ;
111- expect ( dehydratedDeviceIds [ 0 ] ) . not . toEqual ( initialDehydratedDeviceIds [ 0 ] ) ;
127+ await expectDehydratedDeviceEnabled ( app ) ;
112128 } ) ;
113129
114130 test ( "'Reset cryptographic identity' removes dehydrated device" , async ( { page, homeserver, app, credentials } ) => {
0 commit comments