|
@ -62,6 +62,22 @@ import static org.junit.jupiter.api.Assertions.assertTrue; |
|
|
assertTrue(isErrorMessageShown(signUpGUI)); |
|
|
assertTrue(isErrorMessageShown(signUpGUI)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void testExistingUsername() { |
|
|
|
|
|
SignUpGUI signUpGUI = new SignUpGUI(); |
|
|
|
|
|
signUpGUI.getUsernameField().setText("existinguser"); |
|
|
|
|
|
signUpGUI.getPasswordField().setText("password"); |
|
|
|
|
|
signUpGUI.getConfirmPasswordField().setText("password"); |
|
|
|
|
|
signUpGUI.getBirthdayField().setText("1990-01-01"); |
|
|
|
|
|
signUpGUI.getFirstNameField().setText("John"); |
|
|
|
|
|
signUpGUI.getSurnameField().setText("Doe"); |
|
|
|
|
|
|
|
|
|
|
|
signUpGUI.getSignUpButton().doClick(); // Simulate button click |
|
|
|
|
|
|
|
|
|
|
|
// Make sure an error message dialog is shown |
|
|
|
|
|
assertTrue(isErrorMessageShown(signUpGUI)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Helper method to check if an error message dialog is shown |
|
|
// Helper method to check if an error message dialog is shown |
|
|
private boolean isErrorMessageShown(JFrame frame) { |
|
|
private boolean isErrorMessageShown(JFrame frame) { |
|
|
Component[] components = frame.getComponents(); |
|
|
Component[] components = frame.getComponents(); |
|
@ -69,6 +85,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; |
|
|
if (component instanceof JOptionPane) { |
|
|
if (component instanceof JOptionPane) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|