Skip to content

Commit

Permalink
👩‍💻 dx(tests): Experiment with test-only routes.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Dec 10, 2024
1 parent 5bbe7e3 commit fe6000f
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions imports/ui/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import {BrowserRouter} from 'react-router-dom';
import {BrowserRouter, Routes, Route} from 'react-router-dom';

import {CacheProvider} from '@emotion/react';
import createCache from '@emotion/cache';
Expand All @@ -10,6 +10,8 @@ import {SnackbarProvider} from 'notistack';

import CssBaseline from '@mui/material/CssBaseline';

import isTest from '../app/isTest';

import DateTimeLocalizationProvider from './i18n/DateTimeLocalizationProvider';
import CustomWholeWindowDropZone from './input/CustomWholeWindowDropZone';
import ModalProvider from './modal/ModelProvider';
Expand All @@ -24,11 +26,22 @@ export const muiCache = createCache({
prepend: true,
});

const Router = isTest()
? ({children}) => (
<BrowserRouter>
<Routes>
<Route element={<div>test</div>} path="/_test" />
<Route element={{...children}} path="*" />
</Routes>
</BrowserRouter>
)
: BrowserRouter;

const App = () => {
const theme = useUserTheme();

return (
<BrowserRouter>
<Router>
<DateTimeLocalizationProvider>
<CacheProvider value={muiCache}>
<ThemeProvider theme={theme}>
Expand All @@ -47,7 +60,7 @@ const App = () => {
</ThemeProvider>
</CacheProvider>
</DateTimeLocalizationProvider>
</BrowserRouter>
</Router>
);
};

Expand Down

0 comments on commit fe6000f

Please sign in to comment.