Give TestProvider a router - #2260
Merged
Merged
Conversation
Tests that need routed hooks or Link/useNavigate now get a router from TestProvider itself instead of hand-wiring one, and renderHookWithState forwards initialEntries through. Migrated the two existing tests that nested their own MemoryRouter, since react-router throws when a Router renders inside another Router.
kmcginnes
marked this pull request as ready for review
September 24, 2026 21:27
kmcginnes
added a commit
to kmcginnes/graph-explorer
that referenced
this pull request
Sep 24, 2026
## Description - `TestProvider` now always renders a `MemoryRouter` and takes `initialEntries`, and `renderHookWithState` passes it through. Anything that reads the location works without each test wiring its own router. - Moved `DataExplorer.test.tsx` onto it. It was hand-rolling the query client, jotai, and router providers that `TestProvider` already covers. - Dropped the inner `MemoryRouter` in `SchemaDiscoveryBoundary.integration.test.tsx`. Nesting a second router inside `TestProvider` now throws. I split this out of [Add connection links via a dedicated #/connect route](aws#1828), whose route tests use it, so that PR only carries the feature. ## Validation Test-only change. The full suite passes. ## Related Issues Prep for [Add connection links via a dedicated #/connect route](aws#1828). ### Check List - [x] I confirm that my contribution is made under the terms of the Apache 2.0 license. - [x] I have verified `pnpm checks` passes with no errors. - [x] I have verified `pnpm test` passes with no failures. - [x] I have covered new added functionality with unit tests if necessary. - [ ] I have updated documentation if necessary.
kmcginnes
added a commit
to kmcginnes/graph-explorer
that referenced
this pull request
Sep 24, 2026
## Description - `TestProvider` now always renders a `MemoryRouter` and takes `initialEntries`, and `renderHookWithState` passes it through. Anything that reads the location works without each test wiring its own router. - Moved `DataExplorer.test.tsx` onto it. It was hand-rolling the query client, jotai, and router providers that `TestProvider` already covers. - Dropped the inner `MemoryRouter` in `SchemaDiscoveryBoundary.integration.test.tsx`. Nesting a second router inside `TestProvider` now throws. I split this out of [Add connection links via a dedicated #/connect route](aws#1828), whose route tests use it, so that PR only carries the feature. ## Validation Test-only change. The full suite passes. ## Related Issues Prep for [Add connection links via a dedicated #/connect route](aws#1828). ### Check List - [x] I confirm that my contribution is made under the terms of the Apache 2.0 license. - [x] I have verified `pnpm checks` passes with no errors. - [x] I have verified `pnpm test` passes with no failures. - [x] I have covered new added functionality with unit tests if necessary. - [ ] I have updated documentation if necessary.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
TestProvidernow always renders aMemoryRouterand takesinitialEntries, andrenderHookWithStatepasses it through. Anything that reads the location works without each test wiring its own router.DataExplorer.test.tsxonto it. It was hand-rolling the query client, jotai, and router providers thatTestProvideralready covers.MemoryRouterinSchemaDiscoveryBoundary.integration.test.tsx. Nesting a second router insideTestProvidernow throws.I split this out of Add connection links via a dedicated #/connect route, whose route tests use it, so that PR only carries the feature.
Validation
Test-only change. The full suite passes.
Related Issues
Prep for Add connection links via a dedicated #/connect route.
Check List
pnpm checkspasses with no errors.pnpm testpasses with no failures.