Skip to content

Give TestProvider a router - #2260

Merged
kmcginnes merged 1 commit into
mainfrom
test-provider-router
Sep 24, 2026
Merged

kmcginnes merged 1 commit into
mainfrom
test-provider-router

Conversation

@kmcginnes

Copy link
Copy Markdown
Collaborator

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, 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

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I have verified pnpm checks passes with no errors.
  • I have verified pnpm test passes with no failures.
  • I have covered new added functionality with unit tests if necessary.
  • I have updated documentation if necessary.

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
kmcginnes marked this pull request as ready for review September 24, 2026 21:27
@kmcginnes
kmcginnes merged commit 39b7d5b into main Sep 24, 2026
6 checks passed
@kmcginnes
kmcginnes deleted the test-provider-router branch September 24, 2026 22:18
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant