Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import FullPageLoading from './components/FullPageLoading';
const Explorer = lazy(() => import('./components/explorer'));
const AnonymousLanding = lazy(() => import('./components/anonymous'));

class App extends Component {
export class App extends Component {
constructor(props) {
super(props);

Expand Down Expand Up @@ -87,12 +87,17 @@ class App extends Component {
}

redirectLink() {
if (this.redirectURL !== undefined) {
return this.redirectURL;
}

let url = '/';
if (typeof window.sessionStorage !== 'undefined' && sessionStorage.getItem('redirectURL') !== null) {
url = sessionStorage.getItem('redirectURL');
sessionStorage.removeItem('redirectURL');
}
return url;
this.redirectURL = url;
return this.redirectURL;
}

authRoutes() {
Expand Down
12 changes: 11 additions & 1 deletion src/__tests__/App.test.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
/* eslint-env jest */
import { act, render } from '@testing-library/react';
import App from '../App';
import App, { App as AppComponent } from '../App';

describe('App', () => {
it('should not crash', () => {
act(() => {
render(<App />);
});
});

it('preserves the login redirect across renders', () => {
const route = '/0123456789abcdef/00000000--0123456789/0/60';
window.sessionStorage.setItem('redirectURL', route);
const app = new AppComponent({});

expect(app.redirectLink()).toBe(route);
expect(window.sessionStorage.getItem('redirectURL')).toBeNull();
expect(app.redirectLink()).toBe(route);
});
});
Loading