Redirect root to profile home
- send / through the configured profile home page - keep the router regression test in sync with the redirect - preserve the legacy shell fallback for non-router bootstrap
This commit is contained in:
parent
86bcad491f
commit
f5d70768c1
2 changed files with 26 additions and 1 deletions
|
|
@ -134,4 +134,22 @@ describe('createAppRouter', () => {
|
|||
|
||||
expect(history.location.pathname).toBe('/discover');
|
||||
});
|
||||
|
||||
it('redirects the root route to the profile home page', async () => {
|
||||
window.SoulSyncWebShellBridge = createShellBridge({
|
||||
getProfileHomePage: vi.fn<() => ShellPageId>(() => 'search'),
|
||||
});
|
||||
|
||||
const queryClient = createAppQueryClient();
|
||||
const history = createMemoryHistory({ initialEntries: ['/'] });
|
||||
const router = createAppRouter({ history, queryClient });
|
||||
|
||||
render(<AppRouterProvider router={router} queryClient={queryClient} />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(window.SoulSyncWebShellBridge?.activateLegacyPath).toHaveBeenCalledWith('/search');
|
||||
});
|
||||
|
||||
expect(history.location.pathname).toBe('/search');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
import { createFileRoute } from '@tanstack/react-router';
|
||||
import { createFileRoute, redirect } from '@tanstack/react-router';
|
||||
|
||||
import { getProfileHomePath } from '@/platform/shell/bridge';
|
||||
import { LegacyRouteController } from '@/platform/shell/route-controllers';
|
||||
|
||||
export const Route = createFileRoute('/')({
|
||||
beforeLoad: ({ context }) => {
|
||||
const bridge = context.platform.getShellBridge();
|
||||
if (!bridge) return;
|
||||
|
||||
throw redirect({ href: getProfileHomePath(bridge), replace: true });
|
||||
},
|
||||
component: IndexRouteComponent,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue