database-change.json 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. {
  2. "name": "verify-database-change",
  3. "settings": {
  4. "storagePermissions": {
  5. "collections": {
  6. "watch_cursors": "read-write",
  7. "dbchange_test": "read-write"
  8. }
  9. }
  10. },
  11. "_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.",
  12. "nodes": [
  13. {
  14. "id": "seed",
  15. "name": "Make the collection exist",
  16. "type": "storage-insert",
  17. "position": {
  18. "x": 0,
  19. "y": -100
  20. },
  21. "config": {
  22. "collectionSource": "manual",
  23. "collectionManual": "dbchange_test",
  24. "documentData": "{\"probe\": \"fixture\"}",
  25. "ttlMs": 600000
  26. }
  27. },
  28. {
  29. "id": "first",
  30. "name": "Manual Run",
  31. "type": "database-change",
  32. "position": {
  33. "x": 0,
  34. "y": 0
  35. },
  36. "config": {
  37. "collection": "dbchange_test",
  38. "emitOnFirstRun": false
  39. }
  40. },
  41. {
  42. "id": "cleanup",
  43. "name": "Cleanup",
  44. "type": "code",
  45. "position": {
  46. "x": 0,
  47. "y": 100
  48. },
  49. "config": {
  50. "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 };"
  51. }
  52. }
  53. ],
  54. "connections": [
  55. {
  56. "sourceNodeId": "seed",
  57. "sourceOutput": "main",
  58. "targetNodeId": "first",
  59. "targetInput": "data"
  60. },
  61. {
  62. "sourceNodeId": "first",
  63. "sourceOutput": "main",
  64. "targetNodeId": "cleanup",
  65. "targetInput": "data"
  66. }
  67. ],
  68. "expect": {
  69. "first": {
  70. "status": "completed",
  71. "output": {
  72. "count": 0,
  73. "isFirstRun": true
  74. }
  75. },
  76. "cleanup": {
  77. "status": "completed"
  78. },
  79. "seed": {
  80. "status": "completed",
  81. "output": {
  82. "success": true
  83. }
  84. }
  85. },
  86. "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."
  87. }