@@ -345,6 +345,7 @@ describe('ReactQueryDevtools', () => {
345345 // When sorted by query hash the queries get sorted according
346346 // to just the number, with the order being -> query-1, query-2, query-3
347347 fireEvent . change ( sortSelect , { target : { value : 'Query Hash' } } )
348+
348349 /** To check the order of the queries we can use regex to find
349350 * all the row items in an array and then compare the items
350351 * one by one in the order we expect it
@@ -355,10 +356,14 @@ describe('ReactQueryDevtools', () => {
355356 expect ( queries [ 1 ] ?. textContent ) . toEqual ( query2Hash )
356357 expect ( queries [ 2 ] ?. textContent ) . toEqual ( query3Hash )
357358
359+ // Wait for the queries to be resolved
360+ await sleep ( 70 )
361+
358362 // When sorted by the last updated date the queries are sorted by the time
359363 // they were updated and since the query-2 takes longest time to complete
360364 // and query-1 the shortest, so the order is -> query-2, query-3, query-1
361365 fireEvent . change ( sortSelect , { target : { value : 'Last Updated' } } )
366+
362367 queries = await screen . findAllByText ( / \[ " q u e r y - [ 1 - 3 ] " \] / )
363368 expect ( queries [ 0 ] ?. textContent ) . toEqual ( query2Hash )
364369 expect ( queries [ 1 ] ?. textContent ) . toEqual ( query3Hash )
@@ -368,7 +373,10 @@ describe('ReactQueryDevtools', () => {
368373 // query-3 takes precedence because its stale time being infinity, it
369374 // always remains fresh, the rest of the queries are sorted by their last
370375 // updated time, so the resulting order is -> query-3, query-2, query-1
371- fireEvent . change ( sortSelect , { target : { value : 'Status > Last Updated' } } )
376+ fireEvent . change ( sortSelect , {
377+ target : { value : 'Status > Last Updated' } ,
378+ } )
379+
372380 queries = await screen . findAllByText ( / \[ " q u e r y - [ 1 - 3 ] " \] / )
373381 expect ( queries [ 0 ] ?. textContent ) . toEqual ( query3Hash )
374382 expect ( queries [ 1 ] ?. textContent ) . toEqual ( query2Hash )
@@ -377,6 +385,7 @@ describe('ReactQueryDevtools', () => {
377385 // Switch the order form ascending to descending and expect the
378386 // query order to be reversed from previous state
379387 fireEvent . click ( screen . getByRole ( 'button' , { name : / ⬆ a s c / i } ) )
388+
380389 queries = await screen . findAllByText ( / \[ " q u e r y - [ 1 - 3 ] " \] / )
381390 expect ( queries [ 0 ] ?. textContent ) . toEqual ( query1Hash )
382391 expect ( queries [ 1 ] ?. textContent ) . toEqual ( query2Hash )
0 commit comments