admin_object_manager_test.rb 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931
  1. require 'browser_test_helper'
  2. class AdminObjectManagerTest < 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. # already existing
  12. object_manager_attribute_create(
  13. data: {
  14. name: 'customer_id',
  15. display: 'Customer Should Not Creatable',
  16. data_type: 'Text',
  17. },
  18. error: 'already exists'
  19. )
  20. # invalid name
  21. object_manager_attribute_create(
  22. data: {
  23. name: 'some_other_id',
  24. display: 'Should Not Creatable',
  25. data_type: 'Text',
  26. },
  27. error: 'are not allowed'
  28. )
  29. # invalid name
  30. object_manager_attribute_create(
  31. data: {
  32. name: 'some_other_ids',
  33. display: 'Should Not Creatable',
  34. data_type: 'Text',
  35. },
  36. error: 'are not allowed'
  37. )
  38. # invalid name
  39. object_manager_attribute_create(
  40. data: {
  41. name: 'some spaces',
  42. display: 'Should Not Creatable',
  43. data_type: 'Text',
  44. },
  45. error: 'are not allowed'
  46. )
  47. # valid name
  48. object_manager_attribute_create(
  49. data: {
  50. name: 'browser_test1',
  51. display: 'Browser Test 1',
  52. data_type: 'Text',
  53. },
  54. )
  55. watch_for(
  56. css: '.content.active',
  57. value: 'Database Update required',
  58. )
  59. click(css: '.content.active .tab-pane.active div.js-execute')
  60. watch_for(
  61. css: '.modal',
  62. value: 'restart',
  63. )
  64. watch_for_disappear(
  65. css: '.modal',
  66. timeout: 7.minutes,
  67. )
  68. sleep 5
  69. watch_for(
  70. css: '.content.active',
  71. )
  72. # create new ticket
  73. ticket_create(
  74. data: {
  75. customer: 'nico',
  76. group: 'Users',
  77. priority: '2 normal',
  78. state: 'open',
  79. title: 'ticket attribute test #1',
  80. body: 'ticket attribute test #1',
  81. },
  82. #custom_data_select: {
  83. # key1: 'some value',
  84. #},
  85. custom_data_input: {
  86. browser_test1: 'some value öäüß',
  87. },
  88. disable_group_check: true,
  89. )
  90. # update ticket
  91. ticket_update(
  92. data: {},
  93. #custom_data_select: {
  94. # key1: 'some value',
  95. #},
  96. custom_data_input: {
  97. browser_test1: 'some value ABC',
  98. },
  99. )
  100. # discard new attribute
  101. click(css: 'a[href="#manage"]')
  102. click(css: 'a[href="#system/object_manager"]')
  103. watch_for(
  104. css: '.content.active table',
  105. value: 'browser_test1',
  106. )
  107. match_not(
  108. css: '.content.active',
  109. value: 'Database Update required',
  110. )
  111. object_manager_attribute_delete(
  112. data: {
  113. name: 'browser_test1',
  114. },
  115. )
  116. watch_for(
  117. css: '.content.active',
  118. value: 'Database Update required',
  119. )
  120. watch_for(
  121. css: '.content.active table',
  122. value: 'browser_test1',
  123. )
  124. click(css: '.content.active .tab-pane.active div.js-execute')
  125. watch_for(
  126. css: '.modal',
  127. value: 'restart',
  128. )
  129. watch_for_disappear(
  130. css: '.modal',
  131. timeout: 7.minutes,
  132. )
  133. sleep 5
  134. watch_for(
  135. css: '.content.active',
  136. )
  137. match_not(
  138. css: '.content.active',
  139. value: 'Database Update required',
  140. )
  141. match_not(
  142. css: '.content.active table',
  143. value: 'browser_test1',
  144. )
  145. end
  146. def test_basic_b
  147. @browser = browser_instance
  148. login(
  149. username: 'master@example.com',
  150. password: 'test',
  151. url: browser_url,
  152. )
  153. tasks_close_all()
  154. object_manager_attribute_create(
  155. data: {
  156. name: 'browser_test2',
  157. display: 'Browser Test 2',
  158. data_type: 'Select',
  159. data_option: {
  160. options: {
  161. 'aa' => 'AA',
  162. 'bb' => 'BB',
  163. },
  164. },
  165. },
  166. )
  167. object_manager_attribute_discard_changes
  168. sleep 4
  169. object_manager_attribute_create(
  170. data: {
  171. name: 'browser_test2',
  172. display: 'Browser Test 2',
  173. data_type: 'Text',
  174. #data_option: {
  175. # default: 'xxx',
  176. #},
  177. },
  178. )
  179. object_manager_attribute_create(
  180. data: {
  181. name: 'browser_test3',
  182. display: 'Browser Test 3',
  183. data_type: 'Select',
  184. data_option: {
  185. options: {
  186. 'aa' => 'AA',
  187. 'bb' => 'BB',
  188. 'cc' => 'CC',
  189. },
  190. },
  191. },
  192. )
  193. object_manager_attribute_create(
  194. data: {
  195. name: 'browser_test4',
  196. display: 'Browser Test 4',
  197. data_type: 'Integer',
  198. #data_option: {
  199. # default: 'xxx',
  200. # min: 15,
  201. # max: 99,
  202. #},
  203. },
  204. )
  205. object_manager_attribute_create(
  206. data: {
  207. name: 'browser_test5',
  208. display: 'Browser Test 5',
  209. data_type: 'Datetime',
  210. #data_option: {
  211. # future: true,
  212. # past: true,
  213. # diff: 24
  214. #},
  215. },
  216. )
  217. object_manager_attribute_create(
  218. data: {
  219. name: 'browser_test6',
  220. display: 'Browser Test 6',
  221. data_type: 'Date',
  222. #data_option: {
  223. # future: true,
  224. # past: true,
  225. # diff: 24
  226. #},
  227. },
  228. )
  229. # rubocop:disable Lint/BooleanSymbol
  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. # rubocop:enable Lint/BooleanSymbol
  245. watch_for(
  246. css: '.content.active',
  247. value: 'Database Update required',
  248. )
  249. click(css: '.content.active .tab-pane.active div.js-execute')
  250. watch_for(
  251. css: '.modal',
  252. value: 'restart',
  253. )
  254. watch_for_disappear(
  255. css: '.modal',
  256. timeout: 7.minutes,
  257. )
  258. sleep 5
  259. watch_for(
  260. css: '.content.active',
  261. )
  262. # create new ticket
  263. ticket_create(
  264. data: {
  265. customer: 'nico',
  266. group: 'Users',
  267. priority: '2 normal',
  268. state: 'open',
  269. title: 'ticket attribute test all #1',
  270. body: 'ticket attribute test all #1',
  271. },
  272. custom_data_select: {
  273. browser_test3: 'CC',
  274. browser_test7: 'NO',
  275. },
  276. custom_data_input: {
  277. browser_test2: 'some value öäüß',
  278. browser_test4: '25',
  279. },
  280. disable_group_check: true,
  281. )
  282. ticket_verify(
  283. data: {
  284. title: 'ticket attribute test all #1',
  285. custom_data_select: {
  286. browser_test3: 'CC',
  287. browser_test7: 'NO',
  288. },
  289. custom_data_input: {
  290. browser_test2: 'some value öäüß',
  291. browser_test4: '25',
  292. },
  293. },
  294. )
  295. object_manager_attribute_delete(
  296. data: {
  297. name: 'browser_test2',
  298. },
  299. )
  300. object_manager_attribute_delete(
  301. data: {
  302. name: 'browser_test3',
  303. },
  304. )
  305. object_manager_attribute_delete(
  306. data: {
  307. name: 'browser_test4',
  308. },
  309. )
  310. object_manager_attribute_delete(
  311. data: {
  312. name: 'browser_test5',
  313. },
  314. )
  315. object_manager_attribute_delete(
  316. data: {
  317. name: 'browser_test6',
  318. },
  319. )
  320. object_manager_attribute_delete(
  321. data: {
  322. name: 'browser_test7',
  323. },
  324. )
  325. sleep 1
  326. object_manager_attribute_migrate
  327. match_not(
  328. css: '.content.active',
  329. value: 'Database Update required',
  330. )
  331. match_not(
  332. css: '.content.active table',
  333. value: 'browser_test2',
  334. )
  335. match_not(
  336. css: '.content.active table',
  337. value: 'browser_test3',
  338. )
  339. match_not(
  340. css: '.content.active table',
  341. value: 'browser_test4',
  342. )
  343. match_not(
  344. css: '.content.active table',
  345. value: 'browser_test5',
  346. )
  347. match_not(
  348. css: '.content.active table',
  349. value: 'browser_test6',
  350. )
  351. match_not(
  352. css: '.content.active table',
  353. value: 'browser_test7',
  354. )
  355. end
  356. def test_basic_c
  357. @browser = browser_instance
  358. login(
  359. username: 'master@example.com',
  360. password: 'test',
  361. url: browser_url,
  362. )
  363. tasks_close_all()
  364. # valid name
  365. object_manager_attribute_create(
  366. data: {
  367. name: 'browser_update_test1',
  368. display: 'Browser Update Test 1',
  369. data_type: 'Text',
  370. },
  371. )
  372. watch_for(
  373. css: '.content.active',
  374. value: 'Database Update required',
  375. )
  376. click(css: '.content.active .tab-pane.active div.js-execute')
  377. watch_for(
  378. css: '.modal',
  379. value: 'restart',
  380. )
  381. watch_for_disappear(
  382. css: '.modal',
  383. timeout: 7.minutes,
  384. )
  385. sleep 5
  386. watch_for(
  387. css: '.content.active',
  388. )
  389. match_not(
  390. css: '.content.active',
  391. value: 'Database Update required',
  392. )
  393. # valid name
  394. object_manager_attribute_update(
  395. data: {
  396. name: 'browser_update_test1',
  397. display: 'Browser Update Test 2',
  398. data_type: 'Text',
  399. },
  400. )
  401. watch_for(
  402. css: '.content.active',
  403. value: 'Database Update required',
  404. )
  405. click(css: '.content.active .tab-pane.active div.js-execute')
  406. watch_for(
  407. css: '.modal',
  408. value: 'configuration of Zammad has changed',
  409. )
  410. click(css: '.modal .js-submit')
  411. watch_for_disappear(
  412. css: '.modal',
  413. timeout: 7.minutes,
  414. )
  415. sleep 5
  416. watch_for(
  417. css: '.content.active',
  418. )
  419. match_not(
  420. css: '.content.active',
  421. value: 'Database Update required',
  422. )
  423. object_manager_attribute_delete(
  424. data: {
  425. name: 'browser_update_test1',
  426. },
  427. )
  428. watch_for(
  429. css: '.content.active',
  430. value: 'Database Update required',
  431. )
  432. watch_for(
  433. css: '.content.active table',
  434. value: 'browser_update_test1',
  435. )
  436. click(css: '.content.active .tab-pane.active div.js-execute')
  437. watch_for(
  438. css: '.modal',
  439. value: 'restart',
  440. )
  441. watch_for_disappear(
  442. css: '.modal',
  443. timeout: 7.minutes,
  444. )
  445. sleep 5
  446. watch_for(
  447. css: '.content.active',
  448. )
  449. match_not(
  450. css: '.content.active',
  451. value: 'Database Update required',
  452. )
  453. match_not(
  454. css: '.content.active table',
  455. value: 'browser_update_test1',
  456. )
  457. end
  458. def test_that_attributes_with_references_should_have_a_disabled_delete_button
  459. @browser = instance = browser_instance
  460. login(
  461. username: 'master@example.com',
  462. password: 'test',
  463. url: browser_url,
  464. )
  465. tasks_close_all()
  466. # create two new attributes
  467. object_manager_attribute_create(
  468. data: {
  469. name: 'deletable_attribute',
  470. display: 'Deletable Attribute',
  471. data_type: 'Text',
  472. },
  473. )
  474. object_manager_attribute_create(
  475. data: {
  476. name: 'undeletable_attribute',
  477. display: 'Undeletable Attribute',
  478. data_type: 'Text',
  479. },
  480. )
  481. watch_for(
  482. css: '.content.active',
  483. value: 'Database Update required',
  484. )
  485. click(css: '.content.active .tab-pane.active div.js-execute')
  486. watch_for(
  487. css: '.modal',
  488. value: 'restart',
  489. )
  490. watch_for_disappear(
  491. css: '.modal',
  492. timeout: 7.minutes,
  493. )
  494. sleep 5
  495. watch_for(
  496. css: '.content.active',
  497. )
  498. match_not(
  499. css: '.content.active',
  500. value: 'Database Update required',
  501. )
  502. # create a new overview that references the undeletable_attribute
  503. overview_create(
  504. browser: instance,
  505. data: {
  506. name: 'test_overview',
  507. roles: ['Agent'],
  508. selector: {
  509. 'Undeletable Attribute' => 'DUMMY',
  510. },
  511. 'order::direction' => 'down',
  512. 'text_input' => true,
  513. }
  514. )
  515. click(
  516. browser: instance,
  517. css: 'a[href="#manage"]',
  518. mute_log: true,
  519. )
  520. click(
  521. browser: instance,
  522. css: '.content.active a[href="#system/object_manager"]',
  523. mute_log: true,
  524. )
  525. 30.times do
  526. deletable_attribute = instance.find_elements(xpath: '//td[text()="deletable_attribute"]/following-sibling::*[2]')[0]
  527. break if deletable_attribute
  528. sleep 1
  529. end
  530. sleep 1
  531. deletable_attribute = instance.find_elements(xpath: '//td[text()="deletable_attribute"]/following-sibling::*[2]')[0]
  532. assert_not_nil(deletable_attribute)
  533. deletable_attribute_html = deletable_attribute.attribute('innerHTML')
  534. assert(deletable_attribute_html.include?('title="Delete"'))
  535. assert(deletable_attribute_html.include?('href="#"'))
  536. assert(deletable_attribute_html.exclude?('cannot be deleted'))
  537. undeletable_attribute = instance.find_elements(xpath: '//td[text()="undeletable_attribute"]/following-sibling::*[2]')[0]
  538. assert_not_nil(undeletable_attribute)
  539. undeletable_attribute_html = undeletable_attribute.attribute('innerHTML')
  540. assert(undeletable_attribute_html.include?('Overview'))
  541. assert(undeletable_attribute_html.include?('test_overview'))
  542. assert(undeletable_attribute_html.include?('cannot be deleted'))
  543. assert(undeletable_attribute_html.exclude?('href="#"'))
  544. end
  545. def test_proper_sorting_of_select_attributes
  546. @browser = browser_instance
  547. login(
  548. username: 'master@example.com',
  549. password: 'test',
  550. url: browser_url,
  551. )
  552. tasks_close_all()
  553. # lexicographically ordered list of option strings
  554. options = %w[0 000.000 1 100.100 100.200 2 200.100 200.200 3 ä b n ö p sr ß st t ü v]
  555. options_hash = options.reverse.collect { |o| [o, o] }.to_h
  556. object_manager_attribute_create(
  557. data: {
  558. name: 'select_attributes_sorting_test',
  559. display: 'Select Attributes Sorting Test',
  560. data_type: 'Select',
  561. data_option: { options: options_hash },
  562. },
  563. )
  564. sleep 2
  565. # open the select attribute that we just created
  566. execute(js: "$(\".content.active td:contains('select_attributes_sorting_test')\").first().click()")
  567. sleep 3
  568. unsorted_locations = options.map do |key|
  569. [get_location(xpath: "//input[@value='#{key}']").y, key]
  570. end
  571. log("unsorted_locations = #{unsorted_locations.inspect}")
  572. sorted_locations = unsorted_locations.sort_by(&:first).map(&:second)
  573. log("sorted_locations = #{sorted_locations.inspect}")
  574. assert_equal options, sorted_locations
  575. # close the attribute modal
  576. click(css: '.modal button.js-submit')
  577. watch_for(
  578. css: '.content.active',
  579. value: 'Database Update required',
  580. )
  581. watch_for(
  582. css: '.content.active table',
  583. value: 'select_attributes_sorting_test',
  584. )
  585. click(css: '.content.active .tab-pane.active div.js-execute')
  586. watch_for(
  587. css: '.modal',
  588. value: 'restart',
  589. )
  590. watch_for_disappear(
  591. css: '.modal',
  592. timeout: 7.minutes,
  593. )
  594. sleep 5
  595. watch_for(
  596. css: '.content.active',
  597. )
  598. # create a new ticket and check whether the select attributes are correctly sorted or not
  599. click(
  600. css: 'a[href="#ticket/create"]',
  601. mute_log: true,
  602. )
  603. watch_for(
  604. css: 'select[name="select_attributes_sorting_test"]',
  605. )
  606. select_element = @browser.find_elements(css: 'select[name="select_attributes_sorting_test"]')[0]
  607. unsorted_options = select_element.find_elements(xpath: './*').map(&:text).reject { |x| x == '-' }
  608. log unsorted_options.inspect
  609. assert_equal options, unsorted_options
  610. object_manager_attribute_delete(
  611. data: {
  612. name: 'select_attributes_sorting_test',
  613. },
  614. )
  615. object_manager_attribute_migrate
  616. end
  617. def test_deleted_select_attributes
  618. @browser = browser_instance
  619. login(
  620. username: 'master@example.com',
  621. password: 'test',
  622. url: browser_url,
  623. )
  624. options = %w[äöü cat delete dog ß].map { |x| [x, "#{x.capitalize} Display"] }.to_h
  625. options_no_dog = options.except('dog')
  626. options_no_dog_no_delete = options_no_dog.except('delete')
  627. tasks_close_all()
  628. object_manager_attribute_create(
  629. data: {
  630. name: 'select_attributes_delete_test',
  631. display: 'Select Attributes Delete Test',
  632. data_type: 'Select',
  633. data_option: {
  634. options: options,
  635. },
  636. },
  637. )
  638. object_manager_attribute_migrate
  639. ticket_create(
  640. data: {
  641. customer: 'nico',
  642. group: 'Users',
  643. title: 'select_attributes_delete_test',
  644. body: 'select_attributes_delete_test',
  645. },
  646. custom_data_select: {
  647. select_attributes_delete_test: 'Delete Display',
  648. },
  649. disable_group_check: true,
  650. )
  651. watch_for(
  652. css: '.content.active select[name="select_attributes_delete_test"]',
  653. )
  654. # confirm that all options and their display values are there and are in the correct order
  655. select_element = @browser.find_elements(css: '.content.active select[name="select_attributes_delete_test"]')[0]
  656. unsorted_options = select_element.find_elements(xpath: './*').map { |o| o.attribute('value') }.reject { |x| x == '' }
  657. assert_equal options.keys, unsorted_options
  658. unsorted_display_options = select_element.find_elements(xpath: './*').map(&:text).reject { |x| x == '-' }
  659. assert_equal options.values, unsorted_display_options
  660. # confirm that the "delete" option is selected and that its display text is indeed "Delete Display"
  661. selected_option = select_element.find_elements(css: 'option:checked')[0]
  662. assert_equal 'delete', selected_option.attribute('value')
  663. assert_equal 'Delete Display', selected_option.text
  664. object_manager_attribute_update(
  665. data: {
  666. name: 'select_attributes_delete_test',
  667. data_option: {
  668. options: options_no_dog_no_delete,
  669. },
  670. },
  671. )
  672. object_manager_attribute_migrate
  673. screenshot(comment: 'deleted_select_attributes_before_click')
  674. # open the previously created ticket and verify its attribute selection
  675. click(
  676. xpath: '//a/div[contains(text(),"select_attributes_delete_test")]',
  677. )
  678. # confirm that all options and their display values are there and are in the correct order
  679. select_element = @browser.find_elements(css: '.content.active select[name="select_attributes_delete_test"]')[0]
  680. unsorted_options = select_element.find_elements(xpath: './*').map { |o| o.attribute('value') }.reject { |x| x == '' }
  681. assert_equal options_no_dog.keys, unsorted_options
  682. unsorted_display_options = select_element.find_elements(xpath: './*').map(&:text).reject { |x| x == '-' }
  683. assert_equal options_no_dog.values, unsorted_display_options
  684. # confirm that the "delete" option is still selected and that its display text is still indeed "Delete Display"
  685. selected_option = select_element.find_elements(css: 'option:checked')[0]
  686. assert_equal 'delete', selected_option.attribute('value')
  687. assert_equal 'Delete Display', selected_option.text
  688. # create a new ticket and check that the deleted options no longer appear
  689. click(
  690. css: 'a[href="#ticket/create"]',
  691. mute_log: true,
  692. )
  693. watch_for(
  694. css: 'select[name="select_attributes_delete_test"]',
  695. )
  696. select_element = @browser.find_elements(css: 'select[name="select_attributes_delete_test"]')[0]
  697. unsorted_options = select_element.find_elements(xpath: './*').map { |o| o.attribute('value') }.reject { |x| x == '' }
  698. assert_equal options_no_dog_no_delete.keys, unsorted_options
  699. unsorted_display_options = select_element.find_elements(xpath: './*').map(&:text).reject { |x| x == '-' }
  700. assert_equal options_no_dog_no_delete.values, unsorted_display_options
  701. object_manager_attribute_delete(
  702. data: {
  703. name: 'select_attributes_delete_test',
  704. },
  705. )
  706. object_manager_attribute_migrate
  707. end
  708. # verify fix for issue #2233 - Boolean object set to false is not visible
  709. # verify fix for issue #2277 - Note is not shown for customer / organisations if it's empty
  710. def test_false_boolean_attributes_gets_displayed_for_organizations
  711. @browser = browser_instance
  712. login(
  713. username: 'master@example.com',
  714. password: 'test',
  715. url: browser_url,
  716. )
  717. tasks_close_all()
  718. object_manager_attribute_create(
  719. data: {
  720. object: 'Organization',
  721. name: 'bool_test',
  722. display: 'bool_test',
  723. data_type: 'Boolean',
  724. data_option: {
  725. options: {
  726. # rubocop:disable Lint/BooleanSymbol
  727. true: 'YES',
  728. false: 'NO',
  729. # rubocop:enable Lint/BooleanSymbol
  730. }
  731. },
  732. },
  733. )
  734. object_manager_attribute_create(
  735. data: {
  736. object: 'Organization',
  737. name: 'text_test',
  738. display: 'text_test',
  739. data_type: 'Text',
  740. },
  741. )
  742. object_manager_attribute_migrate
  743. ticket_open_by_title(title: 'select')
  744. click( css: '.content.active .tabsSidebar-tab[data-tab="organization"]' )
  745. click( css: '.content.active .sidebar[data-tab="organization"] .js-actions .dropdown-toggle' )
  746. click( css: '.content.active .sidebar[data-tab="organization"] .js-actions [data-type="organization-edit"]' )
  747. modal_ready
  748. select(css: '.content.active .modal select[name="bool_test"]', value: 'NO')
  749. click( css: '.content.active .modal .js-submit' )
  750. modal_disappear
  751. watch_for(
  752. css: '.content.active .sidebar[data-tab="organization"] .sidebar-content',
  753. value: 'bool_test',
  754. )
  755. match_not(
  756. css: '.content.active .sidebar[data-tab="organization"] .sidebar-content',
  757. value: 'text_test',
  758. )
  759. match(
  760. css: '.content.active .sidebar[data-tab="organization"] .sidebar-content',
  761. value: 'note',
  762. )
  763. object_manager_attribute_delete(
  764. data: {
  765. object: 'Organization',
  766. name: 'bool_test',
  767. },
  768. )
  769. object_manager_attribute_delete(
  770. data: {
  771. object: 'Organization',
  772. name: 'text_test',
  773. },
  774. )
  775. object_manager_attribute_migrate
  776. end
  777. # verify fix for issue #2233 - Boolean object set to false is not visible
  778. # verify fix for issue #2277 - Note is not shown for customer / organisations if it's empty
  779. def test_false_boolean_attributes_gets_displayed_for_users
  780. @browser = browser_instance
  781. login(
  782. username: 'master@example.com',
  783. password: 'test',
  784. url: browser_url,
  785. )
  786. tasks_close_all()
  787. object_manager_attribute_create(
  788. data: {
  789. object: 'User',
  790. name: 'bool_test',
  791. display: 'bool_test',
  792. data_type: 'Boolean',
  793. data_option: {
  794. options: {
  795. # rubocop:disable Lint/BooleanSymbol
  796. true: 'YES',
  797. false: 'NO',
  798. # rubocop:enable Lint/BooleanSymbol
  799. }
  800. },
  801. },
  802. )
  803. object_manager_attribute_create(
  804. data: {
  805. object: 'User',
  806. name: 'text_test',
  807. display: 'text_test',
  808. data_type: 'Text',
  809. },
  810. )
  811. object_manager_attribute_migrate
  812. ticket_open_by_title(title: 'select')
  813. click( css: '.content.active .tabsSidebar-tab[data-tab="customer"]' )
  814. click( css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle' )
  815. click( css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]' )
  816. modal_ready
  817. select(css: '.content.active .modal select[name="bool_test"]', value: 'NO')
  818. click( css: '.content.active .modal .js-submit' )
  819. modal_disappear
  820. watch_for(
  821. css: '.content.active .sidebar[data-tab="customer"] .sidebar-content',
  822. value: 'bool_test',
  823. )
  824. match_not(
  825. css: '.content.active .sidebar[data-tab="customer"] .sidebar-content',
  826. value: 'text_test',
  827. )
  828. match(
  829. css: '.content.active .sidebar[data-tab="customer"] .sidebar-content',
  830. value: 'note',
  831. )
  832. object_manager_attribute_delete(
  833. data: {
  834. object: 'User',
  835. name: 'bool_test',
  836. },
  837. )
  838. object_manager_attribute_delete(
  839. data: {
  840. object: 'User',
  841. name: 'text_test',
  842. },
  843. )
  844. object_manager_attribute_migrate
  845. end
  846. end