mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Fix the rest of the tests
This commit is contained in:
@@ -71,7 +71,12 @@ class RootPage extends React.PureComponent<{
|
||||
>
|
||||
<div className={styles.header} data-testid="toolbar">
|
||||
<div className={styles.headerContent}>
|
||||
<Link to="/" className={styles.logo} onClick={onLogoClick}>
|
||||
<Link
|
||||
to="/"
|
||||
className={styles.logo}
|
||||
onClick={onLogoClick}
|
||||
data-testid="home-page"
|
||||
>
|
||||
<Message {...messages.siteName} />
|
||||
</Link>
|
||||
<div className={styles.userbar}>
|
||||
|
@@ -68,7 +68,7 @@ describe('AuthFlow.functional', () => {
|
||||
it('should redirect guest / -> /login', () => {
|
||||
navigate('/');
|
||||
|
||||
expect(flow.navigate, 'was called once');
|
||||
expect(flow.navigate, 'was called twice');
|
||||
expect(flow.navigate, 'to have a call satisfying', ['/login']);
|
||||
});
|
||||
|
||||
@@ -80,8 +80,12 @@ describe('AuthFlow.functional', () => {
|
||||
navigate('/login');
|
||||
navigate('/');
|
||||
|
||||
expect(flow.navigate, 'was called twice');
|
||||
expect(flow.navigate, 'to have a call satisfying', ['/login']);
|
||||
expect(flow.navigate, 'was called thrice');
|
||||
expect(flow.navigate, 'to have calls satisfying', [
|
||||
['/login'],
|
||||
['/login'],
|
||||
['/login'],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -115,12 +115,6 @@ export default class AuthFlow implements AuthContext {
|
||||
options.replace = true;
|
||||
}
|
||||
|
||||
this.currentRequest = {
|
||||
path: route,
|
||||
params: {},
|
||||
query: new URLSearchParams(),
|
||||
};
|
||||
|
||||
if (this.replace) {
|
||||
this.replace(route);
|
||||
}
|
||||
@@ -288,18 +282,18 @@ export default class AuthFlow implements AuthContext {
|
||||
*
|
||||
* @returns {bool} - whether oauth state is being restored
|
||||
*/
|
||||
private restoreOAuthState() {
|
||||
if (/^\/(register|oauth2)/.test(this.getRequest().path)) {
|
||||
// allow register or the new oauth requests
|
||||
return;
|
||||
}
|
||||
|
||||
private restoreOAuthState(): boolean {
|
||||
if (this.oAuthStateRestored) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
this.oAuthStateRestored = true;
|
||||
|
||||
if (/^\/(register|oauth2)/.test(this.getRequest().path)) {
|
||||
// allow register or the new oauth requests
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const data = JSON.parse(localStorage.getItem('oauthData'));
|
||||
const expirationTime = 2 * 60 * 60 * 1000; // 2h
|
||||
|
@@ -105,7 +105,7 @@ export default class CompleteState extends AbstractState {
|
||||
(resp: { redirectUri: string }) => {
|
||||
// TODO: пусть в стейт попадает флаг или тип авторизации
|
||||
// вместо волшебства над редирект урлой
|
||||
if (resp.redirectUri.indexOf('static_page') === 0) {
|
||||
if (resp.redirectUri.includes('static_page')) {
|
||||
context.setState(new FinishState());
|
||||
} else {
|
||||
return context.run('redirect', resp.redirectUri);
|
||||
|
@@ -12,7 +12,7 @@ export default class LoginState extends AbstractState {
|
||||
const { user } = context.getState();
|
||||
|
||||
const isUserAddsSecondAccount =
|
||||
!user.isGuest && /login|password/.test(context.getRequest().path); // TODO: improve me
|
||||
!user.isGuest && /login|password/.test(location.pathname); // TODO: improve me
|
||||
|
||||
// TODO: it may not allow user to leave password state till he click back or enters password
|
||||
if (login) {
|
||||
|
@@ -15,9 +15,11 @@ import { AuthContext } from './AuthFlow';
|
||||
|
||||
export default class PasswordState extends AbstractState {
|
||||
enter(context: AuthContext) {
|
||||
const { login } = getCredentials(context.getState());
|
||||
const { login, isTotpRequired } = getCredentials(context.getState());
|
||||
|
||||
if (login) {
|
||||
if (isTotpRequired) {
|
||||
context.setState(new MfaState());
|
||||
} else if (login) {
|
||||
context.navigate('/password');
|
||||
} else {
|
||||
context.setState(new CompleteState());
|
||||
|
Reference in New Issue
Block a user