Skip to content

Add test coverage for workflows router endpoints#374

Merged
Lightheartdevs merged 1 commit intoLight-Heart-Labs:mainfrom
reo0603:test/workflows-router-coverage
Mar 18, 2026
Merged

Add test coverage for workflows router endpoints#374
Lightheartdevs merged 1 commit intoLight-Heart-Labs:mainfrom
reo0603:test/workflows-router-coverage

Conversation

@reo0603
Copy link
Contributor

@reo0603 reo0603 commented Mar 18, 2026

Summary

  • Add missing test coverage for workflows router endpoints (DELETE, GET executions)
  • Add authenticated endpoint tests for enable/disable/executions

Motivation

Workflows router had 4 endpoints but incomplete test coverage:

  • DELETE /api/workflows/{id} - zero tests
  • GET /api/workflows/{id}/executions - zero tests
  • POST /api/workflows/{id}/enable - only auth test, missing authenticated test

All other routers have comprehensive test coverage following the pattern: auth enforcement tests + authenticated endpoint tests.

Changes

Added 4 new tests:

  • test_workflow_executions_requires_auth - auth enforcement for executions endpoint
  • test_workflow_enable_authenticated - authenticated test (404 on missing workflow)
  • test_workflow_disable_authenticated - authenticated test for DELETE endpoint
  • test_workflow_executions_authenticated - authenticated test for executions endpoint

Testing

Tests follow the same pattern as other routers:

  • Auth enforcement tests verify 401 without credentials
  • Authenticated tests verify proper error handling (404 for nonexistent workflows)

Copy link
Collaborator

@Lightheartdevs Lightheartdevs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean PR — the 4 new tests are correct and follow the existing patterns in the file.

Minor observations (non-blocking):

  1. Pre-existing docstring bug (not introduced by this PR): test_workflow_disable_requires_auth (line 55) has docstring POST /api/workflows/{id}/disable but the actual route is DELETE /api/workflows/{id} and the test correctly uses test_client.delete. The new test_workflow_disable_authenticated gets this right. Consider fixing the old docstring in a follow-up.

  2. Coverage gap to be aware of: The 3 authenticated tests only exercise the 404 "workflow not in catalog" path. The happy paths for enable/disable/executions all require a live n8n connection, so testing them would need aiohttp mocking (the mock_aiohttp_session fixture in conftest.py exists for this). Not a blocker for this PR since it's explicitly filling the auth + 404 gaps, but worth noting for future work.

No CLAUDE.md violations, no bugs, no security issues. LGTM.

@Lightheartdevs Lightheartdevs merged commit 1bd7f91 into Light-Heart-Labs:main Mar 18, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants