Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write Unit Tests for Projects Page #676

Closed
jeromehardaway opened this issue Jan 6, 2025 · 0 comments · Fixed by #682
Closed

Write Unit Tests for Projects Page #676

jeromehardaway opened this issue Jan 6, 2025 · 0 comments · Fixed by #682
Assignees

Comments

@jeromehardaway
Copy link
Contributor

Create unit tests for the Projects page, which pulls project data from the GitHub API. These tests should ensure that the page functions correctly, including fetching, displaying, and interacting with project data retrieved from GitHub.

Acceptance Criteria
1. Rendering Tests:
• Verify that the Projects page renders without errors.
• Check if key UI components (e.g., project cards, filters, search bar) are displayed correctly.
2. Functionality Tests:
• GitHub API Integration: Mock GitHub API calls to test various scenarios (e.g., successful fetch, empty response, API errors).
• Ensure project data is correctly fetched and displayed.
• Validate the filter feature by applying filters to mocked project data.
• Test the search functionality with different inputs and verify filtered results.
3. Edge Cases:
• Handle API rate-limiting or quota errors (e.g., ensure proper error messaging).
• Verify behavior when the GitHub API returns no projects.
• Test for special characters or edge cases in the search input.
4. Error Handling:
• Test for API error scenarios, including timeouts, 500 server errors, and invalid responses.
• Confirm that the page displays appropriate error messages and fallback UI.
5. Pagination (if applicable):
• Verify that pagination works when multiple pages of results are fetched from the GitHub API.
• Test the navigation between pages and ensure proper data rendering.
6. Accessibility Checks:
• Confirm the page meets accessibility standards (e.g., screen reader compatibility, keyboard navigation).
7. Code Coverage:
• Achieve at least 90% test coverage for the Projects page, including the GitHub API integration and UI components.

Technical Notes
• Use Jest and React Testing Library for unit testing.
• Mock GitHub API responses using a tool like msw (Mock Service Worker) to simulate API calls.
• Mock data should include various scenarios:
• Successful response with projects.
• Empty response.
• Error response (e.g., 403, 404, 500).
• Add environment variables or configuration for the GitHub API token to avoid hardcoding sensitive information in tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants