Testing Strategy (Vitest & Playwright)
Relevant source files
The following files were used as context for generating this wiki page:
- package.json
- CLAUDE.md
- tests/e2e/api.test.ts
- tests/e2e/chat.test.ts
- lib/ai/prompts.test.ts
- lib/db/schema.test.ts
- lib/db/lv-queries.test.ts
- app/(chat)/lv/import-actions.test.ts/lv/import-actions.test.ts)
- app/(chat)/lv/preisspiegel-actions.test.ts/lv/preisspiegel-actions.test.ts)
- lib/compliance/daech.test.ts
The LV.AI testing strategy ensures the reliability of AI-driven construction management tools. It combines Vitest for fast unit and integration testing with Playwright for comprehensive end-to-end (E2E) validation of the user interface and API workflows.
This strategy enforces GAEB-conformity, D/A/CH region compliance (VOB/ÖNORM/SIA), and data integrity across chat-based project interactions.
Sources: CLAUDE.md:19-27, package.json:20-22
Testing Architecture
The project employs a tiered testing approach:
- Unit Tests (Vitest): Validate individual functions, AI prompts, and database schemas.
- Integration Tests (Vitest): Verify Server Actions and database queries using mocks for external dependencies.
- End-to-End Tests (Playwright): Simulate real user sessions, verifying the chat interface, file uploads, and API responses.
Test Execution Commands
| Command | Purpose |
|---|---|
pnpm test | Runs all Vitest unit and integration tests. |
pnpm test:watch | Starts Vitest in interactive watch mode. |
pnpm test:e2e | Executes Playwright E2E tests in a simulated browser environment. |
Sources: package.json:20-22
Unit and Integration Testing (Vitest)
Vitest handles logic-heavy components like prompt construction, database schema integrity, and regional compliance modules.
Prompt and AI Logic
Tests verify that AI prompts correctly include identity markers, GAEB formats (X81-X86), and D/A/CH legal frameworks.
regularPromptmust contain "LV.AI", "AVA", and regional references like "VOB/A" or "SIA 118".systemPrompttests ensure dynamic injection of location hints and tool support.
Sources: lib/ai/prompts.test.ts:10-50, lib/ai/prompts.test.ts:77-100
Database and Query Testing
The system validates the Drizzle ORM schema and complex SQL queries.
- Schema Validation: Ensures all Enums (e.g.,
landEnum,gaebFormatEnum) and tables (e.g.,lvDocument,offer) are correctly defined. - Query Mocking: Integration tests for
lv-queries.tsusevi.hoistedto mock database responses, allowing verification of CRUD operations without a live database connection.
Sources: lib/db/schema.test.ts:32-60, lib/db/lv-queries.test.ts:9-40
Server Actions
Integration tests for actions like importLvFileAction and generatePreisspiegelAction mock authentication and external API calls.
- Import Logic: Validates normalization of GAEB Position numbers (OZ) and handling of session-less requests.
- Preisspiegel Logic: Verifies that at least two valid offers are required to generate a comparison.
Sources: app/(chat)/lv/import-actions.test.ts:60-80, app/(chat)/lv/preisspiegel-actions.test.ts:80-100
The diagram shows the organization of Vitest tests and their reliance on mocking for external dependencies.
End-to-End Testing (Playwright)
Playwright tests the application from the user's perspective, focusing on the Chat interface and API stability.
Chat Interface Workflow
Tests in tests/e2e/chat.test.ts verify:
- Initial visibility of the
multimodal-inputandsend-button. - Support for multiline text input.
- Functionality of the "Stop" button during AI generation.
- Behavior of suggested actions on empty chat states.
Sources: tests/e2e/chat.test.ts:3-40
API and Navigation
Tests in tests/e2e/api.test.ts simulate API interactions:
- Message Flow: Sending a message, verifying the "assistant" role appears, and checking for content.
- Dynamic Routing: Confirming that the URL redirects to a specific
/chat/:idafter the first message. - Error Handling: Intercepting API calls to return a 500 status and verifying the UI displays an error toast.
Sources: tests/e2e/api.test.ts:6-60
The sequence diagram illustrates the standard Playwright test flow for a successful chat interaction.
Specialized AVA Validation
The project includes specific testing procedures for construction-specific logic (AVA). These are outlined as "LV.AI-Prüfverfahren" (Validation Procedures).
- GAEB Conformity: Every change to import/export logic requires X81–X86 schema validation.
- Regional Compliance: Logic in
daech.test.tsensures that requesting "DE" returns "VOB", "AT" returns "ÖNORM", and "CH" returns "SIA". - Data Integrity: Changes to offer comparison queries require testing against realistic multi-bidder datasets to prevent calculation errors in the
Preisspiegel.
Sources: CLAUDE.md:83-95, lib/compliance/daech.test.ts:13-35
Compliance Mappings
| Region | Standard (Vergabe) | Vertrag |
|---|---|---|
| DE | VOB/A | VOB/B |
| AT | ÖNORM B2110 | ÖNORM B2111 |
| CH | SIA 118 | SIA 102 |
Sources: CLAUDE.md:73-80, lib/compliance/daech.test.ts:38-55
Summary
The LV.AI testing strategy provides a robust safety net for complex construction procurement workflows. Vitest ensures that the underlying legal and AI prompt logic remains correct across regional variations, while Playwright guarantees a seamless user experience for construction professionals. The enforcement of mandatory GAEB and D/A/CH compliance checks during the testing phase maintains the high technical standards required for construction industry software.