@@ -30,7 +30,7 @@ const ROOM_ID = "!room:id";
3030 *
3131 * @return {object } sync response
3232 */
33- function getSyncResponse ( roomMembers ) {
33+ function getSyncResponse ( roomMembers : string [ ] ) {
3434 const stateEvents = [
3535 testUtils . mkEvent ( {
3636 type : 'm.room.encryption' ,
@@ -43,12 +43,10 @@ function getSyncResponse(roomMembers) {
4343
4444 Array . prototype . push . apply (
4545 stateEvents ,
46- roomMembers . map (
47- ( m ) => testUtils . mkMembership ( {
48- mship : 'join' ,
49- sender : m ,
50- } ) ,
51- ) ,
46+ roomMembers . map ( ( m ) => testUtils . mkMembership ( {
47+ mship : 'join' ,
48+ sender : m ,
49+ } ) ) ,
5250 ) ;
5351
5452 const syncResponse = {
@@ -73,8 +71,8 @@ describe("DeviceList management:", function() {
7371 return ;
7472 }
7573
76- let sessionStoreBackend ;
77- let aliceTestClient ;
74+ let aliceTestClient : TestClient ;
75+ let sessionStoreBackend : Storage ;
7876
7977 async function createTestClient ( ) {
8078 const testClient = new TestClient (
@@ -97,7 +95,10 @@ describe("DeviceList management:", function() {
9795 } ) ;
9896
9997 it ( "Alice shouldn't do a second /query for non-e2e-capable devices" , function ( ) {
100- aliceTestClient . expectKeyQuery ( { device_keys : { '@alice:localhost' : { } } } ) ;
98+ aliceTestClient . expectKeyQuery ( {
99+ device_keys : { '@alice:localhost' : { } } ,
100+ failures : { } ,
101+ } ) ;
101102 return aliceTestClient . start ( ) . then ( function ( ) {
102103 const syncResponse = getSyncResponse ( [ '@bob:xyz' ] ) ;
103104 aliceTestClient . httpBackend . when ( 'GET' , '/sync' ) . respond ( 200 , syncResponse ) ;
@@ -138,7 +139,10 @@ describe("DeviceList management:", function() {
138139
139140 it . skip ( "We should not get confused by out-of-order device query responses" , ( ) => {
140141 // https://github.com/vector-im/element-web/issues/3126
141- aliceTestClient . expectKeyQuery ( { device_keys : { '@alice:localhost' : { } } } ) ;
142+ aliceTestClient . expectKeyQuery ( {
143+ device_keys : { '@alice:localhost' : { } } ,
144+ failures : { } ,
145+ } ) ;
142146 return aliceTestClient . start ( ) . then ( ( ) => {
143147 aliceTestClient . httpBackend . when ( 'GET' , '/sync' ) . respond (
144148 200 , getSyncResponse ( [ '@bob:xyz' , '@chris:abc' ] ) ) ;
@@ -164,11 +168,12 @@ describe("DeviceList management:", function() {
164168 aliceTestClient . httpBackend . flush ( '/keys/query' , 1 ) . then (
165169 ( ) => aliceTestClient . httpBackend . flush ( '/send/' , 1 ) ,
166170 ) ,
167- aliceTestClient . client . crypto . deviceList . saveIfDirty ( ) ,
171+ aliceTestClient . client . crypto ! . deviceList . saveIfDirty ( ) ,
168172 ] ) ;
169173 } ) . then ( ( ) => {
170- aliceTestClient . client . cryptoStore . getEndToEndDeviceData ( null , ( data ) => {
171- expect ( data . syncToken ) . toEqual ( 1 ) ;
174+ // @ts -ignore accessing a protected field
175+ aliceTestClient . client . cryptoStore ! . getEndToEndDeviceData ( null , ( data ) => {
176+ expect ( data ! . syncToken ) . toEqual ( 1 ) ;
172177 } ) ;
173178
174179 // invalidate bob's and chris's device lists in separate syncs
@@ -201,15 +206,16 @@ describe("DeviceList management:", function() {
201206 return aliceTestClient . httpBackend . flush ( '/keys/query' , 1 ) ;
202207 } ) . then ( ( flushed ) => {
203208 expect ( flushed ) . toEqual ( 0 ) ;
204- return aliceTestClient . client . crypto . deviceList . saveIfDirty ( ) ;
209+ return aliceTestClient . client . crypto ! . deviceList . saveIfDirty ( ) ;
205210 } ) . then ( ( ) => {
206- aliceTestClient . client . cryptoStore . getEndToEndDeviceData ( null , ( data ) => {
207- const bobStat = data . trackingStatus [ '@bob:xyz' ] ;
211+ // @ts -ignore accessing a protected field
212+ aliceTestClient . client . cryptoStore ! . getEndToEndDeviceData ( null , ( data ) => {
213+ const bobStat = data ! . trackingStatus [ '@bob:xyz' ] ;
208214 if ( bobStat != 1 && bobStat != 2 ) {
209215 throw new Error ( 'Unexpected status for bob: wanted 1 or 2, got ' +
210216 bobStat ) ;
211217 }
212- const chrisStat = data . trackingStatus [ '@chris:abc' ] ;
218+ const chrisStat = data ! . trackingStatus [ '@chris:abc' ] ;
213219 if ( chrisStat != 1 && chrisStat != 2 ) {
214220 throw new Error (
215221 'Unexpected status for chris: wanted 1 or 2, got ' + chrisStat ,
@@ -234,12 +240,13 @@ describe("DeviceList management:", function() {
234240 // wait for the client to stop processing the response
235241 return aliceTestClient . client . downloadKeys ( [ '@bob:xyz' ] ) ;
236242 } ) . then ( ( ) => {
237- return aliceTestClient . client . crypto . deviceList . saveIfDirty ( ) ;
243+ return aliceTestClient . client . crypto ! . deviceList . saveIfDirty ( ) ;
238244 } ) . then ( ( ) => {
239- aliceTestClient . client . cryptoStore . getEndToEndDeviceData ( null , ( data ) => {
240- const bobStat = data . trackingStatus [ '@bob:xyz' ] ;
245+ // @ts -ignore accessing a protected field
246+ aliceTestClient . client . cryptoStore ! . getEndToEndDeviceData ( null , ( data ) => {
247+ const bobStat = data ! . trackingStatus [ '@bob:xyz' ] ;
241248 expect ( bobStat ) . toEqual ( 3 ) ;
242- const chrisStat = data . trackingStatus [ '@chris:abc' ] ;
249+ const chrisStat = data ! . trackingStatus [ '@chris:abc' ] ;
243250 if ( chrisStat != 1 && chrisStat != 2 ) {
244251 throw new Error (
245252 'Unexpected status for chris: wanted 1 or 2, got ' + bobStat ,
@@ -255,15 +262,16 @@ describe("DeviceList management:", function() {
255262 // wait for the client to stop processing the response
256263 return aliceTestClient . client . downloadKeys ( [ '@chris:abc' ] ) ;
257264 } ) . then ( ( ) => {
258- return aliceTestClient . client . crypto . deviceList . saveIfDirty ( ) ;
265+ return aliceTestClient . client . crypto ! . deviceList . saveIfDirty ( ) ;
259266 } ) . then ( ( ) => {
260- aliceTestClient . client . cryptoStore . getEndToEndDeviceData ( null , ( data ) => {
261- const bobStat = data . trackingStatus [ '@bob:xyz' ] ;
262- const chrisStat = data . trackingStatus [ '@bob:xyz' ] ;
267+ // @ts -ignore accessing a protected field
268+ aliceTestClient . client . cryptoStore ! . getEndToEndDeviceData ( null , ( data ) => {
269+ const bobStat = data ! . trackingStatus [ '@bob:xyz' ] ;
270+ const chrisStat = data ! . trackingStatus [ '@bob:xyz' ] ;
263271
264272 expect ( bobStat ) . toEqual ( 3 ) ;
265273 expect ( chrisStat ) . toEqual ( 3 ) ;
266- expect ( data . syncToken ) . toEqual ( 3 ) ;
274+ expect ( data ! . syncToken ) . toEqual ( 3 ) ;
267275 } ) ;
268276 } ) ;
269277 } ) ;
@@ -285,10 +293,11 @@ describe("DeviceList management:", function() {
285293 } ,
286294 ) ;
287295 await aliceTestClient . httpBackend . flush ( '/keys/query' , 1 ) ;
288- await aliceTestClient . client . crypto . deviceList . saveIfDirty ( ) ;
296+ await aliceTestClient . client . crypto ! . deviceList . saveIfDirty ( ) ;
289297
290- aliceTestClient . client . cryptoStore . getEndToEndDeviceData ( null , ( data ) => {
291- const bobStat = data . trackingStatus [ '@bob:xyz' ] ;
298+ // @ts -ignore accessing a protected field
299+ aliceTestClient . client . cryptoStore ! . getEndToEndDeviceData ( null , ( data ) => {
300+ const bobStat = data ! . trackingStatus [ '@bob:xyz' ] ;
292301
293302 // Alice should be tracking bob's device list
294303 expect ( bobStat ) . toBeGreaterThan (
@@ -322,10 +331,11 @@ describe("DeviceList management:", function() {
322331 ) ;
323332
324333 await aliceTestClient . flushSync ( ) ;
325- await aliceTestClient . client . crypto . deviceList . saveIfDirty ( ) ;
334+ await aliceTestClient . client . crypto ! . deviceList . saveIfDirty ( ) ;
326335
327- aliceTestClient . client . cryptoStore . getEndToEndDeviceData ( null , ( data ) => {
328- const bobStat = data . trackingStatus [ '@bob:xyz' ] ;
336+ // @ts -ignore accessing a protected field
337+ aliceTestClient . client . cryptoStore ! . getEndToEndDeviceData ( null , ( data ) => {
338+ const bobStat = data ! . trackingStatus [ '@bob:xyz' ] ;
329339
330340 // Alice should have marked bob's device list as untracked
331341 expect ( bobStat ) . toEqual (
@@ -359,15 +369,14 @@ describe("DeviceList management:", function() {
359369 ) ;
360370
361371 await aliceTestClient . flushSync ( ) ;
362- await aliceTestClient . client . crypto . deviceList . saveIfDirty ( ) ;
372+ await aliceTestClient . client . crypto ! . deviceList . saveIfDirty ( ) ;
363373
364- aliceTestClient . client . cryptoStore . getEndToEndDeviceData ( null , ( data ) => {
365- const bobStat = data . trackingStatus [ '@bob:xyz' ] ;
374+ // @ts -ignore accessing a protected field
375+ aliceTestClient . client . cryptoStore ! . getEndToEndDeviceData ( null , ( data ) => {
376+ const bobStat = data ! . trackingStatus [ '@bob:xyz' ] ;
366377
367378 // Alice should have marked bob's device list as untracked
368- expect ( bobStat ) . toEqual (
369- 0 ,
370- ) ;
379+ expect ( bobStat ) . toEqual ( 0 ) ;
371380 } ) ;
372381 } ) ;
373382
@@ -388,9 +397,7 @@ describe("DeviceList management:", function() {
388397 const bobStat = data ! . trackingStatus [ '@bob:xyz' ] ;
389398
390399 // Alice should have marked bob's device list as untracked
391- expect ( bobStat ) . toEqual (
392- 0 ,
393- ) ;
400+ expect ( bobStat ) . toEqual ( 0 ) ;
394401 } ) ;
395402 } finally {
396403 anotherTestClient . stop ( ) ;
0 commit comments