06_transformation_test.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. //NOTE: REQUIRES DSL FROM PREVIOUS TEST
  2. let test_utils = require('./test_utils');
  3. let model_building_utils = require('./model_building_utils');
  4. let user = "./users/testuser/";
  5. let rule_toolbars = [
  6. "/Formalisms/__Transformations__/TransformationRule/TransformationRule.defaultIcons.metamodel",
  7. "/autotest/autotest.defaultIcons.pattern.metamodel"
  8. ];
  9. module.exports = {
  10. beforeEach: function (client, done) {
  11. client.url('http://localhost:8124/atompm').pause(300).maximizeWindow(done);
  12. },
  13. 'Login': function (client) {
  14. test_utils.login(client);
  15. },
  16. 'Compile Pattern MM' : function (client) {
  17. let folder_name = "autotest";
  18. let model_name = "autotest.metamodel";
  19. model_building_utils.compile_model(client, "pattern", folder_name, model_name);
  20. },
  21. //
  22. // 'Create Transformation': function (client) {
  23. //
  24. // let trans_formalism = "/Formalisms/__Transformations__/Transformation/MoTif.defaultIcons.metamodel";
  25. //
  26. // test_utils.load_toolbar(client, [trans_formalism]);
  27. //
  28. //
  29. // //BUILD ELEMENTS
  30. //
  31. // let x_coord = 300;
  32. // let y_coords = [200, 320, 440, 560, 680];
  33. //
  34. // let btn_prefix = "#\\2f Formalisms\\2f __Transformations__\\2f Transformation\\2f MoTif\\2e defaultIcons\\2e metamodel\\2f ";
  35. // let type_prefix = "#\\2f Formalisms\\2f __Transformations__\\2f Transformation\\2f MoTif\\2e defaultIcons\\2f ";
  36. //
  37. // let to_create = ["StartIcon", "FRuleIcon", "ARuleIcon", "EndSuccessIcon", "EndFailIcon"];
  38. //
  39. // let ele_map = {};
  40. // let num_elements = 0;
  41. // for (let ele of to_create) {
  42. // client.waitForElementPresent(btn_prefix + ele, 2000, "Button present: " + btn_prefix + ele);
  43. // client.click(btn_prefix + ele);
  44. //
  45. // let built_div = model_building_utils.create_class(client,
  46. // x_coord, y_coords[num_elements], num_elements, type_prefix + ele + "\\2f ");
  47. //
  48. // ele_map[ele] = built_div;
  49. //
  50. // if (ele.includes("Rule")) {
  51. // let rule_name = num_elements + "_" + ele.replace("Icon", "");
  52. // let name_field = "#tr_name > td:nth-child(2) > textarea:nth-child(1)";
  53. // let rule_field = "#tr_rule > td:nth-child(2) > textarea:nth-child(1)";
  54. // let rule_prefix = "/autotest/R_";
  55. //
  56. //
  57. // let attribs = {};
  58. // attribs[name_field] = rule_name;
  59. // attribs[rule_field] = rule_prefix + rule_name + ".model";
  60. // model_building_utils.set_attribs(client, num_elements, attribs, type_prefix + ele + "\\2f ");
  61. // }
  62. // num_elements++;
  63. // }
  64. //
  65. // let assocs = [
  66. // [0, 1, ""],
  67. // [1, 2, "success"],
  68. // [2, 3, "success"],
  69. // [1, 4, "fail"],
  70. // [2, 4, "fail"]
  71. // ];
  72. //
  73. //
  74. // for (let assoc of assocs) {
  75. //
  76. // let start_ele = to_create[assoc[0]];
  77. // let end_ele = to_create[assoc[1]];
  78. //
  79. // let start = ele_map[start_ele];
  80. // let end = ele_map[end_ele];
  81. //
  82. // //TODO: Have path come from check/x mark
  83. //
  84. // let relation_div = "";
  85. // if (assoc[2] == "success") {
  86. // relation_div = "#choice_\\2f Formalisms\\2f __Transformations__\\2f Transformation\\2f MoTif\\2e defaultIcons\\2f success";
  87. // //start += " > path:nth-child(3)";
  88. // } else if (assoc[2] == "fail") {
  89. // relation_div = "#choice_\\2f Formalisms\\2f __Transformations__\\2f Transformation\\2f MoTif\\2e defaultIcons\\2f fail";
  90. // //start += " > path:nth-child(5)";
  91. // }
  92. //
  93. // let offset = 5 * (assoc[0] + assoc[1]);
  94. // model_building_utils.create_assoc(client, start, end, relation_div, offset);
  95. // }
  96. //
  97. //
  98. // model_building_utils.save_model(client, "autotest", "T_autotest.model");
  99. //
  100. // },
  101. // 'Create Rule 1': function (client) {
  102. //
  103. // test_utils.load_toolbar(client, rule_toolbars);
  104. //
  105. // // BUILD LHS AND RHS
  106. // let LHS_btn = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2e metamodel\\2f LHSIcon";
  107. // let RHS_btn = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2e metamodel\\2f RHSIcon";
  108. //
  109. // let ele_map = {};
  110. //
  111. // client.waitForElementPresent(LHS_btn, 2000, "LHS button").click(LHS_btn);
  112. // let LHS_div = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2f LHSIcon\\2f ";
  113. // ele_map["LHS"] = model_building_utils.create_class(client, 150, 200, 0, LHS_div);
  114. //
  115. // client.waitForElementPresent(RHS_btn, 2000, "RHS button").click(RHS_btn);
  116. // let RHS_div = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2f RHSIcon\\2f ";
  117. // ele_map["RHS"] = model_building_utils.create_class(client, 650, 200, 1, RHS_div);
  118. //
  119. // model_building_utils.click_off(client);
  120. //
  121. // //BUILD ELEMENTS INSIDE
  122. // let c_btn = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e pattern\\2e metamodel\\2f __pClassCIcon";
  123. // let d_btn = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e pattern\\2e metamodel\\2f __pClassDIcon";
  124. //
  125. // client.waitForElementPresent(c_btn, 2000, "C button").click(c_btn);
  126. // let c_div = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e pattern\\2f __pClassCIcon\\2f ";
  127. // ele_map["C"] = model_building_utils.create_class(client, 50, 200, 2, c_div);
  128. //
  129. // client.waitForElementPresent(d_btn, 2000, "D button").click(d_btn);
  130. // let d_div = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e pattern\\2f __pClassDIcon\\2f ";
  131. // ele_map["D"] = model_building_utils.create_class(client, 50, 400, 3, d_div);
  132. //
  133. // model_building_utils.move_element(client, ele_map["C"] + " > text:nth-child(1)", ele_map["LHS"], [50, 50], [50, 50]);
  134. // model_building_utils.move_element(client, ele_map["D"] + " > text:nth-child(1)", ele_map["RHS"], [50, 50], [50, 50]);
  135. //
  136. //
  137. // model_building_utils.save_model(client, "autotest", "R_1_FRule.model");
  138. // },
  139. 'Create Rule 2': function (client) {
  140. test_utils.load_toolbar(client, rule_toolbars);
  141. // BUILD LHS AND RHS
  142. let LHS_btn = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2e metamodel\\2f LHSIcon";
  143. let RHS_btn = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2e metamodel\\2f RHSIcon";
  144. let ele_map = {};
  145. client.waitForElementPresent(LHS_btn, 2000, "LHS button").click(LHS_btn);
  146. let LHS_div = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2f LHSIcon\\2f ";
  147. ele_map["LHS"] = model_building_utils.create_class(client, 150, 200, 0, LHS_div);
  148. client.waitForElementPresent(RHS_btn, 2000, "RHS button").click(RHS_btn);
  149. let RHS_div = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2f RHSIcon\\2f ";
  150. ele_map["RHS"] = model_building_utils.create_class(client, 650, 200, 1, RHS_div);
  151. model_building_utils.click_off(client);
  152. //BUILD ELEMENTS INSIDE
  153. let a_btn = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e pattern\\2e metamodel\\2f __pClassAIcon";
  154. let a_div = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e pattern\\2f __pClassAIcon\\2f ";
  155. //BUILD INSIDE LHS
  156. client.waitForElementPresent(a_btn, 2000, "A button").click(a_btn);
  157. ele_map["A_lhs_1"] = model_building_utils.create_class(client, 50, 200, 2, a_div);
  158. ele_map["A_lhs_2"] = model_building_utils.create_class(client, 50, 400, 3, a_div);
  159. model_building_utils.move_element(client, ele_map["A_lhs_1"] + " > text:nth-child(1)", ele_map["LHS"], [50, 50], [50, 20]);
  160. model_building_utils.move_element(client, ele_map["A_lhs_2"] + " > text:nth-child(1)", ele_map["LHS"], [50, 50], [50, 70]);
  161. // //BUILD INSIDE RHS
  162. // ele_map["I_rhs_1"] = model_building_utils.create_class(client, 50, 200, 4, i_div);
  163. // ele_map["I_rhs_2"] = model_building_utils.create_class(client, 50, 400, 5, i_div);
  164. //
  165. // model_building_utils.move_element(client, ele_map["I_rhs_1"] + " > text:nth-child(1)", ele_map["RHS"], [50, 50], [50, 20]);
  166. // model_building_utils.move_element(client, ele_map["I_rhs_2"] + " > text:nth-child(1)", ele_map["RHS"], [50, 50], [50, 70]);
  167. //
  168. // //BUILD ASSOCS
  169. // client.pause(300);
  170. // model_building_utils.create_assoc(client,
  171. // ele_map["I_lhs_1"] + " > text:nth-child(1)", ele_map["I_lhs_2"] + " > text:nth-child(1)", "", 0);
  172. //
  173. // client.pause(300);
  174. // model_building_utils.create_assoc(client,
  175. // ele_map["I_rhs_1"] + " > text:nth-child(1)", ele_map["I_rhs_2"] + " > text:nth-child(1)", "", 0);
  176. model_building_utils.save_model(client, "autotest", "R_2_ARule.model");
  177. },
  178. 'Create Rule 1': function (client) {
  179. test_utils.load_toolbar(client, rule_toolbars);
  180. // BUILD LHS AND RHS
  181. let LHS_btn = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2e metamodel\\2f LHSIcon";
  182. let RHS_btn = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2e metamodel\\2f RHSIcon";
  183. let ele_map = {};
  184. client.waitForElementPresent(LHS_btn, 2000, "LHS button").click(LHS_btn);
  185. let LHS_div = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2f LHSIcon\\2f ";
  186. ele_map["LHS"] = model_building_utils.create_class(client, 150, 200, 0, LHS_div);
  187. client.waitForElementPresent(RHS_btn, 2000, "RHS button").click(RHS_btn);
  188. let RHS_div = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2f RHSIcon\\2f ";
  189. ele_map["RHS"] = model_building_utils.create_class(client, 650, 200, 1, RHS_div);
  190. model_building_utils.click_off(client);
  191. //BUILD ELEMENTS INSIDE
  192. let c_btn = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e pattern\\2e metamodel\\2f __pClassCIcon";
  193. let d_btn = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e pattern\\2e metamodel\\2f __pClassDIcon";
  194. client.waitForElementPresent(c_btn, 2000, "C button").click(c_btn);
  195. let c_div = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e pattern\\2f __pClassCIcon\\2f ";
  196. ele_map["C"] = model_building_utils.create_class(client, 50, 200, 2, c_div);
  197. client.waitForElementPresent(d_btn, 2000, "D button").click(d_btn);
  198. let d_div = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e pattern\\2f __pClassDIcon\\2f ";
  199. ele_map["D"] = model_building_utils.create_class(client, 50, 400, 3, d_div);
  200. model_building_utils.move_element(client, ele_map["C"] + " > text:nth-child(1)", ele_map["LHS"], [50, 50], [50, 50]);
  201. model_building_utils.move_element(client, ele_map["D"] + " > text:nth-child(1)", ele_map["RHS"], [50, 50], [50, 50]);
  202. model_building_utils.save_model(client, "autotest", "R_1_FRule.model");
  203. },
  204. 'Create Rule 2': function (client) {
  205. test_utils.load_toolbar(client, rule_toolbars);
  206. // BUILD LHS AND RHS
  207. let LHS_btn = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2e metamodel\\2f LHSIcon";
  208. let RHS_btn = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2e metamodel\\2f RHSIcon";
  209. let ele_map = {};
  210. client.waitForElementPresent(LHS_btn, 2000, "LHS button").click(LHS_btn);
  211. let LHS_div = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2f LHSIcon\\2f ";
  212. ele_map["LHS"] = model_building_utils.create_class(client, 150, 200, 0, LHS_div);
  213. client.waitForElementPresent(RHS_btn, 2000, "RHS button").click(RHS_btn);
  214. let RHS_div = "#\\2f Formalisms\\2f __Transformations__\\2f TransformationRule\\2f TransformationRule\\2e defaultIcons\\2f RHSIcon\\2f ";
  215. ele_map["RHS"] = model_building_utils.create_class(client, 650, 200, 1, RHS_div);
  216. model_building_utils.click_off(client);
  217. //BUILD ELEMENTS INSIDE
  218. let a_btn = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e pattern\\2e metamodel\\2f __pClassAIcon";
  219. let a_div = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e pattern\\2f __pClassAIcon\\2f ";
  220. //BUILD A
  221. client.waitForElementPresent(a_btn, 2000, "A button").click(a_btn);
  222. ele_map["A_lhs"] = model_building_utils.create_class(client, 50, 200, 2, a_div);
  223. ele_map["A_rhs"] = model_building_utils.create_class(client, 50, 400, 3, a_div);
  224. model_building_utils.move_element(client, ele_map["A_lhs"] + " > text:nth-child(1)", ele_map["LHS"], [50, 50], [50, 20]);
  225. model_building_utils.move_element(client, ele_map["A_rhs"] + " > text:nth-child(1)", ele_map["RHS"], [50, 50], [50, 20]);
  226. model_building_utils.click_off(client);
  227. let b_btn = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e pattern\\2e metamodel\\2f __pClassBIcon";
  228. let b_div = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e pattern\\2f __pClassBIcon\\2f ";
  229. //BUILD B
  230. client.waitForElementPresent(b_btn, 2000, "B button").click(b_btn);
  231. ele_map["B_lhs"] = model_building_utils.create_class(client, 50, 200, 6, b_div);
  232. ele_map["B_rhs"] = model_building_utils.create_class(client, 50, 400, 7, b_div);
  233. model_building_utils.move_element(client, ele_map["B_lhs"] + " > text:nth-child(1)", ele_map["LHS"], [50, 50], [50, 70]);
  234. model_building_utils.move_element(client, ele_map["B_rhs"] + " > text:nth-child(1)", ele_map["RHS"], [50, 50], [50, 70]);
  235. model_building_utils.click_off(client);
  236. //BUILD ASSOCS
  237. client.pause(300);
  238. model_building_utils.create_assoc(client,
  239. ele_map["A_lhs"] + " > text:nth-child(1)", ele_map["B_lhs"] + " > text:nth-child(1)", "", 0);
  240. client.pause(300);
  241. model_building_utils.create_assoc(client,
  242. ele_map["A_rhs"] + " > text:nth-child(1)", ele_map["B_rhs"] + " > text:nth-child(1)", "", 0);
  243. let test_field = "#tr_test > td:nth-child(2) > textarea";
  244. let attrs = {};
  245. attrs[test_field] = "result = \"bonjour world!\"";
  246. model_building_utils.set_attribs(client, 3, attrs, a_div, " > text:nth-child(1)", [5, 5]);
  247. model_building_utils.save_model(client, "autotest", "R_2_ARule.model");
  248. },
  249. after: function (client) {
  250. client.end();
  251. },
  252. };