FAQ | This is a LIVE service | Changelog

Skip to content

refactor application routing into AppRoutes component

Dr Rich Wareham requested to merge github/fork/rjw57/nav-links-issue-29 into master

PR #9 inadvertently introduced a bug where no routes were rendered in many cases. This manifested itself as the navigation links on the sidebar having no effect.

The root cause was a desire to have the application routing be testable in a different router. (In the test suite case, a MemoryRouter.) To this end the routes were broken out into sub components.

This has the unfortunate side-effect that the tests were only ever run with a router populated with just the expected routes and so errors in route matching were silently ignored.

Retain testability by breaking out all the routes into a single "AppRoutes" component which may be used within a MemoryRouter in the test-suite. This now lets tests check routes are correctly followed when all application routes are present.

Collecting all the routes together in one place also increases readability.

Take the opportunity to add a catch all "Not Found" route which provides some feedback on an invalid URL beyond a simple empty page.

Edit: Testing notes: the IAR backend needs to be running on http://localhost:8000/ and the lookupproxy needs to be running on http://localhost:8080/. Configure both backends to use the experimental OAuth2 endpoint and cut-and-paste the token into AssetForm.js. This will become less involved when, e.g, #28 is merged and API auth is handled automatically.

Closes #29 (closed)

Merge request reports