Rolegraph End-to-End Test Framework
This directory contains comprehensive end-to-end tests that validate search results in the UI exactly like the successful rolegraph and knowledge graph ranking tests, using real terraphim_server API without any mocking.
π― Test Objectives
The tests validate that:
- Search Results Appear in UI: Search results from the backend API are correctly displayed in the Svelte frontend
- Role-Based Configuration: The "Terraphim Engineer" role works correctly with local knowledge graph files
- API Integration: Real HTTP API calls to
localhost:8000return expected results - Search Terms Validation: All test search terms ("terraphim-graph", "graph embeddings", etc.) work correctly
- UI State Management: Search input, results display, and error handling work properly
ποΈ Architecture
Test Framework Components
- TerraphimServerManager: Manages the Rust backend server lifecycle
- Real API Integration: Direct HTTP calls to
terraphim_serverendpoints - UI Testing: Playwright tests for Svelte frontend components
- Configuration Management: Automatic setup of "Terraphim Engineer" role configuration
Test Data
The tests use the same search terms and expected results as the successful middleware tests:
const TEST_SEARCH_TERMS = [
'terraphim-graph',
'graph embeddings',
'graph',
'knowledge graph based embeddings',
'terraphim graph scorer'
];
const EXPECTED_RESULTS = {
'terraphim-graph': { minResults: 1, expectedRank: 34 },
'graph embeddings': { minResults: 1, expectedRank: 34 },
'graph': { minResults: 1, expectedRank: 34 },
'knowledge graph based embeddings': { minResults: 1, expectedRank: 34 },
'terraphim graph scorer': { minResults: 1, expectedRank: 34 }
};π Quick Start
Prerequisites
- Rust and Cargo installed
- Node.js and Yarn installed
- Knowledge graph files in
docs/src/kg/
Running Tests
Option 1: Automated Test Runner (Recommended)
# From the desktop directory
This script:
- Builds
terraphim_server - Sets up test configuration
- Installs dependencies
- Runs all tests with proper environment
Option 2: Manual Playwright Test
# From the desktop directory
Option 3: Individual Test
# Run specific test
π Test Suite
Core Tests
-
should display search input and logo on startup- Validates basic UI components are visible
- Checks search input and logo display
-
should perform search for terraphim-graph and display results in UI- Tests search functionality in the UI
- Validates results appear correctly
- Checks for expected content
-
should validate all test search terms against backend API- Tests all search terms against the API
- Validates response structure and content
- Compares results with expected outcomes
-
should perform search in UI and validate results match API- Compares UI results with API results
- Ensures consistency between frontend and backend
-
should handle role switching and validate search behavior- Tests role switching functionality
- Validates search behavior with different roles
-
should handle search suggestions and autocomplete- Tests autocomplete functionality
- Validates suggestion selection
-
should handle error scenarios gracefully- Tests error handling for edge cases
- Validates app stability
-
should validate search performance and responsiveness- Tests search performance
- Validates app responsiveness
βοΈ Configuration
Server Configuration
The tests use a "Terraphim Engineer" configuration that matches the successful middleware tests:
Environment Variables
RUST_LOG=debug: Enable debug logging for the serverCONFIG_PATH: Path to test configuration fileSERVER_PORT=8000: Port for terraphim_serverFRONTEND_URL=http://localhost:1420: URL for Svelte frontend
π Test Validation
API Validation
Tests validate that the API returns:
- Correct response structure (
status,results,total) - Minimum expected results for each search term
- Content containing search terms or related content
- Proper document structure (
title,body)
UI Validation
Tests validate that the UI:
- Displays search results correctly
- Shows expected content from API responses
- Handles empty results gracefully
- Maintains search input state
- Responds to user interactions
Performance Validation
Tests validate:
- Search completion within reasonable time (< 10 seconds)
- App responsiveness during searches
- Error handling without crashes
π Troubleshooting
Common Issues
-
Server fails to start
- Check if
terraphim_serverbuilds successfully - Verify knowledge graph files exist in
docs/src/kg/ - Check server logs for configuration errors
- Check if
-
Tests fail with timeout
- Increase timeout in Playwright config
- Check if server is responding on port 8000
- Verify frontend is accessible on port 1420
-
API calls fail
- Check server is running and healthy
- Verify configuration is correct
- Check network connectivity
-
UI elements not found
- Check if frontend is built and running
- Verify CSS selectors match actual UI
- Check for JavaScript errors in browser console
Debug Mode
Run tests with debug output:
# Enable debug logging
# Run with verbose output
Manual Verification
- Start server manually:
- Test API directly:
- Check frontend:
# Open http://localhost:1420π Expected Results
Successful Test Run
When all tests pass, you should see:
β
SUCCESS: All rolegraph end-to-end tests passed
π― Validation: Search results appear correctly in UI
π API Integration: Backend search working with Terraphim Engineer role
π§ Configuration: Local KG files properly integrated
π₯οΈ UI Testing: Frontend correctly displays search resultsAPI Results
Expected API responses for search terms:
terraphim-graph: 1+ results, rank 34graph embeddings: 1+ results, rank 34graph: 1+ results, rank 34knowledge graph based embeddings: 1+ results, rank 34terraphim graph scorer: 1+ results, rank 34
π Related Tests
- Middleware Tests:
crates/terraphim_middleware/tests/rolegraph_knowledge_graph_ranking_test.rs - MCP Server Tests:
crates/terraphim_mcp_server/tests/mcp_rolegraph_validation_test.rs - Config Tests:
crates/terraphim_config/tests/desktop_config_validation_test.rs
π Contributing
When adding new tests:
- Follow the existing test structure
- Use real API calls (no mocking)
- Validate both API and UI behavior
- Include proper error handling
- Add descriptive test names and comments
- Update this README with new test information