Skip to main content

RuVector Test Suite

Comprehensive test suite for the RuVector semantic search system.

Test Files

1. indexer.test.js

Tests for the project indexing module:

  • YAML parsing and project loading
  • Embedding generation
  • Index creation and export
  • Searchable text generation
  • Edge case handling
  • Performance benchmarks

Coverage Target: 90%

2. search-engine.test.js

Tests for the search engine module:

  • Index initialization and loading
  • Semantic search functionality
  • Result ranking and scoring
  • Filtering capabilities
  • Cache management
  • Error handling

Coverage Target: 90%

3. search-queries.test.js

Integration tests with realistic user queries:

  • Technology-based searches
  • Category-based searches
  • Feature-based searches
  • Semantic understanding
  • Multi-criteria queries
  • Query variations

Coverage Target: All user flows

4. performance.test.js

Performance benchmarks:

  • Indexing speed (30 projects < 5 seconds)
  • Search latency (< 500ms)
  • Throughput testing
  • Memory usage
  • Concurrent load handling
  • Resource limits

Performance Targets:

  • Index 30 projects: < 5 seconds
  • Search query: < 500ms
  • 100 sequential searches: < 10 seconds
  • Memory increase: < 50MB

Test Fixtures

fixtures/sample-projects.yml

Test data with 10+ sample projects covering:

  • Complete projects with all fields
  • Minimal projects (required fields only)
  • Edge cases (empty arrays, special characters, Unicode)
  • Long descriptions
  • Various categories and technologies

Running Tests

Run all RuVector tests

npm test -- tests/ruvector

Run specific test file

npm test -- tests/ruvector/indexer.test.js
npm test -- tests/ruvector/search-engine.test.js
npm test -- tests/ruvector/search-queries.test.js
npm test -- tests/ruvector/performance.test.js

Run with coverage

npm test -- tests/ruvector --coverage

Run performance tests only

npm test -- tests/ruvector/performance.test.js

Test Categories

Unit Tests

  • indexer.test.js: 60+ test cases
  • search-engine.test.js: 50+ test cases

Integration Tests

  • search-queries.test.js: 30+ realistic query scenarios

Performance Tests

  • performance.test.js: Benchmarks and stress tests

Test Philosophy

  1. Comprehensive Coverage: Test happy paths, edge cases, and error conditions
  2. Realistic Scenarios: Use actual project data and user queries
  3. Performance Focus: Ensure system meets speed and memory requirements
  4. Clear Assertions: Each test validates specific behavior
  5. Maintainability: Well-documented, easy to understand tests

Mock vs Real Implementation

Current tests use mock implementations for:

  • ProjectIndexer class
  • SearchEngine class

Once actual implementations are complete, replace mocks with:

import { ProjectIndexer } from '../../src/ruvector/indexing/project-indexer.js';
import { SearchEngine } from '../../assets/js/ruvector/search-engine.js';

Quality Metrics

Test Coverage

  • Statements: > 90%
  • Branches: > 85%
  • Functions: > 90%
  • Lines: > 90%

Performance

  • All performance tests passing
  • No memory leaks detected
  • Response times within thresholds

Search Quality

  • Relevant results for all test queries
  • Proper ranking by relevance score
  • No false positives in top 10 results

Next Steps

  1. Coder agent implements actual ProjectIndexer and SearchEngine classes
  2. Replace mock implementations in tests with real imports
  3. Run full test suite to validate implementation
  4. Adjust performance thresholds based on actual results
  5. Add additional test cases based on findings

Notes

  • Tests use Jest with ES module support
  • Some tests require global.gc() for memory testing
  • Performance tests have longer timeouts (10-20s)
  • Cache behavior is critical for performance—tested extensively

Dependencies

  • Jest (testing framework)
  • @jest/globals (ES module support)
  • Node.js 18+ (for file system operations)

Test Data

All test fixtures are in tests/fixtures/:

  • sample-projects.yml: 10+ test projects
  • Test data covers edge cases and realistic scenarios