mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-27 23:40:28 +05:30
Fix permissions page
This commit is contained in:
parent
232cf0465c
commit
5820a50047
@ -1,5 +1,7 @@
|
||||
import React from 'react';
|
||||
|
||||
import { FormattedMessage as Message } from 'react-intl';
|
||||
|
||||
import icons from 'components/ui/icons.scss';
|
||||
import { PanelBodyHeader } from 'components/ui/Panel';
|
||||
import BaseAuthBody from 'components/auth/BaseAuthBody';
|
||||
|
@ -71,7 +71,7 @@
|
||||
line-height: 9px;
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
left: 0;
|
||||
left: -4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ export default class Button extends FormComponent {
|
||||
PropTypes.string
|
||||
]).isRequired,
|
||||
block: PropTypes.bool,
|
||||
color: PropTypes.oneOf(['green', 'blue', 'red', 'lightViolet', 'darkBlue', 'violet'])
|
||||
color: PropTypes.oneOf(['green', 'blue', 'red', 'lightViolet', 'darkBlue', 'violet', 'orange'])
|
||||
};
|
||||
|
||||
render() {
|
||||
|
@ -83,7 +83,7 @@ export default class AuthFlow {
|
||||
this.run('setOAuthRequest', {});
|
||||
}
|
||||
|
||||
switch (path.replace(/(.)\/.+/, '$1')) { // use only first part of an url
|
||||
switch (path) { // use only first part of an url
|
||||
case '/oauth':
|
||||
this.setState(new OAuthState());
|
||||
break;
|
||||
@ -92,10 +92,6 @@ export default class AuthFlow {
|
||||
this.setState(new RegisterState());
|
||||
break;
|
||||
|
||||
case '/recover-password':
|
||||
this.setState(new RecoverPasswordState());
|
||||
break;
|
||||
|
||||
case '/forgot-password':
|
||||
this.setState(new ForgotPasswordState());
|
||||
break;
|
||||
@ -115,7 +111,14 @@ export default class AuthFlow {
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Error(`Unsupported request: ${path}`);
|
||||
switch (path.replace(/(.)\/.+/, '$1')) { // use only first part of an url
|
||||
case '/recover-password':
|
||||
this.setState(new RecoverPasswordState());
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Error(`Unsupported request: ${path}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,13 @@
|
||||
import AuthFlow from 'services/authFlow/AuthFlow';
|
||||
import AbstractState from 'services/authFlow/AbstractState';
|
||||
|
||||
import OAuthState from 'services/authFlow/OAuthState';
|
||||
import RegisterState from 'services/authFlow/RegisterState';
|
||||
import RecoverPasswordState from 'services/authFlow/RecoverPasswordState';
|
||||
import ForgotPasswordState from 'services/authFlow/ForgotPasswordState';
|
||||
import ResendActivationState from 'services/authFlow/ResendActivationState';
|
||||
import LoginState from 'services/authFlow/LoginState';
|
||||
|
||||
// TODO: navigate and state switching
|
||||
|
||||
describe('AuthFlow', () => {
|
||||
@ -140,4 +147,45 @@ describe('AuthFlow', () => {
|
||||
sinon.assert.calledWithExactly(state.reject, flow, expectedPayload);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#handleRequest()', () => {
|
||||
beforeEach(() => {
|
||||
sinon.stub(flow, 'setState');
|
||||
sinon.stub(flow, 'run');
|
||||
});
|
||||
|
||||
Object.entries({
|
||||
'/': LoginState,
|
||||
'/login': LoginState,
|
||||
'/password': LoginState,
|
||||
'/activation': LoginState,
|
||||
'/change-password': LoginState,
|
||||
'/oauth/permissions': LoginState,
|
||||
'/oauth/finish': LoginState,
|
||||
'/oauth': OAuthState,
|
||||
'/register': RegisterState,
|
||||
'/recover-password': RecoverPasswordState,
|
||||
'/recover-password/key123': RecoverPasswordState,
|
||||
'/forgot-password': ForgotPasswordState,
|
||||
'/resend-activation': ResendActivationState
|
||||
}).forEach(([path, type]) => {
|
||||
it(`should transition to ${type.name} if ${path}`, () => {
|
||||
flow.handleRequest(path);
|
||||
|
||||
sinon.assert.calledOnce(flow.setState);
|
||||
sinon.assert.calledWithExactly(flow.setState, sinon.match.instanceOf(type));
|
||||
});
|
||||
});
|
||||
|
||||
it('should run setOAuthRequest if /', () => {
|
||||
flow.handleRequest('/');
|
||||
|
||||
sinon.assert.calledOnce(flow.run);
|
||||
sinon.assert.calledWithExactly(flow.run, 'setOAuthRequest', {});
|
||||
});
|
||||
|
||||
it('throws if unsupported request', () => {
|
||||
expect(() => flow.handleRequest('/foo/bar')).to.throw('Unsupported request: /foo/bar');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user