Skip to content

Unit Tests

Mert Cengiz edited this page Dec 20, 2024 · 1 revision

Login Page Tests

Test Case Result
Render the component correctly Passed
Handle username and password input Passed
Call login API and dispatch actions on successful login Passed
Show an error toast on failed login Passed

CreatePostModal Tests

Test Case Result
Renders the modal with all fields Passed
Allows users to fill out the form fields Passed
Displays the training programs in the dropdown Passed
Displays the tags in the dropdown Passed
Shows an error toast if no tags are selected Passed
Shows a success toast on successful post creation Passed
Resets fields and closes the modal when cancel is clicked Passed
Test Case Description Result Remarks
Create Post - Success Tests creating a new post with content and tags Passed Verified that the service correctly processes the request and returns the created post with expected fields
Fetch Posts - With Tags Tests retrieving posts filtered by specific tags Passed Successfully returns filtered posts when tags are provided in the request
Fetch Posts - Without Tags Tests retrieving all posts when no tags are specified Passed Correctly falls back to returning all posts when no filtering is requested
Delete Post - Success Tests successful deletion of a post by its ID Passed Confirms proper authorization and successful deletion with appropriate success message
Delete Post - Unauthorized Tests deletion attempt without proper authorization Passed Correctly returns forbidden status when user lacks permission to delete
Get Random Posts - Success Tests retrieving a specified number of random posts Passed Successfully returns the requested number of random posts from the available pool
Like Post - Success Tests the post liking functionality Passed Confirms that a post can be liked by an authorized user
Unlike Post - Success Tests the post unliking functionality Passed Verifies that a previously liked post can be unliked
Get Bookmarked Posts - Success Tests retrieving all posts bookmarked by the user Passed Successfully returns the list of posts that the user has bookmarked
Test Case Description Result Remarks
Join Program Join program with specific id correctly Passed Returned status code is 200
Leave Program Leave joined program with specific id correctly Passed Returned status code is 200
Delete Post Deleted previously created post with specific id Passed Returned status code is 200
Get Training Program Get the correct program inside the post Passed Returned program is not null
Search Query Search for a query correctly Passed Returned status code is 200
Render Search Bar Render the search bar component Passed Render the search bar component correctly
Render Search Results Render the search results page Passed Rendered the search results page correctly
Render Diet Card Component Render the diet card component Passed Rendered the diet card component correctly
Render Diet Detail Component Render the diet detail component Passed Rendered the diet detail component correctly
Rate Program Rate a program with specific id with rating between 0 and 5 correctly Passed Returned status code is 200
Follow User Follow user with a specific username correctly Passed Returned status code is 200
Unfollow User Unfollow already followed user with a specific username correctly Passed Returned status code is 200
Test Case Description Result Remarks
Join Program Join program with specific id correctly Passed Returned status code is 200
Leave Program Leave joined program with specific id correctly Passed Returned status code is 200
Delete Post Deleted previously created post with specific id Passed Returned status code is 200
Get Training Program Get the correct program inside the post Passed Returned program is not null
Search Query Search for a query correctly Passed Returned status code is 200
Render Search Bar Render the search bar component Passed Render the search bar component correctly
Render Search Results Render the search results page Passed Rendered the search results page correctly
Render Diet Card Component Render the diet card component Passed Rendered the diet card component correctly
Render Diet Detail Component Render the diet detail component Passed Rendered the diet detail component correctly
Rate Program Rate a program with specific id with rating between 0 and 5 correctly Passed Returned status code is 200
Follow User Follow user with a specific username correctly Passed Returned status code is 200
Unfollow User Unfollow already followed user with a specific username correctly Passed Returned status code is 200
User Test Case Description Result Remarks
Progress Graph for Each Target Muscle Issue#383 Passed
Test Active Program Reminder for Full Body Strength Program Issue#385 Passed
Test Case Description Result Remarks
Render Home Page Rendered the home page Passed The home page rendered correctly
Render Login Page Rendered the login page Passed Rendered the login page correctly
Render Register Page Rendered the register page Passed Rendered the register page correctly.
Render Search Page Rendered the search page Passed Rendered the search page correctly.
Render Post Creation Rendered the post creation page Passed Rendered the post creation page correctly
Render Progam Creation Rendered the program creation page Passed Rendered the program cration page correctly.
Render Create Feedback Page Rendered the feedback creation page Passed Rendered the feedback creation page correctly.
Render Survey Page Rendered the survey page Passed Rendered the survey page correctly.
Log In Attempted to login with a username and password Passed Returned 200, as expected for the response status.
Register Attempted to register with a username, password, valid role and email Passed Returned 201, as expected for the response status.
Get Exercises Attempted to fetch all exercises available Passed Didn't returned null, as expected to obtain some data.
Create Feedback Attempted to create a feedback with a program, body part, feedback text, week and exercise number Passed Returned 201, as expected for the status.
Make a Survey Attempted to make a survey with a valid level and goals Passed Returned 201, as expected for the status.
Submit Progress in a Joined Program Attempted to submit progress with a programId, exerciseId, newInputs and a token Passed Returned 200, as expected for the status.
Random Posts In Feed Attempted to fetch posts randomly Passed Didn't returned null, as expected to obtain some data.
Test Case Description Result Remarks
Search - Success Tested the /api/search endpoint with a query for fitness programs, returning posts, exercises, and training programs. Passed The endpoint returned arrays for posts, exercises, and training programs as expected.
Add Survey - Success Added a new survey with fitness goals and a fitness level using the /api/surveys endpoint. Passed Survey details (ID, username, fitness goals, and fitness level) were correctly returned in the response.
Get Survey By User - Success Retrieved the survey of the authenticated user from the /api/surveys/user endpoint. Passed The correct survey data was returned, matching the authenticated user's details.
Get User Fitness Goals - Success Retrieved the fitness goals of the authenticated user using the /api/surveys/fitness-goals endpoint. Passed The expected list of fitness goals was returned.
Add Fitness Goals - Success Added new fitness goals to the user's survey using the /api/surveys/fitness-goals endpoint. Passed The added fitness goals were returned correctly in the response.
Remove Fitness Goals - Success Removed specific fitness goals from the user's survey using the /api/surveys/fitness-goals endpoint. Passed The endpoint executed successfully, and the specified goals were removed.
Test Case Description Result Remarks
Register - Success Registered a user with a unique username and email. Passed User data was correctly saved, and a valid session token was returned.
Register - Username Exists Attempted to register with a username that already exists. Passed Registration failed with an "Username already exists" error message, as expected.
Login - Success Logged in with valid credentials. Passed Correct session token was generated and returned for the user.
Login - Invalid Credentials Logged in with incorrect credentials. Passed Login failed with an "Invalid credentials" error message, as expected.
Logout - Success Logged out a user by invalidating the session token. Passed User's session token was correctly invalidated in the database.
Get Authenticated User - Logged In Retrieved details of the currently authenticated user with a valid session token. Passed User details (username, email, and role) were correctly returned.
Get Authenticated User - Guest User Attempted to retrieve details when no session token was provided. Passed Returned null, indicating no authenticated user.
Get Authenticated User Internal - Valid Token Retrieved internal user details with a valid session token. Passed The correct user object was retrieved and matched the session token.
Get Authenticated User Internal - No Token Attempted to retrieve internal user details without a session token. Passed Returned null, as expected for unauthenticated users.

Exercise Service Unit Tests (Issue#378)

Test Case Description Result Remarks
Get All Exercises - Success Retrieved all exercises from the repository. Passed List of exercises was returned, and the repository method was called once.
Get Exercise - Valid ID Retrieved an exercise by a valid ID. Passed The exercise with the given ID was found and returned.
Get Exercise - Invalid ID Attempted to retrieve an exercise with an invalid ID. Passed An EntityNotFoundException was thrown with the appropriate message.
Get User Exercise Progress - Success Retrieved exercise progress for a user with valid data. Passed The progress response correctly displayed the exercise and progress data.
Get User Exercise Progress - Exercise Not Found Attempted to retrieve progress for an exercise that does not exist. Passed An EntityNotFoundException was thrown when the exercise was not found.
Get User Exercise Progress - No Tracking Data Retrieved exercise progress when no tracking data exists for the user. Passed The progress response returned an empty progress list as expected.
Cmpe 352 Archive
Clone this wiki locally