Skip to content

Commit

Permalink
fix(frontend): fix relative links
Browse files Browse the repository at this point in the history
  • Loading branch information
Falinor committed Nov 26, 2024
1 parent d7b8f1e commit a427c0b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function AccountEmailActivationView() {
}

if (!location.state?.email) {
return <Navigate to="email" />;
return <Navigate to="/inscription/email" />;
}

const confirmationClasses = classNames(`fr-${status}-text`, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function AccountEmailCreationView() {
category: TrackEventCategories.AccountCreation,
action: TrackEventActions.AccountCreation.SendEmail
});
navigate('activation', {
navigate('/inscription/activation', {
state: {
email
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render, screen } from '@testing-library/react';
import { MemoryRouter as Router, Route } from 'react-router-dom';
import { createMemoryRouter, Outlet, RouterProvider } from 'react-router-dom';
import AccountEmailCreationView from '../AccountEmailCreationView';
import userEvent from '@testing-library/user-event';
import { store } from '../../../../store/store';
Expand All @@ -9,19 +9,23 @@ describe('AccountEmailCreationView', () => {
const user = userEvent.setup();

function setup() {
const router = createMemoryRouter(
[
{
path: '/inscription/*',
element: <Outlet />,
children: [
{ path: 'email', element: <AccountEmailCreationView /> },
{ path: 'activation', element: 'Activation' }
]
}
],
{ initialEntries: ['/inscription/email'] }
);
render(
<Provider store={store}>
<Router initialEntries={['/inscription/email']}>
<Route
path="/inscription/email"
component={AccountEmailCreationView}
/>
<Route path="/inscription/activation">Activation</Route>
<Route exact path="/">
Accueil
</Route>
</Router>
</Provider>,
<RouterProvider router={router} />
</Provider>
);
}

Expand All @@ -40,7 +44,7 @@ describe('AccountEmailCreationView', () => {
await user.keyboard('{Enter}');

const error = await screen.findByText(
"L'adresse doit être un email valide",
"L'adresse doit être un email valide"
);
expect(error).toBeVisible();
});
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/Account/AccountCreationView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function AccountCreationView() {
path="campagne"
element={<AccountCampaignIntentCreationView />}
/>
<Route path="*" element={<Navigate replace to="email" />} />
<Route path="*" element={<Navigate replace to="../email" />} />
</Routes>
</Col>
<Col n="5" offset="1" className="align-right">
Expand Down

0 comments on commit a427c0b

Please sign in to comment.