admin_object_manager_tree_select_test.rb 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. require 'browser_test_helper'
  2. class AdminObjectManagerTreeSelectTest < TestCase
  3. def test_basic_a
  4. @browser = browser_instance
  5. login(
  6. username: 'master@example.com',
  7. password: 'test',
  8. url: browser_url,
  9. )
  10. tasks_close_all()
  11. object_manager_attribute_create(
  12. data: {
  13. name: 'browser_test_tree_select1',
  14. display: 'Browser Test TreeSelect1',
  15. data_type: 'Tree Select',
  16. data_option: {
  17. options: {
  18. 'Incident' => {
  19. 'Hardware' => {
  20. 'Monitor' => {},
  21. 'Mouse' => {},
  22. 'Keyboard' => {},
  23. },
  24. 'Softwareproblem' => {
  25. 'CRM' => {},
  26. 'EDI' => {},
  27. 'SAP' => {
  28. 'Authentication' => {},
  29. 'Not reachable' => {},
  30. },
  31. 'MS Office' => {
  32. 'Excel' => {},
  33. 'PowerPoint' => {},
  34. 'Word' => {},
  35. 'Outlook' => {},
  36. },
  37. },
  38. },
  39. 'Service request' => {
  40. 'New software requirement' => {},
  41. 'New hardware' => {},
  42. 'Consulting' => {},
  43. },
  44. 'Change request' => {},
  45. },
  46. },
  47. },
  48. )
  49. watch_for(
  50. css: '.content.active',
  51. value: 'Database Update required',
  52. )
  53. click(css: '.content.active .tab-pane.active div.js-execute')
  54. watch_for(
  55. css: '.modal',
  56. value: 'restart',
  57. )
  58. watch_for_disappear(
  59. css: '.modal',
  60. timeout: 240,
  61. )
  62. sleep 5
  63. watch_for(
  64. css: '.content.active',
  65. )
  66. # discard new attribute
  67. click(css: 'a[href="#manage"]')
  68. click(css: 'a[href="#system/object_manager"]')
  69. watch_for(
  70. css: '.content.active table',
  71. value: 'browser_test_tree_select1',
  72. )
  73. match_not(
  74. css: '.content.active',
  75. value: 'Database Update required',
  76. )
  77. object_manager_attribute_delete(
  78. data: {
  79. name: 'browser_test_tree_select1',
  80. },
  81. )
  82. watch_for(
  83. css: '.content.active',
  84. value: 'Database Update required',
  85. )
  86. watch_for(
  87. css: '.content.active table',
  88. value: 'browser_test_tree_select1',
  89. )
  90. click(css: '.content.active .tab-pane.active div.js-execute')
  91. watch_for(
  92. css: '.modal',
  93. value: 'restart',
  94. )
  95. watch_for_disappear(
  96. css: '.modal',
  97. timeout: 240,
  98. )
  99. sleep 5
  100. watch_for(
  101. css: '.content.active',
  102. )
  103. match_not(
  104. css: '.content.active',
  105. value: 'Database Update required',
  106. )
  107. match_not(
  108. css: '.content.active table',
  109. value: 'browser_test_tree_select1',
  110. )
  111. end
  112. # verify the fix for issue #2206 - Unable to modify tree_select attributes with fresh 2.6
  113. def test_modify_tree_select_attributes
  114. @browser = instance = browser_instance
  115. login(
  116. username: 'master@example.com',
  117. password: 'test',
  118. url: browser_url,
  119. )
  120. tasks_close_all()
  121. object_manager_attribute_create(
  122. data: {
  123. name: 'browser_test_tree_select2',
  124. display: 'Browser Test TreeSelect2',
  125. data_type: 'Tree Select',
  126. data_option: {
  127. options: {
  128. 'Incident' => {
  129. 'Hardware' => {
  130. 'Monitor' => {},
  131. 'Mouse' => {},
  132. },
  133. },
  134. 'Service request' => {
  135. 'New software requirement' => {},
  136. 'New hardware' => {},
  137. },
  138. 'Change request' => {},
  139. },
  140. },
  141. },
  142. )
  143. object_manager_attribute_migrate
  144. # open the newly created tree_select and add some new options
  145. object_manager_attribute_update(
  146. data: {
  147. name: 'browser_test_tree_select2',
  148. },
  149. do_not_submit: true,
  150. )
  151. # add two new first level entries
  152. 2.times do |i|
  153. instance.find_elements(css: '.modal .js-treeTable .js-key').last.click
  154. element = instance.find_elements(css: '.modal .js-treeTable .js-key').last
  155. element.clear
  156. element.send_keys("new tree option #{i}")
  157. end
  158. click(
  159. css: '.modal button.js-submit'
  160. )
  161. modal_disappear
  162. object_manager_attribute_migrate
  163. # open the tree select again and check that the newly added options are there
  164. watch_for(
  165. css: '.content.active table',
  166. value: 'browser_test_tree_select2',
  167. )
  168. object_manager_attribute_update(
  169. data: {
  170. name: 'browser_test_tree_select2',
  171. },
  172. do_not_submit: true,
  173. )
  174. 2.times do |i|
  175. exists(
  176. css: '.modal .js-treeTable',
  177. value: "new tree option #{i}",
  178. )
  179. end
  180. modal_close
  181. # clean up and confirm the deletion of newly created attributes
  182. object_manager_attribute_delete(
  183. data: {
  184. name: 'browser_test_tree_select2',
  185. },
  186. )
  187. object_manager_attribute_migrate
  188. match_not(
  189. css: '.content.active table',
  190. value: 'browser_test_tree_select2',
  191. )
  192. end
  193. end