Testing Strategy
Relevant source files
The following files were used as context for generating this wiki page:
Rebase employs a multi-layered testing strategy to ensure the correctness of agent interactions, UI rendering, and project data integrity. The strategy spans unit testing for core logic, component testing for complex React interfaces, performance benchmarking for real-time markdown streaming, and compliance scanning for repository health.
Overview of Test Layers
The project categorizes tests by scope and execution environment. Unit tests validate standalone logic like skill ranking and prompt preparation. Component tests verify UI behavior using vitest and happy-dom. Browser-based performance tests ensure the application remains responsive during heavy streaming loads.
This diagram illustrates the hierarchical breakdown of the Rebase testing suite.
Sources: src/features/skills/model/skills.test.ts, src/features/sessions/ui/AgentTranscript.test.ts, tests/browser/markdown-performance.spec.ts, src/test/noMonoReferences.test.ts
Unit and Logic Testing
Unit tests focus on the project's data models and utility functions without requiring a full UI environment. These tests use vitest to verify business logic, such as how skills are ranked or how markdown is parsed into blocks.
Key Logic Test Areas
- Skill Management: Validates fuzzy matching of skill names, slash command tokenization, and prompt injection logic.
Sources: src/features/skills/model/skills.test.ts:47-65, src/features/skills/model/skills.test.ts:182-200 - Prompt Preparation: Ensures that native commands, file mentions, and notes are correctly applied to the user's input before sending it to an agent.
Sources: src/features/sessions/model/promptPreparation.test.ts:46-60 - Data Models: Checks the consistency of release notes, notes metadata, and diff navigation logic.
Sources: src/app/model/releaseNotes.test.ts, src/features/notes/notes.test.ts, src/features/source-control/model/unifiedDiffDocument.test.ts
| Test Suite | Purpose | Key File |
|---|---|---|
| Skills Logic | Ranks and tokenizes /commands | skills.test.ts |
| Notes Model | Manages note slugs and mentions | notes.test.ts |
| Prompt Prep | Warmed skills and file mentions | promptPreparation.test.ts |
| Release Notes | Parses changelog versions | releaseNotes.test.ts |
UI and Component Testing
Rebase uses vitest combined with happy-dom or react-dom/server to test React components. These tests focus on user interactions, conditional rendering, and complex visual states like the agent transcript.
Agent Transcript Testing
The transcript tests verify that various message blocks (user, tool, assistant, plan) render correctly. They simulate:
- Work Folding: Hiding long tool trails behind summary lines until the user expands them.
- Orchestration Results: Displaying proposed task assignments and subagent rows.
- Real-time Feedback: Timing turn clocks and showing "Working..." states.
Sources: src/features/sessions/ui/AgentTranscript.test.ts:31-60, src/features/sessions/ui/AgentTranscript.test.ts:150-180
Skill Selection and Preview
The SkillsPage tests simulate complex Tauri backend interactions by mocking invoke calls. They ensure that:
- Focus is managed correctly when panels open and close.
- Codex plugin skills are discoverable and previewable.
- Error alerts appear when file reads fail.
Sources: src/features/skills/ui/SkillsPage.test.ts:114-145, src/features/skills/ui/SkillsPage.test.ts:250-275
Performance Testing
Browser-based performance tests use Playwright and Chrome DevTools Protocol (CDP) to measure UI responsiveness during high-frequency events, specifically markdown streaming.
This sequence shows how the project benchmarks markdown rendering performance under simulated CPU constraints.
Sources: tests/browser/markdown-performance.spec.ts:10-40
Performance Metrics
Tests assert specific limits on frame timing to prevent UI "jank":
- p95 Frame Time: Must be less than 75ms under 4x CPU throttle in Chromium.
- Max Frame Time: Must not exceed 150ms in Chromium or 90ms in WebKit.
- Consistency: Verifies that large code blocks preserve blank lines and line numbering across light and dark themes.
Sources: tests/browser/markdown-performance.spec.ts:50-70, tests/browser/markdown-performance.spec.ts:100-125
Compliance and Security Scanning
Rebase includes "lint-like" integration tests that scan the entire working tree using git ls-files to enforce repository standards and prevent regression of branding or sensitive data.
Forbidden Reference Checks
A dedicated suite scans for legacy product names, forbidden upstream URLs, and accidentally embedded terms.
- Typography Guard: Uses regex to strip legitimate font keywords (e.g., "Roboto Mono") before checking for forbidden "mono" string references.
- Upstream Links: Ensures no references to forbidden GitHub repositories or legacy domain names exist in the native tree.
Sources: src/test/noMonoReferences.test.ts:20-50, src/test/upstreamLinks.test.ts:15-40
Visual Regression (CSS Logic)
Testing extends to CSS spacing logic, where the system renders markdown paragraphs and uses happy-dom to inspect the final computed margins. This ensures that consecutive paragraphs maintain the standard 1rem gap even when wrapped in isolation blocks.
Sources: src/features/sessions/ui/agentMarkdownSpacing.test.ts:90-115
Conclusion
The Rebase testing strategy balances speed and depth. Fast unit tests provide immediate feedback on model logic, while specialized UI and performance tests protect the user experience from regression. Compliance tests act as a final safety net for repository health and branding integrity.
Sources: src/test/noMonoReferences.test.ts, tests/browser/markdown-performance.spec.ts