@tanstack/react-query-devtools 5.0.0-alpha.10 → 5.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-query-devtools",
3
- "version": "5.0.0-alpha.10",
3
+ "version": "5.0.0-alpha.11",
4
4
  "description": "Developer tools to interact with and visualize the TanStack/react-query cache",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react'
2
2
  import { fireEvent, screen, waitFor, act } from '@testing-library/react'
3
3
  import '@testing-library/jest-dom'
4
- import { useQuery } from '@tanstack/react-query'
4
+ import { useQuery, onlineManager } from '@tanstack/react-query'
5
5
  import { defaultPanelSize, sortFns } from '../utils'
6
6
  import {
7
7
  getByTextContent,
@@ -478,6 +478,31 @@ describe('ReactQueryDevtools', () => {
478
478
  expect(count).toBe(2)
479
479
  })
480
480
 
481
+ it('should inform onlineManager when offline mode is simulated', () => {
482
+ const { queryClient } = createQueryClient()
483
+ const online: Array<boolean> = []
484
+
485
+ const unsubscribe = onlineManager.subscribe(() => {
486
+ online.push(onlineManager.isOnline())
487
+ })
488
+
489
+ renderWithClient(queryClient, <div />, {
490
+ initialIsOpen: true,
491
+ })
492
+
493
+ fireEvent.click(
494
+ screen.getByRole('button', { name: /mock offline behavior/i }),
495
+ )
496
+
497
+ fireEvent.click(
498
+ screen.getByRole('button', { name: /restore offline mock/i }),
499
+ )
500
+
501
+ expect(online).toStrictEqual([false, true])
502
+
503
+ unsubscribe()
504
+ })
505
+
481
506
  it('should sort the queries according to the sorting filter', async () => {
482
507
  const { queryClient, queryCache } = createQueryClient()
483
508
 
package/src/devtools.tsx CHANGED
@@ -689,6 +689,7 @@ export const ReactQueryDevtoolsPanel = React.forwardRef<
689
689
  } else {
690
690
  onlineManager.setOnline(false)
691
691
  setMockOffline(true)
692
+ window.dispatchEvent(new Event('offline'))
692
693
  }
693
694
  }}
694
695
  aria-label={