Skip to content

Commit

Permalink
refactor: login routes (#1549)
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Setch <[email protected]>
  • Loading branch information
setchy authored Sep 25, 2024
1 parent ae72183 commit 3be3cce
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
11 changes: 7 additions & 4 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { AppContext, AppProvider } from './context/App';
import { AccountsRoute } from './routes/Accounts';
import { FiltersRoute } from './routes/Filters';
import { LoginRoute } from './routes/Login';
import { LoginWithOAuthApp } from './routes/LoginWithOAuthApp';
import { LoginWithPersonalAccessToken } from './routes/LoginWithPersonalAccessToken';
import { LoginWithOAuthAppRoute } from './routes/LoginWithOAuthApp';
import { LoginWithPersonalAccessTokenRoute } from './routes/LoginWithPersonalAccessToken';
import { NotificationsRoute } from './routes/Notifications';
import { SettingsRoute } from './routes/Settings';

Expand Down Expand Up @@ -71,9 +71,12 @@ export const App = () => {
<Route path="/login" element={<LoginRoute />} />
<Route
path="/login-personal-access-token"
element={<LoginWithPersonalAccessToken />}
element={<LoginWithPersonalAccessTokenRoute />}
/>
<Route
path="/login-oauth-app"
element={<LoginWithOAuthAppRoute />}
/>
<Route path="/login-oauth-app" element={<LoginWithOAuthApp />} />
</Routes>
</div>
</Router>
Expand Down
16 changes: 8 additions & 8 deletions src/routes/LoginWithOAuthApp.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MemoryRouter } from 'react-router-dom';
import { AppContext } from '../context/App';
import type { AuthState, ClientID, ClientSecret, Hostname } from '../types';
import * as comms from '../utils/comms';
import { LoginWithOAuthApp, validate } from './LoginWithOAuthApp';
import { LoginWithOAuthAppRoute, validate } from './LoginWithOAuthApp';

const mockNavigate = jest.fn();
jest.mock('react-router-dom', () => ({
Expand All @@ -30,7 +30,7 @@ describe('routes/LoginWithOAuthApp.tsx', () => {
const tree = render(
<AppContext.Provider value={{ auth: mockAuth }}>
<MemoryRouter>
<LoginWithOAuthApp />
<LoginWithOAuthAppRoute />
</MemoryRouter>
</AppContext.Provider>,
);
Expand All @@ -42,7 +42,7 @@ describe('routes/LoginWithOAuthApp.tsx', () => {
render(
<AppContext.Provider value={{ auth: mockAuth }}>
<MemoryRouter>
<LoginWithOAuthApp />
<LoginWithOAuthAppRoute />
</MemoryRouter>
</AppContext.Provider>,
);
Expand Down Expand Up @@ -81,7 +81,7 @@ describe('routes/LoginWithOAuthApp.tsx', () => {
render(
<AppContext.Provider value={{ auth: mockAuth }}>
<MemoryRouter>
<LoginWithOAuthApp />
<LoginWithOAuthAppRoute />
</MemoryRouter>
</AppContext.Provider>,
);
Expand All @@ -95,7 +95,7 @@ describe('routes/LoginWithOAuthApp.tsx', () => {
render(
<AppContext.Provider value={{ auth: mockAuth }}>
<MemoryRouter>
<LoginWithOAuthApp />
<LoginWithOAuthAppRoute />
</MemoryRouter>
</AppContext.Provider>,
);
Expand All @@ -120,7 +120,7 @@ describe('routes/LoginWithOAuthApp.tsx', () => {
}}
>
<MemoryRouter>
<LoginWithOAuthApp />
<LoginWithOAuthAppRoute />
</MemoryRouter>
</AppContext.Provider>,
);
Expand All @@ -147,7 +147,7 @@ describe('routes/LoginWithOAuthApp.tsx', () => {
render(
<AppContext.Provider value={{ auth: mockAuth }}>
<MemoryRouter>
<LoginWithOAuthApp />
<LoginWithOAuthAppRoute />
</MemoryRouter>
</AppContext.Provider>,
);
Expand All @@ -173,7 +173,7 @@ describe('routes/LoginWithOAuthApp.tsx', () => {
render(
<AppContext.Provider value={{ auth: mockAuth }}>
<MemoryRouter>
<LoginWithOAuthApp />
<LoginWithOAuthAppRoute />
</MemoryRouter>
</AppContext.Provider>,
);
Expand Down
2 changes: 1 addition & 1 deletion src/routes/LoginWithOAuthApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const validate = (values: IValues): IFormErrors => {
return errors;
};

export const LoginWithOAuthApp: FC = () => {
export const LoginWithOAuthAppRoute: FC = () => {
const navigate = useNavigate();

const { loginWithOAuthApp } = useContext(AppContext);
Expand Down
18 changes: 9 additions & 9 deletions src/routes/LoginWithPersonalAccessToken.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { MemoryRouter } from 'react-router-dom';
import { AppContext } from '../context/App';
import * as comms from '../utils/comms';
import {
LoginWithPersonalAccessToken,
LoginWithPersonalAccessTokenRoute,
validate,
} from './LoginWithPersonalAccessToken';

Expand All @@ -32,7 +32,7 @@ describe('routes/LoginWithPersonalAccessToken.tsx', () => {
it('renders correctly', () => {
const tree = render(
<MemoryRouter>
<LoginWithPersonalAccessToken />
<LoginWithPersonalAccessTokenRoute />
</MemoryRouter>,
);

Expand All @@ -42,7 +42,7 @@ describe('routes/LoginWithPersonalAccessToken.tsx', () => {
it('let us go back', () => {
render(
<MemoryRouter>
<LoginWithPersonalAccessToken />
<LoginWithPersonalAccessTokenRoute />
</MemoryRouter>,
);

Expand Down Expand Up @@ -80,7 +80,7 @@ describe('routes/LoginWithPersonalAccessToken.tsx', () => {
}}
>
<MemoryRouter>
<LoginWithPersonalAccessToken />
<LoginWithPersonalAccessTokenRoute />
</MemoryRouter>
</AppContext.Provider>,
);
Expand All @@ -102,7 +102,7 @@ describe('routes/LoginWithPersonalAccessToken.tsx', () => {
}}
>
<MemoryRouter>
<LoginWithPersonalAccessToken />
<LoginWithPersonalAccessTokenRoute />
</MemoryRouter>
</AppContext.Provider>,
);
Expand All @@ -123,7 +123,7 @@ describe('routes/LoginWithPersonalAccessToken.tsx', () => {
}}
>
<MemoryRouter>
<LoginWithPersonalAccessToken />
<LoginWithPersonalAccessTokenRoute />
</MemoryRouter>
</AppContext.Provider>,
);
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('routes/LoginWithPersonalAccessToken.tsx', () => {
}}
>
<MemoryRouter>
<LoginWithPersonalAccessToken />
<LoginWithPersonalAccessTokenRoute />
</MemoryRouter>
</AppContext.Provider>,
);
Expand All @@ -181,7 +181,7 @@ describe('routes/LoginWithPersonalAccessToken.tsx', () => {
it('should render the form with errors', () => {
render(
<MemoryRouter>
<LoginWithPersonalAccessToken />
<LoginWithPersonalAccessTokenRoute />
</MemoryRouter>,
);

Expand All @@ -206,7 +206,7 @@ describe('routes/LoginWithPersonalAccessToken.tsx', () => {
}}
>
<MemoryRouter>
<LoginWithPersonalAccessToken />
<LoginWithPersonalAccessTokenRoute />
</MemoryRouter>
</AppContext.Provider>,
);
Expand Down
2 changes: 1 addition & 1 deletion src/routes/LoginWithPersonalAccessToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const validate = (values: IValues): IFormErrors => {
return errors;
};

export const LoginWithPersonalAccessToken: FC = () => {
export const LoginWithPersonalAccessTokenRoute: FC = () => {
const { loginWithPersonalAccessToken } = useContext(AppContext);
const navigate = useNavigate();
const [isValidToken, setIsValidToken] = useState<boolean>(true);
Expand Down

0 comments on commit 3be3cce

Please sign in to comment.