database-change.json 1.6 KB

12345678910111213141516171819202122
  1. {
  2. "name": "verify-database-change",
  3. "settings": {
  4. "storagePermissions": {
  5. "collections": { "watch_cursors": "read-write", "dbchange_test": "read-write" }
  6. }
  7. },
  8. "_comment": "Database Change is a real trigger now - the database reports the change and the webserver starts the workflow - so it can only sit at the start of a flow, and the engine skips a trigger node found anywhere else. That is what this fixture covers: a run started by hand, which has no event to work from and falls back to asking what changed since last time. The event path itself needs a live subscription and a running webserver, so it is not reachable from here; it was verified by hand against insert, update and delete.",
  9. "nodes": [
  10. {"id": "first", "name": "Manual Run", "type": "database-change", "position": {"x": 0, "y": 0},
  11. "config": {"collection": "dbchange_test", "emitOnFirstRun": false}},
  12. {"id": "cleanup", "name": "Cleanup", "type": "code", "position": {"x": 0, "y": 100},
  13. "config": {"code": "// The cursor is keyed by workflow and node, and the harness builds a fresh\n// workflow each run, so this run was always a first run. Clearing it anyway\n// keeps the collection from filling up with one cursor per test run.\nsmartbotic.storage.delete('watch_cursors', context.workflowId + ':first');\nreturn { cleaned: true };"}}
  14. ],
  15. "connections": [
  16. {"sourceNodeId": "first", "sourceOutput": "main", "targetNodeId": "cleanup", "targetInput": "data"}
  17. ],
  18. "expect": {
  19. "first": {"status": "completed", "output": {"count": 0, "isFirstRun": true}},
  20. "cleanup": {"status": "completed"}
  21. }
  22. }