workflow.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. describe("WorkflowModel", function(){
  2. function create_three_step_workflow() {
  3. var workflow_model = new WorkflowModel({
  4. id: 1,
  5. name: "Test-Three-Step-Workflow",
  6. start: 1,
  7. end: 5
  8. });
  9. var registry = new Registry();
  10. var workflow = new Workflow({
  11. model: workflow_model,
  12. data: {
  13. "nodes":[{
  14. "description":"",
  15. "workflow":1,
  16. "child_links":[{
  17. "comment":"",
  18. "name":"to",
  19. "parent":1,
  20. "child":2
  21. },{
  22. "comment":"",
  23. "name":"related",
  24. "parent":1,
  25. "child":5
  26. }],
  27. "node_type":"start",
  28. "id":1,
  29. "name":"start"
  30. },{
  31. "id":2,
  32. "name":"Sleep-1",
  33. "workflow":1,
  34. "node_type":"mapreduce",
  35. "jar_path":"/user/hue/oozie/workspaces/lib/hadoop-examples.jar",
  36. "child_links":[{
  37. "comment":"",
  38. "name":"ok",
  39. "parent":2,
  40. "child":3
  41. },{
  42. "comment":"",
  43. "name":"error",
  44. "parent":2,
  45. "child":6
  46. }],
  47. },{
  48. "id":3,
  49. "name":"Sleep-2",
  50. "workflow":1,
  51. "node_type":"mapreduce",
  52. "jar_path":"/user/hue/oozie/workspaces/lib/hadoop-examples.jar",
  53. "child_links":[{
  54. "comment":"",
  55. "name":"ok",
  56. "parent":3,
  57. "child":4
  58. },{
  59. "comment":"",
  60. "name":"error",
  61. "parent":3,
  62. "child":6
  63. }],
  64. },{
  65. "id":4,
  66. "name":"Sleep-3",
  67. "workflow":1,
  68. "node_type":"mapreduce",
  69. "jar_path":"/user/hue/oozie/workspaces/lib/hadoop-examples.jar",
  70. "child_links":[{
  71. "comment":"",
  72. "name":"ok",
  73. "parent":4,
  74. "child":5
  75. },{
  76. "comment":"",
  77. "name":"error",
  78. "parent":4,
  79. "child":6
  80. }],
  81. },{
  82. "id":6,
  83. "name":"kill",
  84. "workflow":1,
  85. "node_type":"kill",
  86. "child_links":[],
  87. "message":"Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]",
  88. },{
  89. "id":5,
  90. "name":"end",
  91. "workflow":1,
  92. "node_type":"end",
  93. "child_links":[],
  94. }],
  95. },
  96. registry: registry
  97. });
  98. return workflow;
  99. }
  100. describe("Node APIs", function(){
  101. var node = null;
  102. var viewModel = create_three_step_workflow();
  103. viewModel.rebuild();
  104. it("Should be able to detach a node", function() {
  105. node = viewModel.nodes()[2];
  106. node.detach();
  107. viewModel.rebuild();
  108. expect(viewModel.nodes().length).toEqual(4);
  109. });
  110. it("Should be able to append a node", function() {
  111. viewModel.nodes()[1].append(node);
  112. viewModel.rebuild();
  113. expect(viewModel.nodes().length).toEqual(5);
  114. });
  115. it("Should be able to fail when appending the same node", function() {
  116. viewModel.nodes()[1].append(node);
  117. viewModel.rebuild();
  118. expect(viewModel.nodes().length).toEqual(5);
  119. });
  120. });
  121. // describe("Node movement", function(){
  122. // it("Should be able to move a node up", function() {
  123. // });
  124. // it("Should be able to move a node down", function() {
  125. // });
  126. // it("Should be able to create a fork", function() {
  127. // });
  128. // it("Should be able to create a decision", function() {
  129. // });
  130. // });
  131. // describe("Node operations", function(){
  132. // it("Should be able to edit a node", function() {
  133. // $('.edit-node-link')[0].click();
  134. // expect($("#node-modal").length).toBeGreaterThan(0);
  135. // });
  136. // it("Should be able to create a node", function() {
  137. // $('.new-node-link[data-node-type=mapreduce]')[0].click();
  138. // expect($("#node-modal").length).toBeGreaterThan(0);
  139. // });
  140. // it("Should be able to clone a node", function() {
  141. // $('.clone-node-link')[0].click();
  142. // expect($("#node-modal").length).toBeGreaterThan(0);
  143. // });
  144. // it("Should be able to remove a node", function() {
  145. // $('.delete-node-btn')[0].click();
  146. // expect($("#node-modal").length).toBeGreaterThan(0);
  147. // });
  148. // });
  149. });