This integration test validates the complete execution of graph-based workflows through the entire stack: Backend API → Temporal Server → Temporal Worker → Activities → Database.
The test performs the following steps:
- Pre-flight Checks: Verifies that all required services are running
- Setup: Creates a workflow configuration and uploads a test document
- Execution: Monitors the workflow execution through Temporal
- Validation: Observes workflow progress and completion status
- Cleanup: Removes test data
All of the following services must be running:
-
PostgreSQL (Backend Database)
docker compose --profile infra up -d
-
Temporal Server & PostgreSQL (Temporal Database)
docker compose --profile temporal up -d
-
Temporal Worker
cd apps/temporal npm run dev -
Backend Services
cd apps/backend-services npm run start:dev
The test uses the following environment variables (with defaults):
BACKEND_URL(default:http://localhost:3002)TEMPORAL_ADDRESS(default:localhost:7233)TEMPORAL_NAMESPACE(default:default)TEST_API_KEY(required for authentication)TEST_TIMEOUT(default:300000ms / 5 minutes)WORKFLOW_SLUG(default:standard-ocr) — seeded workflow lineage slug in the databaseWORKFLOW_VERSION(optional) — pin a specificversion_number; default is head versionTEST_FILE(default:test-document.jpg)
These are typically already configured in your .env file.
The helper script checks if services are running and provides guidance:
cd apps/backend-services
./integration-tests/run-workflow-test.shcd apps/backend-services
npm run test:int:workflowcd apps/backend-services
ts-node -r tsconfig-paths/register integration-tests/test-graph-workflow.tsThe harness resolves a seeded workflow by WORKFLOW_SLUG (not by loading JSON from disk). Re-seed after template changes:
cd apps/backend-services && npx tsx ../shared/prisma/seed.ts# Test standard OCR workflow (default slug: standard-ocr)
npm run test:int:workflow
# Test multi-page report workflow
WORKFLOW_SLUG=multi-page-report npm run test:int:workflow
# Test with a different file
TEST_FILE=my-test-file.pdf WORKFLOW_SLUG=multi-page-report npm run test:int:workflow1. Pre-flight Checks
├─ Check Temporal Server connectivity (port 7233)
└─ Check Backend API health endpoint
2. Test Setup
├─ Resolve workflow version by WORKFLOW_SLUG (seeded workflow_versions row)
├─ Load test file (from integration-tests/{TEST_FILE})
└─ Upload document via /api/upload (workflow_config_id → versionId-only Temporal start)
3. Workflow Execution
├─ Initialize Temporal client
├─ Monitor workflow execution
├─ Query workflow progress every 2 seconds
├─ Log activity completions
└─ Wait for completion or failure
4. Cleanup
├─ Close Temporal connection
├─ Delete test document
└─ Delete test workflow configuration
When running successfully, you'll see output like:
================================================================================
🔍 Integration Test: Graph Workflow Execution
================================================================================
================================================================================
Pre-flight Checks
================================================================================
ℹ [timestamp] Checking Temporal Server connectivity...
✓ [timestamp] Temporal Server connected at localhost:7233
ℹ [timestamp] Checking Backend API health...
✓ [timestamp] Backend API healthy at http://localhost:3001
✓ [timestamp] All pre-flight checks passed
================================================================================
Test Setup
================================================================================
ℹ [timestamp] Loading workflow configuration from template...
✓ [timestamp] Loaded workflow config: Standard OCR Workflow
ℹ [timestamp] Loading test document...
✓ [timestamp] Test file loaded: 1136.79 KB
ℹ [timestamp] Creating workflow configuration in database...
✓ [timestamp] Workflow config created with ID: wf-xxx-xxx
ℹ [timestamp] Uploading test document...
✓ [timestamp] Document uploaded with ID: doc-xxx-xxx
ℹ [timestamp] Workflow execution ID: graph-doc-xxx-xxx
================================================================================
Workflow Execution
================================================================================
ℹ [timestamp] Monitoring workflow: graph-doc-xxx-xxx
ℹ [timestamp] Waiting for workflow to start...
ℹ [timestamp] ⏳ Step: updateStatus (running)
✓ [timestamp] ✓ Step completed: updateStatus
ℹ [timestamp] ⏳ Step: prepareFileData (running)
...
- Ensure Temporal Server is running:
docker compose --profile temporal ps(from repo root) - Check if port 7233 is accessible:
curl -v localhost:7233
- Ensure backend is running:
cd apps/backend-services && npm run start:dev - Check health endpoint:
curl http://localhost:3001/health
- Re-seed:
npx tsx ../shared/prisma/seed.tsfromapps/backend-services - List slugs in DB or check seed:
standard-ocr,multi-page-report - Canonical JSON templates:
docs-md/graph-workflows/templates/standard-ocr-workflow.json
- Verify the test file exists:
ls apps/backend-services/integration-tests/test-document.jpg
- Workflow slugs (seed):
standard-ocr(default) — templatedocs-md/graph-workflows/templates/standard-ocr-workflow.jsonmulti-page-report— templatedocs-md/graph-workflows/templates/multi-page-report-workflow.json
- Test Documents:
apps/backend-services/integration-tests/test-document.jpg(default)- You can add your own test files and reference them via
TEST_FILEenv var
The test automatically cleans up:
- Test document from database
- Test workflow configuration
- Temporal connections
If the test crashes, you may need to manually clean up:
# Connect to database and remove test documents
psql -d ai_doc_intelligence -c "DELETE FROM documents WHERE metadata->>'test' = 'true';"The test currently fails at the azureOcr.submit activity with:
TypeError: Cannot read properties of undefined (reading 'fileName')
This is the expected behavior for debugging purposes. The test is designed to help identify and fix data mapping issues between workflow activities.