Skip to content

Add unit test suite #4

Description

@Lucasmind

Priority: MEDIUM

Problem

The project has zero tests. This creates high regression risk when refactoring core pipeline logic like thinking tag detection, sentence splitting, and TTS queue ordering.

Suggested Approach

Add a Jest test suite with focus on the most critical paths:

Test Structure

frontend/
├── src/
└── tests/
    ├── unit/
    │   ├── Orchestrator.test.js    # Thinking detection, sentence splitting, state transitions
    │   ├── LLMClient.test.js       # SSE parsing, abort handling, error types
    │   ├── TTSManager.test.js      # Queue ordering, failure handling, PCM decoding
    │   ├── ConversationManager.test.js  # History trimming, emotion tag parsing
    │   ├── EmotionController.test.js    # Emotion mapping, decay timing
    │   └── STTManager.test.js      # VAD integration, transcription handling
    ├── integration/
    │   └── pipeline.test.js        # End-to-end pipeline with mocked services
    └── fixtures/
        └── mock-responses.js       # Mock SSE streams, TTS responses

Critical Test Cases

  1. Thinking tag detection<think> present, absent, malformed (<think without close)
  2. Sentence splitting — Standard punctuation, ellipsis, abbreviations, quotes, Unicode
  3. Emotion tag parsing — Known emotions, unknown emotions (should default to neutral), no tag
  4. TTS queue ordering — Sentences must play in order, queue clear during processing
  5. Retry logic — Verify exponential backoff timing, max retries respected
  6. State machine — No invalid transitions, barge-in interrupts correctly

Files Affected

  • frontend/package.json (add jest dependency + test script)
  • New test files as described above

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions