Add comprehensive unit tests for frontend authAPI methods #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add comprehensive unit tests for frontend authAPI methods
Summary
This PR adds comprehensive unit tests for the frontend authentication API methods (
authAPIobject) to improve test coverage for the client-side authentication layer. The implementation includes:src/backend/tests/test_auth_api.pywith 20 test casesregister,login, andgetProfilemethodsrun_tests.pyThe tests use mock axios instances to simulate HTTP requests/responses and validate that the frontend API client behaves correctly under various conditions including success cases and error handling.
Review & Testing Checklist for Human
src/backend/routes/auth.pyRecommended Test Plan: Run the frontend application and manually test registration, login, and profile retrieval in the browser to verify the actual authAPI functionality works correctly with the backend.
Diagram
%%{ init : { "theme" : "default" }}%% graph TD Frontend["src/frontend/src/utils/api.js<br/>authAPI object"]:::context AuthRoutes["src/backend/routes/auth.py<br/>Backend endpoints"]:::context TestRunner["src/backend/tests/run_tests.py<br/>Test discovery"]:::context NewTests["src/backend/tests/test_auth_api.py<br/>New auth API tests"]:::major-edit ExistingTests["src/backend/tests/test_jwt.py<br/>Existing JWT tests"]:::context NewTests -->|"tests mock calls to"| Frontend NewTests -->|"validates responses match"| AuthRoutes TestRunner -->|"discovers and runs"| NewTests TestRunner -->|"also runs"| ExistingTests Frontend -->|"makes HTTP calls to"| AuthRoutes subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes