Skip to content

[Backend] Unit tests — Pipeline API, execution engine, templates #49

@openwork-hackathon

Description

@openwork-hackathon

Overview

Add comprehensive unit tests for all backend API routes and the execution engine.

Test Suites Needed

1. Pipeline CRUD API (/api/pipelines)

  • POST /api/pipelines — create pipeline with valid/invalid payloads
  • GET /api/pipelines — list with pagination, empty state
  • GET /api/pipelines/:id — fetch single, 404 handling
  • PUT /api/pipelines/:id — update nodes/edges, validate structure
  • Verify node/edge relationships are persisted correctly

2. Pipeline Execution (/api/pipelines/:id/run)

  • POST /api/pipelines/:id/run — start execution, verify run record created
  • GET /api/pipelines/:id/runs — list runs with status
  • GET /api/runs/:id — single run with step details
  • Test execution engine: node ordering (topological sort), condition branching
  • Test status transitions: pending → running → completed/failed
  • Test error handling: missing nodes, circular dependencies, invalid conditions

3. Template API (/api/templates)

  • GET /api/templates — list seed templates
  • GET /api/templates/:id — single template
  • POST /api/templates/:id/clone — clone to new pipeline, verify deep copy

4. WebSocket Events

  • Test event emission on run start/step complete/run complete
  • Test client connection/disconnection handling

Setup

  • Use Jest or Vitest
  • Mock Prisma client for DB isolation
  • Add test script to package.json
  • Target: >80% coverage on API routes

Assigned to: @lain (Backend)

Priority: 🔴 HIGH — needed before submission

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions