Testing the UI and server side functionality of new user account creation in an imitation social blogging site (a Medium.com clone called Conduit) using Cypress.
Links:
Components Tested:
- New user account creation via the HTML sign up form
- New user account creation via the API
Sign up form conditions:
- All fields are required in order to submit the form
- Username and email must be unique (not be associated with any existing accounts)
Happy Path: Valid new user account creation
UI Tests: An e2e approach using the HTML sign up form
Pre-testing steps
- Generate unique user data and write to fixture file
- Navigate to the sign up page
Test Steps
- Type the username
- Type the email address
- Type the password
- Click Sign up button
Expected Results
- Redirected to home page as the logged in user
API Tests:
Pre-testing steps
- Generate new user data and write to fixture file
Test Steps
- Send a POST request to the
/users
endpoint containing username, email, and password in the body
Expected Results
- Response containing success status code of
200
- Note: Discrepancy noted in the documentation showing success status code of
201
. Issue filed here - Response body matches data in the request body
Sad Path: Attempt invalid new user account creation
UI Tests: Attempt to submit the form with missing fields and non-unique username and email
Pre-testing steps
- Register test username and email if not already registered
- Navigate to the sign up page
Test Steps
- Type the username of existing account
- Type the email address of existing account
- Type the password of the existing account
- Click Sign up button
Expected Results
- Submit button remains disabled until all fields are entered
- Attempt to submit leads to error messages
- "email has already been taken"
- "username has already been taken"
- Registration is unsuccessful
API Tests:
Pre-testing steps
- Register test username and email if not already registered
Test Steps
- Send a POST request to the
/users
endpoint containing the existing user's username, email, and password in the body
Expected Results
- Registration fails
- Response containing error status code of
422
- Response error messages indicate missing fields or username/password taken