KEYCLOAK-11631 reset to default befor loading new

This commit is contained in:
Erik Jan de Wit 2020-02-10 16:34:41 +01:00 committed by Stan Silvert
parent 62c9e15776
commit 41bf0b78be
2 changed files with 15 additions and 4 deletions

View file

@ -130,6 +130,16 @@ public class PersonalInfoTest extends BaseAccountPageTest {
personalInfoPage.valuesEqual(testUser);
}
@Test
public void cancelForm() {
setEditUsernameAllowed(false);
personalInfoPage.setValues(testUser2, false);
personalInfoPage.setEmail("hsimpson@springfield.com");
personalInfoPage.clickCancel();
personalInfoPage.valuesEqual(testUser2);
}
@Test
public void disabledEditUsername() {
setEditUsernameAllowed(false);

View file

@ -47,8 +47,7 @@ interface AccountPageState {
export class AccountPage extends React.Component<AccountPageProps, AccountPageState> {
private isRegistrationEmailAsUsername: boolean = features.isRegistrationEmailAsUsername;
private isEditUserNameAllowed: boolean = features.isEditUserNameAllowed;
public state: AccountPageState = {
private readonly DEFAULT_STATE: AccountPageState = {
errors: {
username: '',
firstName: '',
@ -63,6 +62,8 @@ export class AccountPage extends React.Component<AccountPageProps, AccountPageSt
}
};
public state: AccountPageState = this.DEFAULT_STATE;
public constructor(props: AccountPageProps) {
super(props);
this.fetchPersonalInfo();
@ -71,8 +72,8 @@ export class AccountPage extends React.Component<AccountPageProps, AccountPageSt
private fetchPersonalInfo(): void {
AccountServiceClient.Instance.doGet("/")
.then((response: AxiosResponse<FormFields>) => {
this.setState({ formFields: response.data });
console.log({ response });
this.setState(this.DEFAULT_STATE);
this.setState({...{ formFields: response.data }});
});
}