Skip to content

test(desktop): establish proper test environment for desktop/src/ imports in CI #1464

@paradoxSCH

Description

@paradoxSCH

Problem

The root npm run verify includes desktop/src/**/*.test.* patterns in vitest.config.ts, but CI only runs npm ci in the root directory. Desktop is not in root workspaces (workspaces: ["packages/*"]), so desktop/node_modules is never created in CI.

This means any test that imports from desktop/src/ source files will fail because those files transitively depend on Desktop-only packages (lucide-react, @tauri-apps/api, react-markdown, rehype-katex, etc.) that don't exist in root node_modules.

The current workaround (PR #1443) uses vi.mock() for local module boundaries (./CommandPalette, ./Markdown, ./cards) and resolve.alias in vitest.config.ts for external deps. This works but is a testing infrastructure debt.

Why this matters

  • Mocking local modules is a test smell; tests should ideally load real source code
  • The alias + mock approach requires maintaining a growing list of Desktop-only dependencies in tests/mocks/
  • Every new test that imports from desktop/src/ risks hitting a new "missing module" failure in CI
  • desktop/package.json uses workspace:* for @reasonix/core-utils, which npm install in the Desktop directory cannot resolve (Desktop is not a workspace member)

Options

Option A: Extract pure-logic modules
Move reduce/applyIncoming from App.tsx to App.state.ts, and approval cards from thread.tsx to approval-cards.tsx, so tests import files with no Desktop-only transitive deps.

Option B: Install Desktop deps in CI
Update .github/workflows/ci.yml to also install Desktop dependencies. Requires handling workspace:* protocol (e.g., temporarily replacing with file: path or symlinking @reasonix/core-utils before npm install).

Option C: Remove Desktop tests from root runner
Give Desktop its own vitest.config.ts and test script, run separately in CI. Requires Desktop to have its own node_modules installed.

Recommendation

Option A (extract pure logic) is the cleanest long-term fix. The reduce function and State/Action types in App.tsx are already pure functions with no UI dependencies — they just happen to live in a file that imports Tauri APIs. Extracting them aligns with Redux/Flux patterns and eliminates the need for any mocks in reducer tests.

Option B is acceptable if we want to keep the current file structure, but it introduces CI complexity around workspace:* resolution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    v1Legacy TypeScript line (0.x) — v1 branch, maintenance only

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions