admin_object_manager_tree_select_test.rb 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. correct_options = [
  50. {
  51. 'name' => 'Incident',
  52. 'value' => 'Incident',
  53. 'children' => [
  54. {
  55. 'name' => 'Hardware',
  56. 'value' => 'Incident::Hardware',
  57. 'children' => [
  58. {
  59. 'name' => 'Monitor',
  60. 'value' => 'Incident::Hardware::Monitor'
  61. },
  62. {
  63. 'name' => 'Mouse',
  64. 'value' => 'Incident::Hardware::Mouse'
  65. },
  66. {
  67. 'name' => 'Keyboard',
  68. 'value' => 'Incident::Hardware::Keyboard'
  69. }
  70. ]
  71. },
  72. {
  73. 'name' => 'Softwareproblem',
  74. 'value' => 'Incident::Softwareproblem',
  75. 'children' => [
  76. {
  77. 'name' => 'CRM',
  78. 'value' => 'Incident::Softwareproblem::CRM'
  79. },
  80. {
  81. 'name' => 'EDI',
  82. 'value' => 'Incident::Softwareproblem::EDI'
  83. },
  84. {
  85. 'name' => 'SAP',
  86. 'value' => 'Incident::Softwareproblem::SAP',
  87. 'children' => [
  88. {
  89. 'name' => 'Authentication',
  90. 'value' => 'Incident::Softwareproblem::SAP::Authentication'
  91. },
  92. {
  93. 'name' => 'Not reachable',
  94. 'value' => 'Incident::Softwareproblem::SAP::Not reachable'
  95. }
  96. ]
  97. },
  98. {
  99. 'name' => 'MS Office',
  100. 'value' => 'Incident::Softwareproblem::MS Office',
  101. 'children' => [
  102. {
  103. 'name' => 'Excel',
  104. 'value' => 'Incident::Softwareproblem::MS Office::Excel'
  105. },
  106. {
  107. 'name' => 'PowerPoint',
  108. 'value' => 'Incident::Softwareproblem::MS Office::PowerPoint'
  109. },
  110. {
  111. 'name' => 'Word',
  112. 'value' => 'Incident::Softwareproblem::MS Office::Word'
  113. },
  114. {
  115. 'name' => 'Outlook',
  116. 'value' => 'Incident::Softwareproblem::MS Office::Outlook'
  117. }
  118. ]
  119. }
  120. ]
  121. }
  122. ]
  123. },
  124. {
  125. 'name' => 'Service request',
  126. 'value' => 'Service request',
  127. 'children' => [
  128. {
  129. 'name' => 'New software requirement',
  130. 'value' => 'Service request::New software requirement'
  131. },
  132. {
  133. 'name' => 'New hardware',
  134. 'value' => 'Service request::New hardware'
  135. },
  136. {
  137. 'name' => 'Consulting',
  138. 'value' => 'Service request::Consulting'
  139. }
  140. ]
  141. },
  142. {
  143. 'name' => 'Change request',
  144. 'value' => 'Change request'
  145. }
  146. ]
  147. created_attribute = ObjectManager::Attribute.last
  148. assert_equal(correct_options, created_attribute.data_option[:options])
  149. watch_for(
  150. css: '.content.active',
  151. value: 'Database Update required',
  152. )
  153. click(css: '.content.active .tab-pane.active div.js-execute')
  154. watch_for(
  155. css: '.modal',
  156. value: 'restart',
  157. )
  158. watch_for_disappear(
  159. css: '.modal',
  160. timeout: 120,
  161. )
  162. sleep 5
  163. watch_for(
  164. css: '.content.active',
  165. )
  166. # discard new attribute
  167. click(css: 'a[href="#manage"]')
  168. click(css: 'a[href="#system/object_manager"]')
  169. watch_for(
  170. css: '.content.active table',
  171. value: 'browser_test_tree_select1',
  172. )
  173. match_not(
  174. css: '.content.active',
  175. value: 'Database Update required',
  176. )
  177. object_manager_attribute_delete(
  178. data: {
  179. name: 'browser_test_tree_select1',
  180. },
  181. )
  182. watch_for(
  183. css: '.content.active',
  184. value: 'Database Update required',
  185. )
  186. watch_for(
  187. css: '.content.active table',
  188. value: 'browser_test_tree_select1',
  189. )
  190. click(css: '.content.active .tab-pane.active div.js-execute')
  191. watch_for(
  192. css: '.modal',
  193. value: 'restart',
  194. )
  195. watch_for_disappear(
  196. css: '.modal',
  197. timeout: 120,
  198. )
  199. sleep 5
  200. watch_for(
  201. css: '.content.active',
  202. )
  203. match_not(
  204. css: '.content.active',
  205. value: 'Database Update required',
  206. )
  207. match_not(
  208. css: '.content.active table',
  209. value: 'browser_test_tree_select1',
  210. )
  211. end
  212. end