test: add regression tests for recent bug fixes#229
Draft
mschuettlerTNG wants to merge 2 commits into
Draft
Conversation
- deviceDetection: tests for cudaVisibleDevicesEnv (new NVIDIA GPU support), levelZeroDeviceSelectorEnv, vulkanDeviceSelectorEnv, openVinoDeviceSelectorEnv - hardwareDiscovery: tests for parseNvidiaSmiListOutput (NVIDIA GPU detection), enrichWithPowerShellIds (GPU ID fallback enrichment); fix pre-existing test failure by mocking transitive electron dependencies - mcpServers: tests for CRUD operations (load, add, get, update, remove) covering error handling, persistence, and edge cases Export parseNvidiaSmiListOutput and enrichWithPowerShellIds from hardwareDiscovery.ts to enable unit testing. Co-authored-by: Markus Schüttler <mschuettlerTNG@users.noreply.github.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Root cause: the `electron` path alias in vitest.config.ts mapped bare
`electron` imports to the local ./electron/ directory, which has no
index file. This shadowed both vi.mock('electron', ...) and the real
electron npm package, causing all test files that import modules with
`import { app } from 'electron'` to fail at import time.
Fix:
- Remove the unused `electron` alias from vitest.config.ts (no test
files use it — all use relative imports)
- Add proper mocks for electron, ../main.ts, and ../logging/logger.ts
in service.test.ts
- Expand service.test.ts with tests for getDevices() (parsing,
sorting by arch priority, UUID-to-chipId extraction)
- Update AGENTS.md to remove the now-fixed known issue
Co-authored-by: Markus Schüttler <mschuettlerTNG@users.noreply.github.com>
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.
Description:
Adds regression tests covering the most severe bugs and critical features from the last 10 commits, and fixes the pre-existing
service.test.tsfailure.Related Issue:
N/A — proactive regression coverage for recent fixes + test infrastructure fix.
Changes Made:
vitest.config.ts: Removed theelectronpath alias that shadowed theelectronnpm package, causingvi.mock('electron', ...)to fail. No test files used this alias (all use relative imports).service.test.ts(4 tests, was 1): Added proper mocks forelectron,../main.ts, and../logging/logger.ts. Expanded with tests forgetDevices()— parsing xpu-smi output, sorting by architecture priority, and UUID-to-chipId extraction.deviceDetection.test.ts(12 tests): CoverscudaVisibleDevicesEnv(introduced for NVIDIA GPU support — ensures wildcard/undefined returns empty env, specific IDs are passed through),levelZeroDeviceSelectorEnv,vulkanDeviceSelectorEnv, andopenVinoDeviceSelectorEnv.hardwareDiscovery.test.ts(22 tests, was 8): Added tests forparseNvidiaSmiListOutput(NVIDIA GPU detection parsing — single/multiple GPUs, lines without UUID, garbage output handling) andenrichWithPowerShellIds(PowerShell fallback enrichment — case-insensitive matching, preserving existing IDs, handling empty inputs). Fixed mocking to properly handle transitive dependencies.mcpServers.test.ts(17 tests): Full CRUD coverage for the MCP server config system — load, add, get, update, remove operations including error cases (missing files, malformed JSON, duplicate/missing server IDs), file creation on first add, and preservation of existing servers.parseNvidiaSmiListOutputandenrichWithPowerShellIdsfromhardwareDiscovery.tsto enable unit testing.AGENTS.md: Removed the now-fixed known issue aboutservice.test.ts.Testing Done:
Screenshots:
N/A — test-only changes.
Checklist: