{ "name": "verify-database-change", "settings": { "storagePermissions": { "collections": { "watch_cursors": "read-write", "dbchange_test": "read-write" } } }, "_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.", "nodes": [ { "id": "seed", "name": "Make the collection exist", "type": "storage-insert", "position": { "x": 0, "y": -100 }, "config": { "collectionSource": "manual", "collectionManual": "dbchange_test", "documentData": "{\"probe\": \"fixture\"}", "ttlMs": 600000 } }, { "id": "first", "name": "Manual Run", "type": "database-change", "position": { "x": 0, "y": 0 }, "config": { "collection": "dbchange_test", "emitOnFirstRun": false } }, { "id": "cleanup", "name": "Cleanup", "type": "code", "position": { "x": 0, "y": 100 }, "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 };" } } ], "connections": [ { "sourceNodeId": "seed", "sourceOutput": "main", "targetNodeId": "first", "targetInput": "data" }, { "sourceNodeId": "first", "sourceOutput": "main", "targetNodeId": "cleanup", "targetInput": "data" } ], "expect": { "first": { "status": "completed", "output": { "count": 0, "isFirstRun": true } }, "cleanup": { "status": "completed" }, "seed": { "status": "completed", "output": { "success": true } } }, "comment": "\n\nThe first node creates the collection this case watches. It used to rely on dbchange_test already being there, which made the case fail the day that collection was tidied away - for a reason that had nothing to do with database change triggers. The seeded document carries a ten-minute TTL so the fixture clears itself." }