fix: stabilize presenter route loading

This commit is contained in:
lda
2026-07-13 17:55:48 +07:00 Verified
parent b6cc0950b4
commit 129969e829
2 changed files with 11 additions and 2 deletions
+4 -1
View File
@@ -205,7 +205,10 @@ describe("App", () => {
</MemoryRouter>, </MemoryRouter>,
); );
expect(await screen.findByRole("main", { name: /lda.chat presenter notes/i })).toBeInTheDocument(); expect(
await screen.findByRole("main", { name: /lda.chat presenter notes/i }, { timeout: 5_000 }),
).toBeInTheDocument();
expect(screen.getByRole("heading", { level: 1 })).toBeInTheDocument();
expect(screen.queryByRole("main", { name: /lda.chat presentation/i })).not.toBeInTheDocument(); expect(screen.queryByRole("main", { name: /lda.chat presentation/i })).not.toBeInTheDocument();
}); });
}); });
+7 -1
View File
@@ -7,12 +7,18 @@ const PresenterRoute = lazy(() => import("../presentation/presenter/PresenterRou
default: module.PresenterRoute, default: module.PresenterRoute,
}))); })));
const PresenterRouteFallback = () => (
<main className="presenter-route" aria-label="Presenter notes loading" aria-busy="true">
<p>Loading presenter notes...</p>
</main>
);
export const AppRoutes = () => ( export const AppRoutes = () => (
<Routes> <Routes>
<Route path="/" element={<ConsoleHome />} /> <Route path="/" element={<ConsoleHome />} />
<Route path="/console" element={<ConsoleHome />} /> <Route path="/console" element={<ConsoleHome />} />
<Route path="/present" element={<PresentationRoute />} /> <Route path="/present" element={<PresentationRoute />} />
<Route path="/presenter" element={<Suspense fallback={null}><PresenterRoute /></Suspense>} /> <Route path="/presenter" element={<Suspense fallback={<PresenterRouteFallback />}><PresenterRoute /></Suspense>} />
<Route path="*" element={<Navigate to="/" replace />} /> <Route path="*" element={<Navigate to="/" replace />} />
</Routes> </Routes>
); );