Skip to content

test: increase unit test coverage across untested core server and frontend modules #515

Open

Description

@amankv1234

Summary

While the test suite currently passes all existing tests, several critical core modules in both the server engine and frontend hooks have zero or minimal unit test coverage.

Adding unit tests for these modules will prevent regressions, improve CI reliability, and ensure overall codebase stability.


Coverage Gaps Identified

  1. src/server/drivers/keyMap.ts (0% coverage)
    • Cross-platform key code translation dictionaries (VK_MAP, EXTENDED_KEY_VKS, VK_TO_SCANCODE, X11_KEYSYM_MAP, MAC_KEY_MAP).
  2. src/utils/configHelper.ts (0% coverage)
    • Configuration priority resolution (REIN_DATA_DIR → XDG_CONFIG_HOME → ~/.config/rein), upload directory fallback logic, and atomic server-config saving.
  3. src/server/InputHandler.ts (Partial coverage - only pinch-zoom is tested)
    • High-frequency event throttling (8ms window for move/scroll), coordinate sanitization, input payload validation, and button type constraints.
  4. src/hooks/useTrackpadGesture.ts (0% coverage)
    • Touch tracking state management, multi-touch threshold detection (single/two/three-finger taps), and two-finger scroll calculations.

Proposed Implementation Plan (Small & Focused PRs)

In accordance with AGENTS.md guidelines ("Keep pull requests tightly focused on a single feature or fix"), I plan to break the implementation down into small, modular PRs to keep each review lightweight and easy to merge:

  • PR 1: Unit tests for keyMap.ts (tests/server/keyMap.test.ts)
    • Test Windows VK codes, extended key set membership, scancode mappings, and Linux/macOS keysym dictionaries.
  • PR 2: Unit tests for configHelper.ts (tests/utils/configHelper.test.ts)
    • Test directory fallbacks, environment variable precedence, and atomic write operations.
  • PR 3: Unit tests for InputHandler.ts (tests/server/inputHandler.test.ts)
    • Test 8ms move/scroll throttling with fake timers, input sanitization boundaries, and valid mouse button routing.
  • PR 4: Unit tests for useTrackpadGesture.ts (tests/hooks/useTrackpadGesture.test.ts)
    • Test touch gesture handling, tap classification (left/right/middle click), and scroll delta generation via @testing-library/react.

Expected Benefits

  • Guarantees cross-platform key mapping and input stability.
  • Prevents configuration and directory path regressions across different OS environments.
  • Increases test suite coverage without impacting runtime performance.

Activity

  1. github-actions commented on Nov 22, 2026

    @github-actions

    Discussions are carried on Discord.

    Instead of commenting here, go to the Discord channel.

    macOS and macOS-related issues are not supported at the moment. We are looking for funding to support macOS and would appreciate sponsorships.

    If you find this project useful, a GitHub star would be appreciated.

  2. amankv1234 commented on Nov 22, 2026

    @amankv1234
    ContributorAuthor

    @PinJinx , please assign it to me avoid the duplicate effort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions