Testing Strategy
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The testing strategy for LiveCanvas is designed to ensure the reliability and maintainability of a modular monolith architecture. It emphasizes testing in layers that align with core domain boundaries, focusing on business rules and contracts rather than mere implementation details. The strategy prioritizes technical correctness through a combination of automated unit tests, integration tests, and static type checking.
The scope of testing encompasses the backend Elixir application—including GraphQL APIs, Phoenix Channels, and business logic—as well as mobile runtime contracts. Verification is integrated into the development workflow, requiring immediate compilation checks after boundary changes to surface violations early.
Sources: ARCHITECTURE.md:89-94, ARCHITECTURE.md:162-167
Layered Testing Architecture
The project employs a multi-tiered approach to verification, ensuring that each component is validated at the appropriate level of abstraction.
Test Classification
The testing suite is organized into the following primary categories:
| Test Layer | Focus Area | Verification Method |
|---|---|---|
| Context Tests | Internal business rules for core contexts (Accounts, Social, etc.). | Pure input/output assertions for logic; effectful assertions for coordinators. |
| API Tests | GraphQL schema, resolvers, and authorization rules. | Integration tests against the primary client API. |
| Realtime Tests | Phoenix Channels and WebSocket communication. | Validation of chat, presence, and session state broadcasts. |
| Integration Tests | Critical end-to-end user flows. | Multi-component verification of durable and ephemeral state transitions. |
| Boundary Tests | Isolated Membrane/WebRTC modules. | Specialized verification for media orchestration logic. |
Sources: ARCHITECTURE.md:162-170, ARCHITECTURE.md:89-92
Verification Flow
The following diagram illustrates the lifecycle of a code change and the corresponding verification steps required to maintain system integrity.
The strategy requires developers to run mix compile immediately after changing boundary declarations to catch architectural violations before they proliferate.
Sources: AGENTS.md:11-11, ARCHITECTURE.md:92-93, AGENTS.md:32-32
Static Analysis and Type Safety
The project utilizes Elixir typespecs and custom static analysis tools to enforce data integrity and architectural constraints.
- Typespecs: Public functions must include typespecs. Developers are required to run
mix typecheckwhen modifying typed code. - Boundary Enforcement: The
boundarylibrary is used to enforce internal module boundaries (e.g.,LC.Accounts,LC.Infra). This prevents leakage between modules and ensures that only stable entrypoints are exported. - Fixture-Based Testing: The system uses specialized fixtures to test strict-mode failures, specifically for missing or incorrect typespecs.
Sources: AGENTS.md:11-11, ARCHITECTURE.md:66-72, test/support/fixtures/typespecs/manifest.txt:4-5
Realtime and Frontend Verification
Testing extends beyond the backend logic to include the communication layer and client-side runtime contracts.
Realtime State and Channels
Verification of realtime features focuses on:
- Authentication: Ensuring Channel joins are authorized per topic.
- Payload Accuracy: Validating that Presence payloads expose only minimum visible state.
- Connectivity: Clients are expected to handle reconnections and re-fetch authoritative state from Postgres after disconnects.
Sources: ARCHITECTURE.md:151-154, ARCHITECTURE.md:183-183
Mobile Runtime Contracts
The mobile application uses contract assertions to verify environment resolution and runtime bootstrapping. This ensures that the mobile client can correctly interface with the backend services under various states, such as a "forced logout" session or unavailable initial URLs.
Frontend Quality of Life Tools
During development, the frontend configuration includes features to assist in debugging and verification:
- Latency Simulation: The
liveSocketsupportsenableLatencySimfor testing UI behavior under poor network conditions. - Jump-to-Definition: Integrated
PLUG_EDITORsupport allows developers to click on UI elements to open the corresponding HEEx component or function definition. - Server Log Streaming: Backend logs can be streamed directly to the browser console for real-time diagnostics.
Sources: assets/js/app.js:41-43, assets/js/app.js:56-74
Summary
LiveCanvas prioritizes a "test-what-you-ship" philosophy, focusing on domain boundaries and client-facing contracts. By combining strict boundary enforcement through the boundary library, type checking with mix typecheck, and a layered testing suite that spans from pure logic to realtime channels, the strategy ensures that product features are delivered with high technical accuracy while maintaining the flexibility of the modular monolith.
Sources: ARCHITECTURE.md:89-94, AGENTS.md:11-11