tests — workflows

Module: tests-workflows Cohesion: 0.80 Members: 0

tests — workflows

This documentation describes the workflow testing module, located at tests/workflows. This module is crucial for validating the core workflow orchestration capabilities of the system, primarily focusing on the PipelineCompositor class from src/workflows/pipeline.ts. It ensures that pipelines can be defined, parsed, executed, and managed correctly, including complex features like approval gates and custom transforms.

Module Purpose

The tests/workflows module serves as the primary test suite for the PipelineCompositor and related workflow components. Its main goals are to:

Core Component: PipelineCompositor

The PipelineCompositor is the central class under test. It is responsible for:

PipelineCompositor Interactions

The following diagram illustrates the primary interactions of the PipelineCompositor with other components and concepts:

graph TD
    A[PipelineCompositor] -->|orchestrates| B(PipelineStep);
    B -- type: tool --> C[ToolExecutor];
    B -- type: transform --> D[Registered Transforms];
    B -- type: approval --> E[Approval Handler / approveStep()];
    A -- emits events --> F[Events];
    A -- manages --> G[Approval History];

Key Functionalities Tested

The tests cover various aspects of the PipelineCompositor's behavior.

1. Pipeline Execution Flow

The agent-pipeline.test.ts and pipeline-integration.test.ts files extensively test the sequential execution of pipeline steps.

2. Pipeline Definition and Parsing

The PipelineCompositor.parse() method is critical for converting human-readable pipeline strings into executable structures.

3. Tool Execution Integration

The PipelineCompositor relies on an external ToolExecutor to perform actions defined as tool steps.

4. Transform Management

Transforms are built-in text manipulation functions that can be applied as pipeline steps.

5. Approval Gates

The pipeline-approval.test.ts module provides comprehensive testing for approval type steps, which introduce human or automated decision points into a pipeline.

Testing Strategy

The tests utilize vitest for its testing framework, including describe, it, expect, beforeEach, and afterEach hooks. vi.fn() and jest.fn() are used extensively to create mock ToolExecutor implementations and approvalHandler callbacks, allowing for isolated testing of the PipelineCompositor's logic without external dependencies.

The resetPipelineCompositor() function is used in beforeEach to ensure a clean state for each test, preventing side effects from previous tests (e.g., registered custom transforms or approval history). The compositor.dispose() method is called in afterEach to clean up resources and clear internal state.