Skip to content

Conversation

brandongregoryscott
Copy link
Contributor

Fixes #26

Wrap NestedRoutes render in <Switch> and expand route as props to individual NestedRoute to fix fall-through to <Redirect>, add test for this case

  • Related GitHub issue(s) linked in PR description
  • Destination branch merged, built and tested with your changes
  • Code formatted and follows best practices and patterns
  • Code builds cleanly (no additional warnings or errors)
  • Manually tested
  • Automated tests are passing
  • No decreases in automated test coverage
  • [-] Documentation updated (readme, docs, comments, etc.)
  • [-] Localization: No hard-coded error messages in code files (minimally in string constants)

…dual NestedRoute to fix fallthrough to <Redirect>, add test for this case
@brandongregoryscott brandongregoryscott added the bug Something isn't working label Aug 9, 2020
@brandongregoryscott brandongregoryscott requested review from a team and wintondeshong August 9, 2020 17:33
@codecov
Copy link

codecov bot commented Aug 9, 2020

Codecov Report

Merging #29 into master will decrease coverage by 6.34%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##            master      #29      +/-   ##
===========================================
- Coverage   100.00%   93.65%   -6.35%     
===========================================
  Files            9       12       +3     
  Lines          166      205      +39     
  Branches        18       23       +5     
===========================================
+ Hits           166      192      +26     
- Misses           0       12      +12     
- Partials         0        1       +1     
Impacted Files Coverage Δ
src/components/routing/nested-routes.tsx 91.66% <100.00%> (ø)
src/tests/factories/route-definition-factory.ts 100.00% <100.00%> (ø)
src/components/routing/authenticated-route.tsx 26.66% <0.00%> (ø)
src/components/routing/nested-route.tsx 91.66% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 210b753...63d9d11. Read the comment docs.

@brandongregoryscott
Copy link
Contributor Author

🤦 Looks like codecov is seeing a decrease in coverage, probably because this is the first set of tests that are hitting any of the routing components. I'll add some issues to backfill tests for these.

Copy link
Contributor

@wintondeshong wintondeshong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brandongregoryscott thank you for troubleshooting this issue! I'm going to accept, merge and build a release. Going to update the boilerplate to use this. Nice work!

As for test coverage, yeah, I see what you mean. No worries! This is an increase in coverage in my book 👍

const redirectToIfNotFound = notFoundRoute.path; // This is the important setup

const App = () => (
<Router history={history}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought: Could be wrong, but think you could spare the extra setup of 'history' by using MemoryRouter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah, I was seeing that in the docs too. Wasn't sure how I would simulate a navigation change, though it looks like MemoryRouter has an initialEntries prop which may have worked the same way.

@@ -0,0 +1,113 @@
import React from "react";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brandongregoryscott Thank you for writing tests for this!

@wintondeshong wintondeshong merged commit fb2e149 into rsm-hcd:master Aug 10, 2020
@brandongregoryscott brandongregoryscott deleted the support/nested-routes-switch-bug branch August 14, 2020 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NestedRoutes always redirects to not found destination

2 participants