Skip to content

Commit

Permalink
Error on second login (#1644)
Browse files Browse the repository at this point in the history
Fixes #1643
  • Loading branch information
1-alex98 committed Mar 30, 2020
1 parent 476e2d8 commit 352820b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/faforever/client/login/LoginController.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ public void display() {
}

private void setShowLoginProgress(boolean show) {
if (show) {
loginErrorLabel.setVisible(false);
}
loginFormPane.setVisible(!show);
loginProgressPane.setVisible(show);
loginButton.setDisable(show);
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/com/faforever/client/login/LoginControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
import java.util.concurrent.CompletableFuture;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
Expand Down Expand Up @@ -202,4 +204,29 @@ public void testOnDownloadUpdateButtonClicked() throws Exception {
verify(i18n).get("login.button.downloadPreparing");
verify(clientUpdateService, atLeastOnce()).downloadAndInstallInBackground(updateInfo);
}

@Test
public void testOnLoginErrorIsRemoved() throws Exception {
instance.loginErrorLabel.setVisible(true);
when(userService.login(eq("username"), eq("password"), anyBoolean())).thenReturn(CompletableFuture.completedFuture(null));
instance.usernameInput.setText("username");
instance.passwordInput.setText("password");
instance.onLoginButtonClicked();
WaitForAsyncUtils.waitForFxEvents();

assertFalse(instance.loginErrorLabel.isVisible());
}

@Test
public void testWarningOnLoginWithEmail() throws Exception {
instance.loginErrorLabel.setVisible(false);
instance.usernameInput.setText("username@example.com");
instance.passwordInput.setText("password");
instance.onLoginButtonClicked();
WaitForAsyncUtils.waitForFxEvents();

verifyZeroInteractions(userService);
verify(i18n).get("login.withEmailWarning");
assertTrue(instance.loginErrorLabel.isVisible());
}
}

0 comments on commit 352820b

Please sign in to comment.