feat: Update SonarQube exclusions and add unit tests for main worker functions#38
Conversation
…functions - Modified `sonar-project.properties` to exclude test files with the pattern `**/*.test.ts` instead of `**/src/__tests__/**`. - Introduced a new test file `index.test.ts` containing unit tests for the `run` and `handleRunError` functions, ensuring proper error handling and logging. These changes improve the project's test coverage and ensure that SonarQube analysis focuses on relevant source files.
📝 Walkthrough## Walkthrough
The changes update SonarQube analysis exclusions in the configuration file, refine error logging in the main worker's error handler, and align related tests to the new logging approach. The error handler now uses a local logger with formatted messages instead of a generic logging utility and updates the test to match this behavior. Additionally, the Vitest test configuration was broadened to include all test files in the src directory.
## Changes
| File(s) | Change Summary |
|-------------------------------|----------------------------------------------------------------------------------------------------------------|
| sonar-project.properties | Modified SonarQube exclusions: removed __tests__ directory exclusion, added pattern for **/*.test.ts files, retained src/dist exclusion. |
| workers/main/src/index.ts | Replaced generic error logging with direct local logger; updated error parameter name and message formatting in handler; changed return type from never to void. |
| workers/main/src/index.test.ts | Added tests for handleRunError function; used logger.error spying to verify error message logging for different error types. |
| workers/main/vitest.config.ts | Broadened test file inclusion pattern from src/__tests__/**/*.test.ts to src/**/*.test.ts. |
## Suggested reviewers
- killev📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
🔍 Vulnerabilities of
|
| digest | sha256:1681f9cba84adf091ee89f7f95e5457630aece0d80a0b1e9fefa9c80e994c28a |
| vulnerabilities | |
| platform | linux/amd64 |
| size | 243 MB |
| packages | 1628 |
📦 Base Image node:20-alpine
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
Description
|
- Modified the `sonar-project.properties` file to remove the exclusion of `docker-compose.yml`, ensuring that only test files and distribution files are excluded from analysis. This change refines the SonarQube configuration to focus on relevant source files while maintaining coverage on necessary project components.
- Modified `vitest.config.ts` to include all test files in the `src` directory. - Refactored `index.test.ts` to improve error handling tests for the `handleRunError` function, ensuring proper logging for both string and Error object inputs. - Updated the `handleRunError` function in `index.ts` to remove the throw statement, aligning with the new logging behavior. These changes improve test coverage and ensure consistent error logging in the main worker functions.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
workers/main/vitest.config.ts (1)
10-10: Good change to support co-located test files.The expanded test inclusion pattern
src/**/*.test.tsis a good improvement that allows for more flexible test organization, including co-locating tests with source files. This aligns well with the updated SonarQube exclusions mentioned in the PR objectives.Consider reviewing the coverage exclusion on line 16 for consistency. Since tests are no longer required to be in
__tests__directories, the exclusionsrc/__tests__/**might be unnecessary:exclude: ['src/__tests__/**', 'src/dist/**'], + exclude: ['src/dist/**'],However, if you want to maintain backward compatibility for existing
__tests__directories, keeping the exclusion is also reasonable.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
workers/main/src/index.test.ts(1 hunks)workers/main/src/index.ts(2 hunks)workers/main/vitest.config.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- workers/main/src/index.ts
- workers/main/src/index.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Docker Security Scanning (n8n, Dockerfile.n8n, n8n-test:latest)
- GitHub Check: Service Availability Check
- Removed mocked dependencies for the `run` function in `index.test.ts` to streamline the test setup. - Retained focus on testing the `handleRunError` function, ensuring clarity and maintainability of the test file. These changes enhance the readability of the test suite and maintain focus on relevant functionality.
|



sonar-project.propertiesto exclude test files with the pattern**/*.test.tsinstead of**/src/__tests__/**.index.test.tscontaining unit tests for therunandhandleRunErrorfunctions, ensuring proper error handling and logging.These changes improve the project's test coverage and ensure that SonarQube analysis focuses on relevant source files.