Integration tests for the workflow engine and the scheduler #59

Merged
jared merged 1 commits from engine-tests into main 2026-11-22 21:58:56 -05:00
Owner

Part of #45 (phase 3). The integration suite grows from 21 to 37 tests.

Workflow engine (workflows.int.js, 11 tests)

  • An execute step on all workers runs on all 3 workers.
  • A failing step fails the execution and stops the workflow.
  • parse reads KEY=VALUE output, and route jumps on it.
  • A false condition skips the step.
  • A prompt waits, refuses invalid options and routes on the answer (who answered is recorded).
  • Params: required ones are checked, values are substituted, and unsafe values (x; reboot) are refused before anything runs.
  • A dry run logs commands without running them.
  • An endless goto loop is detected and fails the execution.
  • An aborted execution stays failed.

Scheduler (scheduler.int.js, 5 tests)

  • A due schedule runs on its worker, completes, and moves next_run about 60 minutes ahead.
  • A disabled schedule doesn't run.
  • Only admins can create schedules (403 otherwise), and bad input gets a 400.

The test makes a schedule due by setting next_run in the database, the only place these tests reach past the API. The new PULSE_SCHEDULER_TICK_MS setting (default 60 s, minimum 1 s) lets the test stack tick the scheduler every second.

Known bugs, as test.failing

I checked that each one fails on exactly its own assertion:

Bug What happens
#8 Abort marks the execution failed, but the engine still runs the next step
#20 A goto to a missing step ends as completed
#9 A schedule whose worker is offline leaves no record at all
New An invalid cron expression returns 500 instead of 400

When one of these is fixed, its test starts failing until the marker is removed, so the fixes come with tests already written.

Locally: integration 37/37, lint is clean.

🤖 Generated with Claude Code

Part of #45 (phase 3). The integration suite grows from 21 to **37** tests. ## Workflow engine (`workflows.int.js`, 11 tests) - An execute step on all workers runs on all 3 workers. - A failing step fails the execution and stops the workflow. - `parse` reads `KEY=VALUE` output, and `route` jumps on it. - A false `condition` skips the step. - A `prompt` waits, refuses invalid options and routes on the answer (who answered is recorded). - Params: required ones are checked, values are substituted, and unsafe values (`x; reboot`) are refused before anything runs. - A dry run logs commands without running them. - An endless `goto` loop is detected and fails the execution. - An aborted execution stays failed. ## Scheduler (`scheduler.int.js`, 5 tests) - A due schedule runs on its worker, completes, and moves `next_run` about 60 minutes ahead. - A disabled schedule doesn't run. - Only admins can create schedules (403 otherwise), and bad input gets a 400. The test makes a schedule due by setting `next_run` in the database, the only place these tests reach past the API. The new `PULSE_SCHEDULER_TICK_MS` setting (default 60 s, minimum 1 s) lets the test stack tick the scheduler every second. ## Known bugs, as `test.failing` I checked that each one fails on exactly its own assertion: | Bug | What happens | |---|---| | #8 | Abort marks the execution failed, but the engine still runs the next step | | #20 | A goto to a missing step ends as `completed` | | #9 | A schedule whose worker is offline leaves no record at all | | New | An invalid cron expression returns 500 instead of 400 | When one of these is fixed, its test starts failing until the marker is removed, so the fixes come with tests already written. Locally: integration 37/37, lint is clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jared added 1 commit 2026-11-22 21:51:09 -05:00
Integration tests for the workflow engine and the scheduler
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 17s
CI / Test (jest) (push) Successful in 18s
CI / Security (npm audit) (push) Successful in 9s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m2s
CI / Integration (api) (push) Successful in 2m31s
CI / Lint (eslint) (pull_request) Successful in 16s
CI / Test (jest) (pull_request) Successful in 15s
CI / Security (npm audit) (pull_request) Successful in 7s
CI / UI (playwright) (push) Successful in 1m39s
CI / Deploy (push) Skipped
CI / Deploy worker (push) Skipped
CI / Notify (push) Skipped
CI / Integration (api) (pull_request) Successful in 1m51s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 1m24s
CI / UI screenshots (before/after) (pull_request) Successful in 6s
CI / UI (playwright) (pull_request) Successful in 2m21s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
a34867af92
- workflows.int.js (11): all-worker execute, failure stops the workflow,
  parse to route, false conditions skip, prompts (invalid option refused,
  routes on the answer), params (required, substituted, unsafe refused),
  dry run, endless goto detection, abort stays failed.
- scheduler.int.js (5): a due schedule runs on its worker and advances
  next_run; disabled schedules don't run; admin-only and input checks.
- Known bugs as test.failing (each verified to fail on its assertion):
  abort doesn't stop the engine (#8), goto to a missing step completes
  (#20), an offline worker's schedule leaves no trace (#9), and an invalid
  cron expression returns 500 instead of 400.
- PULSE_SCHEDULER_TICK_MS (default 60 s, minimum 1 s) so the test stack
  ticks the scheduler every second.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jared merged commit f5a4333a8e into main 2026-11-22 21:58:56 -05:00
jared deleted branch engine-tests 2026-11-22 21:59:00 -05:00
Sign in to join this conversation.