Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix broken tings
  • Loading branch information
dac09 committed Aug 4, 2023
commit 2b971b39db9ba5e93fc0cd8fcf1dc7821792d13b
13 changes: 10 additions & 3 deletions packages/router/src/__tests__/router.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
Route,
Private,
Redirect,
routes,
routes as generatedRoutes,
Link,
navigate,
back,
Expand All @@ -45,7 +45,7 @@ import {
import { useLocation } from '../location'
import { useParams } from '../params'
import { Set } from '../Set'
import { Spec } from '../util'
import type { Spec, GeneratedRoutesMap } from '../util'

/** running into intermittent test timeout behavior in https://github.com/redwoodjs/redwood/pull/4992
attempting to work around by bumping the default timeout of 5000 */
Expand All @@ -59,9 +59,16 @@ type UnknownAuthContextInterface = AuthContextInterface<
unknown,
unknown,
unknown,
unknown,
unknown,
unknown,
unknown,
unknown
>

// The types are generated in the user's project
const routes = generatedRoutes as GeneratedRoutesMap

function createDummyAuthContextValues(
partial: Partial<UnknownAuthContextInterface>
) {
Expand Down Expand Up @@ -1568,7 +1575,7 @@ describe('Unauthorized redirect error messages', () => {
)
})

test('Private set redirecting to page that needs parameters', async () => {
test.only('Private set redirecting to page that needs parameters', async () => {
const TestRouter = ({ authenticated }: { authenticated?: boolean }) => (
<Router useAuth={mockUseAuth({ isAuthenticated: authenticated })}>
<Route path="/" page={HomePage} name="home" />
Expand Down
2 changes: 1 addition & 1 deletion packages/router/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ const WrappedPage = memo(
wrappersWithAuthMaybe = [AuthenticatedRoute, ...wrappers]
}

if (wrappers.length > 0) {
if (wrappersWithAuthMaybe.length > 0) {
// If wrappers exist e.g. [a,b,c] -> <a><b><c><routeLoader></c></b></a> and returns a single ReactNode
// Wrap AuthenticatedRoute this way, because if we mutate the wrappers array itself
// it causes full rerenders of the page
Expand Down