Browse Source

test_SignUpGUI button actions

remotes/origin/server
Richard Schmidt 11 months ago
parent
commit
8105b8fffd
  1. 26
      src/main/java/SignUpGUI.java
  2. 12
      src/test/java/LoginGUITest.java
  3. 35
      src/test/java/SignUpGUITest.java
  4. 9
      user.json

26
src/main/java/SignUpGUI.java

@ -7,6 +7,32 @@ import java.util.UUID;
public class SignUpGUI extends JFrame implements ActionListener { public class SignUpGUI extends JFrame implements ActionListener {
private JTextField usernameField, passwordField, confirmPasswordField, birthdayField, firstNameField, surnameField; private JTextField usernameField, passwordField, confirmPasswordField, birthdayField, firstNameField, surnameField;
private JButton signUpButton; private JButton signUpButton;
public JTextField getUsernameField() {
return usernameField;
}
public JTextField getPasswordField() {
return passwordField;
}
public JTextField getConfirmPasswordField() {
return confirmPasswordField;
}
public JTextField getBirthdayField() {
return birthdayField;
}
public JTextField getFirstNameField() {
return firstNameField;
}
public JTextField getSurnameField() {
return surnameField;
}
public JButton getSignUpButton() {
return signUpButton;
}
public SignUpGUI() { public SignUpGUI() {
setTitle("Sign Up"); setTitle("Sign Up");

12
src/test/java/LoginGUITest.java

@ -37,14 +37,16 @@ class LoginGUITest {
@Test @Test
public void testStayLoggedInCheckbox() { public void testStayLoggedInCheckbox() {
// Initially, checkbox should be unchecked
assertFalse(loginGUI.getStayLoggedInCheckbox().isSelected());
// Initially, checkbox should be unchecked
assertFalse(loginGUI.getStayLoggedInCheckbox().isSelected());
// Simulate checking the checkbox
loginGUI.getStayLoggedInCheckbox().doClick();
// Simulate checking the checkbox
loginGUI.getStayLoggedInCheckbox().doClick();
assertTrue(loginGUI.getStayLoggedInCheckbox().isSelected());
assertTrue(loginGUI.getStayLoggedInCheckbox().isSelected());
} }
} }

35
src/test/java/SignUpGUITest.java

@ -0,0 +1,35 @@
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
class SignUpGUITest {
private SignUpGUI signUpGUI;
@BeforeEach
void setUp() {
signUpGUI = new SignUpGUI();
signUpGUI.setVisible(true);
}
@AfterEach
void tearDown() {
signUpGUI.dispose();
}
@Test
void testSignUpButtonActionPerformed() {
signUpGUI.getUsernameField().setText("testuser");
signUpGUI.getPasswordField().setText("password");
signUpGUI.getConfirmPasswordField().setText("password");
signUpGUI.getBirthdayField().setText("2000-01-01");
signUpGUI.getFirstNameField().setText("John");
signUpGUI.getSurnameField().setText("Doe");
signUpGUI.getSignUpButton().doClick();
assertFalse(signUpGUI.isVisible());
}
}

9
user.json

@ -16,5 +16,14 @@
"firstName": "", "firstName": "",
"surname": "", "surname": "",
"stayLoggedIn": false "stayLoggedIn": false
},
{
"id": "ccfcc294-48ad-49db-996f-d7c99a93bac9",
"userName": "testuser",
"password": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8",
"birthday": "2000-01-01",
"firstName": "John",
"surname": "Doe",
"stayLoggedIn": false
} }
] ]
Loading…
Cancel
Save