Skip to content

test: add regression tests for recent bug fixes#229

Draft
mschuettlerTNG wants to merge 2 commits into
devfrom
cursor/regression-tests-recent-bugs-54c5
Draft

test: add regression tests for recent bug fixes#229
mschuettlerTNG wants to merge 2 commits into
devfrom
cursor/regression-tests-recent-bugs-54c5

Conversation

@mschuettlerTNG

@mschuettlerTNG mschuettlerTNG commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

Description:

Adds regression tests covering the most severe bugs and critical features from the last 10 commits, and fixes the pre-existing service.test.ts failure.

Related Issue:

N/A — proactive regression coverage for recent fixes + test infrastructure fix.

Changes Made:

  • Fixed vitest.config.ts: Removed the electron path alias that shadowed the electron npm package, causing vi.mock('electron', ...) to fail. No test files used this alias (all use relative imports).
  • Fixed service.test.ts (4 tests, was 1): Added proper mocks for electron, ../main.ts, and ../logging/logger.ts. Expanded with tests for getDevices() — parsing xpu-smi output, sorting by architecture priority, and UUID-to-chipId extraction.
  • New deviceDetection.test.ts (12 tests): Covers cudaVisibleDevicesEnv (introduced for NVIDIA GPU support — ensures wildcard/undefined returns empty env, specific IDs are passed through), levelZeroDeviceSelectorEnv, vulkanDeviceSelectorEnv, and openVinoDeviceSelectorEnv.
  • Updated hardwareDiscovery.test.ts (22 tests, was 8): Added tests for parseNvidiaSmiListOutput (NVIDIA GPU detection parsing — single/multiple GPUs, lines without UUID, garbage output handling) and enrichWithPowerShellIds (PowerShell fallback enrichment — case-insensitive matching, preserving existing IDs, handling empty inputs). Fixed mocking to properly handle transitive dependencies.
  • New 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.
  • Exported parseNvidiaSmiListOutput and enrichWithPowerShellIds from hardwareDiscovery.ts to enable unit testing.
  • Updated AGENTS.md: Removed the now-fixed known issue about service.test.ts.

Testing Done:

  • All 78 tests pass across 8 test files — zero failures (previously 1 known failure).
  • ESLint passes with zero errors.
  • Prettier passes with zero formatting issues.

Screenshots:

N/A — test-only changes.

Checklist:

  • I have tested the changes locally.
  • I have self-reviewed the code changes.
  • I have updated the documentation, if necessary.
Open in Web Open in Cursor 

- 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>
@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a3330368-a318-40be-bcdb-79d610fa99a2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/regression-tests-recent-bugs-54c5

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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>
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 this pull request may close these issues.

2 participants