admin_object_manager_test.rb 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class AdminObjectManagerTest < TestCase
  4. def test_basic_a
  5. @browser = browser_instance
  6. login(
  7. username: 'master@example.com',
  8. password: 'test',
  9. url: browser_url,
  10. )
  11. tasks_close_all()
  12. # already existing
  13. object_manager_attribute_create(
  14. data: {
  15. name: 'customer_id',
  16. display: 'Customer Should Not Creatable',
  17. data_type: 'Text',
  18. },
  19. error: 'already exists'
  20. )
  21. # invalid name
  22. object_manager_attribute_create(
  23. data: {
  24. name: 'some_other_id',
  25. display: 'Should Not Creatable',
  26. data_type: 'Text',
  27. },
  28. error: 'are not allowed'
  29. )
  30. # invalid name
  31. object_manager_attribute_create(
  32. data: {
  33. name: 'some_other_ids',
  34. display: 'Should Not Creatable',
  35. data_type: 'Text',
  36. },
  37. error: 'are not allowed'
  38. )
  39. # invalid name
  40. object_manager_attribute_create(
  41. data: {
  42. name: 'some spaces',
  43. display: 'Should Not Creatable',
  44. data_type: 'Text',
  45. },
  46. error: 'are not allowed'
  47. )
  48. # valid name
  49. object_manager_attribute_create(
  50. data: {
  51. name: 'browser_test1',
  52. display: 'Browser Test 1',
  53. data_type: 'Text',
  54. },
  55. )
  56. watch_for(
  57. css: '.content.active',
  58. value: 'Database Update required',
  59. )
  60. click(css: '.content.active .tab-pane.active div.js-execute')
  61. watch_for(
  62. css: '.modal',
  63. value: 'restart',
  64. )
  65. watch_for_disappear(
  66. css: '.modal',
  67. timeout: 120,
  68. )
  69. sleep 5
  70. watch_for(
  71. css: '.content.active',
  72. )
  73. # create new ticket
  74. ticket = ticket_create(
  75. data: {
  76. customer: 'nico',
  77. group: 'Users',
  78. priority: '2 normal',
  79. state: 'open',
  80. title: 'ticket attribute test #1',
  81. body: 'ticket attribute test #1',
  82. },
  83. #custom_data_select: {
  84. # key1: 'some value',
  85. #},
  86. custom_data_input: {
  87. browser_test1: 'some value öäüß',
  88. },
  89. disable_group_check: true,
  90. )
  91. # update ticket
  92. ticket_update(
  93. data: {},
  94. #custom_data_select: {
  95. # key1: 'some value',
  96. #},
  97. custom_data_input: {
  98. browser_test1: 'some value ABC',
  99. },
  100. )
  101. # discard new attribute
  102. click(css: 'a[href="#manage"]')
  103. click(css: 'a[href="#system/object_manager"]')
  104. watch_for(
  105. css: '.content.active table',
  106. value: 'browser_test1',
  107. )
  108. match_not(
  109. css: '.content.active',
  110. value: 'Database Update required',
  111. )
  112. object_manager_attribute_delete(
  113. data: {
  114. name: 'browser_test1',
  115. },
  116. )
  117. watch_for(
  118. css: '.content.active',
  119. value: 'Database Update required',
  120. )
  121. watch_for(
  122. css: '.content.active table',
  123. value: 'browser_test1',
  124. )
  125. click(css: '.content.active .tab-pane.active div.js-execute')
  126. watch_for(
  127. css: '.modal',
  128. value: 'restart',
  129. )
  130. watch_for_disappear(
  131. css: '.modal',
  132. timeout: 120,
  133. )
  134. sleep 5
  135. watch_for(
  136. css: '.content.active',
  137. )
  138. match_not(
  139. css: '.content.active',
  140. value: 'Database Update required',
  141. )
  142. match_not(
  143. css: '.content.active table',
  144. value: 'browser_test1',
  145. )
  146. end
  147. def test_basic_b
  148. @browser = browser_instance
  149. login(
  150. username: 'master@example.com',
  151. password: 'test',
  152. url: browser_url,
  153. )
  154. tasks_close_all()
  155. object_manager_attribute_create(
  156. data: {
  157. name: 'browser_test2',
  158. display: 'Browser Test 2',
  159. data_type: 'Select',
  160. data_option: {
  161. options: {
  162. 'aa' => 'AA',
  163. 'bb' => 'BB',
  164. },
  165. },
  166. },
  167. )
  168. object_manager_attribute_discard_changes
  169. sleep 4
  170. object_manager_attribute_create(
  171. data: {
  172. name: 'browser_test2',
  173. display: 'Browser Test 2',
  174. data_type: 'Text',
  175. #data_option: {
  176. # default: 'xxx',
  177. #},
  178. },
  179. )
  180. object_manager_attribute_create(
  181. data: {
  182. name: 'browser_test3',
  183. display: 'Browser Test 3',
  184. data_type: 'Select',
  185. data_option: {
  186. options: {
  187. 'aa' => 'AA',
  188. 'bb' => 'BB',
  189. 'cc' => 'CC',
  190. },
  191. },
  192. },
  193. )
  194. object_manager_attribute_create(
  195. data: {
  196. name: 'browser_test4',
  197. display: 'Browser Test 4',
  198. data_type: 'Integer',
  199. #data_option: {
  200. # default: 'xxx',
  201. # min: 15,
  202. # max: 99,
  203. #},
  204. },
  205. )
  206. object_manager_attribute_create(
  207. data: {
  208. name: 'browser_test5',
  209. display: 'Browser Test 5',
  210. data_type: 'Datetime',
  211. #data_option: {
  212. # future: true,
  213. # past: true,
  214. # diff: 24
  215. #},
  216. },
  217. )
  218. object_manager_attribute_create(
  219. data: {
  220. name: 'browser_test6',
  221. display: 'Browser Test 6',
  222. data_type: 'Date',
  223. #data_option: {
  224. # future: true,
  225. # past: true,
  226. # diff: 24
  227. #},
  228. },
  229. )
  230. object_manager_attribute_create(
  231. data: {
  232. name: 'browser_test7',
  233. display: 'Browser Test 7',
  234. data_type: 'Boolean',
  235. data_option: {
  236. options: {
  237. true: 'YES',
  238. false: 'NO',
  239. },
  240. # default: true,
  241. },
  242. },
  243. )
  244. watch_for(
  245. css: '.content.active',
  246. value: 'Database Update required',
  247. )
  248. click(css: '.content.active .tab-pane.active div.js-execute')
  249. watch_for(
  250. css: '.modal',
  251. value: 'restart',
  252. )
  253. watch_for_disappear(
  254. css: '.modal',
  255. timeout: 120,
  256. )
  257. sleep 5
  258. watch_for(
  259. css: '.content.active',
  260. )
  261. # create new ticket
  262. ticket = ticket_create(
  263. data: {
  264. customer: 'nico',
  265. group: 'Users',
  266. priority: '2 normal',
  267. state: 'open',
  268. title: 'ticket attribute test all #1',
  269. body: 'ticket attribute test all #1',
  270. },
  271. custom_data_select: {
  272. browser_test3: 'CC',
  273. browser_test7: 'NO',
  274. },
  275. custom_data_input: {
  276. browser_test2: 'some value öäüß',
  277. browser_test4: '25',
  278. },
  279. disable_group_check: true,
  280. )
  281. ticket_verify(
  282. data: {
  283. title: 'ticket attribute test all #1',
  284. custom_data_select: {
  285. browser_test3: 'CC',
  286. browser_test7: 'NO',
  287. },
  288. custom_data_input: {
  289. browser_test2: 'some value öäüß',
  290. browser_test4: '25',
  291. },
  292. },
  293. )
  294. object_manager_attribute_delete(
  295. data: {
  296. name: 'browser_test2',
  297. },
  298. )
  299. object_manager_attribute_delete(
  300. data: {
  301. name: 'browser_test3',
  302. },
  303. )
  304. object_manager_attribute_delete(
  305. data: {
  306. name: 'browser_test4',
  307. },
  308. )
  309. object_manager_attribute_delete(
  310. data: {
  311. name: 'browser_test5',
  312. },
  313. )
  314. object_manager_attribute_delete(
  315. data: {
  316. name: 'browser_test6',
  317. },
  318. )
  319. object_manager_attribute_delete(
  320. data: {
  321. name: 'browser_test7',
  322. },
  323. )
  324. click(css: '.content.active .tab-pane.active div.js-execute')
  325. watch_for(
  326. css: '.modal',
  327. value: 'restart',
  328. )
  329. watch_for_disappear(
  330. css: '.modal',
  331. timeout: 120,
  332. )
  333. sleep 5
  334. watch_for(
  335. css: '.content.active',
  336. )
  337. match_not(
  338. css: '.content.active',
  339. value: 'Database Update required',
  340. )
  341. match_not(
  342. css: '.content.active table',
  343. value: 'browser_test2',
  344. )
  345. match_not(
  346. css: '.content.active table',
  347. value: 'browser_test3',
  348. )
  349. match_not(
  350. css: '.content.active table',
  351. value: 'browser_test4',
  352. )
  353. match_not(
  354. css: '.content.active table',
  355. value: 'browser_test5',
  356. )
  357. match_not(
  358. css: '.content.active table',
  359. value: 'browser_test6',
  360. )
  361. match_not(
  362. css: '.content.active table',
  363. value: 'browser_test7',
  364. )
  365. end
  366. def test_basic_c
  367. @browser = browser_instance
  368. login(
  369. username: 'master@example.com',
  370. password: 'test',
  371. url: browser_url,
  372. )
  373. tasks_close_all()
  374. # valid name
  375. object_manager_attribute_create(
  376. data: {
  377. name: 'browser_update_test1',
  378. display: 'Browser Update Test 1',
  379. data_type: 'Text',
  380. },
  381. )
  382. watch_for(
  383. css: '.content.active',
  384. value: 'Database Update required',
  385. )
  386. click(css: '.content.active .tab-pane.active div.js-execute')
  387. watch_for(
  388. css: '.modal',
  389. value: 'restart',
  390. )
  391. watch_for_disappear(
  392. css: '.modal',
  393. timeout: 120,
  394. )
  395. sleep 5
  396. watch_for(
  397. css: '.content.active',
  398. )
  399. match_not(
  400. css: '.content.active',
  401. value: 'Database Update required',
  402. )
  403. # valid name
  404. object_manager_attribute_update(
  405. data: {
  406. name: 'browser_update_test1',
  407. display: 'Browser Update Test 2',
  408. data_type: 'Text',
  409. },
  410. )
  411. watch_for(
  412. css: '.content.active',
  413. value: 'Database Update required',
  414. )
  415. click(css: '.content.active .tab-pane.active div.js-execute')
  416. watch_for(
  417. css: '.modal',
  418. value: 'configuration of Zammad has changed',
  419. )
  420. click(css: '.modal .js-submit')
  421. watch_for_disappear(
  422. css: '.modal',
  423. timeout: 120,
  424. )
  425. sleep 5
  426. watch_for(
  427. css: '.content.active',
  428. )
  429. match_not(
  430. css: '.content.active',
  431. value: 'Database Update required',
  432. )
  433. object_manager_attribute_delete(
  434. data: {
  435. name: 'browser_update_test1',
  436. },
  437. )
  438. watch_for(
  439. css: '.content.active',
  440. value: 'Database Update required',
  441. )
  442. watch_for(
  443. css: '.content.active table',
  444. value: 'browser_update_test1',
  445. )
  446. click(css: '.content.active .tab-pane.active div.js-execute')
  447. watch_for(
  448. css: '.modal',
  449. value: 'restart',
  450. )
  451. watch_for_disappear(
  452. css: '.modal',
  453. timeout: 120,
  454. )
  455. sleep 5
  456. watch_for(
  457. css: '.content.active',
  458. )
  459. match_not(
  460. css: '.content.active',
  461. value: 'Database Update required',
  462. )
  463. match_not(
  464. css: '.content.active table',
  465. value: 'browser_update_test1',
  466. )
  467. end
  468. end