-
Notifications
You must be signed in to change notification settings - Fork 1
Sprint2
HardCoder19 edited this page Mar 4, 2025
·
4 revisions
During Sprint 2, our backend team focused on enhancing authentication, implementing profile management, improving API documentation, and ensuring better test coverage. Our frontend team worked on integrating the backend with the frontend and implemented unit and Cypress tests.
- Implemented JWT-based authentication: Users receive a JWT token upon signup/login, which is required for accessing protected endpoints.
-
Profile Management APIs:
-
POST /profile: Creates a new user profile. -
GET /profile: Fetches user profile with authentication. -
PUT /profile: Allows updating user details securely.
-
- API Documentation: We integrated Swagger UI to document all backend endpoints for better usability.
- Unit Testing: Developed unit tests for authentication, profile management, and API responses.
-
Integration with Backend: The frontend now communicates with the backend over
localhost:8080. - Login Process Demonstration: The login form sends credentials to the backend, receives a JWT token, and stores it for authenticated API requests.
- Addition of "Find" page: now you can find and search for events the events going on around you.
-
Testing Implementation:
- Cypress Test: A basic test that verifies UI elements and API interactions.
- Unit Tests: Implemented unit tests with a 1:1 function-to-test ratio.
-
Cypress Test:
- A simple Cypress test that verifies the application pages functionality.
- Login Page Tests: should load the login page successfully, allow user to enter and click buttons, and navigate to different pages.
- Register Component Tests: should render the Register page correctly, allow to type, disable register if incomplete and show validation errors, and navigate to different pages.
- Profile Component Tests: should render the profile form correctly, allow user to select or deselect or enter text, open drop downs, and submit form.
- Main Page Unit Tests: should render the navigation bar correctly and navigate to different pages correctly.
- Forgot Password Page Unit Tests: should render the forgot password form correctly, allow user to enter and navigate.
-
Unit Tests: Implemented tests for React components and API calls. This one was done using both Jest and Cypress.
- Login Page Unit Tests
- should render the login form correctly
- should allow user to enter email and password
- should navigate to /home when login button is clicked
- should navigate to /register when 'Click here' is clicked
- should navigate to /forgotpass when 'forgot password' is clicked
- Profile Page Unit Tests
- should render the profile form correctly
- should allow user to enter profile details
- should allow user to select gender
- should open and close sports dropdown
- should allow user to select and deselect sports preferences
- should navigate to /home when form is submitted
- Register Page Unit Tests
- should render the register form correctly
- should allow user to enter email and validate input
- should allow user to enter password and validate input
- should validate confirm password field
- should navigate to /Profile when Register button is clicked
- Main Page Unit Tests
- should render the main page correctly
- should navigate to /Main when Home button is clicked
- should navigate to /Login when Log In button is clicked
- should navigate to /Register when Get Started button is clicked
- should navigate to /Register when GET STARTED button in the body is clicked
- Forgot Password Page Unit Tests
- should render the forgot password form correctly
- should allow user to enter email
- should show alert when reset password is clicked
- should navigate to /login when 'Cancel' is clicked
- Login Page Unit Tests
-
Authentication Tests:
- Ensured proper JWT generation and validation.
- Tested login/signup error handling.
-
Profile API Tests:
- Verified POST, GET, and PUT operations for profile management.
- Ensured unauthorized requests fail correctly.
We used Swagger UI to document all backend API endpoints. To access the Swagger UI and test all API calls, start the backend server using the air command and visit:
http://localhost:8080/v1/swagger/index.html#/
- Description: Registers a user and returns a JWT token.
-
Required Body:
{ "email": "user@example.com", "password": "securepassword" } -
Success Response (201):
{ "token": "JWT_TOKEN_HERE" } -
Error Responses:
-
400 Bad Request: Missing fields or invalid data. -
500 Internal Server Error: Server failure.
-
- Description: Logs in a user and returns a JWT token.
-
Required Body:
{ "email": "user@example.com", "password": "securepassword" } -
Success Response (200):
{ "token": "JWT_TOKEN_HERE" } -
Error Responses:
-
400 Bad Request: Missing fields or invalid format. -
401 Unauthorized: Invalid credentials. -
500 Internal Server Error: Server failure.
-
- Description: Creates a user profile.
-
Headers:
Authorization: Bearer JWT_TOKEN_HERE -
Required Body:
{ "email": "user@example.com", "first_name": "John", "last_name": "Doe", "age": 25, "gender": "Male", "sport_preference": ["Football", "Tennis"] } -
Success Response (201):
{ "data": { "email": "user@example.com", "first_name": "John", "last_name": "Doe", "age": 25, "gender": "Male", "sport_preference": ["Football", "Tennis"] } } -
Error Responses:
-
400 Bad Request: Missing fields or invalid data. -
401 Unauthorized: Invalid or missing token. -
409 Conflict: Profile already exists. -
500 Internal Server Error: Server failure.
-
- Description: Fetches the authenticated user's profile.
-
Headers:
Authorization: Bearer JWT_TOKEN_HERE -
Success Response (200):
{ "data": { "email": "user@example.com", "first_name": "John", "last_name": "Doe", "age": 25, "gender": "Male", "sport_preference": ["Football", "Tennis"] } } -
Error Responses:
-
401 Unauthorized: Invalid or missing token. -
500 Internal Server Error: Server failure.
-
- Description: Updates the authenticated user's profile.
-
Headers:
Authorization: Bearer JWT_TOKEN_HERE -
Required Body:
{ "first_name": "John", "last_name": "Doe", "age": 26, "gender": "Male", "sport_preference": ["Football", "Tennis"] } -
Success Response (200):
{ "data": { "email": "user@example.com", "first_name": "John", "last_name": "Doe", "age": 26, "gender": "Male", "sport_preference": ["Football", "Tennis"] } } -
Error Responses:
-
400 Bad Request: Missing fields or invalid data. -
401 Unauthorized: Invalid or missing token. -
500 Internal Server Error: Server failure.
-