@@ -14,6 +14,7 @@ import { queryChannelsApi } from '../mock-builders/api/queryChannels';
1414import { useMockedApis } from '../mock-builders/api/useMockedApis' ;
1515import dispatchChannelTruncatedEvent from '../mock-builders/event/channelTruncated' ;
1616import dispatchChannelUpdatedEvent from '../mock-builders/event/channelUpdated' ;
17+ import dispatchConnectionChangedEvent from '../mock-builders/event/connectionChanged' ;
1718import dispatchMemberAddedEvent from '../mock-builders/event/memberAdded' ;
1819import dispatchMemberRemovedEvent from '../mock-builders/event/memberRemoved' ;
1920import dispatchMemberUpdatedEvent from '../mock-builders/event/memberUpdated' ;
@@ -206,7 +207,6 @@ describe('Offline support is enabled', () => {
206207
207208 const channelQueriesRows = BetterSqlite . selectFromTable ( 'channelQueries' ) ;
208209 const cidsInDB = JSON . parse ( channelQueriesRows [ 0 ] . cids ) ;
209-
210210 const filterSortQueryInDB = channelQueriesRows [ 0 ] . id ;
211211 const actualFilterSortQueryInDB = convertFilterSortToQuery ( { filters, sort } ) ;
212212
@@ -285,8 +285,10 @@ describe('Offline support is enabled', () => {
285285
286286 it ( 'should store filter-sort query and cids on ChannelList in channelQueries table' , async ( ) => {
287287 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
288-
289288 const { getByTestId, queryAllByA11yRole } = renderComponent ( ) ;
289+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
290+ // await waiter();
291+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
290292 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
291293
292294 expectCIDsOnUIToBeInDB ( queryAllByA11yRole ) ;
@@ -296,6 +298,7 @@ describe('Offline support is enabled', () => {
296298 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
297299
298300 const { getByTestId, queryAllByA11yRole } = renderComponent ( ) ;
301+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
299302 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
300303
301304 expectAllChannelsWithStateToBeInDB ( queryAllByA11yRole ) ;
@@ -305,6 +308,7 @@ describe('Offline support is enabled', () => {
305308 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
306309
307310 const { getByTestId } = renderComponent ( ) ;
311+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
308312 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
309313 const newMessage = generateMessage ( {
310314 cid : channels [ 0 ] . channel . cid ,
@@ -322,6 +326,7 @@ describe('Offline support is enabled', () => {
322326 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
323327
324328 const { getByTestId, queryAllByA11yRole } = renderComponent ( ) ;
329+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
325330 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
326331
327332 const newChannel = createChannel ( ) ;
@@ -343,6 +348,7 @@ describe('Offline support is enabled', () => {
343348 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
344349
345350 const { getByTestId } = renderComponent ( ) ;
351+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
346352 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
347353
348354 const updatedMessage = { ...channels [ 0 ] . messages [ 0 ] } ;
@@ -361,6 +367,7 @@ describe('Offline support is enabled', () => {
361367 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
362368
363369 const { getByTestId, queryAllByA11yRole } = renderComponent ( ) ;
370+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
364371 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
365372 const removedChannel = channels [ getRandomInt ( 0 , channels . length - 1 ) ] . channel ;
366373 act ( ( ) => dispatchNotificationRemovedFromChannel ( chatClient , removedChannel ) ) ;
@@ -387,6 +394,7 @@ describe('Offline support is enabled', () => {
387394 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
388395
389396 const { getByTestId, queryAllByA11yRole } = renderComponent ( ) ;
397+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
390398 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
391399
392400 const newChannel = createChannel ( ) ;
@@ -416,6 +424,7 @@ describe('Offline support is enabled', () => {
416424 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
417425
418426 const { getByTestId, queryAllByA11yRole } = renderComponent ( ) ;
427+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
419428 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
420429
421430 const channelToTruncate = channels [ getRandomInt ( 0 , channels . length - 1 ) ] . channel ;
@@ -440,6 +449,7 @@ describe('Offline support is enabled', () => {
440449 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
441450
442451 const { getByTestId } = renderComponent ( ) ;
452+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
443453 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
444454
445455 const targetChannel = channels [ getRandomInt ( 0 , channels . length - 1 ) ] ;
@@ -481,6 +491,7 @@ describe('Offline support is enabled', () => {
481491 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
482492
483493 const { getByTestId } = renderComponent ( ) ;
494+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
484495 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
485496
486497 const targetChannel = channels [ getRandomInt ( 0 , channels . length - 1 ) ] ;
@@ -528,6 +539,7 @@ describe('Offline support is enabled', () => {
528539 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
529540
530541 const { getByTestId } = renderComponent ( ) ;
542+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
531543 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
532544
533545 const targetChannel = channels [ getRandomInt ( 0 , channels . length - 1 ) ] ;
@@ -561,6 +573,7 @@ describe('Offline support is enabled', () => {
561573 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
562574
563575 const { getByTestId } = renderComponent ( ) ;
576+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
564577 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
565578
566579 const targetChannel = channels [ getRandomInt ( 0 , channels . length - 1 ) ] ;
@@ -579,6 +592,7 @@ describe('Offline support is enabled', () => {
579592 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
580593
581594 const { getByTestId } = renderComponent ( ) ;
595+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
582596 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
583597
584598 const targetChannel = channels [ getRandomInt ( 0 , channels . length - 1 ) ] ;
@@ -597,6 +611,7 @@ describe('Offline support is enabled', () => {
597611 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
598612
599613 const { getByTestId } = renderComponent ( ) ;
614+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
600615 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
601616
602617 const targetChannel = channels [ getRandomInt ( 0 , channels . length - 1 ) ] ;
@@ -620,6 +635,7 @@ describe('Offline support is enabled', () => {
620635 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
621636
622637 const { getByTestId } = renderComponent ( ) ;
638+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
623639 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
624640
625641 const targetChannel = channels [ getRandomInt ( 0 , channels . length - 1 ) ] ;
@@ -640,6 +656,7 @@ describe('Offline support is enabled', () => {
640656 useMockedApis ( chatClient , [ queryChannelsApi ( channels ) ] ) ;
641657
642658 const { getByTestId } = renderComponent ( ) ;
659+ act ( ( ) => dispatchConnectionChangedEvent ( chatClient ) ) ;
643660 await waitFor ( ( ) => expect ( getByTestId ( 'channel-list' ) ) . toBeTruthy ( ) ) ;
644661 const targetChannel = channels [ getRandomInt ( 0 , channels . length - 1 ) ] ;
645662 const targetMember = targetChannel . members [ getRandomInt ( 0 , targetChannel . members . length - 1 ) ] ;
0 commit comments