[QA] Add Client Unit Tests and Enhance Workflow Summary Reporting#74
Merged
GravityDarkLab merged 10 commits intomainfrom Jul 13, 2025
Merged
Conversation
- Introduced Vitest configuration file to set up testing environment with JSDOM. - Added global mocks for fetch, console methods, and local/session storage. - Created mock API responses for user and course data to facilitate unit testing.
- Implemented comprehensive unit tests for the AI Chat Service, covering methods such as setAuthToken, getAIChatResponse, and confirmCourse. - Included tests for various command scenarios, error handling, and response formatting. - Utilized Vitest for mocking dependencies and simulating asynchronous behavior.
- Implemented comprehensive unit tests for the dashboard service, covering methods such as setAuthToken and getDashboardData. - Included tests for various scenarios including successful data retrieval, handling of empty course lists, and error management. - Utilized Vitest for mocking dependencies and ensuring accurate test coverage.
- Implemented comprehensive unit tests for the achievement service, covering functions such as calculateUserAchievements, getAchievementProgress, and getAllAchievementDefinitions. - Included tests for various scenarios including achievement calculations based on completed, enrolled, and bookmarked courses. - Utilized Vitest for mocking dependencies and ensuring accurate test coverage.
- Added steps to capture test results and output in the workflow summary. - Implemented conditional logic to check for test files and report their execution status. - Included sections for displaying build results and linting outcomes in the summary.
7 tasks
- Enhanced the workflow summary to include stripped ANSI codes from test output for clearer reporting.
- Updated the workflow to filter and display coverage summary specifically for src/services.
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds a full suite of frontend unit tests with supporting mocks and updates the CI workflow to capture and summarize test results, coverage, build output, and linting directly in GitHub Actions.
- Introduces Vitest configuration and global test setup (mocks for fetch, console, storage, timers)
- Adds comprehensive service-level unit tests under
client/src/services/__tests__ - Enhances the
build-and-test-clientGitHub Actions workflow to capture test output, code coverage, build size, and lint outcomes in the workflow summary
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| client/vitest.config.ts | Configures Vitest with jsdom, coverage reporting, and path aliasing |
| client/src/test/setup.ts | Sets up global mocks for fetch, console, localStorage, sessionStorage, and timers |
| client/src/test/mocks/api.ts | Provides mock API response objects for user, course, and error scenarios |
| client/src/services/tests/* (multiple files) | Adds unit tests for user.service, course.service, dashboard.service, aiChat.service, and achievement.service |
| client/package.json | Adds jsdom dependency for test environment |
| .github/workflows/build-and-test-client.yml | Captures test output, extracts stats/coverage, logs build status/size, and reports lint results in summary |
Files not reviewed (1)
- client/package-lock.json: Language not supported
Comments suppressed due to low confidence (2)
.github/workflows/build-and-test-client.yml:52
- Consider adding
continue-on-error: trueto the 'Run tests' step so test failures don't stop the workflow and the summary step underif: always()still runs as intended.
run: |
.github/workflows/build-and-test-client.yml:132
- The grep pattern includes leading spaces when filtering for
src/services. Coverage lines may not have those spaces—adjust the regex (e.g.,grep -E '^src/services') to reliably extract the coverage summary.
COVERAGE_INFO=$(awk '/Coverage report from v8/,0' test-clean.txt | grep -E '^All files|^ src/services|^ src/services' | head -n 20)
mahdibayouli
approved these changes
Jul 13, 2025
Collaborator
mahdibayouli
left a comment
There was a problem hiding this comment.
✅ Approved! Client-side unit tests and enhanced GitHub Actions summary reporting were added. Coverage reporting and failure summaries are handled properly in the workflow! Great work 🚀🚀
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
✅ What's Implemented
🧪 Client-Side Tests
test-output.txtfor further analysis.🔁 GitHub Actions Workflow Enhancements
Improved the
Post workflow summarystep in the CI workflow to:📊 Automated Summary in GitHub Actions Includes:
Test Results
Build Results
dist/folderCode Quality
🎯 Goal
To establish robust, verifiable testing for the frontend and provide enhanced visibility into test coverage, build integrity, and code quality directly in the GitHub Actions summary.