Pull Request: Add Cypress End-to-End Tests for Mighty Pong
Description
This PR introduces several Cypress end-to-end tests for the Mighty Pong web application. The tests cover basic navigation, user registration, form validation, tournament navigation, and error handling. This PR is not definitive, but to introduce the tests to the project. More test to be added according to your suggestions and needs: @pixelsnow @linhtng @wengcychan @djames9
Tests Added:
1. Basic Navigation and Content Tests
These tests ensure that the main pages of the website are accessible and contain the expected content.
- should visit the 'homepage' and contain 'about'
- should visit the 'about' page and contain 'about BeePong'
- should visit the 'api' and contain '{"test": "This is a test JSON"}'
- should visit the 'game' page and contain 'game'
- should visit the 'home' page and contain text about Hive Helsinki students
- should visit the 'health' page and contain '{"status": "healthy"}'
- should visit the 'navbar' and contain 'about'
2. User Registration, Login, Logout, and Duplicate Registration Tests
These tests cover user authentication and validation, ensuring proper registration, login, and error handling during duplicate registration attempts.
- should register twice with the same username, second time should display an error
- should log in successfully
- should log out properly
3. Form Validation Tests
These tests validate form submission behavior and ensure appropriate error messages are displayed for invalid inputs.
- should display an error for empty login fields
- should display an error for invalid username format
- should display an error for password mismatch during registration
4. Accounts Navigation and Form Tests
These tests confirm that the key pages in the accounts section work correctly, including registration, login, and logout.
- should visit the 'register' page and display the registration form
- should visit the 'login' page and display the login form
- should visit the 'logout' page and redirect to home or login page
5. Tournament Navigation and Interaction Tests
These tests ensure that users can navigate the tournament section, create tournaments, and join them.
- should visit the 'tournament' page and display the tournaments
- should visit the 'create tournament' page and display the form
- should visit a tournament page first unlogged, then logged in, and create a tournament
- should navigate to the tournament page, create a tournament, and join it
6. Error Handling Tests
These tests check that the application properly handles non-existent routes and displays appropriate error messages.
- should display 404 page for non-existent routes
Screenshots
During development screenshots have been enabled to capture various stages of each test and can be used to help debug.
Notes:
Future tests for OAuth token and error handling have been commented out and can be revisited later.
Tests related to aliasing input fields (e.g., username) for tournament creation are temporarily commented out pending further debugging.
To-do:
User Cleanup: Consider implementing a cleanup task to remove test users after each test run.
How to Run Tests:
Tests are automatically executed during the docker-compose up process. To manually run tests, use the following command:
I will keep this branch updated with the main, but with ngnix port 443 instead of 8443. Consequently, the pull request will wait until you all have finished working on the school's computers requiring 8443.
Pull Request: Add Cypress End-to-End Tests for Mighty Pong
Description
This PR introduces several Cypress end-to-end tests for the Mighty Pong web application. The tests cover basic navigation, user registration, form validation, tournament navigation, and error handling. This PR is not definitive, but to introduce the tests to the project. More test to be added according to your suggestions and needs: @pixelsnow @linhtng @wengcychan @djames9
Tests Added:
1. Basic Navigation and Content Tests
These tests ensure that the main pages of the website are accessible and contain the expected content.
- should visit the 'homepage' and contain 'about'
- should visit the 'about' page and contain 'about BeePong'
- should visit the 'api' and contain '{"test": "This is a test JSON"}'
- should visit the 'game' page and contain 'game'
- should visit the 'home' page and contain text about Hive Helsinki students
- should visit the 'health' page and contain '{"status": "healthy"}'
- should visit the 'navbar' and contain 'about'
2. User Registration, Login, Logout, and Duplicate Registration Tests
These tests cover user authentication and validation, ensuring proper registration, login, and error handling during duplicate registration attempts.
- should register twice with the same username, second time should display an error
- should log in successfully
- should log out properly
3. Form Validation Tests
These tests validate form submission behavior and ensure appropriate error messages are displayed for invalid inputs.
- should display an error for empty login fields
- should display an error for invalid username format
- should display an error for password mismatch during registration
4. Accounts Navigation and Form Tests
These tests confirm that the key pages in the accounts section work correctly, including registration, login, and logout.
- should visit the 'register' page and display the registration form
- should visit the 'login' page and display the login form
- should visit the 'logout' page and redirect to home or login page
5. Tournament Navigation and Interaction Tests
These tests ensure that users can navigate the tournament section, create tournaments, and join them.
- should visit the 'tournament' page and display the tournaments
- should visit the 'create tournament' page and display the form
- should visit a tournament page first unlogged, then logged in, and create a tournament
- should navigate to the tournament page, create a tournament, and join it
6. Error Handling Tests
These tests check that the application properly handles non-existent routes and displays appropriate error messages.
- should display 404 page for non-existent routes
Screenshots
During development screenshots have been enabled to capture various stages of each test and can be used to help debug.
Notes:
To-do:
User Cleanup: Consider implementing a cleanup task to remove test users after each test run.
How to Run Tests:
Tests are automatically executed during the
docker-compose up
process. To manually run tests, use the following command:See the
make test
section: