mirror of
https://github.com/ansible/awx.git
synced 2026-04-05 01:59:25 -02:30
update LoginPage component and test pseudocode
This commit is contained in:
@@ -24,26 +24,14 @@ describe('<LoginPage />', () => {
|
|||||||
expect(submitButton.length).toBe(1);
|
expect(submitButton.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
// initially renders empty username and password fields
|
// initially renders empty username and password fields, sets empty error message and makes submit button not disabled
|
||||||
// as well as state.username and state.password to empty strings
|
|
||||||
// initially sets state.error and state.loading to false
|
|
||||||
|
|
||||||
// on unmount, unmount is set to true
|
// typing into username and password fields (if the component is not unmounting) will clear out any error message
|
||||||
|
|
||||||
// typing into username and password fields (if the component is not unmounting)
|
// when the submit Button is clicked, as long as it is not disabled state.loading is set to true
|
||||||
// set state.username and state.password, as well as set state.error to empty string
|
// api.login is called with param 1 username and param 2 password
|
||||||
// this is done through the handleUsernameChange and handlePasswordChange functions
|
// if api.login returns an error, the state.error should be set to LOGIN_ERROR_MESSAGE, if the error object returned has response.status set to 401.
|
||||||
// which both call safeSetState
|
// regardless of error or not, after api.login returns, state.loading should be set to false
|
||||||
|
|
||||||
// when the submit Button is clicked, as long as it is not disabled (through state.loading
|
// if api.isAuthenticated mock returns true, Redirect to / should be rendered
|
||||||
// being set tp true), state.loading is set to true (through safeSetState)
|
|
||||||
// api.login is called with param 1 username and param 2 password based on state
|
|
||||||
|
|
||||||
// if api.login returns an error, the state.error should be set to LOGIN_ERROR_MESSAGE
|
|
||||||
// if the error object returned has response.status set to 401.
|
|
||||||
|
|
||||||
// regardless of error or not, after api.login returns state.loading should be set to false
|
|
||||||
// via safeSetState
|
|
||||||
|
|
||||||
// QUESTION: if api.login is valid, how does redirect happen?
|
|
||||||
});
|
});
|
||||||
@@ -63,9 +63,9 @@ class LoginPage extends Component {
|
|||||||
const { username, password, loading, error } = this.state;
|
const { username, password, loading, error } = this.state;
|
||||||
const { logo, loginInfo } = this.props;
|
const { logo, loginInfo } = this.props;
|
||||||
|
|
||||||
// if (api.isAuthenticated()) {
|
if (api.isAuthenticated()) {
|
||||||
// return (<Redirect to="/" />);
|
return (<Redirect to="/" />);
|
||||||
// }
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Login
|
<Login
|
||||||
|
|||||||
Reference in New Issue
Block a user