@@ -144,26 +144,23 @@ test.describe("Cryptography", function () {
144
144
// bob deletes his second device
145
145
await bobSecondDevice . evaluate ( ( cli ) => cli . logout ( true ) ) ;
146
146
147
- // wait for the logout to propagate. Workaround for https://github.com/vector-im/element-web/issues/26263 by repeatedly closing and reopening Bob's user info.
148
- async function awaitOneDevice ( iterations = 1 ) {
149
- const rightPanel = page . locator ( ".mx_RightPanel" ) ;
150
- await rightPanel . getByTestId ( "base-card-back-button" ) . click ( ) ;
151
- await rightPanel . getByText ( "Bob" ) . click ( ) ;
152
- const sessionCountText = await rightPanel
153
- . locator ( ".mx_UserInfo_devices" )
154
- . getByText ( " session" , { exact : false } )
155
- . textContent ( ) ;
156
- // cf https://github.com/vector-im/element-web/issues/26279: Element-R uses the wrong text here
157
- if ( sessionCountText != "1 session" && sessionCountText != "1 verified session" ) {
158
- if ( iterations >= 10 ) {
159
- throw new Error ( `Bob still has ${ sessionCountText } after 10 iterations` ) ;
147
+ // wait for the logout to propagate.
148
+ const onlyOneDevice = await app . client . evaluate (
149
+ async ( cli , { userId } ) => {
150
+ for ( let i = 0 ; i < 10 ; ++ i ) {
151
+ const userDeviceMap = await cli . getCrypto ( ) ?. getUserDeviceInfo ( [ userId ] , true ) ;
152
+ const deviceMap = userDeviceMap ?. get ( userId ) ;
153
+ if ( deviceMap . size === 1 ) return true ;
154
+ await new Promise ( ( r ) => setTimeout ( r , 500 ) ) ;
160
155
}
161
- await awaitOneDevice ( iterations + 1 ) ;
162
- }
156
+ return false ;
157
+ } ,
158
+ { userId : bob . credentials . userId } ,
159
+ ) ;
160
+ if ( ! onlyOneDevice ) {
161
+ throw new Error ( `Bob still has more than one session after 10 iterations!` ) ;
163
162
}
164
163
165
- await awaitOneDevice ( ) ;
166
-
167
164
// close and reopen the room, to get the shield to update.
168
165
await app . viewRoomByName ( "Bob" ) ;
169
166
await app . viewRoomByName ( "TestRoom" ) ;
0 commit comments