utils.mock.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import { interfaces } from 'inversify';
  2. import {
  3. WorkflowJSON,
  4. WorkflowDocumentContainerModule,
  5. WorkflowLinesManager,
  6. WorkflowSimpleLineContribution,
  7. } from '@flowgram.ai/free-layout-core';
  8. import { FlowDocumentContainerModule } from '@flowgram.ai/document';
  9. import { PlaygroundMockTools } from '@flowgram.ai/core';
  10. export function createWorkflowContainer(): interfaces.Container {
  11. const container = PlaygroundMockTools.createContainer([
  12. FlowDocumentContainerModule,
  13. WorkflowDocumentContainerModule,
  14. ]);
  15. const linesManager = container.get(WorkflowLinesManager);
  16. linesManager.registerContribution(WorkflowSimpleLineContribution);
  17. linesManager.switchLineType(WorkflowSimpleLineContribution.type);
  18. return container;
  19. }
  20. export const workflowJSON: WorkflowJSON = {
  21. nodes: [
  22. {
  23. id: 'start_0',
  24. type: 'start',
  25. meta: {
  26. position: { x: 0, y: 0 },
  27. testRun: {
  28. showError: undefined,
  29. },
  30. },
  31. data: undefined,
  32. },
  33. {
  34. id: 'condition_0',
  35. type: 'condition',
  36. meta: {
  37. position: { x: 400, y: 0 },
  38. testRun: {
  39. showError: undefined,
  40. },
  41. },
  42. data: undefined,
  43. },
  44. {
  45. id: 'end_0',
  46. type: 'end',
  47. meta: {
  48. position: { x: 800, y: 0 },
  49. testRun: {
  50. showError: undefined,
  51. },
  52. },
  53. data: undefined,
  54. },
  55. {
  56. id: 'loop_0',
  57. type: 'loop',
  58. meta: {
  59. position: { x: 1200, y: 0 },
  60. testRun: {
  61. showError: undefined,
  62. },
  63. },
  64. data: undefined,
  65. blocks: [
  66. {
  67. id: 'break_0',
  68. type: 'break',
  69. meta: {
  70. position: { x: 0, y: 0 },
  71. testRun: {
  72. showError: undefined,
  73. },
  74. },
  75. data: undefined,
  76. },
  77. {
  78. id: 'variable_0',
  79. type: 'variable',
  80. meta: {
  81. position: { x: 400, y: 0 },
  82. testRun: {
  83. showError: undefined,
  84. },
  85. },
  86. data: undefined,
  87. },
  88. ],
  89. edges: [
  90. {
  91. sourceNodeID: 'break_0',
  92. targetNodeID: 'variable_0',
  93. },
  94. ],
  95. },
  96. ],
  97. edges: [
  98. {
  99. sourceNodeID: 'start_0',
  100. targetNodeID: 'condition_0',
  101. },
  102. {
  103. sourceNodeID: 'condition_0',
  104. sourcePortID: 'if',
  105. targetNodeID: 'end_0',
  106. },
  107. {
  108. sourceNodeID: 'condition_0',
  109. sourcePortID: 'else',
  110. targetNodeID: 'end_0',
  111. },
  112. {
  113. sourceNodeID: 'loop_0',
  114. targetNodeID: 'end_0',
  115. },
  116. {
  117. sourceNodeID: 'start_0',
  118. targetNodeID: 'loop_0',
  119. },
  120. ],
  121. };